Skip to content

Instantly share code, notes, and snippets.

Brad Fults h3h

View GitHub Profile
@h3h
h3h / 01.elm
Last active Sep 25, 2017
Elm Tutorial Roll Dice with SVG – Start here: http://elm-lang.org/examples/random
View 01.elm
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 Dec 18, 2016
Evolving Elm Validation Code
View 01.elm
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
import List
import Regex exposing (regex)
main =
Html.beginnerProgram
{ model = model
View .gitconfig
[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 Dec 9, 2015
Fill up localStorage completely on a given page.
View maxLocalStorage.js
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 Dec 20, 2015
Preventing OS X’s aggressive git shim prompt when you don’t have Xcode installed.
View GitGutter.sublime-settings
{
// Custom path to git binary when not in PATH
"git_binary": "/usr/local/bin/git"
}
@h3h
h3h / explanation.md
Last active Aug 29, 2015
HR 4681 Section 309
View explanation.md

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)
View ruby-upgrade-2.1.5.sh
#!/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 Oct 20, 2014
Automatic Per-field Background Validation for Forms
View background_validation.js.coffee
# 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 Aug 29, 2015
Parse ISO-8601 time strings and respect the embedded time zone.
View time_utilities.rb
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:
#
View circular_enumerator.rb
# 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]
You can’t perform that action at this time.