Skip to content

Instantly share code, notes, and snippets.

@tkhn
tkhn / sphinx_
Created September 13, 2013 11:12
#!/usr/bin/perl
use warnings;
use strict;
use utf8;
use File::Basename;
#---------------------------------------------------------------------
#!/usr/bin/perl -w
# Usage: check_sphinx_search.pl INDEX QUERY MIN-RESULTS
# Example: check_sphinx_search.pl products iphone 15000
use strict;
my $cmd = "search --limit 0 --index ${ARGV[0]} ${ARGV[1]}";
my $min = $ARGV[2];
my $output = `$cmd`;
if($?) {
bark("search command failed");
}
@tkhn
tkhn / puma
Created November 14, 2013 17:29 — forked from niwo/puma
#!/bin/sh
#
# puma - this script starts and stops the puma daemon
#
# chkconfig: - 85 15
# description: Description \
# goes here...
# processname: puma
# config: /etc/puma.conf
# pidfile: /home/stanislaw/apps/micro-apps/puma/puma.pid
#
# Run as root
# $ bash <(curl -s https://raw.github.com/gist/1631411)
#
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl \
libssl-dev \
@tkhn
tkhn / README.md
Created November 20, 2013 10:21 — forked from dergachev/README.md

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
@tkhn
tkhn / Dockerfile
Created November 25, 2013 18:39 — forked from itsderek23/Dockerfile
# docker build -t="rails" .
FROM ubuntu:12.04
RUN apt-get update
## MYSQL
RUN apt-get install -y -q mysql-client libmysqlclient-dev
## RUBY
@tkhn
tkhn / Gemfile
Created November 28, 2013 16:04 — forked from nebiros/Gemfile
group :production do
gem "unicorn"
end
@tkhn
tkhn / production.rb
Created November 28, 2013 16:05 — forked from ganta/production.rb
# RAILS_ROOT/config/unicorn.rb
# Search for "# SET ME!" and replace these with your own settings!.
HOW_DEEP_WE_R_FROM_RAILS_ROOT = "../.."
# Set environment to development unless something else is specified
RAILS_ROOT = File.expand_path(HOW_DEEP_WE_R_FROM_RAILS_ROOT, File.dirname(__FILE__))
SHARED_PATH = File.expand_path('../shared', RAILS_ROOT)
ENV['BUNDLE_GEMFILE'] = File.expand_path("#{HOW_DEEP_WE_R_FROM_RAILS_ROOT}/Gemfile", File.dirname(__FILE__))
from datetime import datetime
class ProcNetDev(object):
"""Parses /proc/net/dev into a usable python datastructure.
By default each time you access the structure, /proc/net/dev is re-read
and parsed so data is always current.
If you want to disable this feature, pass auto_update=False to the constructor.