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
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
image = message.include?('0 failures, 0 errors') ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
end
@minhajuddin
minhajuddin / nginx_setup.sh
Created March 7, 2011 07:27
nginx setup stuff
#create sites-enabled directory to hold config symlinks
sudo mkdir -p /etc/nginx/sites-enabled
#symlink the webapps directory to /var/www/apps
sudo mkdir -p /var/www
sudo ln -ns /home/minhajuddin/webapps /var/www/apps
#symlink an nginx config file to a webapps config file
sudo ln -ns /var/www/apps/ramanujan/config/nginx.conf /etc/nginx/sites-enabled/ramanujan.conf
#hookup /etc/init.d/nginx to auto-start at startup
/usr/sbin/update-rc.d -f nginx defaults
@minhajuddin
minhajuddin / ubuntu_imporant_file_paths.sh
Created February 14, 2011 11:22
file paths of important files in ubuntu
/etc/apt/sources.list #==> File which stores information about apt sources.
/etc/hosts #==> Stores the dns records
/etc/network/interfaces #==> Stores the network settings like ip/dhcp/gateway etc,.
wc -l `git ls-files | grep -E 'cs$|spark$|aspx$|ascx$'`
#trace mongo in RPM
Mongo::Collection.class_eval do
include NewRelic::Agent::MethodTracer
add_method_tracer :find
add_method_tracer :find_one
add_method_tracer :find_and_modify
add_method_tracer :update
add_method_tracer :insert
add_method_tracer :save
add_method_tracer :remove
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
task :spec do
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:client) do |t|
t.pattern = "spec/**/*_spec.rb"
end
end
# with multiple collections + commands for renaming back the collections
require 'mongo'
# Stop writing to your database.
# Then, for each collection:
# Specify the DB and COLLECTION you want to convert.
# Will insert all modified documents into a new collection
# called 'new_' + old_collection_name.
# Then you can delete the old collection and rename the new one
require "test/unit"
require "rubygems"
require "mongoid"
Mongoid.configure do |config|
name = "embed_hash_test"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.persist_in_safe_mode = false
end
config.metals = ["Gridfs"]