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 functools | |
import time | |
def timer(func): | |
"""Print the runtime of a decorated function.""" | |
@functools.wraps(func) | |
def wrapper_timer(*args, **kwargs): | |
start_time = time.perf_counter() | |
value = func(*args, **kwargs) | |
end_time = time.perf_counter() |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 path = require('path'); | |
var webpack = require('webpack'); | |
module.exports = { | |
entry: [ | |
'babel-polyfill', | |
'webpack-dev-server/client?http://localhost:8080', | |
'./src/js/app', | |
'./src/style.scss' | |
], |
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 App = ( | |
<Form> | |
<Row> | |
<Label /> | |
<Input /> | |
</Row> | |
</Form> | |
); |
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 getConfig = function() { | |
var readFile = Q.nfbind(fs.readFile); | |
return readFile(CONFIG_DIR + '/aFile.conf', 'utf-8').then(function(data) { | |
var configJSON = helpers.configStr2JSON(data, true); | |
return configJSON; | |
}); | |
}; |
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 fs = require('fs'); | |
var getConfig = function() { | |
// Using promises because fs.readFile() is async | |
var deferred = Q.defer(); | |
fs.readFile(__dirname + '/../../aFile.conf', 'utf-8', function(err, data) { | |
if (err) { | |
deferred.reject(err); | |
} | |
var configJSON = helpers.config2JSON(data, true); // true indicates we are parsing the input section | |
deferred.resolve(configJSON); |
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
a() | |
.then(b) | |
.then(c) | |
.then(d); |
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
a (function (data1) { | |
b (function (data2) { | |
c (function (data3) { | |
d (function (data4) { | |
e (function (data5) { | |
f (function (data6) { | |
// The Egyptions would be jealous of this pyramid! | |
}) | |
} | |
}) |
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
sayHello(); // will error out (see below for reason) | |
var sayHello = function() { | |
console.log('Hello, world!'); | |
}; |
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
sayHello(); // logs 'Hello, world!' | |
function sayHello() { | |
console.log('Hello, world!'); | |
} | |
NewerOlder