Skip to content

Instantly share code, notes, and snippets.

@alkesh
alkesh / create_chrome_ssb
Created September 16, 2013 11:16
Google Chrome Site Specific Browser (OS X)
#!/bin/sh
echo "What should the Application be called (e.g. Google Calendar)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@alkesh
alkesh / run_tags.rb
Created January 5, 2012 11:17 — forked from bryanl/run_tags.rb
fork of run_tags script to work on OS X using homebrew installed ctags
#!/usr/bin/ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
# More info here: http://vimeo.com/3989493
#
# This fork will work with homebrew installed ctags on OS X ("brew install ctags")
CTAGS = '/usr/local/bin/ctags'
@alkesh
alkesh / ews-curb-spike.rb
Created October 26, 2011 08:08
Authentication using EWS
#!/usr/bin/env ruby
require 'rubygems'
require 'curb'
require 'uri'
#uri = URI.parse("https://oa.bt.com/ews/Services.wsdl")
c = Curl::Easy.new("https://oa.bt.com/ews/Exchange.asmx")
#c = Curl::Easy.new("https://oa.bt.com/ews/Services.wsdl")
@alkesh
alkesh / epel_centos_5.3
Created May 9, 2011 14:00
Centos 5.3 EPEL
sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
@alkesh
alkesh / memusage
Created January 10, 2011 13:01
Find total memory usage for matching processes
#!/usr/bin/env ruby
command = %(ps aux| awk '/.*#{ARGV[0]}.*/{total+=$6}END{print total/1024, "Mb"}')
total_mem = `#{command}`
puts total_mem
@alkesh
alkesh / Creating users on Linux
Created November 30, 2010 11:25
Create user on Debian or Centos
# Debian
adduser <user>
adduser <user> admin
passwd -e <user>
# Centos
useradd -G wheel <user>
passwd <user>
chage -d 0 <user>
@alkesh
alkesh / rails3 default.rake
Created September 9, 2010 14:16
rails3 default.rake
require 'rake/clean'
Rake::TaskManager.class_eval do
def remove_task(task_name)
@tasks.delete(task_name.to_s)
end
end
Rake.application.remove_task('default')
@alkesh
alkesh / db_migrate_all.rake
Created September 9, 2010 14:12
db_migrate_all.rake
namespace :db do
namespace :migrate do
desc "Migrate development, test and production databases"
task :all => :environment do
Dir.glob('config/environments/*.rb').map{|f| File.basename(f).sub(/\.rb$/, '')}.each do |env|
puts "Migrating #{env} database..."
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[env])
ActiveRecord::Migrator.migrate("db/migrate/")
ActiveRecord::Base.remove_connection
end
@alkesh
alkesh / create_admin_user_oel
Created July 7, 2010 12:25
Create user on OEL/CentOS
#!/bin/bash
username=$1
adduser $username
usermod -G wheel $username
echo set user password:
passwd $username
chage -d 0 $username
@alkesh
alkesh / run_tags.rb
Created March 8, 2010 11:44 — forked from bryanl/run_tags.rb
run_tags for VIM when ctags installed to /usr/local/
#!/usr/bin/ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/usr/local/bin/ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'