Skip to content

Instantly share code, notes, and snippets.

Avatar

Julien Vehent jvehent

View GitHub Profile
@jvehent
jvehent / crazyperl.pl
Created Sep 18, 2011
99 bottles of beer
View crazyperl.pl
''=~( '(?{' .('`' |'%') .('[' ^'-')
.('`' |'!') .('`' |',') .'"'. '\\$'
.'==' .('[' ^'+') .('`' |'/') .('['
^'+') .'||' .(';' &'=') .(';' &'=')
.';-' .'-'. '\\$' .'=;' .('[' ^'(')
.('[' ^'.') .('`' |'"') .('!' ^'+')
.'_\\{' .'(\\$' .';=('. '\\$=|' ."\|".( '`'^'.'
).(('`')| '/').').' .'\\"'.+( '{'^'['). ('`'|'"') .('`'|'/'
).('['^'/') .('['^'/'). ('`'|',').( '`'|('%')). '\\".\\"'.( '['^('(')).
'\\"'.('['^ '#').'!!--' .'\\$=.\\"' .('{'^'['). ('`'|'/').( '`'|"\&").(
View gist:1226541
# default foreground color (%N) - -1 is the "default terminal color"
default_color = "-1";
# print timestamp/servertag at the end of line, not at beginning
info_eol = "false";
# these characters are automatically replaced with specified color
# (dark grey by default)
replaces = { "[]=" = "%K$*%n"; };
@jvehent
jvehent / htb_collect.pl
Created Nov 2, 2011
rrds::create with unknown list of datasources
View htb_collect.pl
# define a list of HTB classes to check
# the order matters, because of the RRD database
my @class_list=(100,200,300,400,999);
[..... truncated .... ]
my $datasources = "";
for my $class (0 .. $#class_list){
$datasources .= "DS:$class_list[$class]:$storage_type:". $updatefreq * 10 .":0:U";
View gist:1334562
# SSH class: for outgoing connections to
# avoid lag when somebody else is downloading
# however, an SSH connection cannot fill up
# the connection to more than 70%
echo "#---ssh - id 300 - rate 160 kbit ceil 1120 kbit"
/sbin/tc class add dev eth0 parent 1:1 classid 1:300 htb \
rate 160kbit ceil 1120kbit burst 15k prio 3
# SFQ will mix the packets if there are several
View gist:1629798
#!/usr/bin/env bash
DEBUG="$1"
SRV="smtp.example.net smtp2.example.net smtp.example.com"
# RBL list from http://www.anti-abuse.org/multi-rbl-check/
RBL="bl.spamcop.net cbl.abuseat.org b.barracudacentral.org dnsbl.invaluement.com ddnsbl.internetdefensesystems.com dnsbl.sorbs.net http.dnsbl.sorbs.net dul.dnsbl.sorbs.net misc.dnsbl.sorbs.net smtp.dnsbl.sorbs.net socks.dnsbl.sorbs.net spam.dnsbl.sorbs.net web.dnsbl.sorbs.net zombie.dnsbl.sorbs.net dnsbl-1.uceprotect.net dnsbl-2.uceprotect.net dnsbl-3.uceprotect.net pbl.spamhaus.org sbl.spamhaus.org xbl.spamhaus.org zen.spamhaus.org bl.spamcannibal.org psbl.surriel.com ubl.unsubscore.com dnsbl.njabl.org combined.njabl.org rbl.spamlab.com dnsbl.ahbl.org ircbl.ahbl.org dyna.spamrats.com noptr.spamrats.com spam.spamrats.com cbl.anti-spam.org.cn cdl.anti-spam.org.cn dnsbl.inps.de drone.abuse.ch httpbl.abuse.ch dul.ru korea.services.net short.rbl.jp virus.rbl.jp spamrbl.imp.ch wormrbl.imp.ch virbl.bit.nl rbl.suresupport.com dsn.rfc-ignorant.org ips.backscatterer.org sp
@jvehent
jvehent / zipfile.py
Created Feb 29, 2012
python zip error
View zipfile.py
# iterate through the list on messages
for number in message_number[0].split():
# fetch the current message
typ, data = connection.fetch(number, '(RFC822)')
# parse the email
message = email.message_from_string(data[0][1])
# for each attachment
View gist:2377962
$ grep 'include_recipe "nginx' cookbooks/ -R
cookbooks/python-webserver/recipes/default.rb:include_recipe "nginx"
chef > result = search(:node, "recipes:python-webserver").map {|n| n.fqdn}
=> ["pythonwebserver1.local.vm"]
chef > result = search(:node, "recipes:nginx").map {|n| n.fqdn}
=> []
@jvehent
jvehent / gist:2406497
Created Apr 17, 2012
password manager with openssl
View gist:2406497
# To create a new credential file, use:
echo "credential file created on $(date +%Y%m%d)" |openssl aes-256-ecb -e -a -salt -out credential_file.encrypted
# =======================================
#!/usr/bin/env bash
# --- getpassword.sh
# opens the credential file and display it in the terminal
View gist:2490674
:/lib/udev/devices# tree -alfpugh
.
├── [crw------- root root 0] ./console
├── [lrwxrwxrwx root root 11] ./core -> /proc/kcore
├── [lrwxrwxrwx root root 13] ./fd -> /proc/self/fd
│   ├── [lrwx------ root root 64] /proc/self/fd/0 -> /dev/pts/0
│   ├── [lrwx------ root root 64] /proc/self/fd/1 -> /dev/pts/0
│   ├── [lrwx------ root root 64] /proc/self/fd/2 -> /dev/pts/0
│   └── [lr-x------ root root 64] /proc/self/fd/3 -> /proc/3611/fd [recursive, not followed]
├── [brw------- root root 0] ./loop0
@jvehent
jvehent / conntrack_parse_webforms.py
Created Jun 9, 2012
conntrack_parse_webforms.py
View conntrack_parse_webforms.py
#!/usr/bin/env python
from collections import defaultdict
import sys
import datetime
counters = defaultdict(int)
entries = 0
show_progress = 0
print