This file contains hidden or 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 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) { |
This file contains hidden or 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
| if (module) { | |
| var inherits = require('util').inherits, | |
| EventEmitter = require('events').EventEmitter, | |
| _ = require('underscore'); | |
| } | |
| function Model(attribs){ | |
| EventEmitter.apply(this, arguments); | |
| this._attributes = attribs || {}; |
This file contains hidden or 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
| // 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 | |
| }); |
This file contains hidden or 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 sensitive = [ | |
| { | |
| email: someemail@gmail.com, | |
| secret: 'somesecret', | |
| username: name, | |
| last_message: 'hey' | |
| }, | |
| { | |
| email: someemail1@gmail.com, | |
| secret: 'somesecret2', |
This file contains hidden or 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
| 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 |
This file contains hidden or 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 chat = new Controller({ | |
| view : $('#chat-content'), | |
| socket: app.socket, | |
| model : chatCollection | |
| }); | |
| chat.on('model.add', function(event){ | |
| this.socket.send({ | |
| type : 'chat', | |
| data : event) |
This file contains hidden or 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
| if not window? | |
| inherits = require('util').inherits | |
| EventEmitter = require('events').EventEmitter | |
| _ = require('underscore') | |
| extend = _.extend | |
| keys = Object.keys | |
| class Model extends EventEmitter | |
| constructor: (attribs) -> |
This file contains hidden or 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
| Model = require('./model') | |
| validator = require('validator') | |
| sanitize = validator.sanitize | |
| _ = require('underscore') | |
| m = new Model({ | |
| test : '', | |
| num : 0 | |
| }) |
This file contains hidden or 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
| - (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]; |
This file contains hidden or 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
| 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 | |
OlderNewer