Skip to content

Instantly share code, notes, and snippets.

View nessamurmur's full-sized avatar
☃️
R&R

Nessa Jane Marin nessamurmur

☃️
R&R
View GitHub Profile
@nessamurmur
nessamurmur / copy.rb
Created May 16, 2014 16:01
Copy postgres table to local storage without superuser
conn = ActiveRecord::Base.connection.raw_connection
tempfile = "/tmp/users.csv"
buff = ''
conn.transaction do
conn.exec( "COPY users TO STDIN AS CSV" )
File.open(tempfile, "wb") do |file|
file << buff while buff = conn.get_copy_data
end
end
#!/usr/bin/env escript
% -*- mode: erlang -*-
main([BeamFile]) ->
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(BeamFile,[abstract_code]),
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
@nessamurmur
nessamurmur / .ruby-gemset
Created January 15, 2014 20:00
example ruby version management
example-project
@nessamurmur
nessamurmur / PR
Last active January 2, 2016 09:29
Barely modified hack & ship scripts
#!/bin/sh -x
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git pull origin master
git checkout ${CURRENT}
git rebase master
git push -u origin ${CURRENT}
hub pull-request
@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
@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 / 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 / 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 / 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 / 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