tag:blogger.com,1999:blog-33902889164050070372024-03-13T03:22:52.764+01:00Dies und DasMirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comBlogger41125tag:blogger.com,1999:blog-3390288916405007037.post-42288126108836916012022-11-07T00:00:00.005+01:002022-11-07T15:06:42.666+01:00Buch: Fluent Python: Clear, Concise, and Effective Programming<p> <a href="https://www.oreilly.com/library/view/fluent-python-2nd/9781492056348/" rel="nofollow" target="_blank">Fluent Python, 2nd Edition</a></p><p>Ich habe die erste Auflage irgendwie verpasst und bin über einen Vortrag des Autors auf einer Python Conference auf das Buch gestoßen.</p><p>Keine leichte Kost und sicher nichts für Anfänger. Oder doch? Vielleicht is die breite der Informationen, bei der auch der langjährigen Python Benutzer (25+ Jahre in meinem Fall) noch viel mitnehmen kann. Auch die Verweise auf anderen Ressourcen am Ende jeden Kapitels sind wirklich eine Bereicherung. </p><p><b>Achtung</b>: Es gibt noch ein anderes Buch: "Fluent Python, Programming for Beginners". Dieses ist hier nicht gemeint,</p><h1 class="a-spacing-none a-text-normal" id="title" style="box-sizing: border-box; caret-color: rgb(15, 17, 17); color: #0f1111; font-family: "Amazon Ember", Arial, sans-serif; font-size: 28px; font-weight: 400 !important; line-height: 36px; margin-bottom: 0px !important; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding: 0px; text-rendering: optimizeLegibility;"><br /></h1>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-55936584886564334202022-08-31T18:34:00.000+02:002022-08-31T18:34:06.985+02:00Online resizing a partition on Ubuntu<p>Just to remember myself: How to a resize a file system at runtime on Ubuntu. In this example I want to increase the size of <span style="background-color: #f3f3f3;">/dev/sda3</span> - my root partition on a virtual dev system.</p><p></p><ul style="text-align: left;"><li>Extend the "physical" disk, in my case in VMware vSphere</li><li>Then run then following commands as root</li><ul><li><span style="background-color: #f3f3f3;">echo 1 > /sys/block/sda/device/rescan</span> # make sure the OS rescan the disc</li><li><span style="background-color: #f3f3f3;">growpart /dev/sda 3</span> # grow the partition on the disk</li><li><span style="background-color: #f3f3f3;">resize2fs /dev/sda3</span> # grow the file system on the partition</li></ul></ul><p></p><p><br /></p>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-24627745715993617782020-04-13T15:44:00.000+02:002020-04-13T15:44:00.981+02:00MoneyMoney von Python aus steuernIch benutze das hervorragende Programm <a href="https://moneymoney-app.com/" rel="nofollow">MoneyMoney</a> unter MacOS zum abfragen aller meiner Banktransaktionen. Mit war bekannt, dass es eine API in Lua gibt, mit denen man <a href="https://moneymoney-app.com/extensions/" rel="nofollow">Erweiterungen</a> schreiben kann. Unter anderem kann man eine Erweiterung laden, dass einem alle Amazon Einkäufe der letzten 23 Jahre .... aber lassen wir das.<br />
<br />
Vor kurzem habe ich gelernt, dass man MoneyMoney auch via AppleScript fernsteure kann.<br />
<br />
Also habe ich eine kleine Python Bibliothek zum testen gebaut. Näheres auf <a href="https://github.com/MirkoDziadzka/py-money">https://github.com/MirkoDziadzka/py-money </a>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-73042627480571311882020-04-13T15:34:00.001+02:002022-03-24T11:02:30.396+01:00MacOS Startup SoundFür seine neuen Laptop Modelle hat Apple den Startsound abgestellt. Normalerweise ist das ok. Wenn man aber öfter mal spezielle Boot Tastencodes benutzen will, Ist iss schon ganz nett akustisch zu erfahren wann man die drücken soll.<br />
<br />
Kurz:<br />
<br />
<blockquote class="tr_bq">
<span style="color: #161d27; font-size: 15px;"><span style="font-family: "courier new" , "courier" , monospace;">$ sudo nvram StartupMute=</span></span></blockquote>
<br />
leistet das gewünschte. Wenn man den wieder ausschalten will, einfach das <span style="font-family: Courier New, Courier, monospace;">00</span> <span style="font-family: "courier new" , "courier" , monospace;"></span> durch <span style="font-family: "courier new" , "courier" , monospace;">01</span> ersetzen.<br />
<span style="background-color: white; color: #161d27; font-family: , "helvetica neue light" , "helvetica neue" , "segoe ui" , "helvetica" , "arial" , "sans serif"; font-size: 15px;"><br /></span>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-55779363669242201692020-04-13T15:28:00.001+02:002020-04-13T15:28:47.941+02:00Buch: The Pragmatic Programmer, 2nd editionSeit kurzem gibt es die Neuauflage vom "<a href="https://www.amazon.de/Pragmatic-Programmer-journey-mastery-Anniversary/dp/0135957052" rel="nofollow" target="_blank">The Pragmatic Programmer</a>". Ein Buch was ich jedem Softwareentwickler nur empfehlen kann.<br />
<br />
Die Autoren geben 100 Grundregeln, an denen man den eigenen Softwareentwicklungsprozess überprüfen kann. Alle mit Beispielen und Begründungen hinterlegt.Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-104255324529972552018-11-07T13:17:00.000+01:002018-11-07T13:19:03.440+01:00MacOS file system checkTo see if you new APFS file system is consistent, you can:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">$ sudo fsck_apfs -ln /dev/disk1s1</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
Let me explain this in details:<br />
<br />
<ul>
<li>sudo - assume admin rights</li>
<li>fsck_apfs - the low level program to check an APFS file system</li>
<li>-ln - scan this in "live mode" and do "no changes"</li>
<li>/dev/disk1s1 - the name of your main disk. You can find this by either doing a "df ~" or "diskutil list". The later gives the following output on my system:</li>
</ul>
<br />
<br />
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ diskutil list</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/dev/disk0 (internal):</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> #: TYPE NAME SIZE IDENTIFIER</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 0: GUID_partition_scheme 500.3 GB disk0</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 1: EFI EFI 314.6 MB disk0s1</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 2: Apple_APFS Container disk1 500.0 GB disk0s2</span></span></div>
<div style="font-stretch: normal; line-height: normal; min-height: 13px;">
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"><span style="font-variant-ligatures: no-common-ligatures;"></span><br /></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">/dev/disk1 (synthesized):</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> #: TYPE NAME SIZE IDENTIFIER</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 0: APFS Container Scheme - +500.0 GB disk1</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> Physical Store disk0s2</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 1: APFS Volume Macintosh HD 478.9 GB disk1s1</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 2: APFS Volume Preboot 47.5 MB disk1s2</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 3: APFS Volume Recovery 512.8 MB disk1s3</span></span></div>
<div style="font-stretch: normal; line-height: normal;">
<span style="font-variant-ligatures: no-common-ligatures;"><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;"> 4: APFS Volume VM 1.1 GB disk1s4</span></span></div>
<br />
If this tells you that you should repair your disk, you must boot your Mac into single user mode (console mode). To do this, reboot and press CMD+S during reboot. You will get a unix console with a root prompt.<br />
<br />
here you can run<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"># fsck_apfs -y /dev/disk1s1</span><br />
<br />
-y means here: repair without askingMirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-7341446186742482092018-07-07T00:00:00.000+02:002018-09-18T10:53:19.818+02:00Vortrag: A better language for OWASP Core Rule SetIch habe unser Projekt für eine bessere Sprache für das <a href="https://coreruleset.org/" target="_blank">OWASP Core Rule Set</a> auf dem <a href="https://coreruleset.org/20180626/crs-community-summit-next-week-call-for-posters-and-the-program-is-ready/" target="_blank">Core Ruleset Summit</a> am Rande der <a href="https://2018.appsec.eu/" target="_blank">AppSec EU in London</a> vorgestellt.<br />
<br />
Die Folien und alle Materialien gibt es hier auf der Projektseite <a href="https://github.com/avinetworks/owasp-crs-technical-discussion">https://github.com/avinetworks/owasp-crs-technical-discussion</a>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-58342469079143856992017-01-02T13:50:00.002+01:002017-01-02T13:52:16.513+01:00Replizieren von SVN repositoriesJa, ich weiss. SVN ist nicht mehr hip und alle nehmen git. Aus "historischen Gründen" lauft hier aber noch SVN.<br />
<br />
Für Backup, Redundanz und eventuell offline work, möchte man manchmal read-only Replikas von SVN haben.<br />
<br />
Alles gut <a href="http://svnbook.red-bean.com/de/1.7/svn.ref.svnsync.html" target="_blank">dokumentiert</a>, hier eine Kurz-Zusammenfassung:<br />
<br />
1. Auf dem Mirror das repository erzeugen:<br />
<br />
<blockquote class="tr_bq">
$ svnadmin create "${SVN_MIRROR}/${REPO_NAME}"</blockquote>
<br />
2. Den pre-revprop-change hook anlegen<br />
<br />
<blockquote class="tr_bq">
$ cat "${SVN_MIRROR}/${REPO_NAME}/hooks/pre-revprop-change"<br />
#!/bin/bash </blockquote>
<blockquote class="tr_bq">
exit 0</blockquote>
<br />
3. Die Replika initialisieren:<br />
<br />
<blockquote class="tr_bq">
$ svnsync init --source-username "${USERNAME}" "file:///${SVN_MIRROR}/${REPO_NAME}" "${REMOTE_REPO}"</blockquote>
<br />
4. Initiales und inkrementelles replizieren<br />
<br />
<blockquote class="tr_bq">
$ svnsync sync --source-username "${USERNAME}" "file:///${SVN_MIRROR}/${REPO_NAME}"</blockquote>
<br />
<br />Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-67503288840550060832016-03-06T15:55:00.001+01:002016-03-10T17:06:18.698+01:00Nespresso Pixie reparierenLetztes Wochenende hat meine Nespresso Pixie den Geist aufgegeben.<br />
<br />
Ja, ich trinke gerne einen Espresso nach dem Aufstehen und alle anderen Methoden sind mir persönlich zu aufwendig. Empfehlen kann ich übrigens die Kapseln von <a href="http://www.dallmayr.de/" rel="nofollow" target="_blank">Dallmayr</a>, die einzigen die (mir) nicht schlechter schmecken als die Nespresso Kapseln selber.<br />
<br />
Aber letztes Wochenende gab die Ihren Geist auf. Das Wasser kam nicht mehr vorne raus, sondern unten aus dem Gehäuse. <br />
<br />
Erstmal geflucht. Dann entschieden, das Ding mal aufzuschrauben. Für die Seitenwände braucht mal Torx Schraubenzieher, aber dafür liegt ja das <a href="http://www.ifixit.com/" rel="nofollow" target="_blank">iFixit</a> Set rum. Geht also auch für andere Dinge als Rechner.<br />
<br />
Nur, nachdem die Schrauben raus sind, hat man erstmal nichts gewonnen. Die Seitenwände sind immer noch fest. Also mit 'ner Plastikkarte die Wände abgehebelt.<br />
<br />
Danach sieht man nicht viel mehr. Die Maschine is immer noch ein kompakter Kunststoffblock mit kleinen Öffnungen und es ist nicht klar wie sie weiter.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy6pOyFroZaMkx6M6hGS1W9NVZWFMZnYvHlhomqZH-7mna2YdHolpoPHw4au5Mpm1aYQbYdYShWSmRZeAtbQzMTQ1UCdv_WL3CTw0Ca8QHkBdNs28y2y8SaNs0RiSsUjzNa37KPuSbiiU/s1600/IMG_1078.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy6pOyFroZaMkx6M6hGS1W9NVZWFMZnYvHlhomqZH-7mna2YdHolpoPHw4au5Mpm1aYQbYdYShWSmRZeAtbQzMTQ1UCdv_WL3CTw0Ca8QHkBdNs28y2y8SaNs0RiSsUjzNa37KPuSbiiU/s320/IMG_1078.JPG" width="240" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Aber ich habe schon drei lose Teile gesehen. Später gelernt, daß das Teile vom Schalldämpfer sind. Die sind sind nach 2 Jahren einfach so abgefallen, anscheinend hat sich as Schraubgewinde links gelöst.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkz79ejbaOhdrcQOs-N7hqYQllNLSW1pWekgz0OIPgP1mQxfeJ8xi2VrM7Mt4lCyhFl8PRBXl2c3MYUOuGS4E94aSm0mGccE3zND1xwj2WOAI8bOPnb29FzzV6Lzh9hkjh-wcWfk_cRj8/s1600/IMG_1042.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkz79ejbaOhdrcQOs-N7hqYQllNLSW1pWekgz0OIPgP1mQxfeJ8xi2VrM7Mt4lCyhFl8PRBXl2c3MYUOuGS4E94aSm0mGccE3zND1xwj2WOAI8bOPnb29FzzV6Lzh9hkjh-wcWfk_cRj8/s320/IMG_1042.JPG" width="240" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Reparatur ganz einfach, man muß nur rankommen. Auf dieses weiße Ding muss das wieder rauf.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUwn90cYl_m81tKqCLxEwLvl73vjCUWGocxyt3Zla-mOlT5O67MOHp0799OD4Hnigiy6AYoEz-VFnqOK2UQtjsFToiskEdeSYkoD8CLA_UVRrn37RwrXLPt8sMsv8zbrxEkL-Rzra3pI0/s1600/IMG_1041.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUwn90cYl_m81tKqCLxEwLvl73vjCUWGocxyt3Zla-mOlT5O67MOHp0799OD4Hnigiy6AYoEz-VFnqOK2UQtjsFToiskEdeSYkoD8CLA_UVRrn37RwrXLPt8sMsv8zbrxEkL-Rzra3pI0/s320/IMG_1041.JPG" width="240" /></a></div>
<br />
<br />
Also weiter auseinanderbauen. Aber keine Ahnung wie.<br />
<br />
Google angeworfen und gesucht. Aber es ist wirklich schwer, hier was zu finden. Natürlich gibt es nichts bei Nespresso. Warum sollte man auch sowas veröffentlichen.<br />
Am Ende habe ich ein <a href="http://www.manualslib.com/manual/888212/Nespresso-Pixie-C.html" target="_blank">Service Manual für die Nespresso Pixie EF 280</a> auf <a href="http://www.manualslib.com/" target="_blank">manualslib</a> gefunden.<br />
<br />
Nicht ganz meine Machine, aber besser als nichts.<br />
<br />
Zwei Plastik Clips mußte ich abbrechen, aber an einer Stelle, an der es nicht stört. Ich habe bis heute keine Ahnung, wie der Ring um den Wasserfilter sonst abgehen soll.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglydlrQF8lQ9wXxnj6XoSxd7EfmogwukF6nV_eCKfSGGzSy8VnPZeIFhImFCsZAEjEcWSgcsPMD3hZqIQ2VuBbS8IvKIwqpHwAs2TQLH3Yvj3rYf982WtDAZJulVfWH0fc7BW2rGF3Kgw/s1600/IMG_1079.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglydlrQF8lQ9wXxnj6XoSxd7EfmogwukF6nV_eCKfSGGzSy8VnPZeIFhImFCsZAEjEcWSgcsPMD3hZqIQ2VuBbS8IvKIwqpHwAs2TQLH3Yvj3rYf982WtDAZJulVfWH0fc7BW2rGF3Kgw/s320/IMG_1079.JPG" width="240" /></a></div>
<br />
<br />
<br />
Aber am Ende hat es funktioniert. Es tropft nicht mehr und ich bekommen wieder meinen Espresso nach dem Aufstehen.<br />
<br />
Mein Fazit:<br />
<br />
Hersteller sollten verdammt nochmal sowas wie ein Repair Manual auf ihre Webseite packen. Wenn ich das nicht auf <a href="http://www.manualslib.com/" target="_blank">manualslib</a> gefunden hätte, hätte ich die Machine wegwerfen können.<br />
Es wäre auch nicht schlecht, Schrauben statt Plastik Clips zu nehmen. Ich bezweifle, dass man die Pixie ohne Anleitung auseinanderbekommt. Mit Schrauben wäre das einfacher.<br />
<br />
<b>Update</b>: Bilder ergänzt<br />
<br />
<br />
<br />
<br />
<br />
<br />Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-59219340266607953192015-11-18T00:00:00.000+01:002016-03-10T19:18:57.349+01:00Vortrag: HTTP/2 Was ist das und warum will man es haben<div>
<br /></div>
Im Rahmen des <a href="https://www.owasp.org/index.php/OWASP_German_Chapter_Stammtisch_Initiative" target="_blank">Münchener OWASP Stammtisch</a> habe ich was zum Thema HTTP/2 erzählt.<br />
<br />
Die Folien gibt es wie immer <a href="http://mirko.dziadzka.de/Vortrag/owasp-http2-20151117" target="_blank">direkt auf meiner Webseite zum download</a>.<br />
<br />Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-48070111346428150972014-05-20T20:00:00.001+02:002023-11-14T14:47:37.815+01:00MacOS start scripteFür einen Unix Benutzer gibt es unter MacOS viele ungewohnte Dinge, zum Beispiel start scripte. Das wird auf MacOS alles vom launchd übernommen.<br />
<br />
Hier mal zur Dokumentation ein Beispiel, wie man ein Programm zur boot Zeit als root ausführen lassen kann.<br />
<br />
Mein konkretes Problem: Ich benutze <a href="http://www.tinc-vpn.org/" target="_blank">tinc</a> als Lösung, um alle meine Rechner via VPN zu verbinden. Ich würde gerne zur Boot Zeit folgendes Kommando ausführen<br />
<br />
<blockquote class="tr_bq">
/usr/local/sbin/tincd -n dziadzka.net</blockquote>
Unter MacOS erstelllt man hierzu eine plist Datei im XML format und kopiert sie nach /Library/LaunchDaemons.<br />
<br />
Konkret lege ich eine Datei /Library/LaunchDaemons/net.dziadzka.tincd.plist mit dem folgende Inhalt<br />
<br />
<blockquote class="tr_bq">
<?xml version="1.0" encoding="UTF-8"?><br /><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><br /><plist version="1.0"><br /><dict><br /> <key>KeepAlive</key><br /> <true/><br /> <key>Label</key><br /> <string>net.dziadzka.tincd</string><br /> <key>ProgramArguments</key><br /> <array><br /> <string>/usr/local/sbin/tincd</string><br /> <string>-n</string><br /> <string>dziadzka.net</string><br /> <string>-D</string><br /> </array><br /></dict><br /></plist></blockquote>
Im wesentlichen ist das eine 3-elementige property liste mit den werten<br />
<br />
Label: net.dziadzka.tincd<br />
KeepAlive: true<br />
ProgrammArguments: ["/usr/local/sbin/tincd", "-n", "dziadzka.net", "-D"]<br />
<br />
KeepAlive == true heist, dass sich der Launchd darum kümmert, das Programm nach unfreiwilliger beendigung neu zu starten. Deswegen auch das zusätzliche Argument "-D" für den tincd, damit der sich nicht in den Hintergrund verabschiedet.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-26685467062900629912014-03-18T00:00:00.000+01:002014-03-28T23:25:37.325+01:00Vortrag: Vulnerability Management Systeme am Beispiel von ThreadFixIm Rahmen des <a href="https://www.owasp.org/index.php/OWASP_German_Chapter_Stammtisch_Initiative/M%C3%BCnchen" target="_blank">Münchener OWASP Stammtisch</a> habe ich kurz das Vulnerability Management Tool <a href="http://www.threadfix.org/" target="_blank">ThreadFix</a> vorgestellt.<br />
<br />
Die Folien gibt es wie immer auf <a href="http://mirko.dziadzka.de/Vortrag/owasp-threadfix-20140318.pdf" target="_blank">direkt meiner Webseite zum download</a>.<br />
<br />
<br />Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-57489340345269288822013-12-04T10:27:00.003+01:002013-12-04T10:28:16.742+01:00MacOS: Sparse Bundle kleiner machenAus bestimmten Gründen(tm) benutze ich unter MacOS eine virtuelle Festplatte für den Source Code eines Projekts. Diese virtuelle Festplatte ist unter MacOS als ein <a href="http://en.wikipedia.org/wiki/Sparse_image" target="_blank">Sparse Bundle</a> implementiert.<br />
<br />
Das heist, diese virtuelle Festplatte wächst automatisch, wenn mehr Platz gebraucht wird. Leider wird sie nicht automatisch kleiner, wenn Daten gelöscht werden. Das muss man manuell anstossen:<br />
<br />
<blockquote class="tr_bq">
$ hdiutil compact -batteryallowed ~/Documents/WOD.sparsebundle<br />
Starting to compact…<br />
Reclaiming free space…<br />
...............................................................................<br />
Finishing compaction…<br />
Reclaimed 60.1 GB out of 83.8 GB possible.</blockquote>
<div>
<br /></div>
Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-75745997074557548932013-11-20T17:37:00.000+01:002013-11-21T17:37:59.315+01:00Vortrag: Was eine WAF (nicht) kannAm Dienstag habe ich die 2013 Ausgabe von meinem Vortrag "Was eine WAF (nicht) kann" im Rahmen des <a href="https://www.owasp.org/index.php/OWASP_German_Chapter_Stammtisch_Initiative/M%C3%BCnchen" target="_blank">OWASP Stammtisch München</a> gehalten.<br />
<br />
Die Folien gibt es wie immer <a href="http://mirko.dziadzka.de/Vortrag/owasp-waf-20131119" target="_blank">direkt auf meiner Webseite</a>.Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-84539040581139178932013-08-08T11:44:00.000+02:002013-11-05T13:44:50.217+01:00Wie kopiere ich ein ISO Image auf einen USB Stick (unter MacOS)Da ich das öfter gefragt werde, hier eine Kurzanleitung.<br />
<br />
Es braucht keine Spezielprogramme, im Prinzip, genauso wie unter Linux mit dd.<br />
<br />
Vorbemerkung: Das dd Kommando weiter unten überschreibt die Daten ohne nachfragen. Also bitte aufpassen, das man wirklich den USB Stick überschreibt und nicht was anderes.<br />
<br />
<br />
1. USB stick einstecken<br />
<br />
2. Alle "Platten" anzeigen lassen.<br />
<br />
<blockquote class="tr_bq">
$ diskutil list<br />
....<br />
/dev/disk5<br />
#: TYPE NAME SIZE IDENTIFIER<br />
0: FDisk_partition_scheme *4.0 GB disk5<br />
1: DOS_FAT_32 UNTITLED 4.0 GB disk5s1</blockquote>
<div>
<br /></div>
<br />
Bei mir ist disk5 die richtige. Das merken wir uns mal<br />
<br />
3. abmounten om USB Stick<br />
<br />
<blockquote class="tr_bq">
$ diskutil unmountDisk /dev/disk5<br />
Unmount of all volumes on disk5 was successful</blockquote>
<br />
Jetzt ist der USB Stick im Finder nicht mehr zu sehen, aber mit diskutil sieht man ihn immer noch<br />
<blockquote class="tr_bq">
$ diskutil list<br />
....<br />
/dev/disk5<br />
#: TYPE NAME SIZE IDENTIFIER<br />
0: FDisk_partition_scheme *4.0 GB disk5<br />
1: DOS_FAT_32 UNTITLED 4.0 GB disk5s1</blockquote>
<div>
<br /></div>
4. Kopieren der Daten auf den USB Stick<br />
<blockquote class="tr_bq">
$ sudo dd bs=1024k if=~/Downloads/Fedora-Live-LXDE-x86_64-19-1.iso of=/dev/disk5<br />
Password:<br />
691+0 records in<br />
691+0 records out<br />
724566016 bytes transferred in 1141.584431 secs (634702 bytes/sec)</blockquote>
<div>
Das <i>sudo</i> brauchen wir hier, weil wir ansonsten keine Rechte haben, direkt auf das device /dev/disk5 zuzugreifen.<br />
<ul>
<li><i>bs</i> ist hier die zu verwenden lese/schreibe <i>block size</i>. Wenn die nicht gesetzt wird, nimmt <i>dd</i> 512byte und es dauert ewig.</li>
<li><i>if</i> ist das <i>input file</i>, hier ein Fedora ISO image</li>
<li><i>of</i> ist das <i>output file</i>, hier unser USB Stick</li>
</ul>
<div>
<br /></div>
<div>
Am Ende muss die Partition eventuell noch bootfähig gemacht werde</div>
</div>
<blockquote class="tr_bq">
$ sudo fdisk /dev/disk5</blockquote>
<div>
Und dann mit f die entsprechende Partition markieren</div>
Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-72907006146081380002013-08-05T19:02:00.000+02:002013-08-09T10:31:23.900+02:00Wie mache ich aus Bildern einen FilmWir haben auf der <a href="https://ohm2013.org/" target="_blank">OHM2013</a> mit 'ner Webcam unser Village aufgenommen. Jede Sekunde ein Bild. Das Resultat sind ~300000 Einzelbilder.<br />
<br />
Nun wollte ich aus diesen Einzelbildern einen kleinen Zeitrafferfilm machen.<br />
<br />
<a href="http://ffmpeg.org/" target="_blank">ffmpeg</a> scheint da das Tool der Wahl zu sein, und schnell wurden auch dir richtigen Optionen gefunden.<br />
<br />
<br />
<blockquote class="tr_bq">
$ ffmpeg -pattern_type glob -i '20130801*.jpg' day2.mp4</blockquote>
<br />Leider stieg das nach ein paar Minuten mit der Fehlermeldung<br />
<br />
<blockquote class="tr_bq">
20130801*.jpg: Input/output error</blockquote>
<br />aus. Sehr hilfreich. Not.<br />
<br />
Stellte sich nach etwas suchen heraus, das wir einige leere Files unter den Bildern hatten.<br />
<br />
Ein<br />
<br />
<blockquote class="tr_bq">
$ find . -name \*.jpg -size 0 | xargs rm</blockquote>
<div>
<br /></div>
<div>
hat geholfen.<br /><br />
<br />
<br />
<br /></div>
Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-76692892214766550772013-02-05T15:45:00.001+01:002013-02-05T15:45:28.251+01:00Windows Batch File quirks<div class="tr_bq">
Musste mal ein Windows Batch file debuggen:</div>
<br />
<blockquote>
if SOMETHING_TRUE (<br /> SET FOO=42<br /> SET BAR=%FOO%<br />)<br />echo %FOO%<br />echo %BAR%</blockquote>
<br />
gibt was aus? Ja, FOO ist dann 42, aber BAR ist ein leerer String. Gut, man kann's erklären aber intuitiv ist das sicher nicht, oder?<br />
Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-79890481413255039152013-02-05T12:43:00.000+01:002013-08-08T11:45:48.560+02:00Wie repariere ich unter MacOS eine Platte mit defektem JournalAuf einer meiner Backup Platten (MacOS / Time Machine) war das Journal defekt. Die Platte lässt sich nicht mehr mounten.<br />
<br />
Disk Utility ist nicht sehr hilfreich, Repair sagt alles in Ordnung (aber das Journal ist kaputt), Verify sagt, das Journal ist kaputt.<br />
<br />
Also das Journal vom HFS+ abstellen. Geht ja auch ohne. Nun kann man das mit den üblichen MacOS tools nur bei einem gemounteten File System abstellen, mounten geht aber nicht ...<br />
<br />
Kleine Internet Recherche: Wie bei Linux auch, wird bei MacOS von den disktools ein filesystem spezifisches Programm zum reparieren benutzt, dass kann dann eventuell auch etwas mehr.<br />
<br />
Hier: Das Journal auf einem nicht gemountetem Filesystem abschalten:<br />
<blockquote class="tr_bq">
/System/Library/Filesystems/hfs.fs/hfs.util -N /dev/diskNsM</blockquote>
Danach geht auch das Repair/Verify gut und die Platte lässt sich wieder benutzen - und erstmal backup-enMirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-76014156994467481072012-11-08T12:27:00.000+01:002012-11-15T12:27:28.829+01:00German OWASP Day 2012Gestern war der <a href="https://www.owasp.org/index.php/German_OWASP_Day_2012" target="_blank">dritte German OWASP Day</a>, diesmal wieder in München. Die Veranstaltung ist in den letzten Jahren richtig gut geworden, ich konnte mich oftmals nicht zwischen den 2 (oder 3) Tracks entscheiden.<div>
<br /></div>
<div>
Nächstes Jahr wird das deutsche Chapter der OWASP die <a href="https://www.owasp.org/index.php/Category:OWASP_AppSec_Conference" target="_blank">AppSec EU</a> in Hamburg durchführen. Sicher eine sehr besuchenswerte Veranstaltung.<br /><div>
<br /></div>
<div>
<br /></div>
</div>
Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-86720571336850903642012-10-30T17:06:00.001+01:002012-11-15T22:38:05.426+01:00Vortrag: Praktische Anwendungen von MetaklassenHeute habe ich auf der <a href="https://2012.de.pycon.org/" target="_blank">PyCon DE 2012</a> einen Vortrag zum Thema <a href="https://2012.de.pycon.org/programm/schedule/sessions/30/" target="_blank">"Praktische Anwendungen von Metaklassen"</a> gehalten. Die Folien und etwas Beispiel Code gibt es <a href="http://mirko.dziadzka.de/Vortrag/pycon-meta-20121030/" target="_blank">auf meiner Webseite.</a><br />
<br />Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-15478097375416542182012-02-22T00:20:00.000+01:002013-05-14T23:10:14.068+02:00Buch: The Art of Readable Code<i>"... programs must be written for people to read, and only incidentally for machines to execute<span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif; line-height: 24px;">"</span></i><br />
<div style="text-align: right;">
<span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif; line-height: 24px;"><i><span class="Apple-style-span" style="font-size: xx-small;">Abelson, Sussman & Sussman: Structure and Interpretation of Computer Programms</span></i></span></div>
<span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif; line-height: 24px;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif; line-height: 24px;">Aber wie macht man das? <i><a href="http://shop.oreilly.com/product/9780596802301.do" target="_blank">The Art of Readable Code</a></i> versucht das zu beantworten.</span><br />
<br />
<ul>
<li><span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 24px;">Wann ist Code lesbar</span></span></li>
<li><span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 24px;">Was macht einen guten Namen für eine Variable oder eine Funktion aus</span></span></li>
<li><span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 24px;">Was bedeutet gute Lesbarkeit</span></span></li>
<li><span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 24px;">Welchen Sinn erfüllen Kommentare</span></span></li>
</ul>
<div>
<span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 24px;">All das wird der gute Entwickler wissen, aber dieses Buch fasst dieses implizite Wissen gut zusammen. Ein <b>must read </b>- insbesondere für junge Software Entwickler.</span></span></div>
<br />
<span class="Apple-style-span" style="font-family: 'trebuchet ms', verdana, sans-serif; line-height: 24px;"><br />
</span><br />
<span class="Apple-style-span" style="color: #444444; font-family: 'trebuchet ms', verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 24px;"><i><br />
</i></span></span>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-20428379067594441712012-01-20T08:14:00.000+01:002012-01-20T08:14:56.873+01:00Vortrag: FuseGestern habe ich einen kleine Vortrag zum Thema <a href="http://mirko.dziadzka.de/Vortrag/mucosug-fuse-20120119/">User Space Filesysteme mit Fuse</a> gehalten.Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-53906849811367459342011-06-17T09:51:00.000+02:002013-08-05T19:18:01.487+02:00Vortrag: PythonGestern habe ich zusammen mit <a href="http://www.linkedin.com/in/thijsmetsch" target="_blank">Thijs</a> auf dem monatlichen Treffen der <a href="http://hub.opensolaris.org/bin/view/User+Group+mucosug/WebHome">OpenSolaris Usergroup München</a> einen Vortrag zum Thema Python gehalten.<br />
<br />
<a href="http://mirko.dziadzka.de/Vortrag/mucosug-python-20110616.pdf">Hier sind die Folien für meinen Teil als PDF.</a>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-17167989427807515472011-03-10T01:10:00.002+01:002011-03-10T09:42:54.493+01:00Python parsingIch baue grade einen pure Python parser für <a href="http://www.openpgp.org/">OpenPGP</a> Messages nach <a href="http://www.ietf.org/rfc/rfc4880.txt">RFC 4880</a>. Dabei ist mir wieder mal was aufgefallen.<br />
<br />
Wenn man einen Parser baut, der eine grosse Datenstruktur analysiert und in Pakete zerlegt, hat man in den meisten Sprachen folgendes Muster:<br />
<br />
<br />
<div style="margin: 0px;">In C würde man es wohl so machen:</div><div style="margin: 0px;"><br />
</div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">void parse_message(char * input) {</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> int len = find_packet_len(input);</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> handle_packet(make_packet(input, len)); </span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> input += len;</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">}</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: inherit;">In Python ist der naive Ansatz: </span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span></div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">def parse_message(input):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> while </span><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">input:</span><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> packet_len = find_length_of_packet(input)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> packet = input[:packet_len]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> handle_packet(</span><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">input[:packet_len])</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> input = input[packet_len:]</span><br />
<br />
In funktionalen Sprachen entsprechend.<br />
<br />
Das Problem ist nun, das Python an dieser Stelle jeweils eine Kopie des Paketes und eine Kopie des restlichen Inputs anlegt. Letzteres ist leider eine O(n^2) Operation ....<br />
<br />
Entweder baut man das parsing also um, indem man <span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">input</span> als Array behandelt nur nur über Indizes adressiert:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">def parse_message(input):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> start = 0</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> while len(input) > start: </span><br />
<div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> pl = find_length_of_packet(input, start)</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> handle_packet(</span><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">input[start:start + pl])</span></div><div style="margin: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> start += pl</span></div><br />
Oder, man verfolgt weiter den Stil aus dem oberen Beispiel, legt aber einen Wrapper um den input, der das Kopieren verhindert:<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">class ROList(list):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> def __init__(self, l, start = 0):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> self.__l = tuple(l)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> self.__start = start</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> self.__end = sys.maxint</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> def __getitem__(self, i):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> return self.__l[self.__start + i]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> def __getslice__(self, start, end):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> #print self, start, end, sys.maxint - end</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> res = self.__class__("")</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> res.__l = self.__l</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> res.__start = self.__start + start</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> if end < sys.maxint:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> res.__end = self.__start + end</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> return res</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> def __len__(self):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> if self.__end == sys.maxint:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> return len(self.__l) - self.__start</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> else:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> return self.__end - self.__start</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> def __repr__(self):</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> return "%s : %d" % (self.__l, self.__start)</span><br />
<div><br />
</div><div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">def test_performance(list_type):</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> l = list_type(range(1024*1024))</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> while l:</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> l = l[512:]</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">if __name__ == "__main__":</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> for t in list, ROList:</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> start_time = time.time()</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> test_performance(t)</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> print 'test of %s performance: %f seconds' % (t, time.time() - start_time)</span></div></div><div><br />
</div>Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.comtag:blogger.com,1999:blog-3390288916405007037.post-18667496297402006932011-02-03T20:09:00.000+01:002013-05-14T23:21:25.614+02:00vi - das unbekannte WesenIch benutze unter Unix vi (heutzutage als vim) als einzigen Editor für alles -- und das seit mehr 20 Jahren. Trotzdem (oder grade desshalb) gibt es Ecken im vi, die ich mir noch nie so richtig angesehen haben.<br />
<br />
Irgendwann bin ich mal über autocmd gestolpert. autocmd oder 'automatic commands' dienen dazu, bestimmte Kommandos automatisch auszuführen.<br />
<br />
Einfache Anwendungen dafür sind<br />
<blockquote class="tr_bq">
autocmd BufReadPost,FileReadPost Makefile set noexpandtab</blockquote>
wenn ich ein Makefile bearbeite, dann hätte ich gerne richtige Tabs, oder<br />
<blockquote class="tr_bq">
autocmd BufWritePre *.py :%s/\s\+$//e</blockquote>
wenn ich ein .py file schreibe, dann möchte ich keine Leerzeichen am Zeilenende haben.<br />
<br />
Soweit, sogut.<br />
<br />
Was aber daran wirklich toll ist, findet sich in der <a href="http://vimdoc.sourceforge.net/htmldoc/autocmd.html#gzip-example">Dokumentation zu autocmd</a> - ein Beispiel, wie man ein gzip Komprimiertes File editieren kann, welches beim lese automatisch ausgepackt und beim schreiben wieder gepackt wird.<br />
<br />
Das kann man auch für sinvolleres benutzen, und so finden sich seit ein paar Jahren folgende Zeilen - dich ich irgendwoher aus dem Netz habe - in meiner .vimrc:<br />
<br />
<br />
<blockquote class="tr_bq">
augroup encrypted<br />:au!<br />" First make sure nothing is written to ~/.viminfo<br />" while editing an encrypted file.<br />au BufReadPre,FileReadPre *.gpg set viminfo=<br />" We don't want a swap file, as it writes unencrypted data to disk<br />au BufReadPre,FileReadPre *.gpg set noswapfile<br />" Switch to binary mode to read the encrypted file<br />au BufReadPre,FileReadPre *.gpg set bin<br />au BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2<br />au BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null<br />" Switch to normal mode for editing<br />au BufReadPost,FileReadPost *.gpg set nobin<br />au BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save<br />au BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")<br />" Convert all text to encrypted text before writing<br />au BufWritePre,FileWritePre *.gpg '[,']!gpg --default-key KEYID --default-recipient-self -ae 2>/dev/null<br />" Undo the encryption so we are back in the normal text, directly<br />" after the file has been written.<br />au BufWritePost,FileWritePost *.gpg u <br />augroup END</blockquote>
<br />
<br />
Als KEYID ist hier die ID des PGP Keys anzugeben. Einfaches Lesen und schreiben von mit PGP verschlüsselten Textdateien.<br />
<blockquote class="tr_bq">
<br />$ vi foo.gpg<br />... editiere foo ....<br />$ cat foo.gpg<br />-----BEGIN PGP MESSAGE-----
hQQOAx86mItHGziREBAA0EzP6msleRqcYS/2KLmMgNHEn9EukJOSgPahHJtE8Ni5</blockquote>
Mirko Dziadzkahttp://www.blogger.com/profile/08685836227160046749noreply@blogger.com