{Notes to self, programming, technology, linux, windows, git} U {Papers, reviews, games, coffee, tabletennis, ramblings} = {things worth saving}

Thursday, September 09, 2010

Proper use of a hand operated milk-frother for espresso based drinks

Introduction

Contrary to common belief, it is possible to froth your own silkysmooth milk with proper microfoam. Altho resulting in a rather labour-intensive cappucino, the process is strangely rewarding because of it's volatility, and is a nice alternative to using an espressomachine, either if you don't have the space for one, or if you're away from home on a location that requires a minimal coffee setup.

The MyPressi is a portable, handheld espressomaker that, despite it's size, produces fabulous results. It operates on widely available gas cartridges, and produces espresso at a pressure of 9 Bar. Another handheld, the HandPresso, is manually operated, and while i haven't tried it, i imagine that having to supply your own pressure is more errorprone towards getting consistent results than using the MyPressi.

Method

Assuming you have either of the mentioned handheldes, or some other means of making espresso, you also need:

  1. An accurate digital thermometer. (Proteins in milk, when heated above 67 degrees c, start breaking down, reducing it's ability to froth.)
  2. Hand-frother. They usually come in either glas or metal. Either can be placed directly on the stove. The one i use is a small Bodum frother, and results may vary with larger versions, as the "plunger" will let increasingly more air into the milk.
  3. A timer. I switched to a time-based method, as i developed better technique.
  4. A container with a spout. Used in the final stage, to eliminate remaining bubbles , resulting in a smooth, silky frothed milk. The container used to pour our milk based drink.
  5. Milk with 2%+ fat percentage.
  6. Heat source

Okay, on to the procedure. It's really very simple, and requires only patience, and a quick hand. I'll add some pictures at a later point in time:

  1. Pour milk into the frother. Not too much, as volume will increase about 50%. More than that and you'll have a milk that's too foamy, and also, you'll be squirting milk all over!
  2. Heat the milk on the stove using a not-too-steep temperature curve, until it reaches 67 degrees.
  3. Start your timer.
  4. Step one is to let some air into the milk. Raise the plunger to the top of the frother, and floor it - repeat about 20 times.
  5. Now, keep the plunger inside the milk, and raise/lower it as fast as you can. Don't let the plunger come in contact with the air. Adding too much air to the milk will create a froth reminiscent of soapbubbles. Not very pleasant.
  6. Every 45 seconds or so, repeat step 4, but only let air inside the milk about 4 times.
  7. Keep the head of the plunger just below the "milk-line", as the volume increases, to get maximum thrust.
  8. At the 2 minute mark, or just below it (experiment), you should be done.
  9. Pour the milk into the spout container, and move it in a circular motion, getting rid of some of the milk bubbles.
  10. Tap the container against the counter to further collapse remaining bubbles, leaving only a creamy, silky micro-foamy frothed milk.
  11. Perform latté art, and enjoy.
Finally

The picture below attempts to depict the end result of executing the above procedure. The result was a delicious cortado. Results may vary for you, but the procedure is a good guide to creating your own technique.

Basically, what i've experienced, is that it's really hard to find the balance between a good micro foam, and milk that isn't too thin, but with the procedure i'm using now, i'm closing that gap. You'll always be able to foam better milk on a good machine, but unless you possess lightning speed, you will always get a froth that's a bit thicker, and not that good for latté art. But as usual, it's the taste in the cup that counts.

Tuesday, September 07, 2010

Using svn+ssh protocol with a Windows based svn client and server

What is this?
A guide towards setting up eclipse to connect to a windows based subversion servers using the svn+ssh protocol. (A guide for setting up both server and client with encryption.)

Requirements?

- FreeSSHd server
- Eclipse
- Subversion
- Putty toolsuite (pageant, puttygen, plink)

[this entry is a stub!]

Monday, July 26, 2010

Monday, February 15, 2010

Tuesday, October 13, 2009

Re-flashing and setting up NSLU2 on Arch Linux

Get upslug2 PKGBUILD file from Arch AUR repo: http://aur.archlinux.org/packages.php?ID=11481

$ pkgbuild -s (not as sudo - for automatic dependency handling)
$ pacman -U upslug2-41-2-i686.pkg.tar.gz

- Get NSLU2 in upgrade mode (Turn NSLU2 on while reset button is held in for 10 secs. Orange will turn to red => RELEASE! Toggles between red and green now and is in upgrade mode, ready to receive new firmware)

- Connect NSLU2 directly to ethernet port with RJ45 cable.

$ sudo ifconfig ethx 192.168.1.2 netmask 255.255.255.0 up
$ sudo upslug2 --device ethx
NSLU2 00:1a:70:99:60:c7 Product ID: 1 Protocol ID: 0 Firmware Version: R23V63 [0x2363]

$ sudo upslug2 --image /home/zrrbite/stuff/NSLU2_V23R63.bin (linksys default firmware)
Upgrading LKG9960C7 00:1a:70:99:60:c7
. original flash contents * packet timed out
! being erased - erased
u being upgraded U upgraded
v being verified V verified

Display:
+
Status:
* timeout occurred + sequence error detected

7fffff+000000 ...VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
Rebooting... done


- Set the network protocol with the web interface before doing anything else, since this is what the NSLU2 will use when using the installer from various distros.

If you accidentally set the network settings to DHCP, use arp -a (works on both linux and windows) or a program like angry ip scanner, to locate the slug on the network segment.

Debian: http://www.cyrius.com/debian/nslu2/install.html

NSLU2 linux wiki: http://www.nslu2-linux.org/wiki/Main/HomePage

Add to sources.list to get unrar package:
deb http://http.us.debian.org/debian/ sarge main non-free contrib

apt-get update
apt-get install hellanzb
apt-get install unrar

edit /etc/hellanzb.conf PREFIX / usenet server and start daemon with "hellanzb"
dump nzb files in QUEUE dir with PSFTP (cd /home/mk/hellanzb/nzb/daemon.queue/ )

MT-DAAPD
(Firefly Media Server)

$apt-get install mt-daapd
$mkdir /home/media/music (dump music here)
$vim /etc/mt-daapd.conf
enable logging, change servername if you want, change port if needed, etc.
change runas user to someone with proper privilges (Root? :D)

$chmod o+r -R /home/media/music
$ /etc/init.d/mt-daapd restart

Repeat bold steps everytime music is added. Start iTunes. The server should show up in the left hand side under "Shared". a restart of the daemon will make the entry disappear and reappear on the fly.

Updating the songlist from cmd line may cause problems. Full system scan @ Web admin - http://192.168.1.xxx:3689/ will fix. Reload in iTunes.

Streaming 1 mp3 : 1,6% CPU, ~13% Memory.

TWONKY on Debian Lenny
Twonky supply these embedded (NAS) versions, as is, unsupported.

http://www.twonkyforum.com/unsupported/4.4.18/

Twonky arm little endian release is built against old glibc not supported by Lenny. Suggested to use the uclibc version. And download old uclibc tool chain.
http://www.twonkyforum.com/viewtopic.php?f=8&t=6086 -

http://www.uclibc.org/downloads/


Other Links:

http://www.cyrius.com/debian/nslu2/linux-on-flash.html

http://www.nslu2-linux.org/wiki/DebianSlug/OpenDebianSlug



Friday, October 09, 2009

Possible fixes to apt-get host resolution problems

/etc/nsswitch.conf :

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

Replace it with :

hosts: files dns

Restart network:

sudo /etc/init.d/networking restart

if !work , add to /etc/hosts :

91.189.88.46 ca.archive.ubuntu.com

Restart network again



---------

Check your "/etc/resolv.conf" file. It should have the name servers mentioned


nameserver 208.67.222.222
nameserver 208.67.220.220


That is all you need apart from configuring IP address on your machine.

To check if it works do the following. Type 'nslookup' and press enter:

> server


-------
ping -c2 74.125.45.100
route -nee

Wednesday, October 07, 2009

VMWare networking explained

http://www.extremetech.com/article2/0,2845,1156371,00.asp

Laptop dual-monitor on Linux

xorg.conf:

Extend the appropriate "Display" subsection with the resulting resolution of the two connecting screensizes

Virtual 3360 1050 ((2 x 1680) x 1050)

Restart X server - (Ctrl+alt+backspace)

Run xrandr to check which displays are present. VGA represents external screen. LVDS represents laptop.

xrandr --output VGA-0 --left-of LVDS
xrandr –output VGA-0 –mode 1680×1050

(Distro: Arch Linux)

Links:
http://bbs.archlinux.org/viewtopic.php?id=43138
http://intellinuxgraphics.org/dualhead.html
http://www.linuxquestions.org/questions/linux-general-1/xrandr-screen-cannot-be-larger-than-...-595649/

Wednesday, July 08, 2009

Building tomcat applications in Luntbuild

General:

Since luntbuild will execute any build scripts relative to it's own path in it's own execution environment, environment variables specified in windows won't be considered. You might want to reference these, to allow the script to be run manually without having to manage application locations.


$property environment="env"/$
$property file="tomcat.properties" prefix="tomcat"/$
(tomcat.properties specifies the entry: home=${env.CATALINA_HOME} )

In my case, tomcat.home will point to "C:\Program Files\Apache Software Foundation\Tomcat 5.5" when running the build script manually, and the same when i run it with luntbuild, because i inject CATALINA_HOME = "C:\Program Files\Apache Software Foundation\Tomcat 5.5" into the buildscript.

You could inject this as a value, but i like using environment variables for decoupling.

Also note that specifying a schedule that includes space seems to convince luntbuilt to look for a target in the script named the tail word of the schedule name?


Tomcat specifics:


Luntbuild specifies it's own servlet.api which contains the javax namespace. (Anything to do with servlets and Http). Builds will usually fail if you include tomcat's own servlet api since there will be a collission of jar's, as luntbuild imports it's own.

Inject a "mode" value into the buildscript through luntbuild and use ant conditions to check which jar to include. Both servlet api's work fine when building applications depending on these, manually.

Links
http://blog.exis.com/colin/archives/2005/08/23/i-put-a-spell-on-you-because-youre-mine-aka-why-is-tomcat-holding-onto-jars/
http://www.velocityreviews.com/forums/t139757-anyone-have-problems-with-tomcat-554-undeploy-ant-task.html
http://raibledesigns.com/wiki/Wiki.jsp?page=TomcatAntTasks

Monday, June 22, 2009

spine - note to self on discovery and tdma

RadioControllerP.nc optimization:

uint32_t LISTEN_TIMER = 40;

#define TDMA_FRAME_PERIOD 1024



spineapp Makefile: PFLAGS += -DTOSH_DATA_LENGTH=114 #set max datalength. 48 samples.
Basestation makefile: PFLAGS += -DTOSH_DATA_LENGTH=114


Inject ID into image: tos-set-symbols --target ihex main.ihex main_ID.ihex TOS_NODE_ID=ID ActiveMessageAddressC\$addr=ID


on 15.4:

The full standard 15.4 MAC/PHY protocol includes csma/ca and would work finebut spine does not sit on top of any 15.4 SW implementation and the 15.4 HW is not enough to guarantee the radio access.

Friday, May 22, 2009

Flash spine network of shimmer nodes + simple test app

* make shimmer install bsl, /dev/ttyUSB0 (/apps/BaseStation, /contrib/apps/SpineApp - as many sensors as required)

synchronize channel in makefiles:

#radio channel for TX-RX (spine default so change in BS)
PFLAGS += -DCC2420_DEF_CHANNEL=12


* Run tinyos software listener manually:
$ java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:shimmer

(you need to build libgetenv and libtoscomm from your tinyos before you can install and run any SPINE application.
cd $TOSROOT/support/sdk/java && make (if its not already built?)
sudo tos-install-jni ) - what spine doc means is that tos-install-jni will do the above for you, install libtoscomm in your java JRE

sometimes lobtoscomm-32.so and libgetenv.so aren't build.

If you have not installed the tools RPM and are working directly from the TinyOS CVS repository, you can manually install the tos-locate-jre script. Go to tinyos-2.x/tools/tinyos/java. If the directory has a Makefile in it, type make and (again, on Linux, as superuser) make install. If the directory does not have a Makefile, go to tinyos-2.x/tools and type:

$ ./Bootstrap
$ ./configure
$ make
$ make install

notice where the .so files get copied, and notice how they're named, and where the tos-install-jni script expects them to be. (search and edit)

finally do --- tos-install-jni

Now you can start the listeners

http://docs.tinyos.net/index.php/Mote-PC_serial_communication_and_SerialForwarder#Cannot_find_JNI_error

)

tells Listen to use the serial port /dev/ttyS0 (on a UNIX machine) at the correct speed for a shimmer mote.

in general:   serial@*PORT*:*SPEED*

PORT depends on your platform and where you have plugged the mote in. For Windows/Cygwin platforms, it is COMN, where N is the port number. For Linux/UNIX machines, it is /dev/ttySN for a built-in serial port, or one of /dev/ttyUSBN or /dev/usb/tts/N for a serial-over-USB port. Additionally as we saw in lesson 1, on Linux you will typically need to make this serial port world writeable. As superuser, execute the following command:

chmod 666 serialport

*

One problem with directly using the serial port is that only one PC program can interact with the mote. Additionally, it requires you to run the application on the PC which is physically connected to the mote. The SerialForwarder tool is a simple way to remove both of these limitations.

Most generally, the SerialForwarder program opens a packet source and lets many applications connect to it over a TCP/IP stream in order to use that source. For example, you can run a SerialForwarder whose packet source is the serial port; instead of connecting to the serial port directly, applications connect to the SerialForwarder, which acts as a proxy to read and write packets. Since applications connect to SerialForwarder over TCP/IP, applications can connect over the Internet.

SerialForwarder is the second kind of packet source. A SerialForwarder source has this syntax:

sf@HOST:PORT

The first step is to run a SerialForwarder; since it takes one packet source and exports it as an sf source, it takes a packet source parameter just like the other tools we've used so far: you can pass a -comm parameter, use MOTECOM, or just rely on the default. Close your MsgReader application so that it no longer uses the serial port, and run a SerialForwarder:

java net.tinyos.sf.SerialForwarder (GUI)
set motecom to serial@/dev/ttyUSB0:shimmer

or

java net.tinyos.sf.SerialForwarder -port 9003 -comm sf@localhost:9002 (this last part is the source)
This command opens a second SerialForwarder, whose source is the first SerialForwarder. You'll see that the client count of the first one has increased to one. It's rare that you'd ever want to do this, but it demonstrates that in the message support libraries you can use a variety of packet sources.


(http://docs.tinyos.net/index.php/Mote-PC_serial_communication_and_SerialForwarder)
* Spine_serverSide/defaults.properties :
MOTECOM=sf@127.0.0.1:9002 (supply this to tinyos )
LocalNodeAdapter_ClassName=spine.communication.tinyos.SFLocalNodeAdapter

* Run Spine_serverSide/test/SPINETest.java to test!


* VMWARE player - dhcp router? then set Ethernet to NAT and enable network. (eth1)


* Installation tips: http://docs.tinyos.net/index.php/Boomerang_Tmote_Linux_install

Monday, May 11, 2009

Coffee roast May 2009

4 new beans to try.

Rwanda : Horizon Nyamyumba
"Soft and delicious coffee with a good acidity. Lots of fruit - citrus & blackberry aswell as caramel"

Roast #1: A very small bean. Gave the roast 11 minutes at 220. It seemed to go very fast, but it turned out pretty light still. Alot of shells still attached to the beans. Roast#2 will be darker. Interesting to note that no crust formed on the surface. Tastes as advertised, altho the caramel is the most pungent flavor. Maybe a slight darker roast will bring out the rest.

Roast #2: This roast was 15 minutes. There's nothing to be nervous about. The bean can take it. Apparently, this is the reason why there was no crust on roast #1. A light roast is too heavy. Around 14 minutes, the bean started expulsing it's oils and a nice crust has been formed. The coffee is ALOT softer and the flavors are more apparent. A darker roast definately suits this bean. Delicious!

Roast #3+ : ^

Bolivia Primera : Asipai biolatina

"Good sweetness, creamy, pure citrussy with lots of chocolate"

Roast #1:
Roast #2:

Guatemala: Huehuetenango SHB
"Good body with lang, soft aftertaste of flowers and chocolate"

Roasted same day as the Kenya. I took it to the max, got the oils after second crack. Whole thing took about 14 minutes. I thought i'd made it too dark. Day 1 taste was... relatively tasteless, same as Kenya. Maybe dark roasts need to be cultivated longer.


Kenya: Gethubwini AA+

"Large, rich body with classic and wellbalanced acidity. Wonderful sweetness and the classic taste of blackberry anf flowery essence (roses)"

Roast #1: A bit inconsistent. Roasting took longer than expected. Ended up around 15 minutes
Roast #2: Very consistent. Upped the heat some to 230 degrees. First crack at 5-6, second at 10-11.

Taste: After day 1, i wasn't quite sure about this bean. I thought i'd roasted the fuck out of it, but after 3 days, the flavors have come out nicely!

Sunday, May 10, 2009

SHIMMER sensors in SPINE 1.2 on TinyOS

Quicknotes for Cygwin installation:
(TODO: Edit to be something remotely usable in the near future!)

* install cygwin

* install appropriate tinyOS rpm's ($ cd /cygdrive/*drive*/*packageloc* )
* tinyos-tools-1.3.0-1.cygwin.i386.rpm seems to install and compile javatooling for TinyOS including running "tos-install-jni"which installs 32-bit java JNI code into the appropriate JRE.
* The SHIMMER platform requires the TI MSP430 Tool packages. install them with the command 'rpm -ivh --ignoreos '. Without --ignoreos rpm tells you that the package was intended for a cygwin_nt5.1 OS. Warning: installing the gcc package on cygwin, you'll get an error if the current user isn't "TinyOS", and it'll revert to using "root". Unsure of the effect of this sofar.

* Setup permissions and environment
$chown -R /opt/tinyos-2.x
$chmod 666 /dev/ for all necessary devices

* Add to ~/.bashrc:
export TOSROOT=/opt/tinyos-2.x
export TOSDIR=$TOSROOT/tos
export CLASSPATH=`cygpath -w $TOSROOT/support/sdk/java/tinyos.jar`
#export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:. (linux)
export MAKERULES=$TOSROOT/support/make/Makerules
export PATH=/opt/msp430/bin:$PATH
export CLASSPATH="$CLASSPATH;."

* Check environment setup:
$ tos-check-env *

* Create a /contrib/ folder in $TOSHOME. Copy Spine_nodes from the Spine 1.2 dist into tinyos-2.x-contrib folder
* Compile application through a-d. (SENSORBOARD=*boardtype* make *platform*)

At this time, platforms supported by SPINE1.2 are
a. Telosb motes with spine sensor board
SENSORBOARD=spine make telosb
b. Telosb motes with biosensor sensor board
SENSORBOARD=biosensor make telosb
c. Micaz motes with mts300 board
SENSORBOARD=mts300 make micaz
d. shimmer motes
SENSORBOARD=shimmer make shimmer

Without SENSORBOARD defined, make gives you "error: SENSORBOARD not defined"

* Appropriate compilation units are compiled to "contrib\apps\SPINEApp\build\shimmer"
* app.c
* ident_flags.txt
* main.exe
* main.ihex
* tos_image.xml

* Spine app is defined by the following interface / module:
(detailed information about the tinyos app files http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS)


configuration SPINEApp_AppC {
}

implementation {
components MainC, SPINEApp_C;

components RadioControllerC;
components PacketManagerC;
components SpineStartPktC;
components SpineSetupSensorPktC;
components SpineFunctionReqPktC;
components SpineSetupFunctionPktC;

components new TimerMilliC() as Annce_timer;

components SensorsRegistryC;
components SensorBoardControllerC;

components FunctionManagerC;

SPINEApp_C.Boot -> MainC.Boot;

SPINEApp_C.RadioController -> RadioControllerC;
SPINEApp_C.PacketManager -> PacketManagerC;
SPINEApp_C.SpineStartPkt -> SpineStartPktC;
SPINEApp_C.SpineSetupSensorPkt -> SpineSetupSensorPktC;
SPINEApp_C.SpineFunctionReqPkt -> SpineFunctionReqPktC;
SPINEApp_C.SpineSetupFunctionPkt -> SpineSetupFunctionPktC;

SPINEApp_C.SensorsRegistry -> SensorsRegistryC;
SPINEApp_C.SensorBoardController -> SensorBoardControllerC;

SPINEApp_C.FunctionManager -> FunctionManagerC;

SPINEApp_C.Annce_timer -> Annce_timer;

}



* SERVER SIDE (JAva)

java coordinator applicationss implement the SPINEListener interface. Contains:

void dataReceived(int nodeID, Data data)
void discoveryCompleted(java.util.Vector activeNodes)
void newNodeDiscovered(Node newNode)
void serviceMessageReceived(int nodeID, ServiceMessage msg)


Then, the application can use any APIs exposed by the SPINEManager (see some doc somewhere!)


* Create documentation : SENSORBOARD=shimmer make shimmer docs
* docs will be placed in : contrib\doc\nesdoc\shimmer as html documentation
* docs makes use of Graphviz for generating a componentgraph. If it's not found "sh: dot : command not found". Install package from (http://www.graphviz.org/Download..php). But which one?


Compiling SPINE_ServerApp:
Copy $TOSROOT/support/sdk/java/tinyos.jar to /SPINE_ServerApp/ext-lib/
run "Ant"

If appropriate COMport isn't defined, following error is produced:

run:
[java] serial@COM65:115200 died - exiting (java.io.IOException: Could not open COM65: TOSComm JNI library runtime error: Error 2.
[java] The system cannot find the file specified.
[java] in NativeSerialPort.CreateFile)
[java] Exception in thread "Thread-1" org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted.
[java] at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:196)
[java] at java.lang.Runtime.exit(Runtime.java:88)
[java] at java.lang.System.exit(System.java:906)
[java] at net.tinyos.packet.PhoenixSource.error(PhoenixSource.java:221)
[java] at net.tinyos.packet.PhoenixSource.run(PhoenixSource.java:174)

