Skip to content

Instantly share code, notes, and snippets.

View nickjs's full-sized avatar

Nicholas J. Small nickjs

View GitHub Profile
diff --git a/AppKit/CPArrayController.j b/AppKit/CPArrayController.j
index 5fefb58..729b937 100644
--- a/AppKit/CPArrayController.j
+++ b/AppKit/CPArrayController.j
@@ -334,8 +334,12 @@
- (CPArray)selectedObjects
{
var objects = [[self arrangedObjects] objectsAtIndexes:[self selectionIndexes]];
+ if (objects)
+ objects = [_CPObservableArray arrayWithArray:objects];
function dateFromRailsAPI(aString){
if (!aString)
return;
var regexp = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/,
matches = aString.match(new RegExp(regexp)),
offset = 0,
date = new Date();
if (matches)
@nickjs
nickjs / gist:576724
Created September 13, 2010 02:32 — forked from anonymous/gist:576694
@import <Foundation/CPObject.j>
@import "../Models/MenuItem.j"
@import "../Views/AccountsWindow.j"
@implementation MainMenuController : CPObject
{
CPView _mainView;
CPString _username;
MenuItem mainMenu @accessors;
var SharedController;
@implementation MyController : CPObject
{
}
+ (MyController)sharedController
{
if (!SharedController)
@nickjs
nickjs / CPUserDefaults.j
Created November 1, 2010 21:31
CPUserDefaults
/*
* CPUserDefaults.j
* Foundation
*
* Created by Nicholas Small.
* Copyright 2010, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@nickjs
nickjs / classbug.coffee
Created April 29, 2011 16:21
PARSE ERROR ON LINE 2: UNEXPECTED ','
class User extends Object
foo: @property 'bar', ->
console.log 'foo'
@nickjs
nickjs / observable_test.coffee
Created May 26, 2011 19:16
Use case for extended or something similar.
###
# Use case for `extended` or something similar.
###
# Library Code
# mixin helper
mixin = (to, object) ->
for key, value of object
to[key] = value
@nickjs
nickjs / uselessthing.coffee
Created September 20, 2011 22:40
A totally useless way to use CoffeeScript
c = (obj) ->
(callback) ->
callback.call(obj)
foo = c 'bar'
alert foo -> @length
random = c foo: c 'bar'
alert random -> @foo -> @[0]
class Shopify.ProductsIndexView extends Batman.View
# should be YourApp.ControllerActionView
ready: ->
$('span').slider()
@nickjs
nickjs / stupid.js
Created June 7, 2012 07:06
Infinite Picture Generator
(function() {
var canvas = document.getElementById('canvas');
var MAX_ROWS = canvas.height;
var MAX_COLS = canvas.width;
var code = "var context = document.getElementById('canvas').getContext('2d');var color;\n";
var magicNumber = 255/5;
var pixelCount = 0;