Skip to content

Instantly share code, notes, and snippets.

View jhirbour's full-sized avatar

John Hirbour jhirbour

View GitHub Profile
# History
# history is managed by rvm (~/.rvm/scripts/irbrc.rb)
# IRB.conf[:SAVE_HISTORY] = 1000
#
# loaded by rvm
# require 'rubygems'
# require 'pp'
if defined? Rails && Rails.env
require 'logger'
#!/bin/sh
bundler_version=$(bundler --version | awk '{print $3}')
gemfile_version=$(tail -1 Gemfile.lock | awk '{print $1}')
echo "bundler_version is $bundler_version"
echo "gemfile_version is $gemfile_version"
if [ "$bundler_version" = "$gemfile_version" ]; then
bundler "$@"
else
echo "ALERT!!!! *** CHANGE YOUR BUNDLER VERSION!!!! ***"
#!/bin/bash
MyShellVar=$(ls /tmp)
/usr/bin/osascript << EOF
set MyApplVar to do shell script "echo '$1'"
tell application "Finder"
activate
set result to display dialog MyApplVar buttons {"OK", "OK2"} default button "OK"
end tell
# RVM notes
# when updating OS versions of Xcode (or any of the C/C++ underbits)
#
# if OSx dev is ahead of HomeBrew you may need xcode beta crap from apple's
# download dev site.
#
# you need to rebuild rvm
# https://stackoverflow.com/questions/9663005/how-do-i-recompile-a-ruby-with-rvm
#
# rvm reinstall [RUBY]
# RVM notes
# when updating OS versions of Xcode (or any of the C/C++ underbits)
#
# if OSx dev is ahead of HomeBrew you may need xcode beta crap from apple's
# download dev site.
#
# you need to rebuild rvm
# https://stackoverflow.com/questions/9663005/how-do-i-recompile-a-ruby-with-rvm
#
# rvm reinstall [RUBY]
@jhirbour
jhirbour / me-mux
Created January 27, 2017 16:31
Create a Named Tmux session, named the same as the directory you're currently in.
#!/bin/sh
#PROJECT_NAME=`basename $PWD`
PROJECT_NAME=`basename $PWD | tr '.' '-'`
PROJECT_DIR=$PWD
tmux has-session -t $PROJECT_NAME 2>/dev/null
if [ "$?" -eq 1 ] ; then
echo "No Session found. Creating and configuring."
pushd $PROJECT_DIR
tmux new-session -d -s $PROJECT_NAME

Keybase proof

I hereby claim:

  • I am jhirbour on github.
  • I am jhirbour (https://keybase.io/jhirbour) on keybase.
  • I have a public key whose fingerprint is B7F7 861E C8BE 0D35 28BB 1854 305C E94C 4CEC D7F2

To claim this, I am signing this object:

@jhirbour
jhirbour / explanation.md
Last active September 11, 2015 00:47
PGSQL finding if rows have other rows in a time range near them

I'm trying to find rows in a table where there have been other rows created within a minute of them.

Why you can't use group by:

You can't use group by for this because certain rows will exist inside of 2 groups.

 timestamp                      minute logical group
----------------------------------------------------------- 
2010-01-01 09:09:01             A1
2010-01-01 09:09:58 A1, A2
@jhirbour
jhirbour / clean my spree
Last active August 12, 2020 02:14
Code to empty a spree database of product/taxons/orders
#### DON'T RUN THIS ON YOUR PRODUCTION DATA!!!! It will delete stuff !!!!!!
###
###
### FWIW this was from Spree circa 2013
# clear product data
Spree::Product.all.map { |p| p.destroy! }
Spree::Variant.with_deleted.map { |v| v.destroy! }
Spree::StockItem.all.map { |si| si.destroy! }
@jhirbour
jhirbour / gist:6800583
Created October 2, 2013 21:10
In Spree: Replace t/taxon_name with category/taxon_name

Create or edit: $APP_ROOT/app/helpers/spree/base_helper_decorator.rb

Add this:

Spree::BaseHelper.module_eval do
  def seo_url(taxon)
    return main_app.categories_path(taxon.permalink)
  end
end