* SIMULATION (TOSSIM)

* run "make micaz sim" from tinyos /apps folders (like Blink) (micaz is the only platform supported by TOSSIM currently). Might requires some of the other native compilers. and definately JAVA (1.5). Exports a python interface.

Links:

http://www.physionet.org/physiotools/cygwin/
http://docs.tinyos.net/index.php/Installing_TinyOS_2.1#Manual_installation_on_your_host_OS_with_RPMs (2.1.0)
http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html (2.0.2)
http://ragemaster.livejournal.com/112000.html
http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS
http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2007-February/022355.html
https://www.millennium.berkeley.edu/pipermail/tinyos-help/
http://docs.tinyos.net/index.php/TOSSIM

http://docs.tinyos.net/index.php/Mote-PC_serial_communication_and_SerialForwarder

Saturday, May 02, 2009

Python: svn pre-commit hook

I put together a python svn pre-commit hook that does 2 things.

* Checks commit message syntax {, orphan} {baseline, tag, integrate}. If syntax does not comply with standards, commit is rejected.
* If syntax contains an activity-id, a ticket repository is checked to locate that specific id. Commit fails if id is not found. If repository connection fails (which shouldn't ever happen), commit is let through regardless.


__doc__ = """
iw_check_commit_messages.py
Utility for doing svn stuff.
"""

import os, string, sys, re, pg
from iw_connect import get_activity_ids #import connect method from iw_connect

SVNLOOK = 'C:\\Program Files\\svn-win32-1.4.5\\bin\\svnlook.exe' #location of SVNlook.exe
authors = {"mk" : "Martin Kjeldsen", "sas" : "Soren Ahm Sorensen", "jo": "Jens Olsen" } #list of fullname authors

syntax_ok = '^(ID|id):(\d+|orphan|baseline|activity|integrate)$' #regexp "tasks"
specifies_activity = '^(ID|id):(\d+)'

def do_lookup(repo,txn, cmd):
cmd = '"%s" %s -t %s %s' % (SVNLOOK, cmd, txn, repo)
result = os.popen(cmd, 'r').readline().rstrip('\n')
return result

def run_reg_exp_task(text, exp, mode):
expression = re.compile(exp)
if mode == "eval":
return expression.search(text) != None
elif mode == "getval":
return expression.search(text)

def parse_commit(repo, txn):
"""
This method parses the log assosiated with transaction txn and takes appropriate action
"""
author = do_lookup(repo,txn, "author") #Determine author
author_fullname = "".join([ v for k,v in authors.items() if k==author]) #if authors fullname isn't in authors dictionary, author is empty.
log_msg = do_lookup(repo,txn, "log") #determine log message

if(run_reg_exp_task(log_msg, syntax_ok, "eval")): #eval TASK: is syntax okay?
if not run_reg_exp_task(log_msg, specifies_activity, "eval"): #eval TASK: does it specify an activity?
sys.exit(0) #exit normally if syntax is okay and we're not dealing with activity id's.
else:
#activity_id = get_activity_id(log_msg) #check database for ID. extract it using a regular exp after it's been approven by the first.
activity_id = run_reg_exp_task(log_msg, specifies_activity, "getval").groups()[1] #get the id from the regexp result
ticket_repository = get_activity_ids() #get ticket repository
if ticket_repository == None: #NONE if connection fails. just commit it. Nothing else we can do. It already passed first test.
sys.exit(0)
elif activity_id in ticket_repository: #is log message activity id present?
sys.exit(0)
else: #reject revision
sys.stderr.write("Dear %s, your revision was rejected. You're trying to commit to an activity that doesn't exist (ID:%s). \n" % (author_fullname, activity_id))
sys.exit(1)
else:
sys.stderr.write("Dear %s, your revision was rejected. Syntax: \nLine 1: {ID|id}:{|orphan|baseline|tag|integrate}\nLine 2+:{Optional: Additional information about activity}" % (author_fullname))
sys.exit(1) #reject revision

if __name__ == "__main__":
print __doc__
if len(sys.argv) <>




__doc__ = """
iw_connect.py
Utility for connecting to a postgresdb using pygresql interface
"""

import os, string, sys, pg

iw_database = 'removed'
iw_host = 'removed'
iw_user = 'removed'
iw_passwd = 'removed'

iw_query = "removed"

def connect():
con = pg.connect(dbname=iw_database, host=iw_host, user=iw_user, passwd=iw_passwd)
return con

def get_activity_ids():
try:
con = connect() #connect to db: details specified in iw_connect.py
query = con.query(iw_query) #Run query to get id's to check in. refactor
ids = [str(v[0]) for v in query.getresult()] #convert result to set of strings
return ids
except pg.InternalError: #if connection fails, just commit it. Nothing else we can do. It already passed first test.
return None

Python: Postgres module import failure

 Traceback (most recent call last):
File "
", line 1, in
import pg
File "C:\Python26\Lib\site-packages\pg.py", line 21, in -toplevel-
from _pg import *
ImportError: DLL load failed: The specified module could not be found.


Solution:
Make sure the PostgreSQL C interface (libpq.dll) is installed or
its directory (\Postgresql\bin) is on PATH.

Thursday, March 26, 2009

On cubing: Quick notes on Edge Orientation (Incl. advanced setup)

1,3 = (M U M U M) U2 (M' U M' U M') U2

1,2,3,4 = (M'UM'UM'UM'U)(MUMUMUMU)

1,2,3,4, 8, 11 = (lUl'U)(lUl'U)(lUl'U)(lUl'U)(lUl'U)

1,3, 5, 6, 7, 8, 9, 11 = (dDrR)(dDrR)(dDrR)

Depending on the amount of flipped edges, it can pay off to apply an alg that fixes a great amount of edges and then fix the damage caused afterwards. This requires rememorization. Sometimes it can also pay off to create layers with 4 unfixed edges and do the necessary setup moves, if they are easy.

It also helps to look ahead when Using the layout 2,3,4,5,6,9 you could flip all U edges, which would now leave edge 1 unsolved but in return creates an entire F surface that can be fixed. Algorithms suting this scenario are shown below. If the layout of your cube is too far off the setups might become too complex, but the scenarios below are not unlikely.

2,3,4,5,6,9 : (M'UM'UM'UM'U)(MUMUMUMU) x (M'UM'UM'UM'U)(MUMUMUMU) x'

More mirror algs based on the above concept:

1,2,4,7,8,11: (M'UM'UM'UM'U)(MUMUMUMU) x' ( M'UM'UM'UM'U)(MUMUMUMU) x
1,2,3,5,8,12: (M'UM'UM'UM'U)(MUMUMUMU) z ( M'UM'UM'UM'U)(MUMUMUMU) z'
1,2,4,6,7,10: (M'UM'UM'UM'U)(MUMUMUMU) z' ( M'UM'UM'UM'U)(MUMUMUMU) z

Wednesday, March 25, 2009

On security: Authenticity

Problem

Two solutions can be employed in order for users to send requests R to a database for data and receive said data. Users have a private RSA key skA, and also know the public key of the database pkD. But one of these solutions has a security problem. Which?

  • The first solution involves the user encrypting R under D’s public key, appending his signature on the encrypted request (RSA = public key system = digital signature), and then appending his username A.
  • The second solution involves the user appending his signature on the request, encrypting this under D’s public key, and appending his username A.

Solution

First method

Using the first method the signature of the message is not encrypted with D’s public key, only the R. Since a User ID is also added to the message, unencrypted, a user B is able to intercept the message, sign it with his own signature, replace the existing User ID with his own, and send it to D. The database now takes A’s request, looks up B’s public key, encrypts the response and sends it to B instead of A. This was not supposed to happen.

Second method

The second method avoids this by encrypting everything with D’s public key and by doing so we maintain authenticity. We can therefore conclude that the second method is the most secure.

(solution to old assignment from dSik)

On security: One-time pads

Problem

We’re trying to compromise a One-Time Pad by applying facts we have about the original message. Bits 0-20 (LSB first) contain salary information. What we’re trying to do is to get the recipient of the salary an extra mill. A message will be mentioned as m, a key will be mentioned as k and a ciphertext will be mentioned as c.

Solution

What do we know? We know that the salary is encoded in m in bits 0-20, and we know that we get paid less than a million per month. This is enough information to manipulate m encoded with a One-Time pad! In binary 1 million has MSB 1, using our own encoded notation. We know
that the one-time pad uses XOR to generate c using k. Knowing the location of the MSB in the encoded message, and knowing what it should be, to get an extra million (1), we can change the original message to our liking. For example, if the bit corresponding to our salary MSB bit in c is 0, and we know that we do NOT get paid a million or more, then the corresponding bit in m should also be 0, which means the corresponding bit in k is 0 aswell. Now we can change the bit in c to our liking, 1, which adds a million to our salary.

One-time pad security

The only reason we have been able to compromise the One-Time Pad is because we have enough knowledge about m, to make certain changes. If we did not know anything about the original message, c would be total jibberish.

(solution to old assignment from dSik)

On Xfiles: Paper Clip

When Mulder and Scully, in the episode "Paper clip", go to the mining facility in west virginia and find all those medical records in what Mulder refers to as a "mountain vault", Scully makes a comment about the tissue sample boxes from 1955 being "old".

Having been abducted in 1994, her own medical records are on file, but with a newer tissue sample box made of plastic. She refers to the sample as having been taken "recently", judging by the tissue sample box, cementing the fact that it couldn't have been instated very long ago.

Now... When they check Samantha Mulders file, the tissue sample box is also a newer. Mulder was born in 1961, and Samantha was abducted when he was 12, meaning she was abducted in 1973.

18 years passed from 1955 to Samanthas abduction, and 21 years passed from Samanthas abduction to Scullys abduction. Either 21 years prior to her own abduction is "recent", according to Scully, or... they were keeping recent tissue samples of Samantha.

I was sure Fox Mulder would've noticed it this time, but he never does.

On Tabletennis : Review - Nittaku Narucross Ex Hard 2.2mm

In this micro-review, i'll be comparing the Nittaku Narucross Ex Hard 2.2mm to Joola Express Two 2.0mm, as FH rubbers.

Background:

For a while now, i've been playing with Express, on both sides of my blade. I feel that Express 1, on an all wood blade like W-6, serves me best as a BH rubber, and i still feel this way. Blocking and counter-hitting is a breeze, and sharp/flat loops down the BH line have become so much easier.

The Express 2, in the FH, also provided me with incredible stability in terms of blocking and counter-hitting. Express is by far the best rubber i've tried for this, no doubt. Both rubbers are incredible for short-play because of their hardness.

However, when being forced around the court, to the point where you need to stretch yourself to your limits to reach a ball, i was finding it hard to perform FH loops that weren't simply acts of desperation, but would allow me to get back into the point with a decent trajectory and lots of spin. Because of the speed/elasticity/hardness of the express, performing loops from that angle became extremely hard. So i began looking for something else that would allow me to improve that part of my game, well knowing that i'd be sacrificing some consistency in blocking/counter-hitting.

Nittaku Narucross Ex Hard 2.2mm:

I'm usually not a big fan of 2,2mm sponges, but i found this lying around at my local TT-store, and i couldn't stand for it lying there by it's lonesome. (I also got a sheet of Renaros Bright 2.2mm, that i'll be testing at some point).

Initial impressions

Topsheet - excellent quality. The tackiest new-tech rubber i've tried/seen. The nittaku protective sheet almost appeared to be wet, when i applied it to the rubber.

Rolling the ball around on the surface, you can feel the friction. Bouncing the ball, you can feel the crispy innards begging to come into play. Even at 2,2mm, you sense that it's somewhat slower than the Express 2 2mm, but the Express is by nature more explosive. Didn't come as a surprise to me.

Hardness - It feels about the same as the Express 2.

How does it play?

Blocking/counterhitting - The first thing i wanted to do, was to test it against the Express 2, because it's so brilliant at 2mm. The narucross seemed to lack the same crisp and consistent bounce, but it's by no means shabby. It keeps you on your toes because of the 2.2mm sponge combined with the hardness. You need to be a bit more active in your strokes which begs precision in execution. It's still a great blocking/counter-hitting rubber, and i'm definately going to keep it for further testing.

Looping - This is where it gets interesting. Brush looping is easier due to the tackier topsheet and slightly slower speed. Getting some crazy spinny angles on your FH loops is easier aswell, because of the exact same criteria. It seems to prefer a chinese style of looping. I was able to squeezy some power out of my loops that i didn't have the confidence to do with the Express, which isn't as forgiving. Narucross now offers me some increased stability in that department.

When chasing those balls at crazy angles, as i mentioned was one of my goals for this rubber, i was able , in full stretch, to put the ball back on the table with lots of spin and low trajectory, allowing me time to get back into the points. Big thumbs up.

Counter-looping - Excellent. There's alot of control in this rubber away from the table, i feel. Decent speed coupled with great spin and control will have you putting balls on the table for a long time. Counter-looping away from the table is mostly about keeping the ball in play, and the narucross offered some great improvements over the Express Two, i felt. Close to the table, i still feel the Express Two has the edge.

Smashing - As i've said earlier, it's a bit slower than the express, but it still packs quite a punch. I do prefer to twiddle my blade and smash with the more seemingly more powerful Express 1.

Conclusion

This one i'm keeping. On an all wood blade it provides some excellent play in every aspect of the game, while not being overly fast/bouncy. Adjusting to a more chinese style of looping, i felt it provided me with faster loops than ever. On odd angles, it provided me with a weapon to get back into the points. Hardness/speed allows for spinny and short services. I'll have to do some more testing, but right now i have nothing negative to say about it. Since it's made in germany, there may be durability issues but i'll get to that.

It didn't quite stack up to Express 2 in terms of blocking/counter hitting, but what's the difference between brilliant and more brilliant? It's not much.

Followers