Skip to content

Instantly share code, notes, and snippets.

@mojodna
mojodna / gist:21466
Created Nov 1, 2008
OAuth::RequestProxy for Hashes to facilitate simpler signature creation.
View gist:21466
module OAuth
module RequestProxy
# RequestProxy for Hashes to facilitate simpler signature creation.
# Usage:
# request = OAuth::RequestProxy.proxy \
# "method" => "iq",
# "uri" => [from, to] * "&",
# "parameters" => {
# "oauth_consumer_key" => oauth_consumer_key,
# "oauth_token" => oauth_token,
View gist:22224
#!/usr/bin/env ruby
require '/Users/mattb/Work/Dopplr/code/dopplr/config/environment'
require 'fire_hydrant'
config = YAML.load(File.read("fire_hydrant.yml"))
hydrant = FireHydrant.new(config, false)
hydrant.jack!(OAuthPubSubJack)
hydrant.on_startup do
defer :subscribed, 0 do
View gist:22241
<html>
<head>
<title>Flickr WOE ID Alpha Shape viewer</title>
</head>
<body>
<style type="text/css">
#ymap{
width:100%;
height:100%;
left:0px:
View gist:22267
#!/usr/bin/env ruby
require 'rexml/document'
require 'open-uri'
def load_results(url = "http://d.yimg.com/b/data/us/news/xml/elections/2008a/pres.xml")
doc = REXML::Document.new(open(url))
nodes = doc.elements.collect("//state") { |node| [node.attributes["name"].downcase, node.elements.collect("cand") { |cand| [cand.attributes["name"].downcase, cand.attributes["PopPct"].to_f, cand.attributes["PopVote"].to_i] }] }
votes = {}
View pless.sh
# even simpler colorization for everything (assuming you're not using a lesspipe.sh already)
# (add to your .bashrc)
export LESS="-r"
export LESSOPEN="|pygmentize %s"
View gist:33662
require 'sinatra'
require 'RMagick'
get "/" do
content_type "image/png"
status 200
body RMagick::Image.read("something.png").to_blob
end
View error.xml
<?xml version="1.0" encoding="utf-8"?>
<rsp stat="fail">
<err code="11" msg="Something bad happened" />
</rsp>
View gist:38184
#!/usr/bin/php -q
<?php
/**
* Cron job to update the comics plan.
*/
/* includes */
$_base = dirname(__FILE__) . '/../';
require_once($_base . 'config.php');
require_once($_base . 'lib/Planworld.php');
View gist:43984
#!/usr/bin/env ruby
require "oauth"
require 'oauth/helper'
require 'oauth/client/helper'
require 'oauth/request_proxy/net_http'
require "yaml"
require 'oauth_monkey_patches'
url = "http://query.yahooapis.com/v1/yql?q=show%20tables&format=xml"
@mojodna
mojodna / jsonpretty.txt
Created Feb 20, 2009 — forked from nicksieger/jsonpretty.txt
nicksieger's jsonpretty example with syntax highlighting
View jsonpretty.txt
jsonpretty: A command-line JSON pretty-printer.
Get it: gem install jsonpretty
Source: http://github.com/nicksieger/jsonpretty
Example:
$ curl -i http://github.com/api/v1/json/nicksieger | jsonpretty | pygmentize -l js
HTTP/1.1 200 OK
Server: nginx/0.6.26
You can’t perform that action at this time.