Skip to content

Instantly share code, notes, and snippets.

View joachimhs's full-sized avatar

Joachim Haagen Skeie joachimhs

View GitHub Profile
@joachimhs
joachimhs / AppController.j
Created November 22, 2011 22:51
Objective-J CPOutlineView
/*
* AppController.j
* nibapptest
*
* Created by You on November 20, 2011.
* Copyright 2011, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPOutlineView.j>
@joachimhs
joachimhs / TreeStructure.j
Created November 22, 2011 22:52
Objective-J CPOutlineView
/*
* AppController.j
* nibapptest
*
* Created by You on November 20, 2011.
* Copyright 2011, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPOutlineView.j>
@joachimhs
joachimhs / metamorph.js
Created January 10, 2012 16:55
ember.js metamorph
I have the following template:
<script type="text/x-handlebars" data-template-name="header-template">
<ul id="menu">
{{#each KR.MenuItemController.content }} <li><a href="#">{{ menuName }}</a>
{{#if hasSubItems}}
<ul>
{{#each subItems}}
<li><a href="#" onclick='KR.MenuItemController.set("clickedItem", {{ menuAction}})'>{{ menuName }}</a></li>
{{/each}}
@joachimhs
joachimhs / binding.js
Created January 11, 2012 13:48
bidning problem
For some reason I am unable to get the bindings to work as they are supposed to...
index.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
@joachimhs
joachimhs / gist:2260072
Created March 31, 2012 06:46
handlebars helper disqus
Handlebars.registerHelper('disqus', function(property) {
var value = '<script type="text/javascript" src="http://joachimhs.disqus.com/combination_widget.js?num_items=5&hide_mods=0&color=blue&default_tab=people&excerpt_length=200"></script><a href="http://disqus.com/">Powered by Disqus</a>';
console.log(value);
return new Handlebars.SafeString(value);
});
@joachimhs
joachimhs / Vertx.handler
Created May 14, 2012 16:41
Vert.X Handler
package org.eurekaj.manager.data;
import org.vertx.java.core.Handler;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpServerRequest;
public class HandleInstrumentationMenuRequest implements Handler<Buffer> {
private HttpServerRequest req;
public HandleInstrumentationMenuRequest(HttpServerRequest req) {
@joachimhs
joachimhs / primaryKeyMissing
Created May 23, 2012 08:21
No Primary Key
Model:
MyApp.Photo = DS.Model.extend({
primaryKey: 'id',
id: DS.attr('string'),
photoName: DS.attr('string'),
photoDescription: DS.attr('string'),
photoFullSizeURL: DS.attr('string'),
photoThumbnailURL: DS.attr('string')
});
@joachimhs
joachimhs / gist:2775283
Created May 23, 2012 13:40
No Properties from Ember Data
Problem: The JSON is received from the server, but only the "id" property have a value. The GUI only displays the String "2 1", an the {{photoName}} is ignored. Manually calling MyApp.PhotoController.get('content').objectAt(0).get('photoName') returns "undefined", whereas MyApp.PhotoController.get('content').objectAt(0).get('id') returns the correct ID.
Any Sugggestions ?
//My Model:
MyApp.Photo = DS.Model.extend({
id: DS.attr('number'),
photoName: DS.attr('string'),
photoDescription: DS.attr('string'),
photoFullSizeURL: DS.attr('string'),
@joachimhs
joachimhs / gist:2900484
Created June 9, 2012 10:38
Ember Router
HS.router = Ember.Router.create({
rootElement: '#emberArea',
start: Ember.ViewState.extend({
route: "/",
setupControllers: function(manager) {
if (window.console) console.log('setupControllers: /');
},
@joachimhs
joachimhs / gist:2950393
Created June 18, 2012 20:00
ArrayController
Controller:
HS.BlogPostsListController = Em.ArrayController.create({
content: [],
sortAscending: true,
sortProperties: ['postDate'],
...
});
Populated with: