Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

vikrum

🎯
Focusing
Block or report user

Report or block vikrum

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vikrum
vikrum / .osx
Last active Jun 13, 2019
Vikrum's Most Excellent Antiques, Curiosities, and Dotfiles
View .osx
defaults write com.apple.Safari IncludeDebugMenu 1
defaults write com.apple.dock no-bouncing -bool TRUE
defaults write com.apple.notificationcenterui bannerTime 1
defaults write -g ApplePressAndHoldEnabled -bool false
@vikrum
vikrum / websocketplayground.html
Created Oct 12, 2011
Quick, dirty, in-browser websocket playground
View websocketplayground.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>websocket playground</title>
<meta charset="utf-8">
<meta name="description" content="Quick, dirty, and in-browser websocket playground">
<meta name="author" content="@vikrum5000">
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<style type="text/css">
@vikrum
vikrum / oneliners.txt
Last active Mar 3, 2017
Various One Liners
View oneliners.txt
# On bash + Linux
# Show TCP sockstats every 5 seconds
$ while [ : ]; do echo -n `date`; echo -n ": "; cat /proc/net/sockstat | sed 'N;s/\n/ /;' | grep TCP; sleep 5; done
# Show netstat connection state counts every 5 seconds
$ while [ : ]; do echo -n `date`; echo -n ": "; netstat -n | awk '/^tcp/ {t[$NF]++}END{for(state in t){print state, t[state]} }' | tr '\n' ' '; echo ; sleep 5; done
# Show top 25 established IPs and their counts
$ lsof -n|grep TCP|grep ESTABLISHED|awk '{print $9}' |grep -e "->"|awk -F '->' '{print $2}'|awk -F ':' '{print $1}'|sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n|uniq -c|sort -rn|head -25
@vikrum
vikrum / LockOnLocksOnLocks.java
Created May 2, 2012
Locks On Locks On Locks
View LockOnLocksOnLocks.java
package sandbox;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import org.apache.commons.lang3.time.StopWatch;
public class LockOnLocksOnLocks {
@vikrum
vikrum / App.scala
Created Jun 26, 2012
Scala REPL exposed via Netty
View App.scala
object App extends Logging {
def main(args: Array[String]) = {
setupNetty
scalaReplConsole
}
/**
* Setup Netty for things like logging, etc. This should happen first. Do not get rid of this.
* You'll have a calamity on your hands if it needs to log under stress and it is unable to.
@vikrum
vikrum / twitter-jvm.sh
Created Jul 2, 2012
Twitter's JVM startup template
View twitter-jvm.sh
# Courtesy @marius, April 2012
#
# "Our most common type of system are mostly stateless, high volume,
# low latency RPC systems. For these, we generally use this template:"
HEAP_OPTS="-Xmx17G -Xms17G -XX:NewSize=15G -XX:+UseNUMA"
GC_OPTS="-XX:+UseConcMarkSweepGC -XX:SurvivorRatio=40 -XX:+CMSScavengeBeforeRemark"
GC_LOG_OPTS="-verbosegc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC"
GC_LOG="-Xloggc:/var/log/$APP_NAME/gc.log"
DEBUG_OPTS="-XX:ErrorFile=/var/log/$APP_NAME/java_error%p.log"
@vikrum
vikrum / gist:4005258
Created Nov 3, 2012
Various distributions of the alphabet
View gist:4005258
var naturalDist = "abcdefghiklmnopqrstuvwxyz";
var scrabbleDist = "aaaaaaaaabbccddddeeeeeeeeeeeeffggghhiiiiiiiiijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz";
var englishDist = "aaaaaaaabbcccddddeeeeeeeeeeeefffgghhhhhhiiiiiiijkllllmmnnnnnnnooooooooppqrrrrrrssssssstttttttttuuuvwwwxyyz";
@vikrum
vikrum / firedns.js
Created Jan 14, 2013
A custom DNS server in NodeJS that saves off queries to Firebase so they can be retrieved later. Accompanying blog post: http://5f5.org/ruminations/dns-debugging-over-http.html
View firedns.js
var crypto = require('crypto');
var dns = require('native-dns');
var rest = require('restler');
var server = dns.createServer();
server.on('request', function (request, response) {
var domain = request.question[0].name;
if(domain == 'webutils.flourishworks.com') {
// Don't log this because it can't be uniquely identified and subsequently retrieved
@vikrum
vikrum / bandwidth.pl
Last active Dec 11, 2015
display linux interface bandwidths on a regular interval (http://arctic.org/~dean/scripts/bandwidth) Modified to: 1) include aggregates; 2) average packet sizes; and, 3) scaled totals.
View bandwidth.pl
#!/usr/bin/perl -w
# display linux interface bandwidths on a regular interval
# dep: yum -y install perl-Time-HiRes
# Copyright (c) 2005 Dean Gaudet <dean@arctic.org>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@vikrum
vikrum / sak.sh
Created Feb 4, 2013
Oh, don't mind me, I'm just running roughshod over your processes.
View sak.sh
#!/bin/bash
#
# seek and kill a mem hog fork()'d child
#
SEEK="stud"
SNOOZE="6000"
while [ : ]; do
echo Snoozing for $SNOOZE
You can’t perform that action at this time.