This file contains hidden or 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
| 'use strict'; | |
| var _ = require('lodash'); | |
| module.exports = function(file, api, options) { | |
| const j = api.jscodeshift; | |
| const root = j(file.source); | |
| let hasModifications = false; |
This file contains hidden or 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"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| .clock { | |
| border: 1px solid black; | |
| width: 400px; |
This file contains hidden or 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
| [ | |
| { | |
| "name": "Afghanistan", | |
| "code": "AF" | |
| }, | |
| { | |
| "name": "Åland", | |
| "code": "AX" | |
| }, | |
| { |
This file contains hidden or 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
| // Copies braintree webpage table into a more easily to consume json object. | |
| // Steps: | |
| // 1: go to https://developers.braintreepayments.com/ios+ruby/reference/general/countries | |
| // 2: include jquery on the page | |
| // 3: execute js below | |
| // grabs all country codes and puts it into a json object like so: {name: 'United States', code: 'US' } | |
| var json = []; $('table').find('tr').each(function(i, el) { json.push({'name': $(el).find('td:nth(0)').html(), 'code': $(el).find('td:nth(1)').html()} ) }); copy(json); |
This file contains hidden or 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 logSomething(str) { | |
| console.log(str); | |
| } | |
| window.addEventListener('resize', throttle(logSomething.bind(null, 'nothing'), 250)); | |
| window.addEventListener('resize', debounce(logSomething.bind(null, 'something'), 250)); | |
| function throttle(fn, interval) { | |
| var later; | |
| var timerId; |
This file contains hidden or 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
| // ** Simple Debounce ** | |
| // | |
| // returns a new function that will execute once and only once coalescing | |
| // multiple sequential calls into a single execution at either the very | |
| // beginning or end. | |
| function debounce(callback, delay, immediate) { | |
| var timeout; | |
| return function() { | |
| var context = this; |
This file contains hidden or 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
| // ** Simple Throttling ** | |
| // | |
| // returns a new function that will execute your function | |
| // no more than once every `interval` milliseconds. | |
| function throttle(fn, interval) { | |
| var later, timerId; | |
| return function() { | |
| var now = +new Date(); | |
| if (later && now < (later + interval)) { |
This file contains hidden or 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
| var nestedNumbers = [1,2,3,[1,2,3,[12]]]; | |
| var sumOfArray = function(arr, sum) { | |
| for (var i = 0; i < arr.length; i++) { | |
| if (typeof arr[i] === 'object' && arr[i].length) { | |
| sum = sumOfArray(arr[i], sum); | |
| } else { | |
| sum += arr[i]; | |
| } | |
| } |
This file contains hidden or 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
| // ---- Code ---- | |
| var EventAggregator = function() { | |
| this.events = {}; | |
| } | |
| EventAggregator.prototype.trigger = function (msg) { | |
| var args = Array.prototype.splice.call(arguments, 1); | |
| for(var i = 0, len = this.events[msg].length; i < len; i++) { | |
| this.events[msg][i].apply(this, args); |
This file contains hidden or 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
| export CLICOLOR=1 | |
| export LSCOLORS=GxFxCxDxBxegedabagaced | |
| export PS1='\W\$ ' |
NewerOlder