Skip to content

Instantly share code, notes, and snippets.

View chetan's full-sized avatar
🙌
like my work? sponsor me!

Chetan Sarva chetan

🙌
like my work? sponsor me!
View GitHub Profile
@chetan
chetan / firefox_shutdown_hook.js
Created February 10, 2010 23:12
firefox shutdown hook example
var ShutdownHook = {
prefs: PrefsService, // wrapper around XPCOM preferences API
register: function() {
if (this.prefs.shutdownRegistered) {
return;
}
var observerService =
@chetan
chetan / entourage_growl_notification.scpt
Created February 11, 2010 15:45
entourage growl notification
(*
Public Domain, 2010
Chetan Sarva <csarva@pixelcop.net>
http://chetanislazy.com/
See also:
http://blog.entourage.mvps.org/2009/02/use_growl_with_entourage.html (original, help)
http://blog.geekdaily.org/2007/12/growl-for-entou.html (another script, borrowed some ideas)
*)
@chetan
chetan / buildr_linesofcode_extension.rb
Created February 23, 2010 19:49
fixed LinesOfCode buildr task
module LinesOfCode
include Extension
first_time do
# Define task not specific to any projet.
desc 'Count lines of code in current project'
Project.local_task('loc')
end
@chetan
chetan / reduce_deps.rb
Created February 27, 2010 01:04
reduce buildr spec list
#!/usr/bin/ruby
if ARGV.empty? then
puts "usage: reduce_deps.rb <file with dep constants>"
exit
end
deps_file = ARGV[0]
orig_consts = Object.constants
@chetan
chetan / gist:333147
Created March 15, 2010 18:29
lua script for mysql workbench to clear charset and collation
function clearCharSetAndCollation()
local schemata = grtV.getGlobal("/wb/doc/physicalModels/0/catalog/schemata")
local s
local tables
local t
for s=1, grtV.getn(schemata) do
print(schemata[s].name .. "\n")
#!/usr/bin/ruby
#
# adduser - Unix-like adduser script. Prompts for parameters and uses dscl internally to create
# new NetInfo users and groups.
#
# Chetan Sarva <csarva@pixelcop.net>
def next_user_id(start = 700)
ids = `dscl . -list /Users UniqueID`.split("\n").map{|s| s =~ /(\d+)$/; $1 }.sort.uniq
n = start
# Buildr project bootstrapper
# Chetan Sarva <csarva@pixelcop.net>
#
# Creates standard java project layout directories and files such as etc, src
# and README.
#
# USAGE
#
# buildr bootstrap
#
javascript:%20var%20x=%20$(".content").find("a").not(".thumbnail").each(function(){var%20href=$(this).attr("href");if((!$(this).hasClass("drowsapMorphed"))%20&&%20($(this).next(".drowsapMorphed").length==0)%20&&%20href%20&&%20(href.indexOf('imgur')>=0%20||%20href.indexOf('jpeg')>=0%20||%20href.indexOf('jpg')>=0%20%20||%20href.indexOf('png')>=0)){var%20ext%20=(href.indexOf('imgur')>=0%20&&%20href.indexOf('jpg')<0%20&&%20href.indexOf('png')<0)%20?%20'.jpg'%20:'';%20var%20img%20=%20$("<a%20class='drowsapMorphed'%20href='"+href+"'%20target='blank'%20style='display:block'><img%20style='display:block;max-width:780px;'%20src='"+href+%20ext+"'%20/></a>");$(this).after(img);}});
@chetan
chetan / percona-sysbench-test.sh
Created November 23, 2010 20:40
percona sysbench script
#!/bin/sh
# script for batch running sysbench I/O tests for mysql workload
# http://www.mysqlperformanceblog.com/2009/08/06/ec2ebs-single-and-raid-volumes-io-bencmark/
set -u
set -x
set -e
for size in 256M 16G; do
@chetan
chetan / parse_sysbench_io.rb
Created November 23, 2010 21:31
convert sysbench i/o test output into tsv format
#!/usr/bin/env ruby
module SysBench
class IO
attr_accessor :version, :threads, :test
attr_accessor :total_size, :block_size
attr_accessor :byte_rate, :request_rate
attr_accessor :min, :max, :avg, :top