Skip to content

Instantly share code, notes, and snippets.

Babak Farrokhi farrokhi

Block or report user

Report or block farrokhi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@farrokhi
farrokhi / mem_swap_linux.md
Created Jul 17, 2019
memory usage and swap investigation in linux
View mem_swap_linux.md
grep -A1 Normal  /proc/zoneinfo  ; echo "--"; sysctl vm.min_free_kbytes ; echo "--"; numactl -H | grep free
@farrokhi
farrokhi / autotune.py
Created May 19, 2019
FreeBSD autotuning (loader.conf and sysctl.conf)
View autotune.py
#!/usr/local/bin/python
"""
Autotuning program.
Garrett Cooper, December 2011
Example:
autotune.py --conf loader \
--kernel-reserved=2147483648 \
--userland-reserved=4294967296
@farrokhi
farrokhi / best-mirror.sh
Last active Nov 19, 2018 — forked from lox/mirror_test.sh
A shell script to select the fastest freebsd-update mirror
View best-mirror.sh
#!/bin/sh
# best-mirror.sh
#
# Domesticaed for FreeBSD by Babak Farrokhi (farrokhi@FreeBSD.org)
#
# This script finds the fastest freebsd-update mirror based on
# data transfer rates from cURL.
#
# Note: I used a static list of mirrors, which is not the best way to
@farrokhi
farrokhi / str-perf-test.py
Last active Aug 6, 2018
comparing performance of various string concatenation methods in python
View str-perf-test.py
from functools import wraps
import pickle
from random import randint, choice
import string
import pathlib
import time
import sys
big_list = [] # our huge list of tuples
cache_file = "test-data-cache.pickle"
@farrokhi
farrokhi / freebsd-ntpd.md
Created Jun 18, 2018
Bind FreeBSD ntpd to given IP address
View freebsd-ntpd.md

In order to avoid FreeBSD ntpd listen on wildcard interface, add following lines to /etc/ntp.conf:

interface ignore wildcard
interface listen 10.0.0.1
@farrokhi
farrokhi / cscope.md
Created May 30, 2018
Setting up cscope for a (large) C project
View cscope.md

build/update database:

cd $PROJ_DIR
find . -path .git -path .svn -prune -o -name "*.[ch]" > cscope.files
cscope -bqk

browse code:

cscope -d
@farrokhi
farrokhi / dnskey-result.txt
Last active Oct 20, 2017
Sad state of DNSSEC adoption with top domains
View dnskey-result.txt
#
# The output from my check-dnskey.sh script that requests DNSKEY record
# from top 100 domain names and prints the key if there was any.
# last updated on 2017-oct-20
#
google.com NO
youtube.com NO
facebook.com NO
baidu.com NO
wikipedia.org NO
@farrokhi
farrokhi / sort-vs-gsort.md
Last active Jul 19, 2017
BSD sort vs GNU sort
View sort-vs-gsort.md

dataset size

# wc -l bigdata-random.csv
 13013886 bigdata-random.csv

tools

@farrokhi
farrokhi / splitgateway.sh
Created Aug 16, 2016
Split default route into multiple smaller routes (FreeBSD)
View splitgateway.sh
#!/bin/sh
#
# Split default route into 8 smaller routes to avoid
# lock contention during route lookup
#
# If a default router is not specified, it will be
# taken from rc.conf.
#
ROUTECMD="/sbin/route -q "
@farrokhi
farrokhi / nullroute.sh
Created Aug 16, 2016
Add/Remove null routes with permanent configuration (FreeBSD)
View nullroute.sh
#!/bin/sh
#
# Copyright (c) 2015 Babak Farrokhi. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
You can’t perform that action at this time.