Skip to content

Instantly share code, notes, and snippets.

View amatiasq's full-sized avatar

A. Matías Quezada amatiasq

View GitHub Profile
@amatiasq
amatiasq / funct.js
Created January 20, 2015 16:06
Wrap functions to support promises as arguments
// $q comes from angular
function wrapFunct(fn) {
return function() {
var context = this;
var args = [].slice.call(arguments);
var resolved = $q.all(args.map($q.when));
return resolved.then(function(values) {
return fn.apply(context, values);
@amatiasq
amatiasq / jshintrc.js
Last active August 29, 2015 14:13
All JSHint options
// jshint maxlen:false
{
// Enforcing
"bitwise": true, // Prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others.
"camelcase": true, // Allows you to force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly": false, // Requires you to always put curly braces around blocks in loops and conditionals.
"enforceall": false, // Is a short hand for the most strict JSHint configuration.
"eqeqeq": true, // This options prohibits the use of == and != in favor of === and !==.
"es3": false, // Tells JSHint that your code needs to adhere to ECMAScript 3 specification.
[app:api]
use = egg:thefc
pyramid.debug = true
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = true
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_tm
1 """adding display_networktab column to blog
2
3 Revision ID: 43dd765b5380
4 Revises: 4b76556140fb
5 Create Date: 2014-12-09 17:54:39.803860
6
7 """
8
9 # revision identifiers, used by Alembic.
10 revision = '43dd765b5380'
@amatiasq
amatiasq / search.js
Last active August 29, 2015 14:07
Parse URL search section ('?foo=123&bar=stuff')
function getSearch() {
return window.location.search
.substr(1) // remove the '?'
.split('&')
.map(function(entry) {
return entry
.split('=')
.map(decodeURIComponent);
});
}
@amatiasq
amatiasq / curry.js
Last active January 7, 2025 08:27
Simple way to recursively curry javascript functions http://jsfiddle.net/amatiasq/osrsomq0/
/**
* @param {Function} fn Function to curry.
* @param {Number} lenght The arguments required to invoke the function. Optional. By default is fn.length
* @returns {Function} The currified function.
*/
function curry(fn, length) {
length = length || fn.length;
return function currified() {
var args = [].slice.call(arguments);
@amatiasq
amatiasq / throttle-promise.js
Last active November 16, 2018 16:20
This function will prevent a long operation to be executed twice in parallel. If the function is invoked a second time before the first time has completed it will receive the same promise from the first invocation without need to invoke the operation again.
function throttlePromise(operation) {
var promise = null;
return function() {
if (!promise) {
promise = operation.apply(this, arguments).finally(function() {
promise = null;
});
}
@amatiasq
amatiasq / .jshintrc
Created September 3, 2014 08:28
JSHint config
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope
(function() {
function Deferred() {
if (window.Promise) {
var that = this;
this.promise = new Promise(function(resolve, reject) {
that._resolve = resolve;
that._reject = reject;
});
}
function listenAll(target) {
var protos = [],
proto = target;
while (proto) {
protos.push(proto);
proto = Object.getPrototypeOf(proto)
}
protos