Skip to content

Instantly share code, notes, and snippets.

@jurikern
jurikern / toolchains.xml
Created July 30, 2017 16:40
MacOSX ~/.m2/toolchains.xml
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.9</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/jdk-9.jdk</jdkHome>
class FormBuilder < ActionView::Helpers::FormBuilder
def text_field(attribute, options={})
input_field(attribute, options) do
super
end
end
def password_field(attribute, options={})
input_field(attribute, options) do
super
@jurikern
jurikern / capistrano_console
Created March 20, 2015 08:47
capistrano_console.rb
namespace :rails do
desc "Open the rails console on the remote app server"
task :console => 'rvm:hook' do
on roles(:app), :primary => true do |host|
execute_interactively host, "console #{fetch(:stage)}"
end
end
desc "Open the rails dbconsole on each of the remote servers"
task :dbconsole => 'rvm:hook' do
@jurikern
jurikern / unicorn.rake
Last active August 29, 2015 14:07
Unicorn task for zero downtime deployment
namespace :load do
task :defaults do
set :pids_dir, -> { File.join(current_path, 'tmp', 'pids') }
set :unicorn_pid, -> { File.join(fetch(:pids_dir), "unicorn.pid") }
set :unicorn_config_path, -> { File.join(current_path, "config", "unicorn", "#{fetch(:rails_env)}.rb") }
set :unicorn_roles, -> { :app }
set :unicorn_options, -> { "" }
set :unicorn_rack_env, -> { fetch(:rails_env) == "development" ? "development" : "deployment" }
set :unicorn_restart_sleep_time, 3
end
@jurikern
jurikern / randomizer.sh
Created September 2, 2014 07:28
RoundRobin based randomizer
sudo apt-get install build-essential
cpan install List::Util::WeightedRoundRobin
@jurikern
jurikern / eth1.cfg
Last active August 29, 2015 14:05
Secondary network interface #1
# echo "200 out" >> /etc/iproute2/rt_tables
auto eth1
iface eth1 inet static
address 172.31.10.172
netmask 255.255.240.0
network 172.31.0.0
broadcast 172.31.15.255
up ip route add default via 172.31.0.1 dev eth1 table out
up ip rule add from 172.31.10.172/32 table out
@jurikern
jurikern / eth0.cfg
Last active August 29, 2015 14:05
Primary network interface
# The primary network interface
auto eth0
iface eth0 inet dhcp
up ip addr add 172.31.10.125/32 dev eth0
@jurikern
jurikern / postfix
Last active August 3, 2023 13:27
Postfix base configuration
sudo apt-get update -y
sudo locale-gen en_US
sudo apt-get install postfix opendkim opendkim-tools sasl2-bin libsasl2-modules libsasl2-modules-sql libopendbx1-pgsql iptables-persistent
sudo mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
sudo openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
sudo chmod 600 smtpd.key
sudo openssl req -new -key smtpd.key -out smtpd.csr
sudo openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
Server Software: Webmachine-Ruby/1.2.2
Server Hostname: 127.0.0.1
Server Port: 4000
Document Path: /api/track?token=test_token
Document Length: 0 bytes
Concurrency Level: 100
Time taken for tests: 13.453 seconds
Complete requests: 10000
Server Software: Webmachine-Ruby/1.2.2
Server Hostname: 127.0.0.1
Server Port: 4000
Document Path: /api/track?token=test_token
Document Length: 0 bytes
Concurrency Level: 130
Time taken for tests: 349.434 seconds
Complete requests: 100000