Skip to content

Instantly share code, notes, and snippets.

@jurikern
jurikern / rebase-tools
Last active August 29, 2015 13:55
Git rebase-tools
git rebase
git rebase --abort
git rebase --continue
git rebase --skip
git push origin feature --force
git pull --rebase origin feature
git merge fature --no-ff
@jurikern
jurikern / chee_api
Created May 5, 2014 11:06
chee_request_example
curl -X POST -H "Content-Type: application/json" -d \
'{"deals":[{"id":"1023410623", "quantity":"3"}, {"id":"1023410633", "choices":"1023413223"}], \
"delivery": "smartpost", "delivery_info": { "smartpost": {"deliveryLocationID": "133"}}, \
"user": {"email": "juri.semjonov@gmail.com", "username": "Juri Semjonov", "phone": "55687059"}, \
"purchase": {}}' \
http://localhost:3000/api/v1/api_key/api_secret/purchases
===
{"success":true,"message":"Purchase successfully saved","url":"/en/cart/completed?hash=52b0acfb7bbd10c44f575f0db121fdd2&id=150995149","errors":[]}
@jurikern
jurikern / chef_debian_7_5_bootstrap.sh
Last active August 29, 2015 14:01
Bootstrap chef on a pure Debian 7.5
#!/usr/bin/env bash
locale-gen en_US.UTF-8
\curl -sSL https://get.rvm.io | bash -s stable --ruby
source /usr/local/rvm/scripts/rvm
rvm gemset create teddy
rvm gemset use teddy --default
@jurikern
jurikern / instance.py
Last active August 29, 2015 14:02
Instance model
from django.db import models
from django_fsm import FSMIntegerField, transition
class Instance(models.Model):
# Hardware types definition
X2_HARDWARE_TYPE = 'c3.large'
X4_HARDWARE_TYPE = 'c3.xlarge'
X16_HARDWARE_TYPE = 'c3.4xlarge'
HARDWARE_TYPE_CHOICES = (
@jurikern
jurikern / rails_multiple_connection
Created July 18, 2014 22:02
Using multiple connections within a single model (method)
# Use pipe to transfer data between fork and parent process
reader, writer = IO.pipe
# Fork process to isolate the work with multiple database connections from application
pid = fork do
reader.close()
begin
# if used Redis uncomment this line to reset connection
# REDIS = Redis.new(:host => '', :port => '', :password => '')
Server Software: Webmachine-Ruby/1.2.2
Server Hostname: 127.0.0.1
Server Port: 4000
Document Path: /api/track?token=dfjhdfhfdjhdfjhfd878fg
Document Length: 0 bytes
Concurrency Level: 100
Time taken for tests: 2.607 seconds
Complete requests: 1000
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
@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 / 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 / randomizer.sh
Created September 2, 2014 07:28
RoundRobin based randomizer
sudo apt-get install build-essential
cpan install List::Util::WeightedRoundRobin