Skip to content

Instantly share code, notes, and snippets.


Ankush Sharma darxtrix

View GitHub Profile
Disk Sensor Plugin
from ptop.core import Plugin
import psutil
class DiskSensor(Plugin):
def __init__(self,**kwargs):
# there can be many text (key,value) pairs to display corresponding to each key
View public_channel.go
Assume 1M total subscribers on ticker_INR channel
// Without sharding
go func() {
// 1M subscribers since ticker_INR is a public channel
subscribersBST := channelSubscriberStateMap.Get("ticker_INR")
subscribers := subscribersBST.inorder()
  • JAVA : 1-4 MB
  • C++ : 1 MB
  • Python : 64 KB
  • Golang : 2-4 KB
  • Node.js : Single threaded and event driven
  • An array has a fixed size where as the slices can be of dynamic types
  • Array slices are references that are easier to pass to the functions as compared to pointers. (
  • Go arrays are full objects, when we pass them to functions they are fully copied. Its not like in case of C, i.e pass by reference.
  • The type specification of a go slice is []T where the T is the type of the slice.
letters := []string{"a", "b", "c", "d"}

func make([]T, len, cap) []T
darxtrix /
Last active Apr 19, 2018
#os #memory #optimizations #networking

Memory mapped IO caching policies

Buffered io with disk is the another optimization that can be done

TCP packet sending guarantees

darxtrix / blocking_for_loop.js
Created Feb 11, 2018
#nodejs #blocking_node #async #await
View blocking_for_loop.js
var p = (i) => {
return new Promise((resolve,reject) => {
setTimeout(() => {
async function test() {
for (let i = 0; i < 2; i++) {
darxtrix / seed
Created Feb 8, 2018
metamask seed
View seed
# firefox
catalog column chase globe awesome paddle hand sibling solve crisp state page
View singleton_process_linux
export LOCKFILE="/var/tmp/trade_engine.lockfile"
export CMD="python"
#release lock in case of trap signal
trap 'rm -f "$LOCKFILE"; exit $?' INT TERM
#acquire lock
flock -n $LOCKFILE $CMD
if [ $? -eq 0 ]; then
echo "Another process running of "$CMD
darxtrix /
Created Aug 18, 2017
Visualizations for lehar
import time
import lehar
# Try to hide the cursor
data = [5,4,3,2,1,3,5,1,2]
for i in range(len(data)):
print(" ",end="")