Skip to content

Instantly share code, notes, and snippets.

View ppcano's full-sized avatar

Pepe Cano ppcano

View GitHub Profile
@borismus
borismus / gist:2918946
Created June 12, 2012 17:38
Pinch-zoom recognizer
/**
* Gesture recognizer for compound multi-touch transformations.
*
* 1. pinch/zoom/scale gesture.
* 2. rotate gesture.
*/
function TransformRecognizer(element) {
// Reference positions for the start of the transformation.
this.referencePair = null;

Relationship Semantics

The new relationship semantics change the current app/store/transaction/adapter APIs in several ways:

Changes to the Application API

At present, a record can be freely moved across transactions as long as it has no changes. Once a record accumulates at least one change, an application cannot move it out of its current transaction until the transaction is committed or rolled back.

@ghempton
ghempton / ember-controllers.md
Created July 18, 2012 21:16
Ember.js Controller Brainstorm

Ember.js Controller Brainstorm

Currently, there are several awkward points to Ember.js controllers. Namely:

  1. Passing controllers around to view's not instantiated by the routing system is hard.
  2. Non-singleton controllers are very difficult to manage (e.g. #each where each view has it's own controller).
  3. Sharing data between controllers is difficult.

Solution for 1 and 2: Controllers are lazily created by views

@charlesjolley
charlesjolley / dev_view.coffee
Created August 21, 2012 03:57
Adding event locks to Ember
# example view implements a simple dragging for mouse events.
Wall.DevView = Ember.View.extend
mouseDown: (ev) ->
ev.dispatcher.lock @, 'mouseMove', 'mouseUp'
@_mouseDown = @$().offset()
@_mouseDown.pageX = ev.pageX
@_mouseDown.pageY = ev.pageY
@_mouseDown.dispatcher = ev.dispatcher
console.log 'mouseDown'
@Nopik
Nopik / application.js.hamlbars
Created September 1, 2012 09:30
Named outlets in Ember views
.navbar.navbar-fixed-top
%ul.dropdown-menu
%li.nav-header
Projects
%li.divider
{{outlet projectNames}}
%li.divider
@ronkorving
ronkorving / ios6-timers.js
Last active March 9, 2022 03:40
iOS6 webkit timer bug workaround
(function (window) {
// This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6.
// iOS6 suffers from a bug that kills timers that are created while a page is scrolling.
// This library fixes that problem by recreating timers after scrolling finishes (with interval correction).
// This code is released in the public domain. Do with it what you want, without limitations. I do not promise
// that it works, or that I will provide support (don't sue me).
// Author: rkorving@wizcorp.jp
var timeouts = {};
@domenic
domenic / promises.md
Last active May 13, 2026 13:10
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@ppcano
ppcano / Article.md
Created December 11, 2012 10:29 — forked from Warry/Article.md
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

@leepfrog
leepfrog / gist:4284160
Created December 14, 2012 09:48
#EmberJS - Adding support for CSRF from Rails to your Adapter
App.Adapter = DS.RESTAdapter.extend
# Add CSRF Token from Rails to non-get requests
ajax: (url, type, hash) ->
if hash.data and type isnt "GET"
hash.data['authenticity_token'] = jQuery("meta[name='csrf-token']").attr("content")
@_super(url,type,hash)
@ppcano
ppcano / store_adaper_test.js
Last active December 10, 2015 15:29
record.loadedData in Run.once async problem
asyncTest("Records loaded multiple times and retrieved in recordArray are ready to send state events", function() {
adapter.findQuery = function(store, type, query, recordArray) {
var self = this;
setTimeout(function() {
Ember.run(function() {
// use different recordArray based on the call
var recordArray = (!!people2) ? people2 : people;