Skip to content

Instantly share code, notes, and snippets.

@wesgarrison
wesgarrison / gist:3921560
Created October 20, 2012 01:10
October 19 2012 - rubygems.org - notes on server

[transcript from http://www.youtube.com/watch?v=z73uiWKdJhw and irc]

Why is the server unhappy?

  • Bundle API is 70%-80% of traffic and it has to resolve the dependency graph and Marshal
  • x Processes are spinning in Ruby with 380% (of 400% total CPU [4 x 100%])
  • x Bundle can only use vanilla gems, so that's why we have to use Marshal
  • Redis Heapsize
  • Diskspace

Timing - middle of the day US

@wesgarrison
wesgarrison / order_decorator.rb
Created August 9, 2012 05:36
Overriding Spree tax calculations
# See http://guides.spreecommerce.com/logic_customization.html#extending-classes
# on where/how to use these
Spree::Order.class_eval do
def shipping_tax_zone
zone_address = ship_address
Spree::Zone.match(zone_address) || Spree::Zone.default_tax
end
def billing_tax_zone
# For the queasy, this is MIT licensed. See comment at the end.
module MySQLEncryption
# Mimics MySQL's AES_ENCRYPT() and AES_DECRYPT() encryption functions
def mysql_encrypt(s, key)
encrypt(s, mysql_key(key))
end
def mysql_decrypt(s, key)
@wesgarrison
wesgarrison / .bashrc
Created April 6, 2012 14:45
bashrc for new server setup
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@wesgarrison
wesgarrison / gist:1484362
Created December 16, 2011 03:46
Bookmarklet to remove zero entry lines from Harvest uninvoiced report
$$('tbody .btn-disabled').each(
function(element,index) {
element.up('tbody').hide()
}
);
$$('td.ur-name a.gray').each(
function(element,index){
element.up('tr').hide()
}
);
@pdf = Prawn::Document.new(skip_page_creation: true,
page_layout: :landscape,
page_size: 'LETTER',
margin: 0)
@pdf.start_new_page
@pdf.image "banner.jpg"
@pdf.render_file "test-prawn-fail.pdf"
@wesgarrison
wesgarrison / gist:1346170
Created November 7, 2011 21:01
mysql-slow.log
# Time: 111107 14:58:58
# Query_time: 21.900033 Lock_time: 0.000084 Rows_sent: 293622 Rows_examined: 293622
SET timestamp=1320699538;
SELECT * FROM `versions`;
$$('tbody .btn-disabled')
.each(function(element, index) {
element.up('tbody').hide()
});
@wesgarrison
wesgarrison / .bash_profile
Created September 8, 2011 15:28
bash setup
LSCOLORS='gxfxcxdxbxegedabagacad'
export LSCOLORS
alias ls='ls -hGF' # --color=auto not valid on OS X
alias ll='ls -alhGF' # --color=auto not valid on OS X
alias flushdns='dscacheutil -flushcache'
# git
@wesgarrison
wesgarrison / .toprc
Created September 1, 2011 15:30
unix top() settings file
RCfile for "top with windows" # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
Def fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
winflags=64440, sortindx=10, maxtasks=0
summclr=1, msgsclr=1, headclr=3, taskclr=1
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
winflags=62777, sortindx=0, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
winflags=62777, sortindx=13, maxtasks=0