Skip to content

Instantly share code, notes, and snippets.


Amol Deshmukh adeshmukh-quizlet

View GitHub Profile
adeshmukh-quizlet /
Created Sep 3, 2020 — forked from staaldraad/
AWK to get details from /proc/net/tcp and /proc/net/udp when netstat and lsof are not available
# Gawk version
# Remote
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}'
# Local
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}'
# No Gawk
# Local
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
adeshmukh-quizlet / md5b64
Created Apr 25, 2020
kscript to generate base64 of md5 values
View md5b64
#!/usr/bin/env kscript
import java.util.Base64
val md5 = MessageDigest.getInstance("MD5")
println( { Base64.getEncoder().encodeToString(md5.digest(it.toByteArray())) }.joinToString(" "))
adeshmukh-quizlet / bitrev
Created Apr 23, 2020
Kotlin script to generate bitrev values
View bitrev
#!/usr/bin/env kscript
println( { java.lang.Long.reverse(it.toLong()) }.joinToString(" "))

Keybase proof

I hereby claim:

  • I am adeshmukh-quizlet on github.
  • I am adeshmukh_qz ( on keybase.
  • I have a public key ASBWRTbbokm4Kr9FuY7H4YeyHCyeqJLJyB1Yh-NUQI9wfwo

To claim this, I am signing this object:

adeshmukh-quizlet / ShardIdGenerator.kt
Last active Jul 16, 2019
Distributed ID Generation in Kubernetes
View ShardIdGenerator.kt
// 32-bit value will overflow in 2038. Migrate to 64-bit support by then.
// Ref:
private const val TIME_PART_MASK = 0x0000_0000_FFFF_FFFF
const val SHARD_PART_WIDTH = 5
const val SEQ_PART_WIDTH = 15
* A distributed, thread-safe ID generator that generates