Skip to content

Instantly share code, notes, and snippets.

@yalla
yalla / transproxy.sh
Created June 17, 2011 19:32 — forked from katmagic/transproxy.sh
Transparently proxy all connections (and DNS requests) through Tor.
#!/bin/sh
### BEGIN INIT INFO
# Provides: transproxy
# Required-Start: $network tor
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Transparently proxy all network traffic through Tor.
### END INIT INFO
@yalla
yalla / cpu_stress.sh
Created August 9, 2011 12:29
Small CPU load testing script which uses openssl and is kinda bulletproof on Linux.
#!/bin/bash
NUMCPUS=`grep -c processor /proc/cpuinfo`
if [ -z "$1" ] ; then
NUMINSTANCES=2
else
echo $1 | grep "^[0-9]*$" >/dev/null
if [ "$?" -ne 0 ] ; then
echo Argument $1 is not a number. Aborting.
@yalla
yalla / HOST-RESOURCE-MIB-CPUs.pl
Created August 11, 2011 12:00
Generic HOST-RESOURCES-MIB::hrProcessorLoad Cacti script - gives all CPU-load in a single call. Needs data-, data-input-methode- and graph-tepmplates.
#!/usr/bin/perl
use Net::SNMP;
# base_oid ist HOST-RESOURCES-MIB::hrProcessorLoad
my $base_oid = ".1.3.6.1.2.1.25.3.3.1.2";
($session, $error) = Net::SNMP->session(
-hostname => "$ARGV[0]",
-version => "2",
@yalla
yalla / NETWORK-SERVICES-MIB.pl
Created August 11, 2011 14:26
Get connection statistics from NETWORK-SERVICES-MIB for Cacti
#!/usr/bin/perl
use Net::SNMP;
($session, $error) = Net::SNMP->session(
-hostname => "$ARGV[0]",
-version => "2",
-community => "public",
);
@yalla
yalla / gist:1175283
Created August 27, 2011 11:38
Basic memory caching for CGI-scripts in Apache2
# Load modules
LoadModule cache_module modules/mod_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
# Enable caching for only this script
CacheEnable mem /cgi-bin/bla/myscript
# Ignore the user's request for non-cached content
CacheIgnoreCacheControl On
# Ignore the fact that the cgi-script doesn't give the last modified header
CacheIgnoreNoLastMod On
# Cache for 5 seconds
@yalla
yalla / gist:1176565
Created August 28, 2011 11:34
Save and restore iptables rules
#!/bin/bash
case "$1" in
start)
iptables-save > /tmp/firewall-rules.backup
for i in nat filter mangle; do
iptables -t $i -F
done
# TODO: Add your Tor-rules *here*
@yalla
yalla / gist:1185769
Created September 1, 2011 09:13
How Cisco stacking became a pain in the ass (although it should be easy)
I got a bunch of Cisco 3110X switches for IBM Bladecenters.
What happened. I added a new switch to the stack and the firmware was
incompatible:
*Mar 1 00:24:53.960: %STACKMGR-4-SWITCH_ADDED_VM: Switch 3 has been ADDED to the stack (VERSION_MISMATCH)
*Mar 1 00:24:53.952: %STACKMGR-4-SWITCH_ADDED_VM: Switch 3 has been ADDED to the stack (VERSION_MISMATCH) (Switch 2)
However, the auto-copy process failed:
*Mar 1 00:28:53.975: %IMAGEMGR-6-AUTO_COPY_SW_INITIATED: Auto-copy-software process initiated for switch number(s) 3
@yalla
yalla / cacti_graph_template_bmi_hs22_6-core_cpu_gt.xml
Created September 23, 2011 12:52
24-core CPU template for Cacti
<cacti>
<hash_000021aeee4e0ca11a898bbc3d5d2b516e0ed6>
<name>BMI HS22 6-Core CPU GT</name>
<graph>
<t_title></t_title>
<title>|host_description| - CPU Load</title>
<t_image_format_id></t_image_format_id>
<image_format_id>1</image_format_id>
<t_height></t_height>
<height>120</height>
@yalla
yalla / xgetbv_test.c
Created July 20, 2012 21:41
Test variations of xgetbv
#include <stdio.h>
static unsigned long long _xgetbv(unsigned int index){
unsigned int eax, edx;
/* original code
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
*/
/* Nokia code */
@yalla
yalla / gist:3160485
Created July 22, 2012 17:47
gnuradio compile errors during gr-uhd
Scanning dependencies of target _uhd_swig
[ 89%] Building CXX object gr-uhd/swig/CMakeFiles/_uhd_swig.dir/uhd_swigPYTHON_wrap.cxx.o
Linking CXX shared module _uhd_swig.so
Undefined symbols for architecture x86_64:
"uhd::get_version_string()", referenced from:
__wrap_get_version_string in uhd_swigPYTHON_wrap.cxx.o
get_version_string() in uhd_swigPYTHON_wrap.cxx.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [gr-uhd/swig/_uhd_swig.so] Error 1