Skip to content

Instantly share code, notes, and snippets.

function fruitFetcher(prefix, callback) {
callback([
'apples',
'bananas',
'oranges',
]);
}
function animalFetcher(prefix, callback) {
callback([
import React from 'react';
import ReactDOM from 'react-dom';
import _ from 'lodash';
import './style.css';
const RATE_LIMIT = 500;
class Autocomplete extends React.Component {
constructor(props) {
super(props);
const net = require('net');
const _ = require('lodash');
const state = [1, 1, 1, 1];
let index = 0;
var client = new net.Socket();
function makeGuess() {
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const globby = require('globby');
const glob = '{components,modules,pages,utilities,globals,bundles,legacy-js}/**/*.{js,jsx}';
const stats = JSON.parse(fs.readFileSync(path.join(__dirname, 'stats.json')));
const entryFilter = x => /jsx?$/.test(x) && !/node_modules/.test(x);
@lavelle
lavelle / convert-date-components.js
Last active February 15, 2018 22:13
Lodash Art Gallery
// Author: Giles
const datetimeComponents = _(matchResults).tail().map(_.toNumber).value();
// Better than
var datetimeComponents = _.map(
matchResults.slice(1, 6), // skip the matched result
function(component) {
return parseInt(component, 10);
}
);
@lavelle
lavelle / webdav.js
Last active August 29, 2015 14:06
FSP error code mapping
/**
* WebDAV error code map.
* All taken from http://msdn.microsoft.com/en-us/library/aa142917(v=exchg.65).aspx
* @const
* @type {Object}
*/
var ERROR_MAP = {
DELETE: {
'204': 'OK',
'423': 'IN_USE'
@lavelle
lavelle / console.diff
Created July 29, 2013 20:41
jQuery console diff
diff --git a/jquery.console.js b/../doppio/vendor/jquery.console.js
index 10e893e..7db1f1c 100644
--- a/jquery.console.js
+++ b/../doppio/vendor/jquery.console.js
@@ -38,9 +38,12 @@
// Google Chrome 5.0.375.55 (Mac)
(function($){
- var isWebkit = !!~navigator.userAgent.indexOf(' AppleWebKit/');
-

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@lavelle
lavelle / git-cheat.md
Last active December 19, 2015 10:59
All the useful Git commands I've found (mostly from StackOverflow), in one convenient reference.

Branch from an old commit

git branch branchname ref

where ref is either a sha (abcd123) or a pointer HEAD@{5}

Undo a commit

git reset HEAD~1
@lavelle
lavelle / gist:2871439
Created June 4, 2012 23:24
LayoutManager fetch override
var HeaderView = Backbone.View.extend({
//template: '#header-tmpl',
tagName: 'header',
fetch: function(name){
var done = this.async();
$.ajax({
url: 'header.html',
success: function(contents){
done(contents);