Skip to content

Instantly share code, notes, and snippets.

View vincentbernat's full-sized avatar

Vincent Bernat vincentbernat

View GitHub Profile
# To be run with "python -m unittest -v socketpair"
import socket
import os
import select
import unittest
class TestUnixSocket(unittest.TestCase):
def check_socket(self, socktype):
@vincentbernat
vincentbernat / index.html
Created February 18, 2015 12:29
Angular directive to prevent/allow scrolling.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<!-- ... -->
</head>
<body ped-scrolling="forbid">
<!-- ... -->
@vincentbernat
vincentbernat / gist:993189afbd0a6e7ddfba
Created January 8, 2015 09:51
Logstash 1.1.1 -> Logstash 1.4.2 - ES migration
input {
elasticsearch {
host => "..."
codec => "oldlogstashjson"
query => "NOT _exists_:@version"
}
}
@vincentbernat
vincentbernat / gist:45c00b740a5189a6d87c
Created December 16, 2014 12:32
IAM S3 policy example
{
"Statement": [
{
"Action": [
"s3:DeleteObject",
"s3:PutObject",
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [ "arn:aws:s3:::bucketname/*", "arn:aws:s3:::bucketname" ],
#!/usr/bin/env python
"""
SNMP helper for HAproxy implementing EXCELIANCE-MIB with
`pass_persist` protocol. Data are retrieved from multiple instances of
haproxy using HTTP.
"""
def toOid(oid):
"""Convert a string to tuple OID"""
#!/bin/zsh
include=()
exclude=()
for exc in $(grep '^ignore = Name ' ~/.unison/home.prf | awk '{print $NF}'); do
exclude=($exclude --exclude='**'/$exc)
done
for exc in $(grep '^ignore = Path ' ~/.unison/home.prf | awk '{print $NF}'); do
exclude=($exclude --exclude=$HOME/$exc)
done
[Unit]
Description = dhclient on %I
Wants = network.target
Before = network.target
BindsTo = sys-subsystem-net-devices-%i.device
After = sys-subsystem-net-devices-%i.device
[Service]
Type = forking
PIDFile = /run/dhclient-%I.pid
[Unit]
Description = XBMC Media Center
After = remote-fs.target
After = syslog.target
[Service]
User = xbmc
Group = xbmc
Type = simple
Restart = always
@vincentbernat
vincentbernat / .mbsyncrc.txt
Created June 8, 2014 20:34
mbsync configuration
# -*- conf -*-
FSync no
#
# Luffy
#
IMAPStore remote-luffy
Host imap.luffy.cx
@vincentbernat
vincentbernat / iptables-ns.sh
Created April 28, 2014 10:19
Use of Linux network namespace to test and commit a firewall
#!/bin/zsh
# Use a dedicated network namespace to build and test firewall rules
# before applying them.
set -e
zparseopts -D n=dryrun -dry-run=dryrun t=trace -trace=trace f=iptables
[[ -n $trace ]] && setopt xtrace
[[ -z $iptables ]] && {