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 / game.py
Last active November 29, 2018 10:47
2048 en Python
#!/usr/bin/env python3
# vim: set ts=4 sts=0 et sw=4 smarttab :
"""2048 game in Python (cli, PyQt 4 or 5)."""
import time
import math
import sys
from random import choice
ROW = 4
@greut
greut / fizzbuzz.py
Last active April 19, 2016 09:01
Yet another fizzbuzz
max = 100
f = (("FizzBuzz", range(15, max+1, 15)), ("Buzz", range(5, max+1, 5)), ("Fizz", range(3, max+1, 3)))
for i in range(1, max+1):
for n, r in f:
if i in r:
i = n
break
print(i)
@greut
greut / social.ipynb
Created April 13, 2016 16:52
Social network
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@greut
greut / tictactoe.ipynb
Last active April 20, 2016 07:30
Tic Tac Toe
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@greut
greut / Dockerfile
Created April 8, 2016 08:35
Simple flask container.
FROM buildpack-deps:jessie
EXPOSE 8080 5000
ENV LANG C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get upgrade -q -y && \
apt-get install -q -y \
@greut
greut / enfants.ipynb
Created April 6, 2016 12:41
Premature optimization is the root of all evil.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@greut
greut / fizzbuzz.py
Last active March 30, 2016 14:54
Coroutine python fizzbuzz
"""FizzBuzz.
Write a program that prints the numbers from 1 to 100.
But for multiples of three print “Fizz” instead of the number and
for the multiples of five print “Buzz”.
For numbers which are multiples of both three and five print “FizzBuzz”.
-- http://c2.com/cgi/wiki?FizzBuzzTest
"""
def fizzy(number, text, destination):
"""
Game of Life according to Jack Diedrich.
From the PyCon presentation: Stop Writing Classes.
"""
import os
import time
from itertools import chain
@greut
greut / connect.sh
Created February 18, 2016 10:42
Script de connexion/déconnexion au répertoire perso du CPLN
#!/bin/bash
[ "root" != "$USER" ] && exec sudo $0 "$@"
read -p "Nom d'utilisateur CPLN: " username
uid=$(id -u $SUDO_USER)
gid=$(id -g $SUDO_USER)
sudo mount -t cifs \
//s2.rpn.ch/home/CPLN/Eleves/ET/$username /home/$SUDO_USER/Bureau/CPLN \
-o username=$username,domain=s2,uid=$uid,gid=$gid
@greut
greut / slackbot.py
Last active February 11, 2016 12:53
AsyncIO based bot for Slack
# -*- encoding: utf-8 -*-
import json
import asyncio
import requests
import websockets
TOKEN="xoxb-..."