Skip to content

Instantly share code, notes, and snippets.

@xcombelle
xcombelle / fen_parser.rs
Created July 1, 2017 17:27
a fen parser in rust
use std::env;
#[derive(Debug,Copy,Clone,Eq,PartialEq)]
enum PieceKind {
Empty,
Pawn,
King,
Queen,
Knight,
Bishop,
@xcombelle
xcombelle / bootstrap.tcl
Last active September 9, 2016 20:34
bootstrapping egg-drop
# the idea of the bootstrap proc is that it delegate
# the creation of the dialog between tcl and python
# to the python script so all the protocol always match
# between tcl and python
proc bootstrap {scriptname args} {
set fifo_name /tmp/eggdrop-bootstrap-fifo
set interpreter python3
exec mkfifo $fifo_name
try {
#!/usr/bin/env python3
#################
# Configuration #
#################
# TODO: à migrer dans un fichier de config ?
# Clé privée principale, utilisée pour générer la CSR
private_master_key="/etc/ssl/private/slaanesh.org.key"
@xcombelle
xcombelle / test1.py
Last active May 26, 2016 13:35
alternative syntaxes for sqltemplate.py
def query_users(users,query,registred):
q = SqlQueryBuffer()
q"SELECT name, email FROM"
if users == True:
q"users"
else:
q"admin"
q"WHERE"
q(OR(
AND("name LIKE {query} OR registred={registred}",
@xcombelle
xcombelle / count_3.py
Last active November 13, 2015 20:53
count 3
import random
a1,a0=0,0
question = random.randint(0,2**32)
collection = [question]*2
for i in range(999999):
collection += [random.randint(0,2**32)]*3
random.shuffle(collection)
for x in collection:
@xcombelle
xcombelle / sed-like.py
Created August 31, 2015 16:55
sed like replace in python
import fileinput
for line in fileinput.input(files=["test.txt"],inplace=True):
print(line.replace("toto","toto tutu"),end="")
from __future__ import print_function #useless in python3
import os, time, shutil
import os.path
from glob import glob
import datetime
###Loging###
def logging(message):
@xcombelle
xcombelle / imap_stream.diff
Created June 24, 2015 16:42
imap_stream_diff
diff --git a/imap_stream.py b/imap_stream.py
index f96ea9d..b009bba 100644
--- a/imap_stream.py
+++ b/imap_stream.py
@@ -8,7 +8,7 @@ import ssl
import logging
import functools
-import pyparsing
+#import pyparsing
import random
def f():
total_damage = 0
attack_score = 0
defence_score = 0
enemy_list = list(range(10))
power = 5
unit_size = 2000
enemy_defence = 5
enemy_unit_size = 2000
@xcombelle
xcombelle / sbc
Created May 22, 2015 13:34
super bit count
setup = """
def bitcount (n):
c = 0
while n > 0:
n, r = divmod(n, 2)
c += r
return c
def fact(size):
bc = [bitcount(i) for i in range(2**(size))]