Skip to content

Instantly share code, notes, and snippets.

View keithpitt's full-sized avatar
🍔
This is not a burger

Keith Pitt keithpitt

🍔
This is not a burger
View GitHub Profile
#!/bin/sh
BACKUP_DIR='/var/lib/pgsql/backups/'
FINAL_FILE='backup.gz'
TMP_FILE='tmp.gz'
BACKUP_TMP_FILE="$BACKUP_DIR$TMP_FILE"
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# Standard LSB functions
#. /lib/lsb/init-functions
global.TestHelper = {
loadFixtures: function(db) {
var file = fs.readFileSync("fixtures.yml").toString();
var fixtures = yaml.eval(file);
for(var table in fixtures) {
db.collection(table, function(err, collection) {
collection.remove();
member = Member.create(:username => "keith")
Relationship.exists?( :member1_id => member ) # Fails
Relationship.exists?( :member1_id => member.id ) # Works
def merge_suppliers
@supplier_from = Supplier.find(params[:id])
begin
@supplier_to = Supplier.find(params[:supplier_id])
rescue ActiveRecord::RecordNotFound
flash[:error] = "#{t('object.supplier')} #{t('messages.not_found')}"
return redirect_to(manage_supplier_path(@supplier_from.id))
end
@keithpitt
keithpitt / paginate.rb
Created May 23, 2011 09:20
Locomotive params extra support
+++ b/lib/locomotive/liquid/tags/paginate.rb
@@ -42,7 +42,7 @@ module Locomotive
page_count, current_page = pagination['total_pages'], pagination['current_page']
- path = context.registers[:page].fullpath
+ path = context.registers[:controller].request.fullpath
pagination['previous'] = link(I18n.t('pagination.previous'), current_page - 1, path) if pagination['previous_page']
pagination['next'] = link(I18n.t('pagination.next'), current_page + 1, path) if pagination['next_page']
export RELEASE_NOTES = `git log --format=oneline | grep "$GIT_COMMIT" | sed -e 's/'${GIT_COMMIT}'//'`
@keithpitt
keithpitt / 01-package.json
Created December 5, 2011 06:56 — forked from SlexAxton/01-package.json
Compiling Sproutcore Handlebars Templates on the Server
{ "description" : "Sproutcore Handlebars Precompiler"
, "version" : "0.1.0"
, "author" : "Alex Sexton <Alex.Sexton@bazaarvoice.com>"
, "engines" : ["node >=0.4.7"]
, "main" : "./lib/main"
, "dependencies": {
"handlebars": "1.0.x"
}
}
@keithpitt
keithpitt / NOTES
Created March 29, 2012 00:22
backbone_v_ember
These tests are very un-scientific. We just loaded up
these pages on our local netfox, refreshed a few times,
and tool a ballpark average of the results.
As someone mentioned on Twitter, these are very different
frameworks - all doing very different things. This is not
intended to mean a (Backbone is better than Ember) type page.
Its just some numbers that I thought were interesting.
❯ time ~/.rbenv/shims/ruby -e 'exit' redthread-provisioner/git/master
~/.rbenv/shims/ruby -e 'exit' 0.10s user 0.11s system 97% cpu 0.210 total
❯ time ~/.rbenv/versions/1.9.3-p194-perf/bin/ruby -e 'exit' redthread-provisioner/git/master
~/.rbenv/versions/1.9.3-p194-perf/bin/ruby -e 'exit' 0.02s user 0.02s system 94% cpu 0.047 total