Blog


A blog about security, privacy, algorithms, and email in the enterprise. 

Viewing entries tagged
ruby

Comment

Drinks to Code By

[Cross-posted from the Softartisans' Blog]

To celebrate the commencement of Oktoberfest  festivities in Munich this weekend (and because it’s always fun to think about alcohol), we’re bringing you a handy-dandy guide to see how your programming languages match up to your favorite drinks.It’s important to be prepared –  If all the programming languages were to suddenly turn into drinks, we should know what sort of world we’d be getting (besides a very drunk one)!

C – Tequila.  It gets the job done quickly, but using it isn’t usually that great of an experience.  Everybody uses it at some point, but not too many stick with it unless there’s no other choice, or they need it to do its thing fast.  And if you don’t use it exactly right, chances are things are going to go horribly wrong.

Ruby – Scotch.  You can use it for years, and still discover strange new undertones you hadn’t noticed before.  And then you add a dash of water and discover everything is changed.  But it’s easy to ruin the magic if you don’t know what you’re doing.

Python – Irish Whiskey.  When first starting, you have two main options – Bushmills or Jameson?  Python 2 or 3?  But once you choose one and go with it, it’s remarkably smooth.  There’s not a huge amount of subtlety, but it’s pretty easy to get into and use.

Java – Vodka.  It’s everywhere.  It can be used in pretty much any situation, and most people are willing to use it when it’s the most convenient thing on hand.  But excluding a group of really dedicated fans, it’s not generally people’s first choice.  It just doesn’t have the same elegance as some of the alternatives.  But it can be mixed with other things pretty easily, for those who can’t stand using it straight.

Scheme – Bourbon.  It’s not everyone’s cup of tea, but once you get used to it, it’s amazingly versatile.  It can be mixed or taken straight, and can be used in most environments.  Some people love it, some people can’t stand it.  It has some tantalizing similarities to other types of whiskey, and yet has its own very distinct character.

C# – Sake.  Hugely popular in one area.  There have been attempts to port it to other areas, but in most cases it’s still more of a quirky specialty item.   Although it looks a lot like vodka/Java, using it is remarkably smooth and feels much different.  When mixed with other things, it will either go incredibly well, or go terribly wrong.

Brainf*ck – Absinthe.  It really only exists because, well, why not?  It’s probably nothing like anything you’ve had before, and using it might be actively damaging your brain, but there’s something oddly fascinating about it that makes it hard to turn away.  Most people wouldn’t use it for serious business, but will give it a try for the novelty.

Javascript – Fermented apple juice.   Is it an alcoholic drink, or an accident?  Nobody knows.  But it’s there, so people use it.  It’s not quite at the same level of sophistication as the alternatives, but maybe if you give it a chance to grow a little more it will get there…

There you have it – picking a programming language is a lot like picking a drink. So choose wisely and enjoy your Oktoberfest weekend! But wait, there are so many languages you left out, you may say. Rather than me listing them all (because frankly, there are a ton), I’ll turn it over to you now.  What have I missed? What’s your favorite language, and what drink does it compare to?

Comment

2 Comments

Litmapped, Week of June 8, 2012: Hack Talk

During an Internet Week panel on digital media, New York Times journalist David Carr said that one of his biggest beefs with ebooks is that they impede that voyeuristic pleasure of knowing what your fellow subway riders are reading. He's right. (Ebooks also diminish the pool of snap-judgement factors.) The easiest workaround: ask. So I did, though, lacking the cajones to ask my fellow 5-train riders, I asked my coworkers instead. Here, for your click-through pleasure, are the most interesting stories they've read this week.

Sean Kermes, Software Engineer

  • Read: Trigger Narratives and the Nuclear Option
  • Source: Tempobook
  • Summary: That the trigger has (knock on wood) not been pulled since World War II is an engineering accomplishment comparable to the Moon landing.

Christina Nguyen, UX Engineer

  • Read: 10 Timeframes
  • Source: Contents Magazine
  • Summary: Interaction designers… must make things that allow other people to make things. They define the experiences that permit other people to do their work, or play, or tweet, or post things. They make the forms that the rest of us fill out.

Paula Marciante, Senior Talent Acquisition Manager

  • Read: Hackers Escalate Attacks on Social Networks
  • Source: Financial Times
  • Summary: Security breaches at LinkedIn and eHarmony have highlighted an escalation in attacks on social networks from hackers seeking to exploit personal data, according to security firms.

Claire Willett, Marketing and Development Manager

  • Read: Hello, I Am Sabu
  • Source: New York Magazine
  • Summary: From a housing project on Avenue D, a hacker mastermind of Anonymous and LulzSec was out to upend many worlds. Including his own.

Nick Martin, Software Engineer

Scott Dugas, Software Engineer

  • Read: Investment Disclosures
  • Source: Kottke.org
  • Excerpt: Users love our product because it's something free. Venture Capitalists love it because they can imagine themselves talking about it at T.E.D. or on Charlie Rose. Trust us: Once you invest in Ponzify, you'll have a difficult time investing your money anywhere else ever again.

Julian Ceipek, Development Intern

David Wihl, CEO

  • Read: The Government Comes Knocking: Who Has Your Back?
  • Source: Electronic Frontiers Foundation
  • Summary: The Electronic Frontier Foundation examined the policies of 18 major Internet companies — including email providers, ISPs, cloud storage providers, and social networking sites — to assess whether they publicly commit to standing with users when the government seeks access to user data.

Tamar Rucham, Software Engineer

  • Read: 6 Ways to Run Shell Commands in Ruby
  • Source: Nate Murray
  • Summary: Often times we want to interact with the operating system or run shell commands from within Ruby. Ruby provides a number of ways for us to perform this task.

2 Comments

Comment

Getting Started with Heroku (Ruby on Rails edition)

So What's Heroku?

Heroku is effectively a cloud-based web application platform. By using it you don't have to worry about any physical hardware - Heroku'll take care of it. This is pretty groovy when you just want to put a site up and not worry about getting the actual boxes plugged in and running. On top of that, Heroku supports most of the trendier platforms and languages. In particular, they support Ruby on Rails, which we'll be using here. Pricing can be a little tricky, but for a quick application, one web worker thread with the smallest shared database is free. This is enough for our purposes. We'll be assuming that Ubuntu 11.10 is the operating system of choice.

Setup your Account

The first thing that needs to be done is setting up your account. The signup page is pretty straight forward. Heroku is nice enough to link everyone to their own quick start guide, which we will be paraphrasing here. You'll first want to grab the Heroku toolbelt, which is a client-side application that you can use to manage your applications. On Ubuntu, you just need to run...

wget -qO- https://toolbelt.heroku.com/install.sh | sh

...to install the toolbelt. Typing...

heroku login

...will prompt you for your Heroku username and password. It will also ask if you want to generate and upload a SSH key for your account - you'll want to do that so you don't need to later. At this point you have a working Heroku user account and can authenticate against it.

Installing Ruby and Rails

For whatever reason, this can be kind of tricky on Ubuntu, particularly if Ruby or Rails is already on the system or was installed by aptitude. Luckily, we've made a script that takes a lot of the pain out. It is specifically for Ubuntu 11.10, but feel free to modify it to serve your purposes:

#! /bin/bash
sudo apt-get update
sudo apt-get install build-essential git-core curl postgresql libpq-dev
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
. ~/.bashrc
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
rvm install 1.9.3
rvm --default use 1.9.3
gem install rails -v 3.2.1
Basically, it will update Ubuntu with aptitude, install a number of Heroku dependencies like Postgresql, and then grab RVM, the Ruby Version Manager. It uses this to install Ruby and Rails. One should do it this way on Ubuntu, and never directly with aptitude.

Creating your Application

You'll want to make a new folder for this - let's place it in ~/projects. From the projects directory, do...

heroku create --stack cedar

This will have Heroku create your actual application. It will have an application name in the form of adjective-noun-####. If you open a browser window and visit adjective-noun-####.herokuapp.com, you should see a Heroku welcome page. It's easiest to pull down the repository via git to actually put rails on it. For this, you should do something like

git clone git@heroku.com:adjective-noun-####.git

The actual repository is empty at this point, but the clone operation will create the application folder in your projects directory. We're now going to do something loosely like the guide here. First, we need to create our Rails app locally. From the projects directory, we can create it with

rails new adjective-noun-####

This will populate your application folder with a Rails skeleton. We then need to swap out the sqlite3 gem for the PostgreSQL gem from the Gemfile in the root of the application folder. Just change...

gem 'sqlite3'

...to...

gem 'pg'

and then run 'bundle install' to grab the correct PostgreSQL gems. We can then commit and push our changes to our Heroku server with

git commit -a

git push origin master

If all goes well, Heroku will compile and run the pushed Rails app. If you visit your application web site in a browser, you should see this:

If so, all is well, and you now have Ruby on Rails running on the Heroku environment.  Happy hacking!

 

Comment