Skip to content

Instantly share code, notes, and snippets.

View electrum's full-sized avatar
🚀
Working on @trinodb at @starburstdata

David Phillips electrum

🚀
Working on @trinodb at @starburstdata
View GitHub Profile
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
@jnunemaker
jnunemaker / harmony.rb
Created November 10, 2009 01:20
simple app configuration
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] => harmonyapp.com
def self.[](key)
unless @config
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
end
@config[key]
end
@rcoup
rcoup / aws_usage.py
Created June 1, 2010 21:46
A script to query the Amazon Web Services (S3/EC2/etc) usage reports programmatically.
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
class Video < ActiveRecord::Base
has_many :video_locations
has_many :locations, :through => :video_locations
accepts_nested_attributes_for :locations
has_many :video_people
has_many :people, :through => :video_people
attr_accessible :title, :date, :url
validates_presence_of :title, :date, :url
@igrigorik
igrigorik / ruby-1.9-tips.rb
Created February 3, 2011 17:19
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@jasonLaster
jasonLaster / ConsoleTricks.html
Created February 27, 2011 21:47
WebKit Console tricks adapted from CSS Ninja's excellent tutorial http://bit.ly/fi4lnK
<html>
<body>
<script type="text/javascript" charset="utf-8">
// CONSOLE log
var foo = {baz: "tubular", goo: "rad"}, bar = "baz";
console.log("string",1,foo.goo,bar,foo.baz); // string 1 rad baz tubular
console.log(foo)
// CONSOLE Printf
var foo = {baz: "tubular", goo: "rad"}, bar = "baz";
@jvanzyl
jvanzyl / hack.sh
Created March 31, 2012 14:28 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@cander
cander / basic.sh
Created May 25, 2012 04:47
Bourne Basic - a BASIC interpreter implemented (painfully) in pure Bourne shell
#!/bin/sh
#
#
# From: allbery@ncoast.UUCP (allbery@ncoast.UUCP)
# Subject: bournebasic
# Newsgroups: comp.sources.misc
# Date: 1987-08-18 18:54:12 PST
#
# Here's a useful BASIC interpreter written in Bourne shell.
# There's no manual but this demo shows the most salient features:
@electrum
electrum / javadoc.user.js
Created August 21, 2012 22:54
Latest Javadoc Redirect
// ==UserScript==
// @name Latest Javadoc Redirect
// @match http://docs.oracle.com/javase/*/api/*
// ==/UserScript==
(function() {
var oldVersions = ['1.3', '1.4.2', '1.5.0', '1,5.0', '6'];
var newVersion = '7';
var url = window.location.toString();
for (var i = 0; i < oldVersions.length; i++) {
@1wErt3r
1wErt3r / SMBDIS.ASM
Created November 9, 2012 22:27
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger (doppelheathen@gmail.com)
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no