Skip to content

Instantly share code, notes, and snippets.

@jahil
jahil / sysctl.conf
Created January 13, 2016 15:36
coronis.ucsc.edu FreeBSD Network Tuning
# $FreeBSD: releng/10.1/etc/sysctl.conf 112200 2003-03-13 18:43:50Z mux $
#
# Ensure ZFS uses 4k block size
vfs.zfs.min_auto_ashift=12
kern.ipc.somaxconn=2048
# set to at least 16MB for 10GE hosts
kern.ipc.maxsockbuf=16777216
# socket buffers
net.inet.tcp.recvspace=4194304
net.inet.tcp.sendspace=2097152
@jahil
jahil / sysctl.conf
Created January 13, 2016 15:32
calomel.org freebsd network tuning
# FreeBSD 10.2 -- /etc/sysctl.conf version 0.47
# https://calomel.org/freebsd_network_tuning.html
#
# low latency is important so we highly recommend that you disable hyper
# threading on Intel CPUs as it has an unpredictable affect on latency, cpu
# cache misses and load.
#
# These settings are specifically tuned for a "low" latency FIOS (300/300) and
# gigabit LAN connections. If you have 10gig or 40gig you will need to increase
# the network buffers as proposed. "man tuning" for more information.
@jahil
jahil / sysctl.conf
Created January 13, 2016 15:29
FreeBSD sysctl
Non-executable stack
sysctl kern.elf64.nxstack = 1
sysctl kern.elf32.nxstack = 1
Stack smashing protection
sysctl security.bsd.stack_guard_page = 1
NULL page mapping
sysctl security.bsd.map_at_zero = 0
@jahil
jahil / harden
Last active November 13, 2023 06:07
FreeBSD System Hardening Script
#!/bin/sh
##################################################################
##################################################################
#
# The FreeBSD System Hardening Script
# David Childers - 15 February, 2010
#
# This software is released under the Attribution-ShareAlike version 3.0 Licence.
# www.creativecommons.org/licenses/by-sa/3.0/
#
@jahil
jahil / gist:66e50000d975f9928b51
Created December 20, 2015 14:43
X-Forwarded-For IP Address Extract Uniq Apache Logs
tail -f access_log | awk '{ $1="";print}' | grep -o '\([0-9]\{2,3\}.\)\{3\}\.[0-9]\{2,3\}'
cat access_log | awk '{ $1="";print}' | grep -o '\([0-9]\{2,3\}.\)\{3\}\.[0-9]\{2,3\}' | sort -n | uniq -c | sort -nr | head -20
@jahil
jahil / .vimrc
Created September 21, 2015 12:26
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'mattn/webapi-vim'
Plugin 'mattn/gist-vim'
Plugin 'kien/ctrlp.vim'
Plugin 'bling/vim-airline'
@jahil
jahil / mongodb-backup.sh
Last active August 29, 2015 14:27
Simple MongoDB Backup Script
#!/bin/bash
HOST=localhost
BASE_BAK_FLDR=/backup/mongodb
RM_FLDR_DAYS="+7"
DB_BKP_FLDR=$BASE_BAK_FLDR/$(date +%d-%m-%Y)
[ ! -d $DB_BKP_FLDR ] && mkdir -p $DB_BKP_FLDR
mongodump --host $HOST --out $DB_BKP_FLDR
Patch for OpenSSH Portable to log passwords
Tested on:
OpenSSH 5.3p1 - OpenSSH 6.6p1
May apply to older versions.
To apply:
patch --dry-run < sshlog.patch
@jahil
jahil / npass.sh
Last active August 29, 2015 14:08
GRC's Perfect Passwords Generator
#!/bin/bash
# GRC's Perfect Passwords Generator
WGET="/usr/bin/wget"
FILE=`tempfile`
$WGET -q --tries=10 --timeout=5 http://www.google.com -O $FILE &> /dev/null
[ -z "$1" ] && echo -e "\E[31mGRC's\E[37m Ultra High Security Password Generator v0.1\r\033[0m" && echo -e '--------------------------------------------------\n' &&
echo -e '\E[37mUsage: ppassword [\E[31m-an alphanumeric\E[37m ] [\E[32m-as ascii\E[37m ] [ -hex hexadecimal ]' && exit 100
import requests
url = 'http://kitaabghar.com/bookbase/idara/KrishanChandKeBehtareenAfsanay.html'
def download_file(url,path,filename=''):
try:
if filename=='':