Skip to content

Instantly share code, notes, and snippets.

@athoune
athoune / ping.py
Created Oct 10, 2016
async ping for python 3
View ping.py
#!/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 Oct 17, 2019
Parsing mailq format (from Postfix 2.x)
View mailq.py
#!/usr/bin/env python3
import subprocess
import re
from pypred import Predicate
SPACE = re.compile(r"\s+")
def mailq():
@athoune
athoune / Dockerfile
Last active Sep 6, 2016
tmate-slave Dockerfile on Debian Jessie
View Dockerfile
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 Sep 5, 2016
Dockerfile for tmate-slave with Archlinux
View Dockerfile
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 Aug 29, 2016
Parsing influxdb text format with pyparsing
View influx.py
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_]*")
View sig.py
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 Jun 28, 2016
Ping all the ping
View metaping.py
#!/usr/bin/env python3
import os
import asyncio
import aiohttp
from aiohttp import web
@asyncio.coroutine
def do_ping(session, domain):
View pubsub.go
package main
import (
"math/rand"
"net/http"
"sync"
"golang.org/x/net/websocket"
)
@athoune
athoune / fastcgi_proxy.go
Created Apr 22, 2016
Fastcgi to fastcgi proxy
View fastcgi_proxy.go
package main
import (
"fmt"
"github.com/mholt/caddy/middleware/fastcgi"
"net"
"net/http"
"net/http/fcgi"
"os"
)
View dns_txt.py
#!/usr/bin/env python2
from __future__ import print_function
from dns import resolver
from StringIO import StringIO
import sys
buff = StringIO()
answers = resolver.query(sys.argv[1], 'TXT')