Skip to content

Instantly share code, notes, and snippets.

View grevory's full-sized avatar

Gregory Pike grevory

View GitHub Profile
@pauljoey
pauljoey / es6_toolkit.md
Last active March 22, 2017 13:11
Bullet points for getting started with ES6+

Migrating web project to ES6+

  • Keep your old code exactly as-is.
  • Keep writing ES5.
  • Add JSPM (+Babel +SystemJS) to your project
  • Skip using JSPM for dependency management for now. Stick to what you're already doing.
  • Get the tiniest possible ES6+ snippet working alongside your existing code
  • Begin using ES6 modules to wire up new components that you write
  • Slowly introduce new ES6+ syntax that you are comfortable with, verify the ES5 output
  • Expand ES6+ usage
@escalant3
escalant3 / gist:9783136
Last active August 29, 2015 13:57
Angular idiom to add extra methods to all the $scopes
angular.module('foo', [])
.config(function($provide) {
$provide.decorator('$rootScope', function ($delegate) {
// Shim needed for browsers I don't care about
var proto = Object.getPrototypeOf($delegate);
proto.$bar = function() {
// Do something
};
@uhtred
uhtred / waitFor.js
Last active August 29, 2015 13:57
@problem: When I have no control on some ajax or generated html and I need to wait for them. @Solution: Set an interval to check my conditions and them execute a callback.
@Problem: When I have no control on some ajax or generated html and I need to wait for them.
@Solution: Set an interval to check my conditions and them execute a callback.
function waitFor ( options ) {
options = $.extend( {}, {
callback: function(){},
condition: function(){ return true },
interval: 100
}, options);
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"