Skip to content

Instantly share code, notes, and snippets.

@jiverson
jiverson / destructuring.js
Created April 18, 2016 16:20 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === 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];
@jiverson
jiverson / dataviz_venn.png
Created March 16, 2016 01:45 — forked from emeeks/dataviz_venn.png
Embed Image Data in SVG Elements
dataviz_venn.png
@jiverson
jiverson / index.html
Created March 16, 2016 01:41 — forked from nategood/index.html
Image Data to SVG
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
html, body {
margin: 0; padding: 0;
}

Difference between Debounce and Throttle

Debounce

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.

Throttle

@jiverson
jiverson / circle.css
Created November 30, 2015 20:25
circle image
/* <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%;
}
@jiverson
jiverson / gist:5b84b0d7b0c641fe82c7
Created October 6, 2015 01:20 — forked from masimplo/gist:324e77a2dd20fb4aa227
Decorating $http service to support url interpolation
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);
};
@jiverson
jiverson / cycle-metasyntactic-variables.vim
Created September 30, 2015 00:00 — forked from hail2u/cycle-metasyntactic-variables.vim
'foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'の上で<C-a>/<C-x>すると順にサイクルしてくれるやつ。レジスター使ってる。
" 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)
@jiverson
jiverson / filters.js
Last active August 29, 2015 14:25 — forked from kirkbushell/filters.js
Default value filter for Angular JS applications - allows you to output a variable, and assign it a default value if it has a value of 0, null, or is an empty string. Very similar to PHP's empty() function, but provides a default value instead of a boolean.
/**
* 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;
#!/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") {
@jiverson
jiverson / partial
Created April 23, 2015 16:24
partial script loader
(function () {
"use strict";
angular.module('utils.htmlPartialScriptLoader', [])
.factory('htmlPartialScriptLoader', htmlPartialScriptLoader);
function htmlPartialScriptLoader($q, scriptsForPartial) {
return {
response: response