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 / unwtach.js
Created January 31, 2014 17:42
github repo unwatch
// unwatch all repos containg "foobar"
$("li.subscription-row").each(function(i, row){ if ($(row).find("a.repo-name").text().indexOf("foobar") >= 0) { $(row).find("form.js-unsubscribe-form button").click() } });
#!/usr/bin/env ruby
lines = STDIN.readlines.map{ |s| s.strip.downcase }
# lines = File.read("files.txt").split(/\n/).map{ |s| s.downcase }
files = {}
lines.each{ |s| files[s] = 1 }
lines.each do |s|
if s =~ /^(.*?)\.jn1$/ then
f = $1
user system total real allocations memsize
RABL Ultra Simple 2.660000 0.890000 3.550000 ( 3.557719) 106 8751
AMS Ultra Simple 0.280000 0.010000 0.290000 ( 0.285863) 26 650
Presenters Ultra Simple 0.170000 0.000000 0.170000 ( 0.174525) 24 650
ApiView Ultra Simple 0.190000 0.010000 0.200000 ( 0.196894) 12 842
-------------------------------------------------------------------------------------------------------------------
RABL Simple 14.240000 4.490000 18.730000 ( 18.813523) 590 53565
AMS Simple 1.280000 0.000000 1.280000 ( 1.290985) 105 2726
Presenters Simple 0.690000 0.010000 0.700000 ( 0.690873)
@chetan
chetan / village_voice_bookmarklet.js
Created August 25, 2014 15:01
bookmarklet for single-page slideshows
// bookmarklet
javascript:var d = $("div.slide"), s = $($.grep($("script"), function(el) { return $(el).text().match(/VVMSlideShow/) })).text().replace(/\s+/g, "");s = s.substring(s.indexOf("photoData:")+10, s.indexOf("pointer:")-1);s = JSON.parse(s);_.each(s, function(v, i) {if (i === "1") return;d.append("<img src='" + v["Photo"] + "' />");});
// expanded version
var d = $("div.slide"),
s = $($.grep($("script"), function(el) { return $(el).text().match(/VVMSlideShow/) })).text().replace(/\s+/g, "");
s = s.substring(s.indexOf("photoData:")+10, s.indexOf("pointer:")-1);
s = JSON.parse(s);
_.each(s, function(v, i) {
if (i === "1") return;

Keybase proof

I hereby claim:

  • I am chetan on github.
  • I am chetan (https://keybase.io/chetan) on keybase.
  • I have a public key whose fingerprint is 4B9C 048F 5423 B084 3143 68F1 0747 382F 0F4D C0DD

To claim this, I am signing this object:

@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")