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 / 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);
});
}
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'
[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
@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.
@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);
// Calculates the space closest to the middle of the name
function splitName(name) {
var middle = name.length / 2;
var spaces = [];
var last = name.indexOf(' ');
while(last !== -1) {
spaces.push(last);
last = name.indexOf(' ', last + 1)
}
@amatiasq
amatiasq / race-condition.js
Created March 11, 2015 11:19
Solves a race condition issue on a Promise function: http://jsfiddle.net/amatiasq/zhmz8xdx/
function raceCondition(fn) {
var counter = 0;
return function() {
var index = ++counter;
var prom = fn.apply(this, arguments);
return new Promise(function(resolve, reject) {
prom.then(function(value) {
if (isLast()) resolve(value);
@amatiasq
amatiasq / index.html
Last active October 6, 2016 15:47
Listen to Raygun errors from angular app
<script src="//cdn.raygun.io/raygun4js/raygun.min.js"></script>
<script>
Raygun.init('<TOKEN>', {
excludedHostnames: ['localhost'],
})
.attach()
.withCustomData(function() {
return {
hash: document.location.hash,
};
@amatiasq
amatiasq / eslint.yaml
Last active August 29, 2015 14:20
ESLint conf
env:
browser: true
globals:
define: true
rules:
# possible errors
comma-dangle: [1, "always-multiline"]
no-cond-assign: [2, "except-parens"]
@amatiasq
amatiasq / deep-extend.js
Created May 12, 2015 11:19
Deep extend for simple JSON objects
function deepExtend(target, source) {
Object.keys(source).forEach(function(key) {
var value = source[key];
var dest = target[key];
var sourceType = typeof value;
var destType = typeof target[key];
if (Array.isArray(value) && Array.isArray(dest))
target[key] = dest.concat(value);
else if (sourceType === destType && sourceType === 'object')