Skip to content

Instantly share code, notes, and snippets.

View greut's full-sized avatar
:shipit:
setting up that new work laptop

Yoan Blanc greut

:shipit:
setting up that new work laptop
View GitHub Profile
@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.

@greut
greut / deploy.sh
Created March 18, 2017 15:57
Deploying Django application
#!/bin/bash
#
# Usage: ssh <host> ./deploy.sh
#
set -xe
. ~/.bash_profile
cd www/app
. bin/activate
@greut
greut / views.py
Created March 18, 2017 15:46
One view, multiple lists.
from django.views.generic import ListView
from django.contrib.auth.mixins import LoginRequiredMixin
from .models import Game
class GameListView(LoginRequiredMixin, ListView):
template_name = "games.html"
model = Game
ordering = '-id'
@greut
greut / docker-compose.yml
Last active March 6, 2017 10:35
Simple local django setup with Docker.
version: '2'
volumes:
postgres_data:
services:
postgres:
image: postgres:9.6-alpine
environment:
- POSTGRES_USER=django