- JAVA : 1-4 MB
- C++ : 1 MB
- Python : 64 KB
- Golang : 2-4 KB
- Node.js : Single threaded and event driven
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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() |
- https://github.com/chubin/cheat.sh
- ngrok
- tcp-spy
- 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
- During send() if it is blocking, if we try to send some data from buffer, some less data might be send because of CPU interruption
- https://stackoverflow.com/a/19698872/2679770
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var p = (i) => { | |
return new Promise((resolve,reject) => { | |
setTimeout(() => { | |
resolve(i); | |
},1000); | |
}); | |
} | |
async function test() { | |
for (let i = 0; i < 2; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# firefox | |
catalog column chase globe awesome paddle hand sibling solve crisp state page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="") |
NewerOlder