View .pythonrc.py
""" | |
Startup script for Python interactive mode | |
Add these two lines to .bashrc: | |
PYTHONSTARTUP="$HOME/.pythonrc.py" | |
export PYTHONSTARTUP | |
""" | |
import sys, os, readline, atexit |
View eight_queens_solver.py
#!/usr/bin/env python | |
class EightQueens: | |
def __init__(self): | |
self.array = 64 * [-1] | |
def get(self, x, y): | |
return self.array[x + y * 8] |
View .gitignore
*.pyc |
View data.xml
<doc> | |
<person no="1234"> | |
<name>Tomáš</name> | |
<surname>Těžký</surname> | |
</person> | |
<person no="7"> | |
<name>Standa</name> | |
<surname>Blábol</surname> | |
</person> | |
</doc> |
View rtail.py
#!/usr/bin/env python | |
""" | |
Usage: | |
./rtail.py user@host:path/foo.log bar.log host2:/path/baz.log | |
""" | |
import optparse | |
import os |
View lepl-example.py
#!/usr/bin/env python2.6 | |
from lepl import * | |
retezec = String() | String("'") | |
cislo = Digit()[1:] > (lambda chars: int("".join(chars))) | |
slovnik = Delayed() | |
klicSlovniku = retezec | cislo | |
hodnotaSlovniku = retezec | cislo | slovnik |
View Makefile
all: a b | |
echo a | |
time ./a | |
time ./a | |
echo b | |
time ./b | |
time ./b | |
a: a.cc | |
g++ -O2 -o a a.cc |
View simpleeditor.py
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Až moc jednoduchý textový editor. | |
Vlevo je seznam úryvků, dvojklikem na nějaký se úryvek vloží do textu. | |
""" | |
import pygtk | |
pygtk.require("2.0") |
View qtexample.py
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import time | |
from PyQt4 import QtGui, QtCore | |
app = QtGui.QApplication(sys.argv) | |
widget = QtGui.QWidget() |
OlderNewer