Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# NVM_NODE_UPDATER | |
# v1.0.1 | |
# | |
# Makes keeping NVM-managed, global NodeJS installations up-to-date a breeze. | |
# First, the global NodeJS installation is updated to 'latest'. | |
# Second, all global NPM packages are migrated, then also updated to 'latest'. | |
# Requires the Node Version Manager (https://github.com/creationix/nvm). | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// === Arrays | |
var [a, b] = [1, 2]; | |
console.log(a, b); | |
//=> 1 2 | |
// Use from functions, only select from pattern | |
var foo = () => { | |
return [1, 2, 3]; |

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
html, body { | |
margin: 0; padding: 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* <img class="circle" src="/path/to/your/image.jpg"> */ | |
.circle { | |
border-radius: 50%; | |
-moz-border-radius: 50%; | |
-webkit-border-radius: 50%; | |
-o-border-radius: 50%; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function httpDecorator($delegate: ng.IHttpService) { | |
var $http = $delegate; | |
var wrapper = () => { | |
// interpolate the url | |
var config = arguments[0]; | |
config.url = interpolateUrl(config.url, config.params, config.data); | |
return $http.apply($http, arguments); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Cycle metasyntactic variables | |
function! s:CycleMetasyntacticVariables(num) | |
if type(a:num) != type(0) | |
return | |
endif | |
let vars = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'] | |
let cvar = expand('<cword>') | |
let i = index(vars, cvar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sets a default value for a given input. | |
* | |
* @param mixed input | |
* @param string defaultValue | |
* @return string | |
*/ | |
module.filter( 'default', [ '$filter', function( $filter ) { | |
return function( input, defaultValue ) { | |
if ( !input ) return defaultValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var fs = require('fs'); | |
var path = require('path'); | |
var sass = require('node-sass'); | |
var ENV = process.env.SASS_ENV || 'development'; | |
var file = 'variables.scss'; | |
//if in dev, directly pass file to sass | |
if (ENV === "development") { |