piotrlegnica / stuff
Various stuff and utilities.
Clone this repository (size: 50.9 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/piotrlegnica/stuff/
| commit 14: | 5c0fd3e2d281 |
| parent 13: | 69b9bc502315 |
| branch: | default |
| tags: | tip |
Spelling and other fun useless stuff. Refactored writeColour a bit.
stuff /
README.rst
| r14:5c0fd3e2d281 | 119 loc | 5.1 KB | embed / history / annotate / raw / |
|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | PiotrLegnica's Stuff
====================
You might find some of those useful. Or not.
Released under WTFPL_ license, unless source says otherwise.
And it probably requires Windows and Python 2.6 anyway.
I also have my own `django-trunk-patches`_ patch queue.
.. _WTFPL: http://sam.zoy.org/wtfpl/
.. _`django-trunk-patches`: http://bitbucket.org/piotrlegnica/django-trunk-patches/overview/
What's inside
=============
bigints-add.cpp
Written one day (for SPOJ probably) - very basic and very naive implementation
of bigint addition in C++, using ``std::list<char>`` (i.e. a linked list of digits)
as integer type. Uses base-10 internally, so it requires some memory, but
it works. I'm pretty sure there's much room for improvement.
brainfuck.py
My awesome Brainfuck compiler. Generates `flat assembler`_ source code for either
Linux (using ELF formatter and syscalls for I/O) or Windows
(using PE console formatter and msvcrt's getchar/putchar for I/O).
cpp-comments-filter.cpp
Like above; removes C++ comments (single- and multiline) from stdin, and outputs
result to stdout, using a simple state machine. Probably can be improved, too.
dns.py
A (very) prototype (proof-of-concept) DNS records management util.
Not very useful in itself, but comes with tinydns record file generator -
with support for SRV records! It's ZODB3 powered (pretty heavy for such a small
script, huh?), and has some level of input validation (I'm open to
more suggestions!). Usage::
dns.py dom add <domain> - adds domain
dns.py dom del <domain> - removes domain
dns.py rec <domain> <type> <subdomain> - adds record <type> for <subdomain>.<domain>
<subdomain> may be empty, or a wildcard (*).
dns.py data - generates tinydns-data-compatible data file
du.py
A "disk usage" script, that can render nice coloured tree, and
shows progress as it counts. Usage: ``du.py <path> [<max. tree nesting>]``.
If tree nesting is not given, tree is not rendered. I use it often, so it
definitely works.
dummy.asm, dummy.c
A "do nothing" /SUBSYSTEM:WINDOWS program. I use this as "debugger"
for applications that I don't want to run at all.
Just create a ``REG_SZ`` named ``Debugger`` under
``HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<application>``.
dummy.asm is the same as C, but much more... dummy. Use flat assembler.
Resulting binary shouldn't be bigger than ~2kB.
HLQuery.py, HLQuery1.py
Two versions of UDP HLDS server query library. Written in January 2008, and used
somewhere around then for Counter-Strike 1.6 server monitor. I have no idea why
there are two versions, and which one works better. Go ahead and try.
icon.cpp
Written as an overblown example of ``GetClassLong`` -- an icon stealer application. It opens
given PID, fetches icon of process' first window, and creates its own micro-window
with that icon. It's cool, but might not work with every application, as it does very limited
window enumeration. Usage: ``icon <pid>``.
jobs.cpp
Written as an example -- Windows' job objects. Watch with Process Explorer to see it.
m3u-to-pls.py
Simple M3U to PLS converter. Supports multiple file input and URL fetching.
make-fourcc.py
Small util to convert four character code into big- or little-endian
hex integer constant. Usage: ``make-fourcc.py XXXX [little/big]``.
Little endian is default.
myepisodes.py
MyEpisodes.com RSS to iCalendar converter. Old and not so beautiful, but does
the job. Requires Python 2.5, icalendar and feedparser. CGI script for now
(I'm very slowly working on WSGI-compliant rewrite).
qa.py
Small self-test application -- I used it to learn e.g. German irregulars, by
repeating them over and over. Supports UTF-8 (obviously), but you might
need to change console codepage. It reads simple database in format
``correct answer :: question``, shuffles the questions, logs progress,
and displays correct percentage (i.e. it's neat and cool). Code probably
sucks, but who cares, it works. And it's been tested with py2exe.
scheduler.py
Very, very, very simple "task scheduler" (there's maybe 20 lines of real code).
Probably requires Python 2.5, but who knows.
seh.c
Written as an example -- the simplest SEH unhandled exception
catcher ever.
tree.cpp
Simple non-templated tree written for somebody as simple way to hold
directory hierarchy. There are absolutely no error-handling or correct
memory management, but shows a simple tree and how to print it recursively
just fine, IMHO.
writeColour.py
A portable (I think) "writeColour" function, which uses either Console API on Windows,
or ANSI escape codes on other platforms. ``writeColour`` function uses ``print``-compatible
signature, see ``help(writeColour)``.
Probably could be improved, feel free to send patches.
``writeColor`` function and ``writeColor.py`` module are kept for compatibility, if anyone
uses that and would like to upgrade.
.. _`flat assembler`: http://flatassembler.net
|
