Skip to content

Instantly share code, notes, and snippets.

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
@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 => '')
@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 / 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 / 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": "[email protected]", "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 / 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 / gist:7154025
Created October 25, 2013 12:37
pg_hba no user no password example
# Database administrative login by Unix domain socket
local all postgres trust
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
@jurikern
jurikern / gist:5531825
Created May 7, 2013 10:58
Image Crop from Canvas
detectCanvas: =>
if @canvas
@canvas.replaceWith("<canvas class='picture_canvas' data-block='canvas'></canvas>")
@canvas = @container.find("*[data-block='canvas']")
@ctx = @canvas.get(0).getContext("2d")
handleImage: (e) =>
@detectCanvas()
@jurikern
jurikern / gist:5219692
Created March 22, 2013 08:10
MacOS X wxPython installer issue
sudo installer -pkg wxPython2.8-osx-unicode-universal-py2.7.pkg -target /
installer: Package name is wxPython2.8-osx-unicode-universal-py2.7
installer: Installing at base path /
2013-03-22 10:09:12.634 installer[8633:5a03] Package /Users/semjonow/Desktop/wxPython2.8-osx-unicode-universal-py2.7.pkg uses a deprecated pre-10.2 format (or uses a newer format but is invalid).
installer: The install was successful.
@jurikern
jurikern / gist:5199636
Last active December 15, 2015 04:09
Binded Backbone v2
class Application.Views.Base
@bindWith: (selector) ->
instance = @
$(selector).each ->
new instance($(@))
constructor: (@container) ->
_.extend(@, Backbone.Events)