Skip to content

Instantly share code, notes, and snippets.

@lmignot
lmignot / redux-thunk-examples.js
Created January 30, 2018 17:42 — forked from markerikson/redux-thunk-examples.js
Redux-Thunk examples
// The classic AJAX call - dispatch before the request, and after it comes back
function myThunkActionCreator(someValue) {
return (dispatch, getState) => {
dispatch({type : "REQUEST_STARTED"});
myAjaxLib.post("/someEndpoint", {data : someValue})
.then(
response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}),
error => dispatch({type : "REQUEST_FAILED", error : error})
);
@lmignot
lmignot / gist:02ef92c2a0903e4a68c2
Created February 27, 2015 14:23
Enable text selection in QuickLook
defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder
// Avoid `console` errors in browsers that lack a console
if (!(window.console && console.log)) {
(function() {
var noop = function() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
var length = methods.length;
var console = window.console = {};
while (length--) {
console[methods[length]] = noop;
}
@lmignot
lmignot / mergeObjects.js
Created August 16, 2012 14:54
Takes any number of objects and returns one merged object
//Thanks to: http://stackoverflow.com/users/101909/robkohr
//Posted here: http://stackoverflow.com/a/6635477
var objectMerge = function(){
var out = {};
if(!arguments.length)
return out;
for(var i=0; i<arguments.length; i++) {
for(var key in arguments[i]){
out[key] = arguments[i][key];