Skip to content

Instantly share code, notes, and snippets.

View greut's full-sized avatar
:shipit:
moving slowly and breaking things

Yoan Blanc greut

:shipit:
moving slowly and breaking things
View GitHub Profile
@greut
greut / clic-et-tax.txt
Created April 3, 2018 20:44
l'enfer des déclarations
bcmail-jdk15on-1.55.jar
bcpkix-jdk15on-1.55.jar
bcprov-jdk15on-1.55.jar
commons-beanutils-1.8.0.jar
commons-codec-1.10.jar
commons-collections-3.2.2.jar
commons-csv-1.3.jar
commons-digester-1.7.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
import subprocess
with open("foo.py.gz", "wb") as f:
q = subprocess.Popen(["gzip"], stdout=f, stdin=subprocess.PIPE)
p = subprocess.Popen(["more", "foo.py"], stdout=q.stdin)
q.communicate()
p.wait()
package main
import (
"context"
"fmt"
"net/http"
"time"
)
func test(a, b, c int) {
@greut
greut / meta.lua
Created November 13, 2017 13:24
advanced pandoc2
-- read metadata file into string
local metafile = io.open('metadata.yaml', 'r')
local content = metafile:read("*a")
metafile:close()
-- new elements
local before = pandoc.RawInline('tex', '\\begin{otherlanguage}{english}')
local after = pandoc.RawInline('tex', '\\end{otherlanguage}')
@greut
greut / code-block-in-english.py
Last active November 7, 2017 14:06
pandoc filter for the french
#!/usr/bin/env python3
"""
Convert the CodeBlock into english text. Very useful if the base language adds
some special magic rules which are altering the context. E.g. french puts a
space before the colon (:).
::
$ pandoc \
--filter ./code-block-in-english.py \
...
@greut
greut / test.go
Created June 12, 2017 21:44
Testing parallel processing.
package main
import (
"fmt"
"gopkg.in/h2non/bimg.v1"
"os"
"runtime"
"strconv"
"sync"
)
@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 / commandes.txt
Last active May 18, 2017 14:49
API REST avec Hug
$ hug -f light.py
/#######################################################################\
`.----``..-------..``.----.
:/:::::--:---------:--::::://.
.+::::----##/-/oo+:-##----:::://
`//::-------/oosoo-------::://. ## ## ## ## #####
.-:------./++o/o-.------::-` ``` ## ## ## ## ##
`----.-./+o+:..----. `.:///. ######## ## ## ##
``` `----.-::::::------ `.-:::://. ## ## ## ## ## ####
://::--.``` -:``...-----...` `:--::::::-.` ## ## ## ## ## ##
package ch.hearc.airport;
import java.util.HashMap;
import java.util.concurrent.ArrayBlockingQueue;
public class Main {
static String[] codePlane = { "3B147", "B3291", "6B239", "B1086", "780B4",
"32A64", "17A69", "2A431", "647B8", "349A8", "536B8", "9103A",
"9B210", "139A4", "96B01", "207B9", "830B6", "8435A", "7301B",

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.