Skip to content

Instantly share code, notes, and snippets.

View Lysander's full-sized avatar

Christian Hausknecht Lysander

  • format-h
  • Hamburg, Germany
View GitHub Profile
@Lysander
Lysander / emitter.py
Created May 12, 2012 13:36
Extension for smas Adventure Tutorial
#!/usr/bin/env python
class Emitter:
column = 0
def __call__(self, s, width=80):
for word in str(s).split():
if word == "<p>":
self.column = 0
@Lysander
Lysander / md_to_moinmoin.rb
Created May 13, 2012 16:12
Small Converter to generate markdown for MoinMoin from github's markdown dialect using Redcarpet.
#!/usr/bin/env ruby
require 'redcarpet'
class MoinMoin < Redcarpet::Render::Base
def header(text, level)
prefix = "=" * level
"\n\n#{prefix} #{text} #{prefix}\n"
#!/usr/bin/env python
ITEMS = {
'Werkzeug': 20,
'Öl': 4,
'Holzbalken': 6,
'Korb': 3,
'Stoff': 8,
'Kreide': 1,
'Seil': 4,
@Lysander
Lysander / Example
Created May 21, 2012 12:24
Searches fpr rhymes in a given Text via sys.stdin. A rhyme is defined by the last three chars of a word.
./rhyme.py < abendsonne_goethe.txt
ach : nach, Silberbach
ten : erstaunten, Buchten, erwärmten, Hütten, Schluchten
ebt : hebt, überlebt, strebt, schwebt
ter : hinter, unter
tet : Betrachtet, ausgebreitet
lle : stille, alle
nen : seinen, meinen, grünumgebenen
ich : endlich, Kranich, sich, mich
auf : Lauf, hinauf, auf
#!/usr/bin/env python
from itertools import groupby
TEXT = """
/path/to/bla/bla1
used in 3 files:
/path/to/other/file1
/path/to/other/file2
<html>
<body>
<!-- >>> creole2html(data["query"]["pages"]["13116"]["revisions"][0]["*"]) -->
<p><img src="Siehe auch" title="[[Abandon]]" alt="[[Abandon]]" /></p>\n<h2>abandon ({{Sprache|Englisch}})</h2>\n<h3>{{Wortart|Verb|Englisch}}</h3>\n<p><img src="erweitern" title="Beispiel|Englisch" alt="Beispiel|Englisch" /></p>\n\n<p>{{Englisch Verb \xdcbersicht</p>\n<table>\n<tr>\n\t<td>present_I=abandon</td>\n</tr>\n<tr>\n\t<td>present_he, she, it=abandons</td>\n</tr>\n<tr>\n\t<td>past_simple_I=abandoned</td>\n</tr>\n<tr>\n\t<td>present participle=abandoning</td>\n</tr>\n<tr>\n\t<td>past participle=abandoned</td>\n</tr>\n<tr>\n\t<td>Weitere_Konjugationen=abandon (Konjugation)</td>\n</tr>\n</table>\n<p>}}</p>\n\n<p><img src="Worttrennung" title="Worttrennung" alt="Worttrennung" /><br />\n:a\xb7ban\xb7don oder aban\xb7don</p>\n\n<p><img src="Aussprache" title="Aussprache" alt="Aussprache" /><br />\n:<img src="IPA" title="IPA" alt="IPA" /> <img src="Lautschrift" title="\u0259\u02c8b\xe6nd\u0259n" alt="\u0259\u02c8b\xe
@Lysander
Lysander / results.json
Created June 22, 2012 18:32
Sport results
{
"football": [
{
"event": "EURO 2012",
"results": [
{
"home": "Tschechien",
"away": "Portugal",
"score": "0 - 1"
}
#!/usr/bin/env python
#
# Copyright (C) 2012 Christian Hausknecht <>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@Lysander
Lysander / smile4pycon.py
Created June 29, 2012 13:18
Little fun script, that prints out an happy or unhappy smiley based upton the "+-/1" messages in the "I am goging to pycon"-Thread: http://www.python-forum.de/viewtopic.php?f=5&t=29566
#!/usr/bin/env python
import re
from collections import defaultdict
import requests
from lxml import html
URL = r"http://www.python-forum.de/viewtopic.php?f=5&t=29566"
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2 in line 1.
ISBN;Verlag;Titel;Stand;Preis;Bestand
978-3768825825;Delius Klasing;MV – Bornholm;2009-01;54,90;2
978-3768832021;Delius Klasing;MV – Bornholm;2011-03;54,90;13
978-3892255598;Edition Maritim;Rund Rügen;2008-03;29,90;15
978-3892252368;Delius Klasing;Küstenhandbuch MV;2006-03;29,90;3
978-3980672016;Quick Maritim Medien;Törnplaner/-atlas Peene, Oder, Bodden;2006-04;25,00;5
978-3768831017;Delius Klasing;Kieler Bucht und Rund Fünen (2010);2010-03;69,90;17