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
# A simple test showing possible memory leaks in Python | |
# import gc | |
import time | |
import resource | |
counter = 0 | |
def get_new_id(): | |
global counter |
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
#!/usr/bin/python3 | |
''' | |
## What is this? | |
A simple way of parallelizing commands (including pipelines) in a shell, while preserving output order. | |
For example, we can re-write: | |
``` | |
for i in {1..5}; do |
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
;; This configuration is guile based. | |
;; https://www.gnu.org/software/guile/learn/ | |
;; Based on the awesome script created by Zero Angel: | |
;; https://www.linuxquestions.org/questions/linux-desktop-74/%5Bxbindkeys%5D-advanced-mouse-binds-4175428297/ | |
;; We'll need a named pipe later, because we can't share FDs | |
(if (not (file-exists? ".xbindkey.pipe")) | |
(run-command "mkfifo .xbindkey.pipe") | |
(sleep 1) | |
) |
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 os | |
import sys | |
def rfind_file(filename, value, blocksize, maxsize=0): | |
fd = os.open(filename, os.O_RDONLY) | |
try: | |
size = os.lseek(fd, 0, os.SEEK_END) | |
if maxsize < 0: | |
size = max(size - maxsize, 0) | |
elif maxsize > 0: |
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 os | |
import sys | |
def count_continuous(data, value): | |
for i in range(len(data)): | |
if data[i] != value: break | |
return i | |
def sparse_clz(filename, blocksize): | |
fd = os.open(filename, os.O_RDONLY) |
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
(doesn't seem to work for h264) | |
HTTP/1.1 206 | |
access-control-allow-origin: * | |
connection: keep-alive | |
content-type: video/h264 | |
content-range: bytes 0- | |
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
// An experiment of using the virtual memory as a huge directly addressed map/dictionary. | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <sys/mman.h> | |
uint64_t setupMemory(uint64_t virtualSize); | |
int main() | |
{ |
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
class SmartTabs: | |
def __init__(self): | |
self.columns = [0] | |
def __call__(self, line): | |
cells = line.split('\t') | |
cols = self.columns | |
# Pad as needed or update existing columns |
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
// Doesn't work. | |
// Some NAT servers reset the port binding at new 'connections'. | |
let NatDetector = new (function() { | |
this.settings = { | |
server1p1: 'stun:stun1.l.google.com:19302', | |
server1p2: 'stun:stun1.l.google.com:19302', // TODO: change port only | |
server2p1: 'stun:stun2.l.google.com:19302' | |
// 'stun:stun.l.google.com:19302', |