Skip to content

Instantly share code, notes, and snippets.

@wadey
wadey / twitter-entities.js
Created June 17, 2010 17:50
JavaScript parser for Tweet Entities
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Copyright 2010, Wade Simmons
* Licensed under the MIT license
@wadey
wadey / index.html
Created December 3, 2010 22:06
SimpleGeo Advanced getLocation Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://cdn.simplegeo.com/js/1.2/simplegeo.context.jq.min.js"></script>
<script type="text/javascript" src="http://github.com/simplegeo/polymaps/raw/v2.4.0/polymaps.js"></script>
</head>
<body>
<script type="text/javascript">
@wadey
wadey / get_location_1.js
Created December 21, 2010 22:27
SimpleGeo JavaScript getLocation examples
client.getLocation({enableHighAccuracy: true}, function(err, position) {
if (err) {
// Could not retrieve location information. Check err for more information
} else {
// Latitude and longitude available in position.coords
}
});
@wadey
wadey / example-server.js
Created December 31, 2010 20:16
Example node-thrift server
var thrift = require('thrift');
var JobExchange = require('./gen-nodejs/JobExchange'),
ttypes = require('./gen-nodejs/scheduler_types');
var server = thrift.createServer(JobExchange, {
insert_job: function(job, callback) {
// job is an instance of ttypes.Job
process.nextTick(function() {
callback(1);
// This example attempts to time out before the connection is established
var net = require('net');
var start = Date.now();
var stream = net.createConnection(9999, 'google.com');
stream.setTimeout(1000);
var thrift = require('thrift');
var sys = require('sys');
var scheduler_thrift = require('./gen-nodejs/JobExchange.js'),
scheduler_ttypes = require('./gen-nodejs/scheduler_types.js');
var conn = thrift.createConnection('localhost', 8081),
client = thrift.createClient(scheduler_thrift, conn);
conn.on('error', function(err) {
@wadey
wadey / index.html
Created January 13, 2011 18:35 — forked from mager/index.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@import url("http://github.com/simplegeo/polymaps/raw/v2.4.0/examples/example.css");
html, body {height: 100%;}
svg {display: block;}
.layer circle {fill: #f00;stroke: #000;stroke-width: 2px;}
</style>
# works
# func({a: 1, b: 2})
func
a: 1
b: 2
# doesn't work
# func(1, 2)
func
1
Emoji: {
'sunny': '2600',
'zap': '26a1',
'leaves': '1f343',
'lipstick': '1f483',
'cop': '1f46c',
'wheelchair': '267f',
'fish': '1f413',
'hammer': '1f52c',
'moneybag': '1f4b0',
$ npm install thrift --loglevel info
npm info it worked if it ends with ok
npm info using npm@1.0.6
npm info using node@v0.4.7
npm info addNamed [ 'thrift', '' ]
npm info into /Users/wade/sandbox/ttest thrift@0.6.0-1
npm info installOne thrift@0.6.0-1
npm info unbuild /Users/wade/sandbox/ttest/node_modules/thrift
npm info preinstall thrift@0.6.0-1
npm info build /Users/wade/sandbox/ttest/node_modules/thrift