Skip to content

Instantly share code, notes, and snippets.

View JesseHerrick's full-sized avatar

Jesse Herrick JesseHerrick

View GitHub Profile
@JesseHerrick
JesseHerrick / install-therubyracer-mac-os-mojave.md
Created March 5, 2020 22:19
Install therubyracer on Mac OS Mojave
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/v8@3.15 --with-cxx=/usr/bin/gcc
@JesseHerrick
JesseHerrick / mysql2-mojave.md
Created March 5, 2020 22:11 — forked from fernandoaleman/mysql2-mojave.md
Install mysql2 on MacOS Mojave

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@JesseHerrick
JesseHerrick / install-libxml-ruby.md
Last active March 5, 2020 19:49
Install libxml-ruby on Mac OS Catalina
@JesseHerrick
JesseHerrick / typeahead-force-selection.js
Last active June 21, 2017 20:53
Force selection of TypeAhead.JS result before form can be submitted.
var checkAutocompleteInput = function() {
if ($('#autocomplete').find('.tt-selectable').length === 0) { // "#autocomplete" is the autocomplete input menu section
$('.actions input').attr('disabled', 'disabled') // ".actions input" is the Submit button for the form
} else {
$('.actions input').removeAttr('disabled')
}
};
$('#autocomplete .typeahead').typeahead({...}, {...}).on('typeahead:render', function(e) {
$('#autocomplete').parent().find('.tt-selectable:first').addClass('tt-cursor');
@JesseHerrick
JesseHerrick / site-changed.sh
Created December 11, 2015 01:35
Checks for site changes and reports yes or no. Useful for things like audition results :)
# $1 = site to check
while true
do
curl -L "$1" -o site1.html &>/dev/null
curl -L "$1" -o site2.html &>/dev/null
if diff -q site1.html site2.html &>/dev/null; then
echo "YES!!!"
@JesseHerrick
JesseHerrick / secret-santa.rb
Created December 4, 2015 01:23
Like drawing out of a hat, but better!
# list of people to secret santa
names = ['Foo', 'Bar', 'John', 'Jim']
raise 'not even!' if names.count % 2 != 0
def assigned?(matches, person)
matched_people = matches.values
matched_people.include? person
end
@JesseHerrick
JesseHerrick / hash_to_xml.rb
Created July 24, 2015 15:00
Because no one should have to figure out how to do this again. A recursive way to convert a Ruby hash into raw xml.
# this method is used to create a full XML structure for the Freshbooks API
# don't expect it to work for anything else
def to_xml(data_hash)
req_method = data_hash.delete(:method)
'<?xml version="1.0" encoding="utf-8"?>' +
"<request method=\"#{req_method}\">" +
hash_to_raw_xml(data_hash) +
'</request>'
end
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
DB_CONFIG=<<EOF
default: &default
hostname: localhost
adapter: postgresql
@JesseHerrick
JesseHerrick / write.sh
Created May 23, 2015 20:50
write() function for writing articles
#!/usr/bin/env bash
write() {
command="$@"
# run the command
$@
# special command exec stuff
case $command in

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5