How to Take Over the World with Lithium

How to Take Over the World with Lithium

This talk was originally about how to take over the world. Then Instagram was acquired by Facebook for a BILLION DOLLARS.

I figure, a billion dollars? That's gotta be enough for a moon base with a laser. Let's just make a billion dollars, and the taking-over-the-world part will handle itself.

7fca546408cc6d46ab158f06baed2535?s=128

Nate Abele

April 13, 2012
Tweet

Transcript

  1. 2.

    ?

  2. 3.

    $1B

  3. 7.

    $ li3 library extract moneygram moneygram created in /<path to

    app> from / <path to lithium>/console/command/create/ template/app.phar.gz
  4. 8.
  5. 11.
  6. 13.

    $ li3 create Photos Photos created in moneygram\models. PhotosController created

    in moneygram\controllers. PhotosTest created in moneygram\tests\cases\models. PhotosControllerTest created in moneygram\tests\cases\controllers.
  7. 16.
  8. 18.

    views/photos/add.html.php <?=$this->form->create($photo, array( 'type' => 'file' )); ?> <?=$this->form->field('title'); ?>

    <?=$this->form->field('description'); ?> <?=$this->form->field('file', array( 'type' => 'file' )); ?> <?=$this->form->submit('Save'); ?> <?=$this->form->end(); ?>
  9. 19.
  10. 20.
  11. 21.
  12. 23.
  13. 24.

    models/Photos.php namespace moneygram\models; class Photos extends \lithium\data\Model { // ..

    protected $_meta = array('source' => 'fs.files'); protected $_schema = array( '_id' => array('type' => '_id'), 'title' => array('type' => 'string'), 'description' => array('type' => 'string'), ); }
  14. 25.
  15. 28.

    config/bootstrap/media.php Media::type('jpg', 'image/jpeg', array( 'cast' => false, 'encode' => function($data)

    { return $data['photo']->file->getBytes(); } )); config/bootstrap.php require __DIR__ . '/bootstrap/media.php';
  16. 29.
  17. 30.

    views/photos/index.html.php <ul class="thumbnails"> <?php foreach ($photos as $photo): ?> <li

    class="span3"> <div class="thumbnail"> <?=$this->html->image("/photos/view/{$photo->_id}.jpg"); ?> <div class="caption"> <h5><?=$this->html->link( $photo->title, array('Photos::view', 'id' => $photo->_id) ); ?></h5> </div> </div> </li> <?php endforeach ?> </ul>
  18. 32.
  19. 37.

    controllers/PhotosController.php public function edit() { // ... $new = $filter->apply($imagine->load(

    $photo->file->getBytes() )); $photo->delete(); $photo = Photos::create(array( '_id' => $photo->_id, 'title' => $photo->title, 'file' => $new->get('jpg') )); $photo->save(); return $this->redirect(array( 'Photos::view', 'id' => $photo->_id )); }
  20. 39.

    extensions/imagine/SepiaToneFilter.php public function apply(\Imagine\Image\ImageInterface $image) { $new = $this->_imagine->create($image->getSize(), new

    Color('fff')); for ($x = 0; $x < $image->getSize()->getWidth(); $x++) { for ($y = 0; $y < $image->getSize()->getHeight(); $y++) { $position = new Point($x, $y); $pixel = $image->getColorAt($position); $r = $pixel->getRed(); $g = $pixel->getGreen(); $b = $pixel->getBlue(); $r = min(array((0.272 * $r) + (0.534 * $g) + (0.131 * ($b)), 255)); $g = min(array((0.349 * $r) + (0.686 * $g) + (0.168 * ($b)), 255)); $b = min(array((0.393 * $r) + (0.769 * $g) + (0.189 * ($b)), 255)); $r = ($r > 255) ? 255 : $r; $g = ($g > 255) ? 255 : $g; $b = ($b > 255) ? 255 : $b; $pixel = new Color(array($r, $g, $b)); $new->draw()->dot($position, $pixel); } } return $new; }
  21. 40.