Skip to content

Instantly share code, notes, and snippets.

View theIV's full-sized avatar

Stewart Laufer theIV

View GitHub Profile
@theIV
theIV / .psqlrc
Created February 8, 2016 21:32 — forked from pivaldi/.psqlrc
.psqlrc dot file to customize the default psql sessions
-- psql prompt can be customized
\set PROMPT1 '%[%033[1;33m%]%M:%>%[%033[1;32m%] %n@%/%R%[%033[0m%]%# '
\set PROMPT2 :PROMPT1
\set PROMPT3 '>> '
-- Missing LIMIT fetch count is set to 1000
\set FETCH_COUNT 1000
-- Set pager to off
\pset pager off
@theIV
theIV / db.rake
Created October 10, 2015 18:59 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
# Credits:
# Jason Pirkey, Táve Corporation, http://www.tave.com/
# Jeremy Mickelson, https://github.com/CyborgMaster
# See http://help.papertrailapp.com/kb/hosting-services/aws-elastic-beanstalk/
packages:
yum:
rubygems: []
ruby-devel: []
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@theIV
theIV / as3.rake
Created March 26, 2014 17:04 — forked from otobrglez/as3.rake
# 1) Put 's3' gem in Gemfile.
# 2) Create as3.yml configuration for S3
# 3) Create initializer for as3.yml
# 4) Make "assets" folder inside your bucket
# 5) After running task run "RAILS_ENV=production rake assets:precompile"
# 6) Invoke task by running "rake as3:upload"
namespace :as3 do
desc "Uploads compiled assets (public/assets) to Amazone AS3"
task :upload do
# How to use Paperclip for generic attachment types on models in Ruby on Rails
class User < ActiveRecord::Base
has_many :user_assets
end
# example of building a model which is a generic attachment asset
@user.build_user_asset(:asset_type => "podcast", :attached_file => some_uploaded_file_data)
# make a generic asset class, with instances initialized for specific asset
@theIV
theIV / README.md
Last active December 14, 2015 03:39 — forked from ryanb/chef_solo_bootstrap.sh
@theIV
theIV / coupons
Created November 6, 2012 19:09 — forked from rapind/coupons
Load Groupon Codes into Shopify Discounts
# http://forums.shopify.com/categories/6/posts/42926
# This is a fairly simple mechanize script to create a few hundred or so shopify discounts from a CSV of groupon codes.
# You'll want to change all of the "changeme" values to your own.
# The script expects there to be a groupon_codes.csv in the same directory.
#
# The groupons_code.csv should look like this:
# 8m7677
# 8m6749
# 8m5398
# 8m7699
@theIV
theIV / gfm.rb
Created March 15, 2010 18:52 — forked from mojombo/gfm.rb
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@theIV
theIV / .autotest
Created April 15, 2009 18:07 — forked from olauzon/.autotest
require 'autotest/redgreen'
# require 'autotest/pretty'
# require 'autotest/snarl'
# require 'autotest/timestamp'
module Autotest::Growl
def self.growl title, msg, img, pri=0, sticky=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end