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
- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(TUIFastIndexPath *)indexPath | |
{ | |
CGFloat calcuatedHeight = 55.0; | |
NSDictionary *post = [_posts objectAtIndex:indexPath.row]; | |
NSString *type = [post valueForKey:@"type"]; | |
NSString *message = [post valueForKey:@"message"]; | |
if (!message) message = type; | |
TUIAttributedString *s = [TUIAttributedString stringWithString:message]; | |
[s setAlignment:TUITextAlignmentLeft lineBreakMode:TUILineBreakModeWordWrap]; | |
s.color = [TUIColor blackColor]; |
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
// | |
// NewsTableCellView.m | |
// Crew | |
// | |
// Created by John Wright on 8/18/11. | |
// Copyright 2011 QuickLeft. All rights reserved. | |
// | |
#import "PostCellView.h" | |
#import "Crew.h" |
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
+ (NSImage *)maskImageNamed:(NSString *)name color:(NSColor *)color | |
{ | |
NSImage *image = [NSImage imageNamed:name]; | |
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height); | |
CGContextRef c = MyCreateBitmapContext(image.size.width, image.size.height); | |
[image drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; | |
CGContextSetFillColorWithColor(c, [color CGColor]); | |
CGContextSetBlendMode(c, kCGBlendModeSourceAtop); | |
CGContextFillRect(c, rect); | |
CGImageRef ciImage = CGBitmapContextCreateImage(c); |
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
modalContent = """ | |
<li> | |
<input id="email" placeholder="Email" type="text"></input> | |
</li> | |
<li> | |
<input id="password" placeholder="Password" type="password"></input> | |
</li> | |
""" | |
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
# The root namespace for your app | |
# Everything starts from here. | |
window.App = | |
start: -> | |
# Connect to DNode | |
DNode.connect (remote) -> | |
try | |
# Our remote db object | |
App.db = remote.db | |
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
# Overwrite the Backbone sync method to use Dnode and rbdb | |
Backbone.sync = (method, model, success, error) -> | |
# Backbone Models have a "hasChanged" function, distinguishing them from Collections | |
isCollection = if model.hasChanged? then false else true | |
# Each model has a collection name, the collection in our MongoDB API | |
collectionName = if isCollection then new (model.model)().collectionName() else model.collectionName() | |
# A generic response handler using Node style callbacks to invoke Backbone success/error handlers | |
handleResponse = (err, obj) -> | |
if err? |
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
# Start up the http server | |
console.log("Starting on port #{options.port}") | |
server.listen(options.port) | |
# Start up dnode and expose our remote secure API to the user. This API has built-in token based security so we will be ok if the | |
# web-socket is over https | |
remote = | |
db: dbSecure | |
dnode(remote).listen(server) |
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
# Now create a secure API to this | |
# library that requires authentication | |
# Users can only access these collections | |
collectionWhiteList = ["records", "sources", "searchers"] | |
# These collections don't need any authentication at all for | |
findWithNoAuthentication = ["sources"] | |
secureTemplate = (user, collectionName, cb, doneCB) -> | |
if not user? or not user.accessToken? |
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
// Map from CRUD to HTTP for our default `Backbone.sync` implementation. | |
var methodMap = { | |
'create': 'POST', | |
'update': 'PUT', | |
'delete': 'DELETE', | |
'read' : 'GET' | |
}; |
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
# Bus 0.1(alpha) | |
# (c) 2010 John Wright, QuickLeft Inc. | |
# Bus may be freely distributed under the MIT license. | |
# For all details and documentation: | |
# http://github.com/mrjjwright/Bus | |
# | |
# | |
# | |
# Bus would not be possible without Jeremy Ashkenas who wrote CoffeeScript, the language |