Skip to content

Instantly share code, notes, and snippets.

View ibanez270dx's full-sized avatar
:shipit:
shippin' it

Jeff Miller ibanez270dx

:shipit:
shippin' it
View GitHub Profile
@ibanez270dx
ibanez270dx / ssh_iterm_colors.sh
Last active August 29, 2015 14:21
colors for remote sessions
#!/bin/bash
###########################
# AppleScripts
###########################
# Change the background color and alpha of the current terminal window (formatted to be the same as RGBA).
function iterm_bg {
local R=$1
local G=$2
@ibanez270dx
ibanez270dx / benchmark output.rb
Last active August 29, 2015 14:22
SQL vs. ActiveRecord Benchmark (Subscribers)
# 100_000 users
# Rehearsal ---------------------------------------------------
# SQL Conditional 3.910000 0.060000 3.970000 ( 3.991377)
# AR Conditional 4.930000 0.050000 4.980000 ( 4.971518)
# ------------------------------------------ total: 8.950000sec
#
# user system total real
# SQL Conditional 3.760000 0.030000 3.790000 ( 3.800231)
# AR Conditional 4.910000 0.040000 4.950000 ( 4.957218)
#
@ibanez270dx
ibanez270dx / init.coffee
Created October 10, 2015 09:10
Compile CoffeeScript & SCSS on save by hooking into Atom's init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
fs = require 'fs'
path = require 'path'
nodeCLI = require '/usr/local/lib/node_modules/shelljs-nodecli'
@ibanez270dx
ibanez270dx / styles.less
Last active October 13, 2015 08:02
My styles.less configuration (for Atom). Adds contrast between the editor and everything else when using "one-dark-ui" UI theme and "afterglow-like" syntax theme.
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/
@ibanez270dx
ibanez270dx / splat-case.rb
Created October 24, 2015 12:15
use splat with an array when case
# if we want to check whether a particular value is in an array, we have
# a couple options... Most times simply calling array.include?(element) is
# sufficient, but we can also get creative by using the splat function
# with a case statement to check multiple arrays ;)
hondai = ['hondai', 'acura', 'civic', 'element', 'fit', ...]
toyota = ['toyota', 'lexus', 'tercel', 'rx', 'yaris', ...]
case car
when *toyota then # Do something for Toyota cars
@ibanez270dx
ibanez270dx / apps.sh
Created October 26, 2015 01:23
Fresh OSX setup
#!/bin/sh
# First install homebrew and cask
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install cask brew-cask
# Applications
brew cask install 1password
brew cask install anvil
brew cask install atom
@ibanez270dx
ibanez270dx / gist:75b935176a3dfaa7fdce
Created October 27, 2015 01:22
iTerm2 drop down over full-screen'd apps
Open iTerm2 over full-screen'd apps (HACK)
------------------------------------------
READ: https://gitlab.com/gnachman/iterm2/issues/1570
defaults write /Applications/iTerm.app/Contents/Info LSUIElement true
@ibanez270dx
ibanez270dx / deflate.rb
Last active October 28, 2015 13:43
Turn a hash into a sorted array of strings in order to compare to another hash
def deflate(hash)
hash.collect do |k,v|
[k.to_s].push v.is_a?(Hash) ? v.to_a.flatten : v
end.flatten.collect(&:to_s).sort
end
event1 = { foo: 'bar', bars: [4,6,10] }
event2 = { bars: [10,4,6], foo: 'bar' }
event1 == event2
@ibanez270dx
ibanez270dx / scraper.rb
Last active September 27, 2017 14:35
Use Capybara w/ Poltergeist (PhantomJS) to scrape the text content from the body of an HTML page located at the given URL.
#!/usr/bin/env ruby
require 'capybara'
require 'capybara/poltergeist'
class Scraper
include Capybara::DSL
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new app,
phantomjs_options: ['--load-images=no','--ignore-ssl-errors=yes'],
js_errors: false,
#!/usr/bin/env bash
##################################################
# Bash Prompt
##################################################
# Current configuration produces:
# 00:00:50 jeff@edison:~/Dev/humani.se (git:master:156d0b4) ruby-2.2.0
# → _