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
View go-build.md
@farrokhi
farrokhi / mem_swap_linux.md
Created Jan 19, 2020
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 / freebsd-ntpd.md
Created Jan 19, 2020
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 Jan 19, 2020
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 / cpu-mem-online.sh
Created Jan 19, 2020
Turn all CPU and RAM online in Linux under VMWare
View cpu-mem-online.sh
#!/bin/bash
# Based on script by William Lam - http://engineering.ucsb.edu/~duonglt/vmware/
# Bring CPUs online
for CPU_DIR in /sys/devices/system/cpu/cpu[0-9]*
do
CPU=${CPU_DIR##*/}
echo "Found cpu: '${CPU_DIR}' ..."
CPU_STATE_FILE="${CPU_DIR}/online"
if [ -f "${CPU_STATE_FILE}" ]; then
@farrokhi
farrokhi / ensure-ssh-agent.sh
Created Jan 19, 2020
Ensure ssh-agent is running and you have proper env variables set (re-use if possible)
View ensure-ssh-agent.sh
AGENT_SCRIPT=${HOME}/load-agent.sh
while true; do
[ -r ${AGENT_SCRIPT} ] && source ${AGENT_SCRIPT}
if [ -n "$SSH_AGENT_PID" ]; then
# ensure the variable actually reflects a running ssh-agent process
ps -p $SSH_AGENT_PID | grep -q ssh-agent$ && break
fi
# SSH_AGENT_PID is either not set or has stale PID
echo "Running ssh-agent"
@farrokhi
farrokhi / cleanup_memory.sh
Created Jan 19, 2020
Enforce dropping page cache and trigger memory page compactor for Linux MM
View cleanup_memory.sh
#!/bin/sh
set -u
NUMA_BEFORE=`numactl -H | grep free:`
SLAB_BEFORE=`grep Normal /proc/buddyinfo`
printf "Dropping page cache..."
sysctl -qw vm.drop_caches=1
echo
@farrokhi
farrokhi / hugepages_settings.sh
Created Jan 19, 2020
Calculate recommended value for HugePages/HugeTLB in Linux
View hugepages_settings.sh
#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
@farrokhi
farrokhi / vim-headers.md
Created Jan 19, 2020
vim header file for text documents with proper line-breaking
View vim-headers.md

Text file with hard line-breaks:

# vim:ts=4:sw=4:tw=79:wm=2

Golang source files with proper tab and spacing:

// vim:noet:noai:ts=4:sw=4
@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
You can’t perform that action at this time.