Skip to content

Instantly share code, notes, and snippets.

View jhirbour's full-sized avatar

John Hirbour jhirbour

View GitHub Profile
@jhirbour
jhirbour / ror_os_x
Last active June 5, 2024 21:09
Getting RoR up and running on OS X
How to get RoR running on OS X.
# Supported OS
OS X: 10.8.4
# PREFACE:
* None of these commands should be run as root. Run them as the user you want to do devlopment as. There ARE steps where you'll be prompted for your password.
* you SHOULD NOT have mysql installed locally if you intend to use this guide... if you do the "brew install mysql" commands may break it...
@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
@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 / 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

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 / 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
# 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]
#!/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
#!/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!!!! ***"