Skip to content

Instantly share code, notes, and snippets.

View iMilnb's full-sized avatar

iMil iMilnb

View GitHub Profile
use Storable qw(retrieve);
use JSON;
my $h;
my $json;
my @jarr;
@files = <$ARGV[0]>;
foreach $file (@files) {
$h = retrieve($file);
@iMilnb
iMilnb / grub_default_kernel
Last active August 29, 2015 14:24
Change the default boot kernel with `grub` 2.0.2beta
mykern=3.14.43-foo-bar-0.1-baz
dpkg -i linux-image-${mykern}_amd64.deb
sed -i 's/^GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/' /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
UUID=`blkid -s UUID -o value /dev/xvda1`
grub-set-default "gnulinux-advanced-$UUID>gnulinux-$mykern-advanced-$UUID"
@iMilnb
iMilnb / gist:5787416
Created June 15, 2013 08:37
state file for Zend Server 6 deployment via SaltStack
### setup Zend Server
{% if 'php_version' in grains %}
{% set php_version = grains['php_version'] %}
{% else %}
# pillars are set in our common/pillar
{% set php_version = pillar['zs6_php'] %}
{% endif %}
{% set zs_user = pillar['zs6_user'] %}
{% set zs_serial = pillar['zs6_serial'] %}
@iMilnb
iMilnb / file_return.py
Created June 17, 2013 13:13
A simple SaltStack returner that prints state summary in a human-readable flat file
'''
Return human readable salt data to a flat file
'''
# Import python libs
import yaml
def __virtual__():
return 'file'
@iMilnb
iMilnb / yaml_smtp_return.py
Created June 17, 2013 16:52
Human-readable smtp returner for Salt
'''
Return yaml-formatted salt data via email
The following fields can be set in the minion conf file:
smtp.from (required)
smtp.to (required)
smtp.host (required)
smtp.username (optional)
smtp.password (optional)
@iMilnb
iMilnb / gist:6274243
Created August 19, 2013 21:10
Update OpenVPN remotes for vpntunnel endpoints with IP addresses instead of FQDN as resolving fails from time to time
#!/bin/sh
[ $# -lt 1 ] && exit 1
tunnel="jenny.vpntunnel.se"
ovpntmp="/tmp/openvpn.conf-tmp"
ovpncnf=$1
host -t a ${tunnel} >/dev/null 2>&1 || exit 1
@iMilnb
iMilnb / gist:8146933
Created December 27, 2013 13:30
configuration nginx pour réecrire les requètes de la neufbox vers l'infra neuf
server {
listen 89; # le traffic de la neufbox est capturé puis renvoyé vers le port 89 via pf
server_name foobar *.neufbox.neuf.fr;
access_log /var/log/nginx/neufbox.access.log;
error_log /var/log/nginx/neufbox.error.log;
resolver 127.0.0.1;
location / {
@iMilnb
iMilnb / gist:8389380
Created January 12, 2014 19:38
Oneliner to generate dvblast configuration files from `channels.conf'
i=1 && for f in `cut -f2 -d: channels.conf |sort -u`; do cf=etc/dvblast$((i++)).conf; echo "; dvblast -f $f -c $cf" > $cf; awk -F: -v f=$f -v b=$i 'BEGIN {p = 0} $0 ~ f {printf "; %s\n224.0.0.%s:123%d 1 %s %s,%s\n",$1,b,++p,$13,$11,$12}' channels.conf >> $cf ;done
@iMilnb
iMilnb / subspam.py
Created August 28, 2015 00:01
Automatic SpamCop report validation with python mechanize
import mechanize
br = mechanize.Browser()
br.set_handle_robots(False)
br.open("http://www.spamcop.net/")
br.select_form(nr=0)
br.form['username']='your@spamcop.registered.email'
br.form['password']='yourSpamCopPassword'
@iMilnb
iMilnb / sysctl.conf
Last active October 1, 2016 14:45
sysctl kernel parameters for full gigabit throughput on NetBSD
# documentation
# https://calomel.org/freebsd_network_tuning.html
# https://mail-index.netbsd.org/tech-net/2015/08/03/msg005317.html
# http://proj.sunet.se/E2E/tcptune.html
#
# Warning: this is aimed at a **client** setup, a server with
# many connexions could exhaust its memory with values this high
#
kern.sbmax=16777216
net.inet.tcp.recvbuf_auto=1