Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
export CFLAGS="-march=core2 -O3 -pipe -fomit-frame-pointer"
VERSION="1.9.3-p327"
curl https://raw.github.com/gist/1688857/2-$VERSION-patched.sh > /tmp/$VERSION-perf
rbenv install /tmp/$VERSION-perf
var instances = session.getInstances();
instances.sort(function(a, b)
{
var date1 = parseInt(a.date.replace(/-/g, ""));
var date2 = parseInt(b.date.replace(/-/g, ""));
if (date1 < date2)
{
return -1;
}
@pgib
pgib / httpd.conf
Created August 31, 2012 15:56
Apache config directive to disallow access to any .php file found in a wp-content folder
<LocationMatch "wp-content/.*\.php$">
Order allow,deny
Deny from all
Satisfy All
</LocationMatch>
@pgib
pgib / .profile
Created August 29, 2012 05:43
Simple .zprofile/.bash_profile entry to look for an existing screen session
if [ -z "$WINDOW" ]; then
screen -q -list
if [ $? -gt 8 ]; then
echo -n "Screen found. Re-attach? [Y/n]: "
read response
case $response in
N*|n*)
echo "Okay. Type screen -R -U -D later..."
;;
*)
#<Transaction _id: 5032980c67896cb5e500001d, _type: nil, event_id: BSON::ObjectId('5032732167896caf2e000001'), transaction_type: "auth", transaction_currency: "USD", attendee_id: "503297e767896cb5e5000014", invoice_id: "503297e767896cb5e5000016", success: nil, message: "Cancelled: Data format problem", complete: false, receipt_id: nil, reference_num: nil, response_code: nil, iso: nil, auth_code: nil, trans_time: nil, trans_date: nil, trans_type: nil, trans_amount: nil, card_type: nil, trans_id: nil, timed_out: nil, bank_totals: nil, ticket: nil, authorization: nil, parsed_message: "Approved">
e = Essentials::Event.create( {:start_date => "Thu Jul 19 00:00:00 UTC 2012", :group_name => "Boston Sites Program", :group => Essentials::Program.first.id.to_s, :location => "borkbork", :end_time => nil, :created_at => "Thu Jul 19 18:28:36 UTC 2012", :body => " asdfasdf ", :title => "bork", :updated_at => "Thu Jul 19 18:39:20 UTC 2012", :user_type => "grantee", :highlighted => false, :time_zone => "Mountain Time (US & Canada)", :program => nil, :summary => "asdfasdf", :start_time => "Thu Jul 19 19:00:00 UTC 2012", :active => false} )
start_with_zone = ActiveSupport::TimeWithZone.new(e.start_time.getutc, ActiveSupport::TimeZone.new(e.time_zone))
if e.start_time && e.end_time
end_with_zone = ActiveSupport::TimeWithZone.new(end_time.getutc, ActiveSupport::TimeZone.new(time_zone))
"#{start_with_zone.strftime('%H:%M %Z')} - #{end_with_zone.strftime('%H:%M %Z')}"
else
"#{start_with_zone.strftime('%H:%M %Z')}"
@pgib
pgib / class-gotcha.coffee
Created July 4, 2012 19:50
An easy thing to overlook with classes and instance variables in Javascript
# =======================================================================
# INCORRECT
# =======================================================================
class Foo
# don't expect this to be an instance variable. it is not!! it is the
# java equivalent of: public static colours = new Array()
colours: []
addColour: (colour) =>
@pgib
pgib / cookies.js.coffee
Created June 19, 2012 19:16
set and get cookies
setCookie = (name, value, path, expires, domain, secure) ->
if typeof expires is "undefined"
expireDate = new Date()
expireDate.setTime expireDate.getTime() + (3600000 * 24 * 365)
expires = expireDate.toGMTString()
curCookie = name + "=" + escape(value) + (if (expires) then "; expires=" + expires else "") + (if (path) then "; path=" + path else "") + (if (domain) then "; domain=" + domain else "") + (if (secure) then "; secure" else "")
document.cookie = curCookie
getCookie = (name) ->
@pgib
pgib / apod.sh
Created May 23, 2012 22:38 — forked from schallis/apod.sh
Automatically download NASA Astronomy Pictures of the Day
# Download the latest pic of the day from NASA and delete or archive any
# previous ones in a specified directory. Optionally create a copy of the most
# current picture to allow OSX to pick up pictures as wallpapers
#
# Steve Challis 2011
# http://schallis.com/2011/mar/20/nasa-astronomy-picture-of-the-day-background/
# Get a fresch picture from NASA
todays_pic=`ruby -rubygems latest_nasa_photo.rb`
@pgib
pgib / make_soup.sh
Created May 23, 2012 18:32
Put this soup in your .bash_profile and smoke (or slurp) it!
ayv_deploy_dir="/Users/${USER}/Sites/ayv/deploy"
make_soup()
{
current_branch=`git status | head -n 1 | awk '{print $4}'`
echo "Pushing $current_branch to soup... (Press Ctrl-c to abort)"
sleep 2
git checkout soup
git fetch upstream && git merge upstream/soup
git merge $current_branch && git push upstream soup || git reset --hard