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 / 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 / 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 / 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 / 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 / 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 / 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 / shkip.rb
Created May 19, 2015 01:15
SKHIP work in progress
require 'io/console'
require 'optparse'
require 'ostruct'
require 'fileutils'
NAME = "Safari Keyword History Index Parser"
VERSION = "v0.0.1"
TIME = Time.now
def box_me_up(str)
@ibanez270dx
ibanez270dx / prompt.sh
Last active August 29, 2015 14:17
Bash Prompt -- Git, RbEnv, etc...
#!/usr/bin/env bash
# Examples:
#
# ps1_set --prompt ∴
#
# This will yield a prompt like the following, for example,
#
# 00:00:50 jeff@edison:~/dev/humani.se (git:master:156d0b4) ruby-2.2.0
@ibanez270dx
ibanez270dx / hex2rgba.rb
Last active August 29, 2015 14:17
Convert Hex color to RGBA
def hex_to_rgba(input, alpha=1)
components = (input.match /#?([0-9A-F]{2})/ )[1..3]
components.map!{ |x| x + x } if input.size == 4
"rgba(#{components.collect(&:hex).join(',')},#{alpha})"
end
@ibanez270dx
ibanez270dx / download_data.rb
Last active August 29, 2015 14:15
Scrape a title from specifically formatted content then download and rename
require 'nokogiri'
require 'open-uri'
dir = Dir.pwd
url = "some_url"
data = Nokogiri::HTML(open(url))
data.css('a').each do |link|
filename = link['href']
if filename =~ /^BD/