Ändringar
0071 is the most recent release. It has a lot of new features, new interfaces, and probably some new bugs too. 0071 is not 100% compatible with older projects. Please see the changelog to get an overview of the differences between versions.
(Source: createdigitalmotion.com)
Python.
Plumbum was born to fill this very gap: on the one hand, be pythonic (and be backed by strong libraries), and on the other, make it all as easy and one-liner-ish by nature: use a real programming language, with a well-behaved object model and high level concepts, to achieve what you’d normally do in a shell script, with the same expressive power and wrist-handiness of the shell. I call it shell combinators, as they mimic shell syntax, but keep you pythonic.
Plumbum is actually a collection of utilities that I wrote for several separate projects, but the time has come to consolidate them into a single, production-grade library. The library provides local and remote program execution, with support for piping and IO redirection; local and remote file-system path abstraction; a programmatic command-line interface (CLI) toolkit, and numerous other utilities.
Exempel:
from plumbum import local
from plumbum.cmd import wc, ls, echo, grep
from plumbum.utils import copy, delete
delete(local.cwd // "*/*.pyc")
for fn in local.cwd / "src" // "*.py":
print wc("-l", fn)
num_of_src_lines = (ls["-l"] | grep["\\.py"] | wc["-l"])()
echo["1"] > "/proc/sys/net/ipv4/ip_forward")()
Clojure
Var på Clojure meetup igår. Mycket trevligt.
Postade tidigare den här länken, för att lära sig mer. Men vill nu även lägga till de här:
- 4clojure - “4Clojure is a resource to help fledgling clojurians learn the language through interactive problems. The first few problems are easy enough that even someone with no prior experience should find the learning curve forgiving.”
- Cemerik, Starting Clojure (mk. 2) - “A complete (though not pretty!) URL shortener webapp is built from scratch, with discussions of immutable data structures, function composition, and mild concurrency topics scattered throughout.”

Farbrausch är en demoscene-grupp som gjort en hel del imponerande produktioner. Nu släpper de mycket av sina verktyg med källkod. Härligt!
Uppdatering av lolguides
Har donat lite med backenden för lolguides.net ikväll. Mycket skönt. Har äntligen fått insamlingsdelen trådad. Har även lyckats pilla till lite ny funktionalitet, det är nu enkelt att lägga till små notiser (olika eller likadana för index och champsidor).
Uppdatering: Glad att jag använder bootstrap2
Övningar för den som är vill lära sig funktionell programmering med Clojure.
Scrapy is a fast high-level screen scraping and web crawling framework, used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing.
Skulle kunna vara ett lite mer rigid alternativ till BeautifulSoup för lolguides.net kanske?
Java, Axis 1.4, SSL
Har nu haft ett par frustrerande duster med Axis 1.4 och webtjänster som använder SSL.
Axis 1.4 är ifrån 2006 och har en del brister. Några av dem involverar SSL.
Problem 1
Byta certifikat dynamiskt, i run-time. Detta går helt enkelt inte i en orörd Axis 1.4 -version. Se Apaches Axis wiki sida om problemet. Lösningen är att använda en forkad axis.
Problem 2
I javaversioner äldre än 1.6 18 så går det utmärkt att tjänsten du kommunicerar med gör s.k SSL renegotiation. I nyare versioner av java så fungerar det inte utan pill, då det finns risk för Man-in-the-middle attacker. Mer teknisk information om detta här http://java.sun.com/javase/javaseforbusiness/docs/TLSReadme.html och här
http://www.oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html. Lösningen på nyare versioner av java är att passa in flaggan -Dsun.security.ssl.allowUnsafeRenegotiation=true till jvmen eller sätta den i din kod (java.lang.System.setProperty(“sun.security.ssl.allowUnsafeRenegotiation”, “true”);). Vägen till att komma fram till detta var lång och snårig. Felmeddelandet jag fick från Axis var det informativa:
AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (0)null
faultActor:
faultNode:
faultDetail:
{}:return code: 0
{http://xml.apache.org/axis/}HttpErrorCode:0
(0)null
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
Slutventilerat för stunden. :-)
PBS is a unique subprocess wrapper that maps your system programs to Python functions dynamically. PBS helps you write shell scripts in Python by giving you the good features of Bash (easy command calling, easy piping) with all the power and flexibility of Python.
Ser väldigt smidigt ut.
import pbs
print pbs.ifconfig("eth0")
# resolves to "curl http://duckduckgo.com/ -o page.html --silent"
pbs.curl("http://duckduckgo.com/", o="page.html", silent=True)
# print the number of folders and files in /etc
print pbs.wc(pbs.ls("/etc", "-1"), "-l")
# sudo
with pbs.sudo:
print pbs.ls("/root")