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
2.1.1 :001 > array = [1] * 100 | |
=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] | |
2.1.1 :002 > array.each_slice(array.size / 4).to_a | |
=> [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] | |
2.1.1 :003 > arrays = array.each_slice(array.size / 4).to_a | |
=> [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, |
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
package com.shippingeasy.javapdf; | |
import java.io.File; | |
import java.awt.image.BufferedImage; | |
import javax.imageio.ImageIO; | |
import org.apache.pdfbox.pdmodel.*; | |
import org.apache.pdfbox.pdmodel.edit.*; | |
import org.apache.pdfbox.pdmodel.graphics.xobject.*; |
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 Backend | |
def called(klass, method, args, time) | |
clues_performance << marshall(klass, method, args, time) | |
end | |
private | |
def marshal(klass, method, args, time) | |
{ | |
"code" => "#{klass}##{method}" | |
"args" => args.to_s |
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
import sys | |
import json | |
raw = sys.stdin.read() | |
data = json.loads(raw) | |
data["response"] = "Howdy from python" | |
print json.dumps(data) |
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
> find /home/shipit/file_backup -type d | \ | |
sed 's/\/home\/shipit\/file_backup\///' | \ | |
xargs mkdir -p | |
> find /home/shipit/file_backup -type f | \ | |
awk '{src = $0; dest = $0; gsub(/\/home\/shipit\/file_backup\//, "", dest); print src " " dest}' | \ | |
xargs -I{} echo 'cp {}' > copy_en_masse | |
> chmod +x copy_en_masse |
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/bash | |
# Command to copy assets from within a gem to a path in the | |
# deployed app's public directory so that they can be served | |
# in staging/production | |
error() { | |
echo "ERROR: $@" | |
echo | |
echo "USAGE: cp_gem_assets [gemname] [path_in_gem] [path_in_public]" | |
exit -1 | |
} |
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
common: &common | |
image: myapp | |
environment: | |
APPENV: production | |
ELASTIC_HOST: es01 | |
ELASTIC_PORT: 9200 | |
REDIS_HOST: r01 | |
REDIS_PORT: 6379 | |
myapp01: |
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
## | |
# Will run resque jobs inline within a spec so that | |
# if you need jobs to run to set up a state, you | |
# can simply invoke the methods that enqueue those | |
# jobs and everything is run by the test run | |
RSpec.shared_context "resque run inline" do | |
around(:each) do |example| | |
without_resque_spec do | |
inline = Resque.inline | |
Resque.inline = true |
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
-- Create procedure | |
DROP FUNCTION IF EXISTS die_on_delete(); | |
CREATE FUNCTION die_on_delete() RETURNS trigger AS $$ | |
BEGIN | |
RAISE EXCEPTION 'DONT DELETE ME BRO!'; | |
END; | |
$$ LANGUAGE plpgsql; | |
-- Create trigger | |
DROP TRIGGER IF EXISTS die_on_order_delete ON orders; |
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
HTTP_LOG_PATH = File.expand_path("~/http.log") | |
FileUtils.rm_f(HTTP_LOG_PATH) | |
module NetInstrumentation | |
def self.included(base) | |
puts "Writing HTTP out to ~/http.log" | |
base.send(:alias_method, :__original_request, :request) | |
base.send(:alias_method, :request, :__logged_request) | |
end |
OlderNewer