Skip to content

Instantly share code, notes, and snippets.

View greut's full-sized avatar
:shipit:
available for hire

Yoan Blanc greut

:shipit:
available for hire
View GitHub Profile
@greut
greut / run.php
Created April 30, 2011 18:18
A web server in pure PHP (non-concurrent and concurrent)
#!/usr/bin/env php
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Hello World!</title>
@greut
greut / Main.java
Created May 29, 2017 07:37
TCP + UDP Java Echo Server.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@greut
greut / accesspoint.md
Last active February 10, 2021 23:32
Laptop Access-Point with monitoring

Access Point

Setup

  • hostapd
  • dnsmasq
  • ntop
  • iptables

NetworkManager

package main
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/hashicorp/go-retryablehttp"
)
type LeveledLogrus struct {
*logrus.Logger
@greut
greut / keybase.md
Created September 22, 2020 09:56
keybase.md

Keybase proof

I hereby claim:

  • I am greut on github.
  • I am yblanc (https://keybase.io/yblanc) on keybase.
  • I have a public key whose fingerprint is A2A7 E23A 88A2 1EA5 561E 581F 068A F996 C3F7 2ADA

To claim this, I am signing this object:

@greut
greut / api.py
Last active June 2, 2020 21:20
Revamped api.py (with test and 100% coverage)
"""
Slack Web API
=============
The `Slack Web API`_ let you communicate with Slack.
Usage:
------
The following example calls the ``api.test`` method which test whether your
Sourdough oatmeal chocolate chip cookies
1/2 cup discard sourdough
1/2 cup softened butter
1 egg
1/2 cup dark brown sugar
@greut
greut / vpn.sh
Created February 20, 2020 11:31
connecting to HE-Arc vpn
#!/bin/bash
USERNAME=yoan.blanc
PASSWORD="..."
GID=100
DIRS="ORG"
PID=openconnect.pid
echo "Welcome to HE-ARC"
echo ""
@greut
greut / bot.py
Last active February 12, 2020 13:47
Sample asyncio bot for Slack
"""Sample Slack ping bot using asyncio and websockets."""
import asyncio
import json
import signal
import aiohttp
from config import DEBUG, TOKEN
import websockets

A Discord Bot with asyncio

Following last year’s article on Slack, here is how to create a bot for Discord. We will go through a minimalist bot that does close to nothing. Most of the provided examples using libraries like discord.py hide asyncio away. Here we will make it explicit how it works under the hood. Be aware that this is not the easiest way to build a bot but a step-stone to understand what complete libraries do for you.