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
//Copied from http://stackoverflow.com/q/4899799/119909 | |
function pixel(x,y){ | |
d[0] = 255;//r | |
d[1] = 0;//g | |
d[2] = 0;//b | |
d[3] = 255;//a | |
ctx.putImageData( id, x, y ); | |
} | |
var ctx = document.getElementById('c').getContext('2d'); | |
var id = ctx.createImageData(1,1); |
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
//Use ES6 modules for your controllers in SailsJS | |
//requires https://github.com/artificialio/sails-hook-babel | |
export default { | |
controllerAction1(req, res) { | |
//... | |
}, | |
controllerAction2(req, res) { | |
//... |
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
//Transpiled from Babel | |
"use strict"; | |
function MRDbg() { | |
for (var _len = arguments.length, txt = Array(_len), _key = 0; _key < _len; _key++) { | |
txt[_key] = arguments[_key]; | |
} | |
return function (prev, cur, i, arr) { | |
if (i === 1) { |
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
//Proposal for temporary scope variables | |
let result = something.crazy.long.bar ? something.crazy.long.bar() : something.crazy.long.other(); | |
//with() - Not 'strict' compliant | |
with (something.crazy.long){ | |
result = bar ? bar() : other(); | |
} | |
//fat arrow function |
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 myPromise(fn){ | |
let done = false; | |
let next = []; | |
fn(() => { | |
done = true; | |
while (next.length > 0) next.pop()(); | |
}); | |
return { | |
then: fn => { |
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
// g++ -o mypi -std=c++14 mypi.cpp | |
#include <iostream> | |
#include <string> | |
#include <ctime> | |
#include <limits> | |
double myPi(long long loopCount); | |
typedef std::numeric_limits< double > dbl; |
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
set -g mouse on | |
#set-option -g mouse on | |
set -g status-interval 2 | |
set -g status-right "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors --interval 2 --powerline-right)#[default]" | |
set -g status-right-length 60 | |
set -g pane-border-status top | |
set -g pane-border-format "#{pane_index} #{pane_current_command} #{pane_pid}" | |
set -g default-terminal "screen-256color" | |
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S - ; save-buffer %1 ; delete-buffer' |
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
watch --color git diff --color --stat | |
watch git status --porcelain |
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 fib_i(num) { | |
console.log(`Series of ${num}`); | |
let num2 = 0, num1 = 1; | |
for (let i = 0; i < num; i++) { | |
console.log(num1); | |
const next = num2 + num1; | |
num2 = num1; | |
num1 = next; | |
} | |
} |
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
// Use only vanilla JS | |
function callWhenReadyToGo(cb) { | |
var allImagesLoaded = false; | |
// Look at all P and SPAN for very short text that says "loading" | |
// we don't want long text as it might be part of a longer paragraph then | |
var textEls = document.querySelectorAll('SPAN, P'); | |
var loadingEls = []; | |
for (var i = 0; i < textEls.lenth; i++){ |
OlderNewer