Skip to content

Instantly share code, notes, and snippets.

View dastergon's full-sized avatar

Pavlos Ratis dastergon

View GitHub Profile
diff --git a/include/net/tcp.h b/include/net/tcp.h
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -285,6 +285,7 @@
extern int sysctl_tcp_adv_win_scale;
extern int sysctl_tcp_tw_reuse;
extern int sysctl_tcp_frto;
+extern int sysctl_tcp_syn_acceptq_pct;
extern int sysctl_tcp_low_latency;
extern int sysctl_tcp_dma_copybreak;
#!/usr/bin/perl
use warnings;
use strict;
my $bin=$ARGV[0];
my @line = split /\s+/, `nm $bin |grep runtime.buildVersion`;
my $addr = hex($line[0]);
my $end = $addr + 16;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@noopkat
noopkat / mech-keyboard-questions.md
Last active July 31, 2019 08:35
Mech Keyboard Questions to ask yourself
  1. How many keys do you want ie. do you need function keys / cursor arrow keys / numpad?
  2. Do you like loud clicky keys, bumpy tactile, or linear fast to hit keys?
  3. Do you want to be able to swap out switches for different ones or mix / match your switches?
  4. Do you need it to be portable?
  5. Do you want LED lighting?
  6. Do you want to program it with macros to be highly custom?
  7. Do you want USB-c?
  8. Windows or Mac?
  9. Do you want split / ergonomic / ortholinear?
  10. Do you want to use custom / creative keycap sets or keep it OEM?
s = status --short --branch --ignore-submodules=untracked
find = log --pretty=\"format:%Cgreen%H\n%s\n\n%b\" --name-status --grep
amend = commit --amend --no-edit
undo = reset HEAD~
upload = "!git push rakyll $(git rev-parse --abbrev-ref HEAD)"
prune = "!git co master && git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
delete = branch -D
pr = "!git fetch origin pull/$1/head:pr$1"
sync = "!git pull -q -r origin master"
@JenkinsDev
JenkinsDev / fisher-yates-shuffle.py
Last active October 14, 2020 15:00
Fisher-Yates Shuffle In Python
from random import randint, random
from math import floor
def fisher_yates_shuffle(the_list):
list_range = range(0, len(the_list))
for i in list_range:
j = randint(list_range[0], list_range[-1])
the_list[i], the_list[j] = the_list[j], the_list[i]
return the_list
@drewfradette
drewfradette / headtail.py
Created February 13, 2013 03:30
Python - recreate head/tail functionality
import os
def head(filename, count=1):
"""
This one is fairly trivial to implement but it is here for completeness.
"""
with open(filename, 'r') as f:
lines = [f.readline() for line in xrange(1, count+1)]
return filter(len, lines)
@garethr
garethr / kubernetes.rego
Last active August 23, 2022 10:27
Collecting together Kubernetes rego examples, including porting the https://kubesec.io rules to rego
package kubernetes
name = input.metadata.name
kind = input.kind
is_service {
kind = "Service"
}
@ameerkat
ameerkat / BoyerMooreStringSearch.py
Created October 14, 2010 17:46
Boyer Moore string search implementation in Python
# Boyer Moore String Search implementation in Python
# Ameer Ayoub <ameer.ayoub@gmail.com>
# Generate the Bad Character Skip List
def generateBadCharShift(term):
skipList = {}
for i in range(0, len(term)-1):
skipList[term[i]] = len(term)-i-1
return skipList

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory