Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
require 'datamapper'
require 'dm-paperclip'
require 'haml'
require 'fileutils'
APP_ROOT = File.expand_path(File.dirname(__FILE__))
DataMapper::setup(:default, "sqlite3://#{APP_ROOT}/db.sqlite3")
# Potential solution to "Using accepts_nested_attributes_for with a belongs_to association, and using find_or_create_by_attr behaviour"
# http://stackoverflow.com/questions/2970255/using-accepts-nested-attributes-for-with-a-belongs-to-association-and-using-find
class Upload < AR:B
belongs_to :user
belongs_to :observed_property
belongs_to :sensor
attr_accessor :observed_property_attributes,
:sensor_attributes
attr_accessible :observed_property_attributes,
@vreon
vreon / .Xresources
Created February 27, 2011 03:26
molokai color theme for xterm
! Molokai theme
*xterm*background: #101010
*xterm*foreground: #d0d0d0
*xterm*cursorColor: #d0d0d0
*xterm*color0: #101010
*xterm*color1: #960050
*xterm*color2: #66aa11
*xterm*color3: #c47f2c
*xterm*color4: #30309b
*xterm*color5: #7e40a5
@pepijndevos
pepijndevos / vocoder.clj
Created July 4, 2011 19:48
Overtone Vocoder
(ns test
(:use overtone.live
;overtone.inst.synth
overtone.inst.io))
(def a (buffer 2048))
(def b (buffer 2048))
(definst vocoder [freq 432]
(let [input (in 8)
@jeffrafter
jeffrafter / nginx.conf
Created September 20, 2011 15:58
Nginx proxy pass to localhost:3000 for development
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@samaaron
samaaron / gist:1284485
Created October 13, 2011 15:17
basic sequencer
(ns overtone.studio.sequencer
(:use [overtone.live]))
(defn- play-sample
[samp time vol]
(at time (stereo-player samp :vol vol)))
(defn determine-time
[onset-time b-idx beat-dur num-beats]
(+ onset-time (* b-idx beat-dur)))
@bennylope
bennylope / remotefiles.conf
Created October 19, 2011 01:30
nginx remote file proxying
location ~* ^/remote-files/(http[s]*://)(.*?)/(.*) {
# Do not allow people to mess with this location directly
# Only internal redirects are allowed
internal;
# nginx has to be able to resolve the remote URLs
resolver 8.8.8.8;
# Location-specific logging
#access_log /usr/local/etc/nginx/logs/internal_redirect.access.log main;
@vmihailenco
vmihailenco / proxy.go
Created November 20, 2011 15:22
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
@jcasimir
jcasimir / exporter.rb
Created February 26, 2012 20:09 — forked from chad/exporter.rb
Export ActiveRecord Tables to CSV
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end
@dlapiduz
dlapiduz / eydeploy.rb
Created April 20, 2012 23:13
config/eydeploy.rb
def conditionally_enable_maintenance_page
return true
end