Skip to content

Instantly share code, notes, and snippets.

@johanb
johanb / video_santafy.rb
Created April 23, 2012 11:49 — forked from alskipp/video_santafy.rb
macruby video Santa-fy (with support for multiple Santas)
framework 'Cocoa'
framework 'avfoundation'
class Santa
t_url = NSURL.URLWithString("http://dl.dropbox.com/u/349788/mustache.png")
t_source = CGImageSourceCreateWithURL t_url, nil
@@tache = CGImageSourceCreateImageAtIndex t_source, 0, nil
g_url = NSURL.URLWithString("http://dl.dropbox.com/u/349788/glasses.png")
g_source = CGImageSourceCreateWithURL g_url, nil
@johanb
johanb / Plea.markdown
Created June 30, 2012 12:05 — forked from justinko/Plea.markdown
Am I doing it wrong?

Dear Rubyists,

I just lost a contract because of my code in a Rails project.

The specific code in question is related to a "posting a comment" feature. Here are the details:

In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.

The "senior developer", whom is the stake holder's right hand man, said this:

@johanb
johanb / mailapp.js
Created August 8, 2012 15:58 — forked from trek/mailapp.js
Mail = Ember.Application.create();
// Let's pretend that Javascript can handle mutliline strings nicely:
Mail.ApplicationView = Ember.View.extend({
template: Ember.Handlebars.compile('
<!-- this gets replaced with content based on state when
connectOutlet is called on ApplicationController -->
{{outlet}}
1.9.3-p125 :044 > accepts = "en,en-US;0.8,es;0.2"
=> "en,en-US;0.8,es;0.2"
1.9.3-p125 :045 > accepts.scan(/([\w-]{2,})/).map(&:first).map(&:to_sym)
=> [:en, :"en-US", :es]
1.9.3-p125 :046 > accepts.downcase.scan(/([\w-]{2,})/).map(&:first)
=> ["en", "en-us", "es"]
####
symbols = Symbol.all_symbols
#!/usr/bin/ruby
# Make sure you have these gems installed
require 'rubygems'
require 'thread'
require 'csv'
require 'twitter'
require 'marky_markov'
# Create a new Twitter account that you'd like to have your auto-tweets posted to