Skip to content

Instantly share code, notes, and snippets.

View YenTheFirst's full-sized avatar

Talin YenTheFirst

  • Opendoor
  • San Francisco
View GitHub Profile
pulseaudio --start
pactl load-module module-raop-sink server=10.0.1.22 sink_name=raop.CFA.local description="CFA"
mpg123 <the_file>
@YenTheFirst
YenTheFirst / get_twitter_rss.rb
Created February 1, 2011 04:02
a simple rack app, that wraps 'status' rss calls to twitter with the necessary oauth
require 'simple_oauth'
require 'net/http'
require 'rack'
class GetTwitterRSS
@@consumer_secrets={:consumer_key=>"<<YOUR_KEY>>",:consumer_secret=>"<<YOUR_SECRET>>}
@@user_secrets={"username
1"=>{:token_secret=>"<<TOKEN_SECRET>>",:token=>"<<ACCESS_TOKEN>>"}}
@@base="api.twitter.com"
def call(env)
@YenTheFirst
YenTheFirst / index.html
Created May 26, 2011 17:57 — forked from mlevans/index.html
Displaying Map Tiles from TileStream
<!Doctype html>
<html>
<head>
<title>311 Density</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://github.com/CloudMade/Leaflet/raw/master/dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="https://github.com/CloudMade/Leaflet/raw/master/dist/leaflet.ie.css" /><![endif]-->
</head>
<body>
@YenTheFirst
YenTheFirst / pretty_methods.rb
Created June 23, 2011 18:34
Pretty Ruby Methods
#Pretty Methods
#you can call any_object.pretty_methods
#it will return a hash of classes from that objects ancestor chain, and all the method names (as symbols) of that object which are created by that ancestor.
#example: 5.pretty_methods: {Fixnum=>[:%, %+, :odd? ....], Integer=>[:ceil,:round,...],...Kernel=>[:is_a?, :taint, ...]
#you can pass the parameter 'false' to get back classes as strings, instead of Class objects
#add 'require <path>/pretty_methods.rb' to your .irbrc file, and have the fun by default!
@YenTheFirst
YenTheFirst / wtf.rb
Created July 26, 2011 03:47
WTF ActiveSupport::TimeZone
$ rails console
> a = Time.zone.now # => Mon, 25 Jul 2011 23:47:52 EDT -04:00
> b = Time.zone.parse(a.to_s) # => Mon, 25 Jul 2011 23:47:52 EDT -04:00
> c = Time.zone.parse(a.strftime("%Y-%m-%d %H:%M:%S.%N %z")) # => Mon, 25 Jul 2011 23:47:52 EDT -04:00
> a == b # => false
> a == c # => true
> a.nsec # => 583744338
> b.nsec # => 0
> c.nsec # => 583744338
@YenTheFirst
YenTheFirst / mustachify.user.js
Created August 24, 2011 20:52
mustachify the interwebs!
//mustachify the interwebs!
//
// tested only on google chrome, so far
//
// ==UserScript==
// @name mustache image
// @include http://*
// ==/UserScript==
//we need jquery, 'cus otherwise searching for all the stupid background-image using inline styles is a pain.
@YenTheFirst
YenTheFirst / output_1.png
Created September 22, 2011 00:43
Selective Coloring
require 'chunky_png'
module ChunkyPNG::Color
LUMA_WEIGHTS = [0.30, 0.59, 0.11]
#based on http://en.wikipedia.org/wiki/HSL_and_HSV
def self.to_hcy_floats(i) #creates hue, chroma, luma tuple
r,g,b = to_truecolor_bytes(i).map {|x| x/255.0}
minx,maxx = [r,g,b].minmax
require 'github_v3_api'
g = g=GitHubV3API.new(ENV['GITHUB_OAUTH2_TOKEN'])
cfa = g.orgs.list.first
names = cfa.repos.map(&:name)
names.each do |name|
hooks = g.get("/repos/codeforamerica/#{name}/hooks")
scream_hook = hooks.find {|h| h["name"] == "web" && h["config"]["url"] =~ /6178/}
@YenTheFirst
YenTheFirst / gist:2975721
Created June 22, 2012 23:13
map tile number overlay
//this is a very very minor modification of http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ , to use google maps api v3.
//if you run this javascript on a page, or include it, you'll get nice tile number overlays.
function TileToQuadKey ( x, y, zoom){
var quad = "";
for (var i = zoom; i > 0; i--){
var mask = 1 << (i - 1);
var cell = 0;
if ((x & mask) != 0)
cell++;
@YenTheFirst
YenTheFirst / generated.html
Created June 30, 2012 00:11
image maker thingy
<html><body>
<div style='position: absolute; left: 0px; top: 0px; background: url("http://tile.stamen.com/terrain/13/1312/3165.png") -10px -10px no-repeat; width: 256px; height:256px;'> </div>
<div style='position: absolute; left: 0px; top: 246px; background: url("http://tile.stamen.com/terrain/13/1312/3166.png") -10px 0px no-repeat; width: 256px; height:256px;'> </div>
<div style='position: absolute; left: 0px; top: 502px; background: url("http://tile.stamen.com/terrain/13/1312/3167.png") -10px 0px no-repeat; width: 256px; height:256px;'> </div>
<div style='position: absolute; left: 0px; top: 758px; background: url("http://tile.stamen.com/terrain/13/1312/3168.png") -10px 0px no-repeat; width: 256px; height:10px;'>