Skip to content

Instantly share code, notes, and snippets.

View hendricius's full-sized avatar

Hendrik Kleinwaechter hendricius

View GitHub Profile
@hendricius
hendricius / 01_add_cors.config.yaml
Created June 27, 2016 17:24 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk (Rails)
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@hendricius
hendricius / parallel_curl.sh
Last active January 5, 2016 20:36 — forked from CMCDragonkai/parallel_curl.sh
Bash: GNU Parallel with Curl
# do it once
seq 1 | parallel -n0 "curl http://localhost:3000"
# do it twice
seq 2 | parallel -n0 "curl --header 'Connection: keep-alive' http://localhost:3000"
# do it 4 times, but at 2 a time
seq 10000 | parallel -n0 -j10 "curl --header 'Connection: keep-alive' https://prelive.tripl.de"
```
namespace :db do
desc "Populate database"
task :populate => :environment do
[Brand].each(&:delete_all)
filename = File.join Rails.root, "databases/brands.csv"
counter = 0
CSV.foreach(filename, headers: true) do |row|
p row
class PdfMerger
def merge(pdf_paths, destination)
first_pdf_path = pdf_paths.delete_at(0)
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf|
pdf_paths.each do |pdf_path|
pdf.go_to_page(pdf.page_count)