Skip to content

Instantly share code, notes, and snippets.

View fxlv's full-sized avatar

Kaspars Mickēvičs fxlv

View GitHub Profile
# pushover notification script for mikrotik routers
# scp it to the router and then run:
#
# /file/remove pushover.rsc
# /system script remove pushover
# /system/script/add name=pushover source=[/file get pushover.rsc contents]
#
# enable it to run at startup with this command
# /system/scheduler/add name=pushover on-event=pushover start-time=startup interval=0
#
/*
* IP checksumming functions.
* (c) 2008 Gerd Hoffmann <kraxel@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; under version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@fxlv
fxlv / gist:802358e6422848f5fd88
Created May 14, 2015 06:55
Graphite apache virtualhost config
<VirtualHost *:80>
ServerName graphite
DocumentRoot "/usr/local/share/graphite-web/content/"
# I've found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=5 threads=5 inactivity-timeout=120 display-name=graphite
WSGIProcessGroup graphite
WSGIApplicationGroup graphite
WSGIImportScript /usr/local/etc/graphite/graphite.wsgi process-group=graphite application-group=graphite
@fxlv
fxlv / gist:40f3a332bdd33b405ffb
Created February 7, 2015 19:45
kernel building debian
#!/bin/bash
make-kpkg clean
timestamp=`date +"%Y%m%d"`
time sudo fakeroot make-kpkg \
--revision $timestamp \
--initrd --jobs 8 \
kernel_image kernel_headers
search for PL2303HX and download an OSX driver
(http://www.prolific.com.tw/us/showproduct.aspx?p_id=229&pcid=41)
then
screen /dev/cu.PL2303-00001004 115200
#!/usr/bin/env python
import sys
# default dns query timeout is 5 seconds
retrans = 5
# give the user a chance to override it by passing an argument
if (len(sys.argv) == 2):
retrans = int(sys.argv[1])
# 3 dummy IP addresses
nameservers = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
@fxlv
fxlv / gist:6657ba422a9e7afd18ac
Last active August 29, 2015 14:13
Excerpt from eglibc-2.13/resolv/res_send.c, comments added to explain logic.
/*
* ns == current nameserver index (eg. 1,2 or 3)
* statp->retrans == retransmition time interval (this is defined in resolv.h)
*
* do a bitwise shift to the left to get the new timeout
* if ns == 0 then this does nothing
*/
int seconds = (statp->retrans << ns);
if (ns > 0)
// divide the time that was calculated after the bitwise shift by the nameserver count
@fxlv
fxlv / gist:6a692cfe711c8746c3cb
Last active August 29, 2015 14:13
vagrantfile multi machine example
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision :shell, inline: "apt-get update; apt-get -y upgrade"
config.vm.box = "fxlv/debian_wheezy64"
@fxlv
fxlv / gist:33c8cad7c0c51e264e26
Created January 7, 2015 06:23
dns resolver tracing with ktrace in openbsd
23513 ping 1420611042.842872 CALL connect(0x4,0x202092630,0x10)
23513 ping 1420611042.842878 STRU struct sockaddr { AF_INET, 10.0.1.1:53 }
23513 ping 1420611042.842890 RET connect 0
23513 ping 1420611042.842896 CALL sendto(0x4,0x202091800,0x1e,0,0,0)
23513 ping 1420611042.843135 GIO fd 4 wrote 30 bytes
"\M-`\M-m\^A\0\0\^A\0\0\0\0\0\0\bsuperduperdomain\^Ccom\0\0\^A\0\^A"
23513 ping 1420611042.843146 RET sendto 30/0x1e
23513 ping 1420611042.843155 CALL poll(0x7f7fffff9440,0x1,0x1388)
23513 ping 1420611047.846041 RET poll 0
#!/bin/bash
echo "cleaning up apt cache"
sudo apt-get clean
sudo /etc/init.d/rsyslog stop
echo "Removing old logs"
sudo find /var/log -type f -delete
echo "Zeroing out disk"
sudo dd if=/dev/zero of=/zero bs=1M
echo "Removing zero file"
sudo rm -v /zero