Skip to content

Instantly share code, notes, and snippets.

@nemunaire
nemunaire / ansible-min.c
Created March 10, 2014 13:37
Minimal Ansible module written in C.
#include<stdio.h>
int main()
{
printf("{ \"changed\": false }");
}
@nemunaire
nemunaire / fix_multipart_pgp.pl
Created March 13, 2014 11:10
This script changes the Content-type header of each part of a multipart message (only for PGP encrypted or signed parts) ; to allow Mutt to decrypt or verify parts automatically.
#!/usr/bin/env perl
use v5.14;
use strict;
use warnings;
use utf8;
use open IO => ':utf8';
use open ':std';
use Encode;
@nemunaire
nemunaire / nagios-status.pl
Last active August 22, 2019 08:49
View in terminal hosts and services states of your domain. This is done by reading a nagios status file.
#!/usr/bin/env perl
#=============================================================================
#
# FILE: status.pl
#
# USAGE: ./status.pl [options]
#
# DESCRIPTION: Give Nagios status about hosts and services
#
# REQUIREMENTS: Perl 5.10.1; Term::ANSIColor
@nemunaire
nemunaire / redshift.conf
Created March 25, 2014 15:05
Redshift configuration for Paris
[redshift]
gamma=0.9
adjustment-method=vidmode
location-provider=manual
[manual]
lat=48.51
lon=2.20
@nemunaire
nemunaire / ratp-trafic.pl
Last active August 29, 2015 14:01
Display traffic information for various RATP reseau: métro, RER and tramway
#!/usr/bin/env perl
#=============================================================================
#
# FILE: ratp-trafic.pl
#
# USAGE: ./ratp-trafic.pl [options] [lines]
#
# DESCRIPTION: Check RATP reseau status
#
# OPTIONS: -raw: Display JSON formated data.
@nemunaire
nemunaire / dmarc-report-display.pl
Last active April 23, 2021 17:23
Parse and display DMARC reports for human review.
#!/usr/bin/env perl
#=============================================================================
#
# FILE: dmarc-report-display.pl
#
# USAGE: ./dmarc-report-display.pl REPORT
#
# DESCRIPTION: Parse and display a DMARC report
#
# REQUIREMENTS: Perl 5.10; File::LibMagic, Term::ANSIColor; XML::LibXML
@nemunaire
nemunaire / tree2ftp.pl
Last active October 12, 2021 20:24
Generate FTP commands to send the content of a directory and subdirectories
#!/usr/bin/env perl
#=============================================================================
#
# FILE: tree2ftp.pl
#
# USAGE: ./tree2ftp.pl [options] host path [path ...]
#
# DESCRIPTION: Send a directory to FTP
#
# OPTIONS: -username: Username
@nemunaire
nemunaire / merge_files.py
Last active April 7, 2021 08:04
An Ansible module to merge files contained in a directory to a single file
#!/usr/bin/python2
import filecmp
import json
import os
import shutil
import tempfile
def main():
@nemunaire
nemunaire / bromem.sh
Created June 22, 2015 23:17
Display memory used by a program, using Linux cgroup
#!/bin/sh
CGROUP_dir=/sys/fs/cgroup/memory
CGROUP_name=${0%.*}
CGROUP_limit=550502400
if [ "$EUID" != "0" ]
then
sudo $0 $@
exit $?
#!/bin/sh
if [ "$1" = "-draft1" ] || [ "$1" = "-draft2" ]
then
shift
alias khash='python -c "import sys; import base64; print(base64.b32encode(sys.stdin.readline().strip().encode()).decode().lower())"'
elif [ "$1" = "-draft3" ]
then
shift
alias khash='sha224sum | cut -d " " -f 1'