Skip to content

Instantly share code, notes, and snippets.

Avatar

Ankush Sharma darxtrix

View GitHub Profile
View disk_sensor.py
'''
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
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()
View thread_stack_size_comparison.md
  • JAVA : 1-4 MB
  • C++ : 1 MB
  • Python : 64 KB
  • Golang : 2-4 KB
  • Node.js : Single threaded and event driven
View golang_readme.md
  • 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 Apr 19, 2018
#os #memory #optimizations #networking
View os_concepts.md

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 Feb 11, 2018
#nodejs #blocking_node #async #await
View blocking_for_loop.js
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 Feb 8, 2018
metamask seed
View seed
# firefox
catalog column chase globe awesome paddle hand sibling solve crisp state page
View singleton_process_linux
#!/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 Aug 18, 2017
Visualizations for lehar
View algoviz.py
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="")
You can’t perform that action at this time.