mecker. mecker. mecker.

Linkschleuder #8

Linkschleuder #7

sqlite dump mit python

Shell:

sqlite3 my.db
>> SELECT * FROM sqlite_master;

python:

import sqlite3, os

con = sqlite3.connect("my.db")
with open("dump.sql", "w") as f:
    for line in con.iterdump():
        f.write("%s\n" % line)

via stack­over­flow. Denn ich stehe auf Kriegsfuß mit dieser dämlichen SQL-Logik. CouchDB und MongoDB ftw.

Linkschleuder #6

parsing human-readable timedeltas in python

Just a simple, fail-safe in­ter­pre­ta­ti­on of time deltas using crontab-like syntax using python’s horrible regular expression syntax.

import re
from datetime import timedelta

def tdelta(input):

    keys = ["weeks", "days", "hours", "minutes"]
    regex = "".join(["((?P<%s>\d+)%s ?)?" % (k, k[0]) for k in keys])
    kwargs = {}
    for k,v in re.match(regex, input).groupdict(default="0").items():
        kwargs[k] = int(v)
    return timedelta(**kwargs)

>>> print tdelta("3w")
21 days, 0:00:00
>>> print tdelta("3w 12h 57m")
21 days, 12:57:00

walk-through

datetime‘s timedelta object provides a fairly simple interface to add, substract and compare datetime-objects in python. In my example, wei­ter­le­sen.

Regenwolken – hosting CloudApp on your own server

Freedombox Logo by El Bazza

CoudApp allows you to share any kind of data with your friends using Amazon S3 as backend. It provides a verbose API and has several working clients for iPhone, iPad and Android as well. Cloud.app is a really handy, extendable Mac-client leaving nothing to be desired. CloudApp offers a Pro mode, allowing you to share data up to 250 Mb and unlimited uploads as well as links to your domain. For free you’ll get 10 uploads per day and a filesize limit of 25 MiB.

I had some leisure time and found out, CloudApp’s services is similar to Facebooks privacy options. Their security/privacy (marked as “private”) relies simply on weit­er­lesen.

RSDF/DLC/CCF Decryption

tl;dr decrypt! RSDF, DLC und CCF online. In bunt und in Farbe!1 Nur so lange der Vorrat die API reicht. Ent­wick­lung auf GitHub: posativ/opendlc.


Ich bin es leid. Es gibt Software dafür, eine be­hin­der­ter als die andere. Von ganz schwer bis fast: jDown­loa­der, Cryptload, Ci­nuxLoa­der, RSD/MSD und pyLoad. Alles ominöse Tools, um der Content-Mafia eins aus­zu­wi­schen und dabei selbst etwas Geld zu verdienen – mit Hehlerware. Irgendwie sehr verlogen, diese „Szene”.

Stand der Dinge: Wir haben drei Container-Formate, namentlich: RSDF, CCF und DLC, eingeführt von respektive: RapidShare Downloader (RSD), Cryptload und JDown­loa­der. Diese Container verstecken ver­schlüs­seln die URLs zu den Hostern wie RapidShare, uploaded.to, Netload und so weiter, damit die gemeinen 14-jährigen wei­ter­le­sen.

Linkschleuder #4

Heute mal durch und durch Python, zudem noch ein Jahr alt und eigentlich über­flüs­sig

Ach, und re­Struc­tu­red­Text hab ich auch noch!1

Und Sonstige! Alles muss raus!

Weitere HTML Abstraktion in Python

pamela

Ich räume gerade meine Notizen auf und nun kommt alles mal zusammen. Es gibt als mäch­ti­ge­re Sprache (zu Kosten von Ein­fach­heit natürlich) Pamela. Hat was vom erwähnten SHPAML, nur nicht ganz so hübsch. Eigentlich sogar hässlich, schon fast eine Art Semi-HTML.

<html
    <head
        <title:My first Pamela document
    <body
        <h1:Lorem ipsum
     <p
        Lorem <b:ipsum dolor sit amet>, consectetuer adipiscing elit. Sed
        feugiat, dui eu 
wei­ter­le­sen.

SHPAML – XML-Preprocessor

SHPAML ist ein verdammt schneller und einfacher HTML/XML-Prepro­ces­sor. Die Syntax lehnt sich an Haml an und er­mög­licht ein einfaches Pro­gram­mie­ren einer Website. Für SHPAML gibt es kein Syntax-High­light­ing (obwohl das Python-High­light­ing imho ausreicht) was auch nicht nötig ist, da die Syntax auf einfachen Key-Symbolen und Ein­rü­ckung basiert.

Python

>>> from shpaml import convert_text
>>> print convert_text("b | foo")
>>> '<b>foo</b>

Diese Markup-Sprache nutze ich mitt­ler­wei­le in diversen Projekten, allen voran lilith und pastebin. Als offenes Beispiel gebe ich mal die \<entry>-Spe­zi­fi­ka­ti­on eines Atom-Feeds an. Das Beispiel benötigt pro Durchlauf gerade einmal 243.54 µsec, also nicht mal eine Mil­li­se­kun­de, sodass man SHPAML einfach überall nutzen muss.

entry
    
wei­ter­le­sen.

Linkschleuder #3

Lang ist die letzte Linkschleu­der her. Aber ich hab nebenbei noch etwas gesammelt:

Summarizing (X)HTML in Python

Hey, my first post in english. It’s for search engine op­ti­miza­t­i­on only :P

I currently use this snippet generator for my post previews. In some situation it behaves wrong (pre­ser­ver­ing whitespace in pre-tags, to be precisely) and it is really hard to maintain. See the source code.

This is my first time using the HTMLParser of the python standard library. It was really straight-forwarded to solve this without any side effects! Currently, it is slower than the ac­tive­sta­te-solution, which is about two times faster. Sum­ma­ri­zing Wiki-Software: MindTouch Deki with about 39 lines and 3483 characters takes about 20ms versus 40ms.

I have no plans to update this code listing, wei­ter­le­sen.

ältere Beiträge → ← neuere Beiträge