Example of different ways to bind instance methods so they persist access to this
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
# reload configs | |
bind r source-file ~/.tmux.conf | |
# increase the scroll buffer size | |
set -g history-limit 10000 | |
# add the prefix key Ctrl+J | |
set-option -g prefix C-j | |
set-option -g prefix2 C-b |
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
import fetch from './fetch-proxy.js'; | |
export async function saveImage(imageURI) { | |
return await fetch('user/picture', { | |
method: 'PUT', | |
body: { photoContent: imageURI }, | |
fileKeys: ['photoContent'], | |
}); | |
} |
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
// Abstract creating an action that has a type and a payload: | |
// const addTodo = createAction(ADD_TODO); | |
// is equivalent to | |
// const addTodo = (payload) => ({ type: ADD_TODO, payload }); | |
// | |
// Optionally you can pass in a payloadMap when defining an action | |
// to reshape the payload before storing it on the action. | |
import { identity } from 'lodash'; |
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
// This demo uses Babel for es2015 compilation and Promises, and superagent for requests. | |
// An example async pipeline, using a demo API | |
document.getElementById('run').addEventListener('click', (evt) => { | |
iteratePromises(function* () { | |
log('Requesting list of posts'); | |
let postsResponse = yield superagent.get( | |
'http://jsonplaceholder.typicode.com/posts/'); | |
log('Requesting author of first post'); |
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
// Find symlinks that don't work and fix them. | |
// | |
// This is done by: | |
// 1. Getting a list of all file paths in a directory | |
// 2. Filtering for broken symlinks by reading binary content as unicode | |
// 5. Determining relative path between source and target | |
// 6. Deleting old link file | |
// 7. Creating new relative link file | |
var fs = require('fs'); |
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
/** | |
* getProgressPlugin | |
* Return a progress plugin instance which outputs build progress percentages in realtime | |
* | |
* @return {Object} A ProgressPlugin instance | |
*/ | |
function getProgressPlugin() { | |
var chars = 0, lastState, lastStateTime; | |
return new webpack.ProgressPlugin(function(percentage, msg) { | |
var state = msg; |
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
var crossDomain = (function(){ | |
var top = null; | |
try { | |
top = window.top.location.host; | |
} catch(err) {} | |
return (top === null); | |
}()); |
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
settings = { | |
jshint: true, | |
editor: { | |
theme: "monokai", | |
indentUnit: 4, | |
smartIndent: true, | |
lineWrapping: true, | |
lineNumbers: true, | |
matchBrackets: true | |
} |
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 getExternalIp() { | |
var ifconfig = require('os').networkInterfaces(); | |
var device, i, I, protocol; | |
for (device in ifconfig) { | |
// ignore network loopback interface | |
if (device.indexOf('lo') !== -1 || !ifconfig.hasOwnProperty(device)) { | |
continue; | |
} | |
for (i=0, I=ifconfig[device].length; i<I; i++) { |
NewerOlder