Skip to content

Instantly share code, notes, and snippets.

@andreimaxim
andreimaxim / daemon.rb
Last active December 14, 2015 15:48 — forked from alinbsp/gist:5109459
require 'syslog'
require 'daemonize/version'
module Daemonize
APP_NAME = "ruby_daemon"
PID_FILE = APP_NAME + ".pid"
CWD = "."
# The code that will actually daemonize a process. It is
# based on the coding rules specified in the 13th chapter
unicorn_profiles="dev prod"
unicorn_dev_enable="yes"
unicorn_dev_user="devuser"
unicorn_dev_listen="/tmp/unicorn.dev.socket"
unicorn_dev_dir="/usr/local/www/dev"
unicorn_dev_config="/usr/local/www/dev/config.ru"
unicorn_dev_env="development"
unicorn_dev_flags="" # any additional flags
unicorn_dev_rails="YES" # For rails
let g:path_to_matcher = "/usr/local/bin/matcher"
let g:ctrlp_max_files = 25000
let ctrlp_filter_greps = "".
\ "egrep -iv '\\.(" .
\ "jar|class|swp|swo|log|so|o|pyc|as|fla|swf|jpe?g|png|gif|mo|po|wav|zip" .
\ ")$' | " .
\ "egrep -v '^(\\./)?(.git/|.hg/|.svn/)'"
if has("unix")
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>nginx</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/nginx/sbin/nginx</string>
<string>-g</string>
# This block requires the geo module, which enables the use of
# variables which depend on the IP address of the client.
#
# In this case, everyone outside of the 192.168.0.x network
# is considered an "external" client.
geo $external {
default 1;
192.168.0.0/24 0;
}

ruby-1.9.3-p484 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p484 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

Using Unicorn with Upstart

This configuration works with Upstart on Ubuntu 12.04 LTS

The reason why it needs to be done this way (i.e. with the pre-start and post-stop stanzas), is because Upstart is unable to track whever Unicorn master process re-execs itself on hot deploys. One can use it without hot-deploys and run Unicorn in foreground also, it then only needs one exec stanza.

This presumes you are not using RVM, so no voodoo dances.

require_relative './clojure-1.8.0.jar'
def clojure; Java::ClojureLang; end
i = clojure.PersistentHashMap.create(a: 'b')
puts i[:a] #=> 'b'
@andreimaxim
andreimaxim / keybase.md
Last active September 8, 2016 11:51
keybase.md

Keybase proof

I hereby claim:

  • I am andreimaxim on github.
  • I am andreimaxim (https://keybase.io/andreimaxim) on keybase.
  • I have a public key ASCty5268_70lSW2XCIanVXixKf2SbPxSBNIuzEMw9BIRQo

To claim this, I am signing this object: