Skip to content

Instantly share code, notes, and snippets.

View farrokhi's full-sized avatar
🚀

Babak Farrokhi farrokhi

🚀
View GitHub Profile
@farrokhi
farrokhi / bad-mx.txt
Created February 14, 2016 11:45
List of domains with bad MX record
500px.com
59saniye.com
8tracks.com
about.me
alarabiya.net
anonymox.net
archive.is
ashleymadison.com
badoo.com
badoocdn.com
@farrokhi
farrokhi / cpuflags.sh
Created August 16, 2016 09:33
Script to detect best cpuflags settings for CC
#!/bin/sh
COMPILERS="clang gcc gcc45 gcc46 gcc47 gcc48 gcc49 gcc5 gcc6"
check_compilers()
{
echo "Looking for available C compilers..."
for C in ${COMPILERS}
do
P=`which ${C} 2>&1`
@farrokhi
farrokhi / splitgateway.sh
Created August 16, 2016 09:36
Split default route into multiple smaller routes (FreeBSD)
#!/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 / dnskey-result.txt
Last active October 20, 2017 11:10
Sad state of DNSSEC adoption with top domains
#
# 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 / nullroute.sh
Created August 16, 2016 09:35
Add/Remove null routes with permanent configuration (FreeBSD)
#!/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.
@farrokhi
farrokhi / cscope.md
Created May 30, 2018 07:40
Setting up cscope for a (large) C project

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 / freebsd-ntpd.md
Created June 18, 2018 14:41
Bind FreeBSD ntpd to given IP address

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 / str-perf-test.py
Last active August 6, 2018 15:38
comparing performance of various string concatenation methods in python
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 / mem_swap_linux.md
Created July 17, 2019 12:18
memory usage and swap investigation in linux
grep -A1 Normal  /proc/zoneinfo  ; echo "--"; sysctl vm.min_free_kbytes ; echo "--"; numactl -H | grep free
@farrokhi
farrokhi / sort-vs-gsort.md
Last active October 28, 2019 12:05
BSD sort vs GNU sort

dataset size

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

tools