Skip to content

Instantly share code, notes, and snippets.

View kashyapp's full-sized avatar

Kashyap Paidimarri kashyapp

View GitHub Profile
@kashyapp
kashyapp / conntrack.md
Last active August 30, 2017 12:55
conntrack logging
@kashyapp
kashyapp / proxy.pac
Created January 11, 2017 08:23
auto proxy config for 10.0.* only (setup using ssh -D)
// ssh -D 1080 remotehost
// save this file as something like /usr/local/etc/proxy.pac
// point your browser auto proxy config to this as file:///usr/local/etc/proxy.pac
function FindProxyForURL(url, host) {
PROXY = "SOCKS localhost; DIRECT"
// Apple.com via proxy
if (shExpMatch(host,"10.0.*")) {
return PROXY;
}
@kashyapp
kashyapp / kafka-part-distrib.sh
Created August 30, 2014 03:52
matrix that shows partition distribution for a topic across brokers
#!/bin/bash -e
/usr/share/fk-3p-kafka/bin/kafka-topics.sh $ZOOKEEPER --describe --topic $1 \
| grep Leader \
| awk '{print $4,$8}' | sed 's/,/ /' \
| awk '{
for(i=1;i<7;++i){a[i]=0};
sum[$2]++; sum[$3]++;
a[$2]=1; a[$3]=1;
printf "%3d ",$1;
for (i=1;i<7;++i) {printf "%3d ",a[i]}; printf "\n";

TLDR

If a program is writing to stdout, there is a big risk that if the other end of the pipe is frozen, the program itself will hang.

from a previous instance, not shutdown cleanly

root@bigfoot-kafka3:/etc/service/fk-3p-kafka/log/main# fuser *
current:             32391
lock:                32391
@kashyapp
kashyapp / 0_sheevaplug.md
Last active April 15, 2017 21:26
Sheevaplug + OS X

The Device

SheevaPlug JTAGKey FT2232D B:
  Product ID:  0x9e8f
  Vendor ID:	0x9e88

Install FTDI Driver for OS X

Download and install FTDI VCP driver from http://www.ftdichip.com/Drivers/VCP.htm

Patch it

to identify our device

@kashyapp
kashyapp / steelman.sh
Created July 5, 2013 10:48
Launch instance on Google Compute Engine
#!/bin/bash -e
set -x
NAME=steelman
BOOTDISK=boot-steelman
if ! ./gcutil getinstance --zone=us-central1-a ${NAME}; then
./gcutil addinstance \
--zone=us-central1-a \
--disk=${BOOTDISK},boot \
@kashyapp
kashyapp / couchdb.sh
Last active December 19, 2015 09:29
Couchdb dependencies for Debian 7.0 Wheezy
# all could be a single apt-get install of course. Broken down only for clarity.
apt-get install build-essential
apt-get install libicu-dev
apt-get install libmozjs185-dev
apt-get install libcurl4-openssl-dev
apt-get install erlang-dev erlang-eunit erlang-manpages erlang-nox
@kashyapp
kashyapp / gollum-custom.css
Created May 3, 2013 06:03
custom css for github/gollum
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300);
body {
font-family: helvetica,arial,freesans,clean,sans-serif;
}
#head h1,
.markdown-body h2,
.markdown-body h1 {
font-weight: 300;
font-family: 'Open Sans', helvetica, sans-serif;
@kashyapp
kashyapp / migrate.js
Created April 7, 2013 03:04
Migrate from list to sortedset for irc archives.
var r = require('redis');
r.debug_mode = true;
var redis = r.createClient(),
allRows = [],
migrated = 0;
redis.on("end", function(){
console.log("we should be done here");
});
@kashyapp
kashyapp / FreshExpiringLoadingCache.java
Last active October 14, 2018 19:40
Loading cache that keeps keys fresh until expiry.
import com.yammer.dropwizard.util.Duration;
import com.google.common.cache.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.*;
import static com.google.common.base.Throwables.propagateIfInstanceOf;
public class LocalAppConfigStorage implements AppConfigStorage {