Skip to content

Instantly share code, notes, and snippets.

View realmyst's full-sized avatar

Alexander Shcherbinin realmyst

  • Russia, Ulyanovsk
View GitHub Profile
var k = "";
var t = "a";
var $b = "+-a^+6";
var window = {TKK: "406395.1620790940"};
var Zb = "+-3^+b+-f";
var cb = "&";
var Yb = "+";
var jd = ".";
var Gf = "=";
var uM = null;
curl -O 'https://material-design.storage.googleapis.com/publish/material_v_9/0B6Okdz75tqQsSmZ5VlNBRHBXNXM/inline whatismaterial-materialprop-physicalprop-PaperShadow_01_xhdpi_008.mp4'
curl -O 'https://material-design.storage.googleapis.com/publish/material_v_9/0B6Okdz75tqQsaVFKVXI0RUFOWTg/inline whatismaterial-materialprop-physicalprop-PaperShadow_02_xhdpi_008.mp4'
curl -O 'https://material-design.storage.googleapis.com/publish/material_v_9/0B6Okdz75tqQsUGtDSTgtekFORGs/whatismaterial-materialprop-physicalprop-InkDisplay_xhdpi_006.mp4'
curl -O 'https://material-design.storage.googleapis.com/publish/material_v_9/0B6Okdz75tqQsT2ZXakpkaGp4bzQ/whatismaterial-materialprop-physicalprop-InkBehavior_xhdpi_006.mp4'
curl -O 'https://material-design.storage.googleapis.com/publish/material_v_9/0B6Okdz75tqQsc2VZVUJ5bFNscFU/whatismaterial_properties_physical_07_xhdpi_009.mp4'
curl -O 'https://material-design.storage.googleapis.com/publish/material_v_9/0B6Okdz75tqQsMndnRld3dl9nVU0/whatismaterial-materialprop-transformingmate
#/etc/init/{{item.app}}.conf
description "Unicorn"
start on startup
console output
env NEW_RELIC_APP_NAME={{app_name}}
env UNICORN_WORKERS={{unicorn_workers}}
env app=/u/apps/{{item.app}}/current
class StateEventInput < SimpleForm::Inputs::CollectionSelectInput
def collection
object.send(transitions)
end
def input(wrapper_options)
label_method = :human_event
value_method = :event
current_state = template.content_tag(:div, template.content_tag(:span, "Current state: #{object.send(human_name)}", :class => "label label-info") )
#See https://github.com/pluginaweek/state_machine/issues/251
module StateMachine
module Integrations
module ActiveModel
public :around_validation
end
module ActiveRecord
public :around_save
end
require 'rubygems'
require 'zmq'
require 'json'
context = ::ZMQ::Context.new
listen_socket = context.socket(::ZMQ::SUB)
listen_socket = listen_socket.setsockopt(::ZMQ::SUBSCRIBE, "")
listen_socket.bind("tcp://0.0.0.0:5555")
require 'zmq'
context = ZMQ::Context.new
pub = context.socket ZMQ::PUB
pub.setsockopt ZMQ::IDENTITY, 'ping-pinger'
pub.bind 'tcp://*:5555'
i=0
loop do
pub.send "ping pinger #{i+=1}" ; sleep 1
end
require 'em-websocket'
class MainServer
attr_accessor :data, :connect
def initialize(host, port)
@connect = TCPSocket.new host, port
end
end
def contains_point?(point, poly)
c = false
i = -1
j = poly.size - 1
while (i += 1) < poly.size
if ((poly[i][:y] <= point[:y] && point[:y] < poly[j][:y]) || (poly[j][:y] <= point[:y] && point[:y] < poly[i][:y]))
if (point[:x] < (poly[j][:x] - poly[i][:x]) * (point[:y] - poly[i][:y]) / (poly[j][:y] - poly[i][:y]) + poly[i][:x])
c = !c
end
j = i

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file: