Skip to content

Instantly share code, notes, and snippets.

module Paperclip
class AutoOrient < Paperclip::Processor
def initialize(file, options = {}, *args)
@file = file
end
def make( *args )
dst = Tempfile.new([@basename, @format].compact.join("."))
dst.binmode
<?php
echo "Prepping CSS and JS for deploy...\n";
$css_files['app'] = array('reset', '960', 'screen', 'jquery.tagsinput', 'jquery.autocomplete', 'tipsy', 'prettify');
//$css_files['splash'] = array('reset', 'splash');
//$css_files['iphone'] = array('reset', 'screen', 'iphone');
$js_files['app'] = array('jquery.autocomplete.min', 'jquery.tagsinput', 'jquery.scrollTo-1.4.2-min', 'forrst',
'jquery.tipsy', 'jquery.autoresize.min', 'prettify',
$v = new Validation(
array(
'name' => 'Kyle Bragger',
'age' => 24
)
);
$v->presence('name')->format('name', '/^[a-z ]+$/i')->presence('age');
$this->assertTrue($v->run());
$this->assertEqual($v->errors, array());
after running:
- sudo gem install rails --no-ri --no-rdoc
- mkdir -p /var/www
- set up nginx and virtual host
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db

Rails 2.3.5 on App Engine

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working. Rails 2.3.5 currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

Install the Development Environment

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine
sudo gem install appengine-tools --pre
@kylebragger
kylebragger / gist:262964
Created December 24, 2009 02:09
#keeping it posi (oh, Patrick!)
class Hash
def keeping(keys = [])
raise 'Please specify at least one key!' if keys.empty?
strkeys = keys.collect {|k| k.to_s}
self.clone.delete_if {|k,v| !strkeys.include?(k.to_s)}
end
end
# Tests!
h = {:kyle => 'Bragger', :patrick => 'Ewing'}
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json