Skip to content

Instantly share code, notes, and snippets.

class Song
include MongoMapper::Document
plugin Grip
attachment :mp3
key :title, String
key :artist, String
key :album, String
key :genre, String
class SongsController < ApplicationController
def index
@songs = Song.all(:destroyed_at => nil)
@totals = load_totals(@songs)
end
def new
@song = Song.new
render :layout => false
class Event
include MongoMapper::Document
include MultiParameterAttributes
key :name, String, :required => true
key :start_date, Date, :required => true
key :start_time, Time, :required => true
end
class Job < CouchRestBase
include Delayed::Backend::Base
use_database :delayed_job
property :priority
property :attempts
property :handler
property :run_at
property :locked_at
property :locked_by
/* Trivial keyboard input layout to english switcher by Alexander V. Zhouravlev.
* Compile it with gcc -framework Carbon -o SwitchToEnglish SwitchToEnglish.m */
#import <Carbon/Carbon.h>
int main (int argc, const char *argv[])
{
TISInputSourceRef english = TISCopyInputSourceForLanguage(CFSTR("en-US"));
if (!english)
return 1;
@faust45
faust45 / stack.js
Created November 5, 2010 14:28 — forked from tj/stack.js
var error = new Error;
Object.defineProperty(global, '__stack', {
get: function(){
Error.prepareStackTrace = function(err, frames){
err.frames = frames;
};
try {
throw error;
} catch (err) {
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby)
#
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses!
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165
#
# ... kudos to @chadfowler for the tip!
#
# (note: works on 1.8.7 as well :-))
def should_i_upgrade?
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby)
#
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses!
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165
#
# ... kudos to @chadfowler for the tip!
#
# (note: works on 1.8.7 as well :-))
def should_i_upgrade?
@faust45
faust45 / es.sh
Created January 17, 2013 17:25 — forked from aaronshaf/es.sh
cd ~
sudo apt-get update
sudo apt-get install unzip curl python-software-properties openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.2.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@faust45
faust45 / -
Created September 11, 2013 16:59 — forked from anonymous/-
require Rails.root.to_s + '/lib/watch.rb'
watch TheFind::SearchQuery, :initialize do
before do |*args|
attrs = args[0]
SmartLog.info("SearchPoduct", attrs)
end
end