Skip to content

Instantly share code, notes, and snippets.

View minhajuddin's full-sized avatar
⌨️
Beep boop, beep boop

Khaja Minhajuddin minhajuddin

⌨️
Beep boop, beep boop
View GitHub Profile
declare @foo xml
select @foo='<ext><name><first>Khaja</first><last>Minhajuddin</last></name><age>25</age></ext>';
select @foo.value('(//ext/name/first)[1]','varchar(50)') 'First Name',
@foo.value('(//ext/name/last)[1]','varchar(50)') 'Last Name',
@foo.value('(//ext/age)[1]','integer') 'Age';
#!/usr/bin/env ruby
# Script to create a jekyll blog post using a template. It takes one input parameter
# which is the title of the blog post
# e.g. command:
# $ ./new.rb "helper script to create new posts using jekyll"
#
# Author:Khaja Minhajuddin (http://minhajuddin.com)
# Some constants
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
#!/bin/sh
#This is a start script for nginx. Tested on Unbuntu Edge.
#Should work on Ubuntu, Debian and probably a few other Linux distros.
#Change DAEMON and CONFIG_FILE if neccessary
#Copied from: http://www.openmymind.net/2010/7/1/Installing-Nginx-with-Passenger-on-Linux
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/nginx/sbin/nginx
@minhajuddin
minhajuddin / env.rb
Created November 10, 2010 07:45 — forked from gmoeck/env.rb
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/rspec'
require 'cucumber/rails/world'
require 'cucumber/web/tableish'
require 'capybara/rails'
require 'capybara/cucumber'
God.watch do |w|
w.uid = "git"
w.gid = "git"
w.name = "asset-proxy"
w.pid_file = "/data/camouflage/tmp/camo.pid"
w.interval = 30.seconds
w.env = {
"PORT" => '8080',
"CAMOUFLAGE_KEY" => '0x24FEEDFACEDEADBEEFCAFE'
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@minhajuddin
minhajuddin / nginx.conf
Created December 14, 2010 11:59
nginx configuration file for unicorn
upstream foobar_server {
# This is the socket we configured in unicorn.rb
server unix:/home/ubuntu/apps/foobar/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name *.foobar.com;
root /home/ubuntu/apps/foobar/public;
#!/usr/bin/env rackup
require File.expand_path('app', File.dirname(__FILE__))
Ramaze.start(:file => __FILE__, :started => true)
run Ramaze
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do