Skip to content

Instantly share code, notes, and snippets.

@xcombelle
xcombelle / ep_delete.py
Last active December 11, 2015 21:48
a simple python 3 script to delete a pad in etherpad lite via http api
#!/usr/bin/env python3
import urllib.request,urllib.parse
import argparse
import json
import sys
parser = argparse.ArgumentParser()
parser.add_argument("--apifile", help="Api file",default="APIKEY.txt")
parser.add_argument( "--hostname", help="Host name",default="localhost")
@xcombelle
xcombelle / LICENSE
Last active December 21, 2015 19:59
bot pour wikipédia qui liste les pages recréées
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
import re
import sys
from collections import defaultdict
import unicodedata
def remove_accents(input_str):
nkfd_form = unicodedata.normalize('NFKD', input_str)
return "".join([c for c in nkfd_form if not unicodedata.combining(c)]).replace("œ","oe")
def magic(text):
words = defaultdict(list)
>>> for age,name in itertools.product((21,22,23),("jim","toto")):
... print (age,name, (not (age > 22 or name == "jim")) == (age <=22 and name !="jim"))
...
21 jim True
21 toto True
22 jim True
22 toto True
23 jim True
23 toto True
#Theoretical exercises in patterns to make API changes smoother
from functools import wraps
def deprecated_in_favor_of(new_name):
def wrap(f):
@wraps(f)
def wrapped_f(*args, **kwargs):
if not wrapped_f._called:
print(f.__name__ + ' deprecated in favor of ' + new_name)
@xcombelle
xcombelle / try.el
Created September 9, 2014 08:42
unsuccessful install nimrod-mode
; what I have in /emacs.d/init.el
(require 'package)
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; what I did to install nimrod-mode
; M-x package-install nimrod-mode
@xcombelle
xcombelle / css errors.txt
Created January 27, 2015 19:52
css errors of gokibitz.com under iceweasel 35.0
20:48:01,813 Pseudo-classe ou pseudo-élément « -webkit-inner-spin-button » inconnu. Jeu de règles ignoré suite à un mauvais sélecteur. app.css:126
20:48:01,813 Pseudo-classe ou pseudo-élément « -webkit-search-cancel-button » inconnu. Jeu de règles ignoré suite à un mauvais sélecteur. app.css:135
20:48:01,813 Propriété « -moz-osx-font-smoothing » inconnue. Déclaration abandonnée. app.css:219
20:48:01,815 Couleur attendue, mais « auto » trouvé. Couleur attendue, mais « -webkit-focus-ring-color » trouvé. Une fin de valeur était attendue, mais « -webkit-focus-ring-color » a été trouvé. Erreur d'analyse de la valeur pour « outline ». Déclaration abandonnée. app.css:855
20:48:01,818 Une fin de valeur était attendue, mais « \9 » a été trouvé. Erreur d'analyse de la valeur pour « margin-top ». Déclaration abandonnée. app.css:1862
20:48:01,818 Couleur attendue, mais « auto » trouvé. Couleur attendue, mais « -webkit-focus-ring-color » trouvé. Une fin de valeur était attendue, mais « -webkit-focus-ring-color
@xcombelle
xcombelle / fixup.py
Created April 27, 2015 14:59
fixup for chat.python.
import pprint
d=[
{
"exchange": "B",
"price": {
"id": 1,
"value": "false"
}
},
@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))]
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