Skip to content

Instantly share code, notes, and snippets.

@praxxis
praxxis / gist:88d156af12b26a6d9225
Created June 10, 2014 21:54
Sinon useFakeTimers and Ember
test('creates a local creation time property when saving', function () {
expect(1);
var now = new Date().getTime(),
clock = sinon.useFakeTimers(now),
model = App.Model.create(),
promise = Em.RSVP.resolve(),
superStub = sinon.stub(model, '_super').returns(promise);
model.save().then(function () {

Stuff you can do in Canvas JSX files

JSX

function foo(paths) {
  return <svg>{paths}</svg>;
}
@max-mapper
max-mapper / readme.md
Last active August 29, 2015 14:07
Node >= 0.10 Streams2 protips

@mafintosh said most of this, I just wrote it down

how to destroy/end streams in node >= 0.10

  • usually you call .destroy() if it has .destroy
  • if it doesnt have .destroy you are out of luck and the stream should upgrade to use e.g. newer through2
  • in request you call .abort() (this should get fixed to use .destroy())
  • .end() tries to end the stream gracefully

what about close

@johanobergman
johanobergman / 1. description.txt
Last active September 29, 2015 22:37
Sections in Ember.js components.
Simply register the two helpers "section" and "yield-section", and start right away!
See example below, using ember-cli:
@nimbupani
nimbupani / color-overlay.scss
Created February 18, 2012 05:02
Sass Snippets
// Use @include colorize('image.png', red, 0.5)
@mixin colorize($image, $color, $opacity) {
background: $color;
$color: transparentize($color, 1 - $opacity);
background: -webkit-linear-gradient(left, $color, $color), url($image);
background: -moz-linear-gradient(left, $color, $color), url($image);
background: -ms-linear-gradient(left, $color, $color), url($image);
background: -o-linear-gradient(left, $color, $color), url($image);
}
(function( exports ) {
function EventEmitter() {}
EventEmitter.prototype.emit = function() {
var type, handlers, args, listeners;
type = arguments[0];
args = [].slice.call( arguments, 1 );
@chuckha
chuckha / install_package.sh
Created December 4, 2012 17:07
install a python package
#!/bin/bash
rm -rf dist
rm -rf build
rm -rf *.egg-info
python setup.py install
@max-mapper
max-mapper / readme.md
Created December 6, 2012 20:50
hybrid app article topics
  • touch events to make web apps feel fast
  • default mobile css overrides (-webkit-touch-callout: none; etc)
  • using zepto to make mobile web apps
  • client side templating and routing for quick loading apps
  • supporting retina devices with sprites
  • css3 flexible box model and column layouts for responsive web apps
  • using phonegap to deploy web apps as native
  • web first development workflow (chrome dev tools, safari debugging)
  • how to submit a web app to the app store + google play
  • cross platform mobile code via feature detection
anonymous
anonymous / color.coffee
Created December 13, 2012 00:20
CoffeeScript Color parser
PopKit.Color = SC.Object.extend SC.Copyable,
rgb: (->
PopKit.Color.hsbToRgb(@get("hsb"))
).property("hsb")
copy: -> PopKit.Color.create(hsb: @get("hsb"))
PopKit.Color.reopenClass
hsbToRgb: (hsb) ->
[h, s, b] = hsb
@johnkpaul
johnkpaul / app.js
Created August 4, 2012 18:45
IE9- and Backbone.history's pushState
//in your application, rather than using window.location to get the current url
App.getLocation = function(){
return window.location.protocol + '//' + window.location.host
+ '/' + Backbone.history.options.root + Backbone.history.getFragment()
}