Skip to content

Instantly share code, notes, and snippets.

View jmoyers's full-sized avatar

Joshua Moyers jmoyers

View GitHub Profile
var tweet_li_template = _.template(
"<li><div class='tweet'>{content}</div>" +
"<div class='details'>{time} via {source}</div></li>"
);
$.getJSON("http://twitter.com/statuses/user_timeline/so_co_co.json?count=3&callback=?", function(data){
var fragments = [];
_.each( data, function(tweet){
// Linkify urls, @'s
var status = tweet.text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
if (module) {
var inherits = require('util').inherits,
EventEmitter = require('events').EventEmitter,
_ = require('underscore');
}
function Model(attribs){
EventEmitter.apply(this, arguments);
this._attributes = attribs || {};
// Assume we're in ~/project/models/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
var User = new Schema({
email : String
, password : String
, name : String
});
var sensitive = [
{
email: [email protected],
secret: 'somesecret',
username: name,
last_message: 'hey'
},
{
email: [email protected],
secret: 'somesecret2',
function parseCookie(str){
var obj = {}
, pairs = str.split(/[;,] */);
for (var i = 0, len = pairs.length; i < len; ++i) {
var pair = pairs[i]
, eqlIndex = pair.indexOf('=')
, key = pair.substr(0, eqlIndex).trim().toLowerCase()
, val = pair.substr(++eqlIndex, pair.length).trim();
// Quoted values
var chat = new Controller({
view : $('#chat-content'),
socket: app.socket,
model : chatCollection
});
chat.on('model.add', function(event){
this.socket.send({
type : 'chat',
data : event)
if not window?
inherits = require('util').inherits
EventEmitter = require('events').EventEmitter
_ = require('underscore')
extend = _.extend
keys = Object.keys
class Model extends EventEmitter
constructor: (attribs) ->
Model = require('./model')
validator = require('validator')
sanitize = validator.sanitize
_ = require('underscore')
m = new Model({
test : '',
num : 0
})
- (NSImage *)avatarIconForAvatar:(AvatarWrapper *)avatarWrapper
{
CGFloat red = GetRValue(avatarWrapper.avatarData.color)/255.;
CGFloat blue = GetBValue(avatarWrapper.avatarData.color)/255.;
CGFloat green = GetGValue(avatarWrapper.avatarData.color)/255.;
NSImage *avatarBody = [[NSImage alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"avatar_icon_mask" ofType:@"png"]];
NSImage *resultImage = [[[NSImage alloc] initWithSize:[avatarBody size]] autorelease];
getListeners: (channel)->
branches = ['root'].concat(channel.split(@pattern))
numbranches = branches.length
curr = @listeners
walk = (a, b)->
for v,i in a
if a[i] != b[i] then return false
return true