Skip to content

Instantly share code, notes, and snippets.

View athoune's full-sized avatar

Mathieu Lecarme athoune

View GitHub Profile

Keybase proof

I hereby claim:

  • I am athoune on github.
  • I am athoune (https://keybase.io/athoune) on keybase.
  • I have a public key ASAJyjChoVZ45_odQgM9uacmNqeKRTFAQMhtV7UhoFSdkwo

To claim this, I am signing this object:

@athoune
athoune / ping.py
Created October 10, 2016 12:16
async ping for python 3
#!/usr/bin/env python3
import asyncio
@asyncio.coroutine
def ping(loop, target, dump=False):
create = asyncio.create_subprocess_exec('ping', '-c', '10', target,
stdout=asyncio.subprocess.PIPE)
proc = yield from create
@athoune
athoune / mailq.py
Last active October 17, 2019 20:11
Parsing mailq format (from Postfix 2.x)
#!/usr/bin/env python3
import subprocess
import re
from pypred import Predicate
SPACE = re.compile(r"\s+")
def mailq():
@athoune
athoune / Dockerfile
Last active September 6, 2016 16:01
tmate-slave Dockerfile on Debian Jessie
FROM debian:jessie
ENV DEVTOOLS git-core build-essential pkg-config libtool libevent-dev \
libncurses-dev zlib1g-dev automake cmake ruby libssl-dev
RUN apt-get update && apt-get install --yes --no-install-recommends $DEVTOOLS \
libssl1.0.0 libevent-2.0-5 libncurses5 &&\
rm -rf /var/lib/apt/lists/* &&\
mkdir -p /src &&\
@athoune
athoune / Dockerfile
Created September 5, 2016 16:12
Dockerfile for tmate-slave with Archlinux
FROM base/archlinux
RUN pacman-key --populate archlinux &&\
pacman-key --refresh-keys &&\
pacman-key -r arojas@us.es
RUN pacman -Sy
RUN yes | pacman -Sy libevent libssh libutempter msgpack-c openssl zlib automake cmake ruby autoconf gcc pkg-config make libunistring git
@athoune
athoune / influx.py
Created August 29, 2016 15:21
Parsing influxdb text format with pyparsing
from pyparsing import QuotedString, Word, nums, delimitedList, Optional, \
Regex, Group, Suppress, ParseException
integer = Regex(r"(?P<integer>\d+)i").setParseAction(lambda s, locs, toks:
int(toks[0][:-1]))
real = Regex(r"[+-]?\d+(\.\d+)?")("real").setParseAction(lambda s, locs, toks:
float(toks[0]))
number = Word(nums)
key = Regex(r"[a-zA-Z][a-zA-Z0-9_]*")
import asyncio
import functools
import os
import signal
def ask_signal(signame, exit=False):
print("got signal %s" % signame)
if exit:
loop.stop()
@athoune
athoune / metaping.py
Created June 28, 2016 15:29
Ping all the ping
#!/usr/bin/env python3
import os
import asyncio
import aiohttp
from aiohttp import web
@asyncio.coroutine
def do_ping(session, domain):
package main
import (
"math/rand"
"net/http"
"sync"
"golang.org/x/net/websocket"
)
@athoune
athoune / fastcgi_proxy.go
Created April 22, 2016 12:55
Fastcgi to fastcgi proxy
package main
import (
"fmt"
"github.com/mholt/caddy/middleware/fastcgi"
"net"
"net/http"
"net/http/fcgi"
"os"
)