Skip to content

Instantly share code, notes, and snippets.

View kcrwfrd's full-sized avatar

Kevin Crawford kcrwfrd

View GitHub Profile
@paulsturgess
paulsturgess / mpd.md
Last active December 16, 2015 06:59
MPD On OSX

Installation

brew install mpd

Config

~/.mpdconf

port "6600"

@apkostka
apkostka / GJMap Wrapper
Created June 5, 2013 16:15
Wrapper for Google maps that creates markers from a JSON list. Relies on the google maps API (http://maps.googleapis.com/maps/api/js?sensor=false&v=3&language=en). Sample format is given for JSON objects.
var poi = [
{
name: 'name',
address: 'address',
phone: 'phone',
lat: 0.000,
lng: -0.000,
category: 'category',
icon: 'path/to/icon'
}
@jameshartig
jameshartig / ioCrawler.go
Last active September 19, 2018 00:23
Google I/O 2014 redeem easter egg crawler
//before running make sure you setup a GOPATH env variable and ran: "go get code.google.com/p/go.net/html"
//to run: go run ioCrawler.go -url="http://developers.google.com/"
//also try http://developer.android.com/index.html
//output goo.gl links to try and redeem will be sent to foundLinks.txt
//by the way there's an artificial "rate limit" in func crawler, you can lower that or raise it as you wish
//You can also comment out the onlyGoogleRegex code if you don't want to limit to google.com/youtube
//if you're getting I/O timeout errors, then you might need to increase the timeouts on line 231
@noahmiller
noahmiller / gulpfile-error-handling.js
Created May 15, 2014 16:54
Example error handling in a gulpfile
var gulp = require('gulp');
var gutil = require('gulp-util');
var jshint = require('gulp-jshint');
// Command line option:
// --fatal=[warning|error|off]
var fatalLevel = require('yargs').argv.fatal;
var ERROR_LEVELS = ['error', 'warning'];

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@kristopolous
kristopolous / hn_seach.js
Last active July 24, 2023 04:12
hn job query search
// Usage:
// Copy and paste all of this into a debug console window of the "Who is Hiring?" comment thread
// then use as follows:
//
// query(term | [term, term, ...], term | [term, term, ...], ...)
//
// When arguments are in an array then that means an "or" and when they are seperate that means "and"
//
// Term is of the format:
// ((-)text/RegExp) ( '-' means negation )
@lyoshenka
lyoshenka / coding_maxims.md
Last active August 23, 2023 21:18
Keep this in mind
@lirenlin
lirenlin / gist:013bc9fae7acfc48cc92cf40993cc772
Last active July 12, 2024 21:11
graph vs DAG vs tree
A Tree is just a restricted form of a Graph.
Trees have direction (parent / child relationships) and don't contain cycles.
It has only one path between any two vertices
They fit with in the category of Directed Acyclic Graphs (or a DAG).
So Trees are DAGs with the restriction that a child can only have one parent.
Directed Acyclic Graphs is a kind of directed graph that have no cycles.

iOS restrictions re: bringing up the keyboard on programmatic focus

I can't find exact specifications on this, but it seems that iOS restricts bringing up the keyboard via programmatically focusing on <input>. It only brings up the keyboard in response to explicit user interaction.

  1. iOS focus on input field only brings up keyboard when called inside a click handler.
  2. It doesn’t work if the focus is async.

This presents a curious problem when you want to autofocus an input inside a modal or lightbox, since what you generally do is click on a button to bring up the lightbox, and then focus on the input after the lightbox has been opened. Without anything fancy, it actually works ok. The problem shows up when you try to add something fancy like a setTimeout or a promise.then(). I don't know why people would want to use a setTimeout here, but waiting for a promise is actually a pretty common use case. E.g. we try to batch dom manipulations like getting a lightbox to show up inside `requestAnimati

@gaearon
gaearon / uselayouteffect-ssr.md
Last active October 22, 2024 04:12
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {