Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View h3h's full-sized avatar

Bradford Fults h3h

View GitHub Profile
@h3h
h3h / 01.elm
Last active September 25, 2017 08:06
Elm Tutorial Roll Dice with SVG – Start here: http://elm-lang.org/examples/random
module Main exposing (..)
import Html exposing (..)
import Html.Attributes
import Html.Events exposing (..)
import List
import Random
import Svg exposing (..)
import Svg.Attributes exposing (..)
@h3h
h3h / 01.elm
Last active December 18, 2016 06:22
Evolving Elm Validation Code
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import List
import Regex exposing (regex)
main =
Html.beginnerProgram
{ model = model
@h3h
h3h / .gitconfig
Created December 11, 2015 20:26
Git Config
[alias]
amend = commit --amend
co = checkout
st = status
cp = cherry-pick
# edit config (global, local)
ec = !vim ~/.gitconfig
ecl = !vim .git/config
@h3h
h3h / maxLocalStorage.js
Last active December 9, 2015 00:08
Fill up localStorage completely on a given page.
var DATA = [
'0',
'0000000000',
'0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
];
var chunkSize, i, printFactor;
var chunkIndex = (DATA.length - 1);
while (chunkIndex >= 0) {
try {
chunkSize = DATA[chunkIndex].length;
@h3h
h3h / GitGutter.sublime-settings
Last active December 20, 2015 22:50
Preventing OS X’s aggressive git shim prompt when you don’t have Xcode installed.
{
// Custom path to git binary when not in PATH
"git_binary": "/usr/local/bin/git"
}
@h3h
h3h / explanation.md
Last active August 29, 2015 14:11
HR 4681 Section 309

TL;DR

Congress (House & Senate) just passed (amidst the release of the torture report and the Gruber hearing) an amendment to the annual intelligence agencies’ budget bill (HR 4681, Section 309) that makes it legal to:

  • Collect all electronic communications from everyone in the world
  • Store all of that data for at least 5 years
  • Store the data indefinitely if it’s encrypted or evidence of a crime (presumably until a supercomputer can break the encryption, assuming that hadn’t happened within 5 years)
  • Disseminate the data (presumably at the inteliigence agencies’ own discretion, e.g. to your local police or the DEA)
#!/bin/bash -e
number_of_cores=`sysctl -n hw.ncpu`
brew update && \
brew upgrade ruby-build libxml2 libxslt libiconv
brew link --force libiconv && \
bundle config --global build.nokogiri "--with-xml2-include=/usr/local/include --with-xml2-lib=/usr/local/lib --with-xslt-dir=/usr/local/opt/libxslt --with-iconv-include=/usr/local/include --with-iconv-lib=/usr/local/lib" && \
bundle config --global jobs `expr $number_of_cores - 1` && \
rbenv install 2.1.5 && \
@h3h
h3h / background_validation.js.coffee
Created October 20, 2014 14:53
Automatic Per-field Background Validation for Forms
# Automatic Per-field Background Validation for Forms
#
# Usage:
#
# 1. Add a 'bg-validatible' class to your <form>
# 2. Add data-bg-validation-url-template="/validation/{field_id}" to your <form>
# 3. Add data-bg-validation-success-message="Looks good!" to your <form> or each validatible element
# 4. Add data-bg-validation-output="relative_selector_to_field" to the <form> or each validatable element
# 5. Add data-bg-validation-field="some_field_id" to each validatable field
# 6. (Optionally) Add a data-bg-validation-include="other_id,other2_id" attribute to the validatable field to send
@h3h
h3h / time_utilities.rb
Last active August 29, 2015 14:05
Parse ISO-8601 time strings and respect the embedded time zone.
require 'active_support/core_ext/time'
require 'active_support/values/time_zone'
module TimeUtilities
# Parses an ISO-8601 time string with a time zone and keeps the time zone in
# the Time object returned, unlike Ruby Core.
#
# Examples:
#
@h3h
h3h / circular_enumerator.rb
Created August 15, 2014 20:59
CircularEnumerator
# Utility converter to make a circular enumerator, wrapping around to the
# beginning of a list after it has exhausted all entries.
#
# Example:
#
# >> e = CircularEnumerator([1,2,3,4,5])
# => #<Enumerator: [1, 2, 3, 4, 5]:each>
#
# >> 10.times.map { e.next }
# => [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]