Skip to content

Instantly share code, notes, and snippets.

@pc035860
pc035860 / 0_reuse_code.js
Created October 7, 2013 07:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
app.directive('autoFillSync', function($timeout) {
return {
require: 'ngModel',
link: function(scope, elem, attrs) {
var origVal = elem.val();
$timeout(function () {
var newVal = elem.val();
if(ngModel.$pristine && origVal !== newVal) {
ngModel.$setViewValue(newVal);
}
@pc035860
pc035860 / gist:8129655
Created December 26, 2013 04:05
javascript basic proxy function
/**
* Context and arguments proxy function
*
* @param {function} func the function
* @param {object} context the context
* @param {array} args arguments
* @return {function} proxied function
*/
function proxy(func, context, args) {
return function () {
@pc035860
pc035860 / async-chunk-queued.js
Created December 28, 2013 10:54
Chunked Executions Need "setImmediate" and "Promise"
// async version of timedChunk plus queued by robin
function asyncChunkQueued(items, process, context, callback) {
var todo = items.concat(), //create a clone of the original
i = 0, // index counter
dfd = $.Deferred(),
routine = function () {
process.call(context, todo.shift(), i++)
.then(function () {
if (todo.length > 0) {
_setImmediate(routine);
var Promise = require('bluebird');
// log the error
Promise.onPossiblyUnhandledRejection(function(error){
// this will be called even though there is a catch
console.log('uncaught error here', error);
});
var toCall = Promise.coroutine(function* () {
console.log('going to explode');
@pc035860
pc035860 / fire-util.js
Created March 9, 2014 15:19
Util module for working with Firebase & angularFire
angular.module('fireUtil', ['firebase'])
.provider('fireUtil', function () {
var util, $get;
util = {
rootUrl: null,
$get: ['Firebase', function (Firebase) {
var _rootRef = util.rootUrl ? new Firebase(util.rootUrl) : null;
@pc035860
pc035860 / glance.js
Created March 9, 2014 16:11
Attach a new helper function "$glance" to scope. Enables complex conditional scope one-time observation.
angular.module('scope.glance', [])
.factory('attach$glance', ['$q', function ($q) {
function $glance(watchExpression, checkFunction, objectEquality) {
var scope = this;
var dfd = $q.defer(),
clearWatch;
checkFunction = checkFunction || function (newVal, oldVal, scope) {
@pc035860
pc035860 / README.md
Last active August 29, 2015 13:57
`fireutil` module for powering up `angularFire` https://github.com/firebase/angularFire

fireutil

A collection of utilities for making your life with angularFire better.

$firebaseArr

Reference: FirebaseExtended/angularfire#200 (comment)

Generate $firebase object of an array type, which can be used with handy angular filters.

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

// SmoothScroll for websites v1.2.1
// Licensed under the terms of the MIT license.
// People involved
// - Balazs Galambosi (maintainer)
// - Michael Herf (Pulse Algorithm)
(function(){
// Scroll Variables (tweakable)