Skip to content

Instantly share code, notes, and snippets.

Array
(
[diagnostics] => Array
(
[publiclyCallable] => true
[url] => Array
(
[0] => Array
(
[@content] => http://weather.yahooapis.com/forecastrss?w=2502265
@gaarf
gaarf / gist:c560769f163b0f823495
Last active August 29, 2015 14:05
CDAPTracker proposed signature
// node.js mode:
var CDAPTracker = require('cask-cdaptracker');
var tracker = new CDAPTracker({
endpoint: 'https://somehost.domain.tld/path/foo/bar'
});
tracker.track({hello: 'world'}) // it returns a promise
.then(function (response) {
console.log('the world was tracked!', response)
@gaarf
gaarf / stealthtweeet.html
Created March 21, 2010 01:04
Stealth Tweets with Unicode
<!DOCTYPE HTML>
<html>
<head>
<title>Stealth Tweets with Unicode</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?3.0.0/build/cssreset/reset-min.css&3.0.0/build/cssfonts/fonts-min.css" />
<script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script>
<script>
YUI().use('node',function(Y) {
@gaarf
gaarf / merge_master.rb
Created February 4, 2011 00:45
git merge master into all local branches
#!/usr/bin/env ruby
BRANCHES = []
`git branch`.each_line do |line|
branch = line.gsub(/[^\w]/, '')
if line[0]==42
STARTED_ON_BRANCH = branch
end
BRANCHES << branch
end
@gaarf
gaarf / safari_demo.png
Created March 24, 2011 23:26
a css triangle demo
safari_demo.png
@gaarf
gaarf / stream.js
Created April 11, 2011 03:09
twitter streamer for nodejs
var SECRETS = {
consumer_key: 'xxxxxxx',
consumer_secret: 'xxxxxxx',
access_token: 'xxxxxxx',
access_token_secret: 'xxxxxxx'
};
var OAuth = require('oauth').OAuth,
oa = new OAuth(null, null, SECRETS.consumer_key, SECRETS.consumer_secret, "1.0A", null, "HMAC-SHA1"),
start, request, counter;
@gaarf
gaarf / kittens.html
Created May 18, 2011 00:59
Re-order yourself some kittens
<!DOCTYPE HTML>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(function() {
var SLOT_COUNT = 5,
SLOT_WIDTH = 210, // css must match
SLOT_HALF_WIDTH = SLOT_WIDTH/2,
$xreorder = $('#xreorder').css('width',SLOT_WIDTH*SLOT_COUNT);
@gaarf
gaarf / test.js
Created November 6, 2011 03:09
Expresso or Node 0.6.0 issue?
// expresso
// this worked fine in 0.4.x
// but with node 0.6.0 results in:
// uncaught undefined: Error: connect ECONNREFUSED
// at errnoException (net.js:614:11)
// at Object.afterConnect [as oncomplete] (net.js:605:18)
@gaarf
gaarf / gist:1366188
Created November 15, 2011 04:52
Methods to deal with FB Signed Requests
# see https://github.com/ptarjan/base64url/blob/master/ruby.rb
def base64_url_decode(str)
str += '=' * (4 - str.length.modulo(4))
Base64.decode64(str.gsub("-", "+").gsub("_", "/"))
end
# see http://developers.facebook.com/docs/authentication/signed_request/
def valid_facebook_signature?(signature, encoded_data)
base64_url_decode(signature) == HMAC::SHA256.digest(FACEBOOK_APP_SECRET, encoded_data)
end
@gaarf
gaarf / .profile
Created February 22, 2012 19:53
my .profile
export VISUAL=nano
export EDITOR=nano
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=gxgxcxdxbxegedabagacad # cyan directories
export NODE_ENV='development'
export RAILS_ENV=$NODE_ENV # haha
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi