Skip to content

Instantly share code, notes, and snippets.

View doublejosh's full-sized avatar
🎰
front-ending

Josh Lind doublejosh

🎰
front-ending
View GitHub Profile
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@bzerangue
bzerangue / json-to-ndjson.md
Last active January 31, 2024 20:57
JSON to NDJSON

NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.

  • Each line is a valid JSON value
  • Line separator is ‘\n’

1. Convert JSON to NDJSON?

cat test.json | jq -c '.[]' > testNDJSON.json
@iamEAP
iamEAP / .travis.yml
Last active January 20, 2023 09:23
Template for integrating Travis-CI and Pantheon Multidev
language: php
#
# Important to note, this is the version of PHP used to run this build, not the
# one used to run your Drupal installation. Ensure compatibility with the Drush
# and Terminus versions you're using for this build.
#
php:
- 5.3
@jtwalters
jtwalters / cross-browser-window-load-function.js
Last active November 16, 2016 22:04
Cross browser addEvent function (window load, ready, etc.)
(function () {
//////////////////////////////
// Add event (cross browser)
// From http://stackoverflow.com/a/10150042
//////////////////////////////
function addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent('on' + event, function() {
/**
* New Tabia/Components JS-pattern.
*/
// Loose augmentation pattern. Creates top-level namespace variable if it
// doesn't already exist.
var Tabia = Tabia || {};
// Create a base for this module's data and functions.
Tabia.myBehavior = {};
@angrytoast
angrytoast / omghosts
Created April 10, 2014 23:39
omg hosts
#! /usr/bin/env bash
PROBLEM="$(cat /etc/hosts | grep tableausoftware.com | grep -v '^#' | wc -w)"
if [ "$PROBLEM" -gt 0 ]; then
say omg fix yer hosts
fi
@iamEAP
iamEAP / nightly_workflow.sh
Last active November 3, 2015 10:21
Keep Pantheon test environment up-to-date and squeeky clean
#!/bin/bash
PSITE='your-site-name'
PUUID='aaaaaaaa-1111-bbbb-2222-cccccccccccc'
PEMAIL='your-email@example.com'
PPASS='your-password-here--i-know'
# Authenticate with Terminus
drush pauth $PEMAIL --password=$PPASS
foo = false;
(function () {
foo = true;
})();
setTimeout(function () {
foo = false;
}, 0);
"""Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
__version__ = "0.6"