Skip to content

Instantly share code, notes, and snippets.

View r4um's full-sized avatar

Pranay Kanwar r4um

View GitHub Profile
@r4um
r4um / zookeeper_3.3.5dfsg1-1ubuntu1.debian.patch
Created May 3, 2012 13:44
zookeeper debian diff for build on lucid
diff -r -U1 a/changelog b/changelog
--- a/changelog 2012-03-23 23:04:21.000000000 +0530
+++ b/changelog 2012-03-26 22:04:43.579323262 +0530
@@ -1,3 +1,4 @@
-zookeeper (3.3.5+dfsg1-1ubuntu1) precise; urgency=low
+zookeeper (3.3.5+dfsg1-1ubuntu1) lucid; urgency=low
+ [ James Page ]
* d/patches/fixes/ZOOKEEPER-1431: Fix up memory leak in zookeeper
@@ -7,3 +8,6 @@
@r4um
r4um / reboot-linksysX3000.rb
Created April 19, 2012 19:08
Reboot Cisco Linksys X3000
#!/usr/bin/ruby
require 'optparse'
require 'net/http'
require 'uri'
class Rebooter
def self.reboot(args)
options = {}
@r4um
r4um / trunc.c
Created April 18, 2012 14:16
truncate file
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int main(int argc,char **argv)
{
int fd;
@r4um
r4um / ifaddr.c
Created April 18, 2012 14:14
fetch if addr
#include <unistd.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
@r4um
r4um / hook.c
Created April 18, 2012 14:12
override RLIMIT_NOFILE
# gcc -shared -fPIC -ldl -o hook.so hook.c
#include <stdio.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/resource.h>
#if defined(RTLD_NEXT)
#define REAL_LIBC RTLD_NEXT
#else
#define REAL_LIBC ((void *) -1L)
@r4um
r4um / mfd.pl
Created April 18, 2012 14:06
load perlmods
$modules_dir="$Bin/modules";
$modules_file="$modules_dir/module_order";
open(MOD_ORDER,$modules_file) or die "[-] Error: Could not open module order file, $!.\n";
my @MODULES=<MOD_ORDER>;
close($modules_file);
foreach my $module (@MODULES) {
next if $module =~ /^#/; # skip #
chomp($line);
$module =~ s/\s+//;
@r4um
r4um / hlight.pl
Created April 18, 2012 14:04
rxvt-unicode highlighter module
#! perl
#
# rxvt-unicode highlighter module
# Highlight text on the console given regex and rendition string
# Specified via hlight.X and hlight.rend.X resources respectively
# Where X is any number for ex 0, 1 etc. for multiple entries.
#
# For example to hilight text "warning", put the following in .Xdefaults
#
# URxvt*hlight.0: warning
@r4um
r4um / elfin.pl
Created April 18, 2012 14:01
Dumb run "commands directives via a file" processor.
#!/usr/bin/perl -w
#vim: set ft=perl et ts=4 sw=4:
# elfin -- mischievous; small
# Dumb run "commands directives via a file" processor.
# Make this > 500 LOC and u'll die.
use strict;
use File::Path;
use File::Copy;
@r4um
r4um / foxy_proxy_keyconfig.js
Created April 18, 2012 13:54
cycle proxy (use keyconfig)
var fp = Components.classes["@leahscape.org/foxyproxy/service;1"].getService().wrappedJSObject;
fp.cycleMode();
@r4um
r4um / enc-b.rb
Created April 18, 2012 13:51
System::Security::Cryptography file enc/dec
require 'System'
require 'pp'
include System
include System::Text
include System::Security::Cryptography
class CredentialStore
def initialize(file)