This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SomeSchema.methods.mapReduce = function(callback) { | |
function map() { | |
/*global emit:true */ | |
emit('something', {foos:this.foos, users:1}); | |
} | |
function reduce(k, av) { | |
var foos = 0; | |
av.forEach(function(v) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am using Mongo v2.0.2, and currently on Mongoose v3.6.0. | |
I have a collection called "Users". Each doc has a String field called "ua", which is NOT indexed - but I tried with an indexed field and the behaviour is the same. | |
I want to find all the docs that have a ua containing, say, "Safari". So I try to use RegExp queries. | |
----- | |
Directly in Mongo console, everything works fine: |
OlderNewer