RedSnakePhilly 2013

A Field Guide to Ruby and Python

Pam Selle

Geek Kingdoms:

  • Python born in 1991
  • Ruby born in 1995

“Spaces are ultimately important in Python”

“In Ruby parenthesis are a vestigial appendage”

Ruby is known for:

  • readability
  • web dev with rails
  • ops

Python is known for:

  • data
  • scientific apps
  • use at google

Ruby ops tools:

  • vagrant
  • chef
  • capistrano
  • travis
  • puppet

Python ops tools

  • buildbot
  • some others

Ruby web tools:

  • rails
  • radiant
  • sinatra
  • padrino

Python web tools:

  • web apps
  • django
  • plone
  • pyramid
  • web2py
  • flask

Ruby science and data tools:

  • sciruby.com

Python science and data tools:

  • scipy.org
  • pandas
  • numpy

Ruby interactive shell: pry/irb

Python interactive shell: ipython

Rails 4 / Ruby 2

Jearvon Dharrie

Goal: spark conversation about Ruby ecosystem as a Ruby programmer who wants Ruby to stick around

Ruby council proposal by Brian Shirai to combat the solo Matz benevolent dictator decisions.

Big changes between Ruby 1.8 and 1.9:

  • vm
  • encoding
  • io
  • threads
  • apis

RubySpec prososal:

  • know what works between versions with comprehensive test suite
  • runs against Ruby to keep versions on common spec

MRI:

  • some shortomcings
  • no concurrency
  • no jit compiler
  • code base is messy, tests aren’t great

“When people say Ruby sucks, they mean MRI sucks”

Alternative Ruby implementations:

  • Rubinius
  • JRuby
  • Topaz
  • Maglev

Brian Shirai’s process:

  • documentation
  • RubySpec
  • implementation
  • debate
  • vote

We should all care about Ruby because it builds the langague ecosystem.

Testing Python Web Applications at Scale

Jeffrey J. Persch

If you’re a startup and you’re doing things right, you’re running fast and getting crushed by a wave.

Small scale mock ups with lots of ways to start testing.

What about load testing 1x vs 10x

Just log everything. Store it forever.

We love Python because it allows us to simply express complex ideas with readable code.

Monetate can test load against traffic from a previous day by replaying logs, replaying all traffic against different configurations. It’s a great way to learn things about your infrastructure you wouldn’t have anticipated.

Use Python to make simple tools to push your systems to the test

Using RubyMotion for rapid iOS development

Justin Campbell

1st iOS app:

  • iphone 3g
  • new app store
  • first mac
  • inexperienced
  • everything was under NDA so it was hard to get answers

2nd iOS app:

  • worked at philly startup
  • consultant built app
  • only mac guy in the office
  • app in phonegap
  • telephony c library
  • hard to understand

3rd iOS app:

  • RubyMotion
  • May 2012
  • prototype app in 4 hours
  • finished and polished in 1 month
  • dividata.com

RubyMotion released by @lrz

  • Former MacRuby dev @ Apple
  • created hipbyte company
  • $199 for RubyMotion
  • not including iOS developer license

Ruby compilier for iOS

  • not a cross compiler, does not compile into Objective-C
  • rake workflow
  • 1.9ish core library
  • missing require, binding, and eval (app store doesn’t want arbetrary code running)
  • adds named parameters

What else is cool about it? It has types, selector shortcuts, pointers, concurrency.

To create a new app you just:

$ motion create some_new_app

Ruby 3x more concise than Objective-C (LOC comparison)

Also! * rake on command line * use any editor you want * amazing community

rubymotion-wrappers.com

justincampbell/rubymotion-demo

justincampbell/rubymotion-cocos2d

appstore.com/dividata

Vision Spreadsheet: An Environment for Computer Vision

Scott Determan

  • Spreadsheet meets computer vision meets SciPython
  • Numeric spreadsheets: grid of cells with numbers
  • Visual spreadsheet: cells contain images or image computation, measurements, plots
  • Change a call visually, all dependent cells change

Example project to identify white blood cells based on image analysis

  • image manipulation to extract intensity to get a usable represetnation of the image
  • slider to move threshold of image attribute
  • can write Python code to inject into a cell and manipulate data
  • and you can manipulate video in cells too whoa!

The Patterns You Can’t {See, Refactor}

Kyle Burton

Lisp macros are worth your time to learn, most powerful feature for expressiveness in your code.

Language features that you don’t yet understand, the ones that look weird, they likely wield a lot of power. Get to know them.

!refactorable

  • if, for, while
  • class, function, var, package
  • def, try, catch, throw

special powers

  • reduce syntax
    • clojure has “..” macro to chain together method return to another method call
  • defer execution
    • easy way to say when some condition “when” - expands out to if statement you would have written
  • introduce bindings
  • reorder computation

With great power comes great responsibility. Macros can change semantics of your code. Watch out for the sharp edges!

C++ templates

Dave Richardson

Lots of good C++ advice in here that my brain couldn’t keep up with :(

Apologies to the speaker for not getting notes on this.

Hector Castro Building Command-line Applications with Ruby

Hector Castro

Types of command line interfaces

  • non interactive (e.g. mv command)
  • interactive (e.g. ssh-keygem, vim, emacs)

Goals:

  • reduce interactivity and unnecessary output
  • emit accurate exist status
  • have a concise name
  • respect single and multi-leter options (-h and –help)
  • ensure you provide a –help option
  • use stdout correctly
  • use stderr correctly

Thor

Subclass a Thor class to build your command line app.

Cucumber

Aruba executes backticked code within cucumber tests.

Ronn

Takes markdown and creates html and man pages.

Using SimPy to Model AWS Autoscaling for Realtime Computation

Dan Williams

CheckVideo - smart camera to classify objects as people or vehicles

ARM processor with digital signal procssor

Tell camera what types of objects are of interest, alert when items of interest are in view

Capture a 10 second video clip of event. Requires accuracty in image recognition and serious computing to do this.

Approach:

  • turn up sensitivity on devices
  • send more events

Event load is very cyclical per day.

Use AWS EC2 autoscaling to create pool of servers that increase and descrease size based on aggregate cpu load.

SimPy - use discrete event simulation to model proposed solution to problem. Python framework uses 3 main object classes: * process * resource * monitor

Uses Python generators as a sort of co-routine.

Output plot results, simulate n cameras, see how system responds to time varying load.

Working in production for 2 years with no tinkering required.

Building Android Apps with JRuby and Ruboto

Rob DiMarco

Android basics

  • Java based SDK
  • byte code compiled into Dalvik executables
  • code, data, and resoruces packaged

Android components

  • activities (single screen)
  • services (background processes)
  • content providers (data management)
  • broadcast receivers (receives system messages)
  • manifest file

JRuby

  • 100% Java implementation of Ruby
  • most Ruby standard lib is implemented, 1.9 compatible
  • easy integration with Ruby and Java

Ruboto

  • opens up full Android SDK in Ruby
  • Ruby components whenever possible
  • build and deployment framework
  • requires Java, JRuby and Android SDK
  • packaged as a gem

Device installation is as simple as a rake install start

Deployment details

  • compile Java code
  • build package
  • install on emulator

Run on device

Roboto core platform app or bundle JRuby jars in package

Ruby script update

rake update_scripts

Getting it onto physical devices

  • sd card/usb
  • dropbox
  • github with qr code
  • google play

Oh and you can use Ruboto IRB!

How the Python gogolet it’s stripes: Simulating nature’s patterns with Numpy

Tom Adelman

This was awesome! Lots of really impressive methods of replicating of natural patterns with algorithms. Apologies to speaker for not having better notes on this.