Skip to content

Instantly share code, notes, and snippets.

View aadityabhatia's full-sized avatar

Sonny Bhatia aadityabhatia

View GitHub Profile
@aadityabhatia
aadityabhatia / supybot-xkcd-plugin.py
Created April 16, 2011 06:22
Xkcd plugin for supybot
###
# Copyright (c) 2011, Aaditya Bhatia
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
@aadityabhatia
aadityabhatia / bubble.py
Created July 13, 2011 21:03
XMPP MUC YouTube snarfer
if 'youtube' in options_db and 'youtu' in text:
match = re.search('https?://.*?(?:youtube\.com/|youtu\.be).*?(?:v=|/)(.*?)(?:&|#|\s|$)', text)
try:
if match:
id = match.group(1)
entry = json.loads(urllib2.urlopen("http://gdata.youtube.com/feeds/api/videos/" + id + "?alt=json").read())['entry']
title = entry['title']['$t']
secs = entry['media$group']['media$content'][0]['duration']
viewCount = entry['yt$statistics']['viewCount']
duration = "%d:%02d" % (secs/60, secs%60)
@aadityabhatia
aadityabhatia / favicons.js
Created May 29, 2012 00:03
favicons next to links
$("a[href^='http']").each(function() {
$(this).css({
background: "url(http://www.google.com/s2/u/0/favicons?domain=" + this.hostname +
") left center no-repeat",
"padding-left": "20px"
});
});
@aadityabhatia
aadityabhatia / cluster.coffee
Created September 22, 2012 11:35
node cluster that restarts when git HEAD is updated
cluster = require 'cluster'
if not cluster.isMaster then return require './app'
util = require 'util'
express = require 'express'
gitpull = require 'gitpull'
gitsha = require 'gitsha'
require 'colors'
@aadityabhatia
aadityabhatia / httpProxyCluster.coffee
Created October 10, 2012 22:40
node.js HTTP Proxy Cluster
cluster = require 'cluster'
if not cluster.isMaster then return require 'webapp2'
PORT = process.env.PORT or 8000
process.env.PORT = 0
httpProxy = require 'http-proxy'
util = require 'util'
express = require 'express'
@aadityabhatia
aadityabhatia / jQuery-bookmarklet.js
Created November 18, 2012 19:56
bookmarklet to inject jQuery into any page
(function() {
if(typeof jQuery!='undefined') {
return console.log('jQuery already present: v'+jQuery.fn.jquery);
}
if(typeof($) === 'function') {
console.log('$ already defined. Use $jq(), not $().');
}
var script=document.createElement('script');
script.src='http://code.jquery.com/jquery-latest.min.js';
var head=document.getElementsByTagName('head')[0],
@aadityabhatia
aadityabhatia / enum-baseline.ps1
Last active February 21, 2021 06:56
PowerShell script to enumerate and compare snapshots of Windows system state and config
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$outputFile
)
$data = @{}
function header($text) {
"`n"
@aadityabhatia
aadityabhatia / example.coffee
Created February 21, 2017 22:53
node library for analyzing FAT16 filesystems
fs = require 'fs'
fatReader = require './fatReader'
fd = fs.openSync 'fatFilesystem.fat', 'r'
fat = fatReader.getFS(fd)
fatReader.log fat
console.log "\nReading root directory"
@aadityabhatia
aadityabhatia / registry-diff.ps1
Last active December 31, 2024 16:56
PowerShell script to create and compare snapshots of Windows Registry sections
[CmdletBinding()]
Param(
[Parameter(Position=1, Mandatory=$True)]
[string]$dataFile1,
[Parameter(Position=2, Mandatory=$True)]
[string]$dataFile2
)
$dataObj1 = cat -raw "$dataFile1.json" | ConvertFrom-Json
$dataObj2 = cat -raw "$dataFile2.json" | ConvertFrom-Json
@aadityabhatia
aadityabhatia / connect-otw.bash
Created February 27, 2017 03:18
SSH helper for wargames at overthewire.org
#!/bin/bash
connect-otw () {
name=$(basename $PWD)
num="$1";
shift;
( test -n "$name" || exit 3; test -f "$name$num" || exit 4;
sshpass -f "$name$num" ssh -q $name$num@$name.labs.overthewire.org $@ )
}