Skip to content

Instantly share code, notes, and snippets.

@fser
fser / update_song_display
Created November 7, 2012 15:01
update awesome widget with mpc current song
#!/usr/bin/env perl
# François Serman <[email protected]>
# 07 nov 2012
# Initial version: updates awesome widget perdiodicaly, or when killed
# via SIGUSR1
#
# Awesome setup:
# mpdbox = widget({ type = "textbox", name = "mpdbox" })
# ...
@fser
fser / treeperl.pl
Created November 28, 2012 17:41
Displays directory tree easy way with only printable characters (unlike gnu tree)
#!/usr/bin/perl
# François Serman <[email protected]>
# 07 nov 2012
#
# Displays a treeview of a directory, very simply.
# If no parameters is given, takes PWD as base.
use strict;
our $prefix = shift || $ENV{PWD};
@fser
fser / bench.c
Created February 14, 2013 14:03
How much does a simple syscall (such as `getpid`) cost in CPU cycle?
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
uint64_t rdtsc();
#ifdef __i386
__inline__ uint64_t rdtsc() {
uint64_t x;
__asm__ volatile ("rdtsc" : "=A" (x));
#ifdef __gnu_linux__
#define SPORT source
#define DPORT dest
#else
#define SPORT th_sport
#define DPORT th_dport
#endif
// ...
#!/bin/bash
openssl aes-256-cbc -d -a -in $1 -out $1.clear
echo "clear file is in $1.clear"
@fser
fser / extract
Last active August 29, 2015 14:00
can be used to extract ogg from https://github.com/usrbinnc/netcat-cpi-kernel-module's headers files
#!/usr/bin/env python
from binascii import unhexlify
import sys
l = len(sys.argv) - 1
inf = ''
outf = ''
if l == 0:
@fser
fser / db.php
Created July 7, 2014 17:34
asynchronous tests using php
<?php
$dbh = NULL;
try {
$dbh = new PDO("sqlite:/tmp/panel.db");
}
catch(PDOException $e)
{
die ($e->getMessage());
@fser
fser / a.c
Created September 14, 2014 22:19
Compile using gcc -c {a,b}.c; gcc -o sample {a,b}.o. This program crashes, can you guess why?
char toto[] = "hello world";
@fser
fser / pushover.pl
Created January 3, 2015 16:32
Inspired from hilight.pl for IRSSI, should strip it though.
# Print hilighted messages & private messages to window named "hilight"
# for irssi 0.7.99 by Timo Sirainen
use Irssi;
use URI;
use LWP;
use vars qw($VERSION %IRSSI);
$VERSION = "0.01";
$last_notif = 0;
@fser
fser / wpa_supplicant_lille1
Created January 16, 2015 10:30
WPA Supplicant configuration file for Lille1 WPA entreprise protected wifi
network={
ssid="LILLE1"
key_mgmt=WPA-EAP
eap=PEAP
identity="firstname.lastname"
password="YourAwesomePassword"
phase2="auth=MSCHAPV2"
}