Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
mrjjwright / styed_component.js
Created Jan 19, 2017
Simple Styled Component
View styed_component.js
const TeamSelectionContainer = styled.div`
height: 100%;
display: flex;
flex-direction: column;
color: white;
font-size: 25px;
`;
@mrjjwright
mrjjwright / mobservable-vidom.js
Last active Jan 12, 2016
Make vidom components reactive using mobservable
View mobservable-vidom.js
(function() {
function mrFactory(mobservable, vidom) {
if (!mobservable)
throw new Error("mobservable-vidom requires the Mobservable package.")
if (!vidom)
throw new Error("mobservable-vidom requires vidom to be available");
var isTracking = false;
// WeakMap<Node, Object>;
@mrjjwright
mrjjwright / AppDelegate.swift
Last active Aug 29, 2015
Few Component nesting
View AppDelegate.swift
import Cocoa
import Few
private func render1(component: Few.Component<()>, state: ()) -> Element {
return View(backgroundColor: NSColor.redColor())
.direction(.Column)
.flex(1)
}
@mrjjwright
mrjjwright / Repository.coffee
Last active Aug 29, 2015
JSON git like repository idea
View Repository.coffee
Immutable = require('immutable')
immutableDiff = require("immutablediff")
sha = require("stable-sha1")
class Repository
constructor: (initialData) ->
@workingCopy = Immutable.fromJS(initialData)
@objectMap = {}
@author = "mrjjwright@gmail.com"
@mrjjwright
mrjjwright / gist:3240020
Created Aug 2, 2012
Extract largest image thumbnail from url using node and cheerio
View gist:3240020
cheerio = require('cheerio')
Shred = require('shred')
shred = new Shred()
http = require('http')
URL = require('url')
server = http.createServer (request, response) ->
url = URL.parse(request.url, true)
urlToDiscover = url.query['url']
startDiscovery urlToDiscover, (theImageURL) ->
@mrjjwright
mrjjwright / gist:3029371
Created Jul 1, 2012
AppPlay - an app developer's logic tool
View gist:3029371
- AppPlay is an interactive logic tool for app developers. Your app
manages lots of related logic:
- States
- Events
- Simple Conditional logic
- Stories
- User Actions
- Screenshots of how things should look.
- This logic is independent of how you technically implement it and
should be maintained outside your code.
@mrjjwright
mrjjwright / ExampleAppDelegate.m
Created Apr 10, 2012
Modify TUIKit example to show textview inside of a scrollview
View ExampleAppDelegate.m
/* TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy */
TUINSView *tuiScrollViewContainer = [[TUINSView alloc] initWithFrame:b];
[scrollViewWindow setContentView:tuiScrollViewContainer];
scrollExample = [[TUIScrollView alloc] initWithFrame:b];
scrollExample.backgroundColor = [TUIColor redColor];
TUITextView *textView = [[TUITextView alloc] initWithFrame:scrollExample.bounds];
textView.text = @"hellodfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddfdfddf
View TUILayout.h
//
// TUILayout.h
// Crew
//
// Created by John Wright on 11/13/11.
// Copyright (c) 2011 AirHeart. All rights reserved.
//
#define kTUILayoutViewHeight @"kTUILayoutViewHeight"
@mrjjwright
mrjjwright / hyperlinkString.m
Created Aug 24, 2011
TUIAttributedString as hyperlink
View hyperlinkString.m
+(id)hyperlinkFromString:(NSString*)inString withURL:(NSURL*)aURL
{
TUIAttributedString* attrString = [TUIAttributedString stringWithString:inString];
NSRange range = NSMakeRange(0, [attrString length]);
[attrString beginEditing];
[attrString addAttribute:NSLinkAttributeName value:[aURL absoluteString] range:range];
// make the text appear in blue
NSColor *blueColor = [TUIColor colorWithHexString:@"#3B5998"].nsColor;
@mrjjwright
mrjjwright / calculate.m
Created Aug 20, 2011
Calculate height for a given row
View calculate.m
- (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];