Skip to content

Instantly share code, notes, and snippets.

View cgrinaldi's full-sized avatar

Chris Rinaldi cgrinaldi

View GitHub Profile
@cgrinaldi
cgrinaldi / promise-mistake-after.js
Created June 14, 2015 23:18
An example of properly using promises (no deferred!)
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;
});
};
@cgrinaldi
cgrinaldi / js-example.jsx
Last active November 21, 2015 17:57
An example of transpiling JSX into JavaScript
var App = (
<Form>
<Row>
<Label />
<Input />
</Row>
</Form>
);
@cgrinaldi
cgrinaldi / basic-webpack-config.js
Created November 21, 2015 18:26
A basic Webpack configuration
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'
],
@cgrinaldi
cgrinaldi / 0_reuse_code.js
Created November 29, 2016 21:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@cgrinaldi
cgrinaldi / timer_decorator.py
Created December 12, 2018 16:42
Timer decorator for function timing
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()