This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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))]). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| example-project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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. | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [1,2,3,4] | |
| Enum.each a, fn (num) -> | |
| # several | |
| # lines | |
| # of transformations | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [1, 2, 3, 4] | |
| a.each do |num| | |
| # several | |
| # lines | |
| # of transformations | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |