Skip to content

Instantly share code, notes, and snippets.

View berzniz's full-sized avatar

Tal Bereznitskey berzniz

View GitHub Profile
Backbone.easyXDMxhr = new easyXDM.Rpc({
remote: 'http://foo.bar/cors/',
}, {
remote: {
request: {}
}
});
Backbone.ajax = function() {
var options = arguments[0];
//
// TBKeychainCounter.h
//
// Created by Tal Bereznitskey on 5/11/13.
// Copyright (c) 2013 Tal Bereznitskey. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TBKeychainCounter : NSObject
- (void)viewDidLoad
{
[super viewDidLoad];
[self observeModel]
[self render];
}
- (void)observeModel
{
// KVO is used to observe model changes
initialize: function() {
// Observe changes to the model and call the render function when they happen
this.model.on('change', this.render, this);
// Render the view for the first time
render();
}
userMarkedObjectAsFavorite: function() {
// We're changing the mode, not the UI
@berzniz
berzniz / gist:2900942
Created June 9, 2012 13:21
handlebars25
var compiledTemplate = Handlebars.getTemplate('hello');
var html = compiledTemplate({ name : 'World' });
@berzniz
berzniz / gist:2900905
Created June 9, 2012 13:01
handlebars3
Handlebars.getTemplate = function(name) {
if (Handlebars.templates === undefined || Handlebars.templates[name] === undefined) {
$.ajax({
url : 'templatesfolder/' + name + '.handlebars',
success : function(data) {
if (Handlebars.templates === undefined) {
Handlebars.templates = {};
}
Handlebars.templates[name] = Handlebars.compile(data);
},
@berzniz
berzniz / gist:2900902
Created June 9, 2012 12:59
handlebars2
var compiledTemplate = Handlebars.templates['hello'];
var html = compiledTemplate({ name : 'World' });
@berzniz
berzniz / gist:2900899
Created June 9, 2012 12:57
handlebars1
var rawTemplate = '<p>Hello {{name}}</p>'; // (step 1)
var compiledTemplate = Handlebars.compile(rawTemplate); // (step 2)
var html = compiledTemplate({ name : 'World' }); // (step 3)
// html content will now be: <p>Hello World</p>
@berzniz
berzniz / gist:2594243
Created May 4, 2012 11:28
With booleans
BOOL viewAcontainsViewB = (viewA.origin.y < viewB.origin.y) && (viewB.origin.y + viewB.size.height < viewA.origin.y + viewA.size.height);
if (viewAcontainsViewB) {
[self doSomething];
}
@berzniz
berzniz / gist:2594221
Created May 4, 2012 11:27
No booleans
if ((viewA.origin.y < viewB.origin.y) && (viewB.origin.y + viewB.size.height < viewA.origin.y + viewA.size.height)) {
[self doSomething];
}