Skip to content

Instantly share code, notes, and snippets.

@jgv
jgv / application.js
Created October 10, 2013 17:21
webcam synth
window.onload = function(){
navigator.getMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
(function init(g){
try {
Synth.audio.ctx = new (g.AudioContext || g.webkitAudioContext);
@jgv
jgv / unicorn.rb
Created February 6, 2013 23:12
Our unicorn config for Heroku.
worker_processes 4
timeout 30
preload_app true
listen 3000 if ENV["RAILS_ENV"] == "development"
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
@jgv
jgv / index.html
Created February 5, 2013 00:47
Video scrobbly thing.
<!doctype html>
<html>
<head>
<style>
* { margin:0; paddding:0; }
video { width:100%; height:100%; display:none; }
</style>
</head>
<body>
<video id="video" poster="http://content.bitsontherun.com/thumbs/q1fx20VZ-720.jpg" preload="none">
@jgv
jgv / populate.rake
Last active February 1, 2018 20:40
Rake task to populate a database with data from factory girl.
require 'factory_girl'
namespace :db do
desc "Populate the database with some sample data"
task :populate, [:count] => [:environment] do |t, args|
args.with_defaults(:count => 10)
puts "Resetting the database"
Rake::Task['db:reset'].invoke
puts "Creating #{args[:count]} users"
new_users = FactoryGirl.create_list(:user, args[:count].to_i)
@jgv
jgv / pictures.rb
Last active December 11, 2015 17:59
Factory Girl definitions.
# Picture factory definition
FactoryGirl.define do
factory :picture do
image { File.open(Dir.glob(File.join(Rails.root) + "/spec/support/pictures/*").sample) }
end
end
@jgv
jgv / pictures.rb
Created January 25, 2013 22:03
Populate a database with data from Factory Girl.
FactoryGirl.define do
factory :picture do
image { File.open(File.join(Rails.root, 'spec', 'support', 'pictures', 'spec.png')) }
end
end
@jgv
jgv / gist:3902117
Created October 16, 2012 21:20
map theme
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"></script>
<script>
var events = [];
// event constructor
function CalendarEvent(name, permalink, lat, lon, description, start_date, start_time, id){
this.name = name;
this.permalink = permalink;
this.lat = lat;
avg := Object clone
avg myAverage := method(l,
for(i, 0, l size, if (l at(i) type != "Number", "not a number" println return))
if (l type == "List", if(l size > 0, l average, "blank list"), "not a list"))
avg myAverage(list(1, 2, "three")) println
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
export PROMPT_COMMAND="history -a"
#rds
export AWS_RDS_HOME=~/.rds
export PATH=$PATH:$AWS_RDS_HOME/bin
#ec 2
export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`