Skip to content

Instantly share code, notes, and snippets.

View zzet's full-sized avatar
🎯
I may be slow to respond.

Andrew Kumanyaev zzet

🎯
I may be slow to respond.
View GitHub Profile
var args = require('system').args;
if (args.length === 3) {
var url = args[1];
var filename = args[2];
var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };
page.open(url, function () {
page.onConsoleMessage = function (msg) {
def check(name = nil)
puts "\n=== Checking #{":" if name} #{name}"
e = rescuing do
yield
end
if e
puts e
puts
@zzet
zzet / gist:7900439
Created December 10, 2013 21:22 — forked from dnagir/gist:1573414
  • This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
  • Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
  • You will lose all data in the ramdisk tablespace when you shut your machine down

  $ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
  Started erase on disk1
  Unmounting disk
  Erasing
 Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fc9db4e27b0>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fcd3e3c7180>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing': undefined method `devise' for #<Class:0x00000003091160> (NoMethodError)
from /rest/u/apps/gitlab/current/app/models/user.rb:41:in `<class:User>'
from /rest/u/apps/gitlab/current/app/models/user.rb:38:in `<top (required)>'
...
from /rest/u/apps/gitlab/current/app/models/issue.rb:20:in `include'
from /rest/u/apps/gitlab/current/app/models/issue.rb:20:in `<class:Issue>'
from /rest/u/apps/gitlab/current/app/models/issue.rb:19:in `<top (required)>'
...
from /rest/u/apps/gitlab/current/lib/api/notes.rb:6:in `<class:Notes>'
from /rest/u/apps/gitlab/current/lib/api/notes.rb:3:in `<module:API>'

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:

{
"items":[
{
"title": "Test news",
"description": "Some little description",
"autor": {
"id": 1
},
"labels": [
{
@zzet
zzet / gist:4004159
Created November 2, 2012 20:36
One news respond
{
"title": "Test news",
"description": "Some little description",
"body": "News content",
"url": "http://example.com/news/1",
"id": 1,
"autor": {
"name": "John",
"id": 1
},