Skip to content

Instantly share code, notes, and snippets.

View nessamurmur's full-sized avatar

Nessa Jane Marin nessamurmur

View GitHub Profile
@nessamurmur
nessamurmur / sidekiq
Created August 29, 2013 16:05
Sidekiq init script with deployment user
#!/bin/bash
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
#
# Description: Starts and Stops Sidekiq message processor for Stratus application.
#
# User-specified exit parameters used in this script:
#
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found
@nessamurmur
nessamurmur / gist:6627481
Created September 19, 2013 18:06
SQL is NOT DRY.
SELECT people.first_name,
people.last_name,
SUM(CAST(transactions.amount_in_cents AS float) / 100.00), // total transaction amount all time
ytd.amount,
transactions.amount_in_cents, // last transaction processed
last_transaction.created_at // date of last transaction
FROM people
JOIN transactions
ON people.id = transactions.person_id
@nessamurmur
nessamurmur / pre-commit.sh
Last active December 23, 2015 19:59 — forked from alexbevi/pre-commit.sh
Try to prevent binding.prys being commited
# Git pre-commit hook to check all staged Ruby (*.rb/erb/coffee) files
# for Pry binding references
#
# Installation
#
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
#
# Based on
#
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
@nessamurmur
nessamurmur / open.rb
Created September 26, 2013 23:01
Open pbcopy
open(“| pbcopy”, “w”) { |clipboard| clipboard.write array.inspect }
@nessamurmur
nessamurmur / unicorn.conf
Last active December 24, 2015 02:19
Basic monit example
check process unicorn
with pidfile /path/to/pid/unicorn.pid
start program = "/sbin/service unicorn start" with timeout 120 seconds
stop program = "/sbin/service unicorn stop"
if totalmem is greater than 500 MB for 2 cycles then restart
@nessamurmur
nessamurmur / each.rb
Created October 1, 2013 12:57
each ruby
a = [1, 2, 3, 4]
a.each do |num|
# several
# lines
# of transformations
end
@nessamurmur
nessamurmur / each.ex
Created October 1, 2013 12:57
each elixir
a = [1,2,3,4]
Enum.each a, fn (num) ->
# several
# lines
# of transformations
end
@nessamurmur
nessamurmur / test.js
Last active December 29, 2015 07:09
temp thing.
// Here, under the hood PhantomJS is opening
//localhost:3000/uri/goes/here and rendering it to a pdf.
var pdf = new NodePDF('localhost:3000/uri/goes/here', 'filename.pdf', {width:1440, height:900}); //the options might be optional. Play with it a bit.
// This is a callback for what to do on errors
pdf.on('error', function(msg){
console.log(msg); // you may want to log errors while you're working on it at least.
// What you might really want to do when done is present an error to the user.
});
@nessamurmur
nessamurmur / template.rb
Last active December 31, 2015 07:09
This seems _bad_. But I've seen it ALOT.
class Template < ActiveRecord::Base
belongs_to :template_type
def some_method
if template_type == :type_1
# do type one things
elsif template_type == :type_2
# do type two things
else
# something else
@nessamurmur
nessamurmur / awesome_template.rb
Created December 13, 2013 22:21
It seems to me like it makes more since to just make use of the things rails does automagically...
class AwesomeTemplate < Template
# We don't even care about custom behavior in this template.
# We just want to be able to identify it as a different type
end