Skip to content

Instantly share code, notes, and snippets.

View darxtrix's full-sized avatar

Ankush Sharma darxtrix

View GitHub Profile
@darxtrix
darxtrix / disk_sensor.py
Created November 24, 2018 19:25
Ptop disk sensor
'''
Disk Sensor Plugin
'''
from ptop.core import Plugin
import psutil
class DiskSensor(Plugin):
def __init__(self,**kwargs):
super(DiskSensor,self).__init__(**kwargs)
# there can be many text (key,value) pairs to display corresponding to each key
/*
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
@darxtrix
darxtrix / golang_readme.md
Last active April 20, 2018 17:52
#golang #basic
  • 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. (https://stackoverflow.com/questions/2439453/using-a-pointer-to-array)
  • 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
darxtrix / os_concepts.md
Last active April 19, 2018 15:59
#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
darxtrix / blocking_for_loop.js
Created February 11, 2018 16:58
#nodejs #blocking_node #async #await
var p = (i) => {
return new Promise((resolve,reject) => {
setTimeout(() => {
resolve(i);
},1000);
});
}
async function test() {
for (let i = 0; i < 2; i++) {
@darxtrix
darxtrix / seed
Created February 8, 2018 12:06
metamask seed
# firefox
catalog column chase globe awesome paddle hand sibling solve crisp state page
#!/bin/bash
#globals
export LOCKFILE="/var/tmp/trade_engine.lockfile"
export CMD="python print.py"
#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
darxtrix / algoviz.py
Created August 18, 2017 10:34
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="")