Saturday, November 1, 2008

Ikea hack: monitor shelve

Ikea hacking is all the rage these days. When you can't find exactly what you want the price of their products allows you to hack it into exactly what you need without feeling guilty about it. My solution is not so much a hack but more an insight into using the product for some other purpose.

My desk at home was a real mess, you'll just have to trust me: I did not take a before picture. I realised most of the trouble would be solved if I would make a shelve on which I could put my monitor. All the loose routers and other devices would slide right under. And if I did not use my Electribe it could slide under as well...

Walking through the Ikea I realized they did not have the product I was looking for. Then I noticed a display for the Effectiv filing cabinets, and there was this perfect base with ajustable legs.

So I brought it home, assembled it (no missing pieces, yihaa!) and started to clean up my desk. Here's the result:

Thursday, October 30, 2008

Disconnect GPRS connection if your NIC is connected

This is a VBScript I created some time ago. It will connect your GPRS connection if your NIC is not connected and disconnect the GPRS connection if the NIC is connected. It will work with other dial-up connections as well.

The script will run as a service with SrvAny and will reconnect the GPRS connection if the connection was dropped. I'm using WMI to determine the status of the LAN connection. For some reason I did not find the correct status of the GPRS connection in WMI and needed to use the output of ipconfig to determine if GPRS was still up.

Dim Shell, Hell, GPRS, ExecuteObj, strcmd, GPRSConnected

On error resume next

Set Shell = CreateObject("WScript.Shell")
strComputer = "."
GPRS = "0"

Do
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapter Where NetConnectionID = 'Local Area Connection'")

For Each objItem in colItems
If objItem.NetConnectionStatus = 7 Then
If GPRS = "0" Then
' Wscript.Echo "LAN connection disconnected!"
Shell.Run ("rasdial GPRS"), 0
GPRS = "1"
End if
Else
If GPRS = "1" Then
' Wscript.Echo "LAN connection connected!"
Shell.Run ("rasdial GPRS /DISCONNECT"), 0
GPRS = "0"
End if
End if
Next

If GPRS = "1" Then
Set ExecuteObj = Shell.Exec("ipconfig.exe")
Do While Not ExecuteObj.StdOut.AtEndOfStream
strcmd = ExecuteObj.StdOut.ReadLine()
If Instr(strcmd, "PPP") > 0 Then
GPRSConnected = "1"
End if
Loop
If not GPRSConnected = "1" Then
' Wscript.Echo "GPRS connection disconnected!"
Shell.Run ("rasdial GPRS"), 0
End if
Set ExecuteObj = nothing
Set GPRSConnected = nothing
End if

Wscript.Sleep 10000

Loop Until Hell="Freezes over!"

Automate HTML form submission

I needed to make a large amount of changes that would require me to open a form, fill it in, submit it and repeat this hundreds of times. I really did not have the time to do this so I needed a quick way to automate this process.

First let's take a look at part of the form I needed to fill in:

<form method="POST" action="/cgi-bin/script.cgi">
<input type="radio" name="brand" value="product1">Product 1
<input type="radio" name="brand" value="product2">Product 2
<td>User: </td>
<td><input type="text" name="username" size="20" id="fp1"></td>
<input type="submit" value="Submit" name="submit">

So there's a radio button to select a product and a textbox to submit a username. The data is then posted to the script.cgi script. Now, how would we automate the process to fill this form from a script? I chose to use cURL to submit the data to the script like this:

curl -d "brand=pin&username=product1&username=user&submit=Submit" http://myserver.net/cgi-bin/script.cgi

The parameter -d tells cURL to HTTP post data. The data is specified between the quotes, first a value name and then the value data. Different values are seperated by the & character. Remember to figure out what part triggers submission of the code and to add this value as well. In my case "submit=Submit".

Now all you need to do is use your favorite method to call cURL and enter the correct data between the quotes. I used Bash and chose to read the data from CSV files.

One more thing: I needed to post a slash in one of the values ("server.net/user") and got strange results. As it turned out I needed to escape the data like this: "server.net%2Fuser". You can find a complete list of HTML escape characters here.

Monday, October 27, 2008

Sync Windows Mobile with multiple Exchange servers

It's been a long time since I updated my blog. My new job keeps me busy I guess.

I needed to sync my Windows Mobile smartphone to the Exchange server of my employer and the server of the customer I work for. WM cannot sync to multiple Exchange servers out of the box. Also, I didn't like the security settings that came with the ActiveSync connection to one of the Outlook WebAccess servers. Also I did not want to sync my personal appointments to either server.

I've found a very nice tool that would run on your smartphone and sync to the OWA server: Chronobis. This tool gets the calendar and contact information from your OWA server and syncs your phone, either one way or bi-directional.

Chronobis only supports one Exchange server so I needed to find a way to sync my Outlook calendar to the phone. As I'm running Outlook in a virtual machine I was not able to use ActiveSync and a cable.

For now I sync Outlook with a seperate Google Calendar using Google Calendar Sync. Then I use ActiveGCSync to sync my phone with Google Calendar. This works but of course my PC needs to be on to do the syncronisation between Google Calendar and Outlook.

If this all sounds to complicated, you might take a look at http://www.scheduleworld.com/. They give the option to sync multiple sources. For me that was not an option as one of the OWA servers is not publicly available.

Until my next post: goodbye!

Tuesday, April 29, 2008

Charge USB devices in your car

I've switched to USB chargers for all my gadgets. Even if it didn't come with a USB cable as standard I've either bought a suitable cable or in some cases created my own. For devices that use 5V at less then 500 mA that is easy. Just cut and strip a USB cable and connect the positive lead of your cable to the positive lead of the USB cable (usually green). Do the same for the negative lead.


Now, how do you charge all the devices in your car? You can get car cigarette power to USB converters. But they usually have only one connection. This is how I fixed that.

1. Get a suitable case and a 4 port USB hub that is bus powered.
2. Place the USB hub in the case and make a hole to pass the cables through. (Left)
3. Connect the USB adapter, USB hub and your USB cables.
4. Get a car cigarette extension cord an connect the USB adapter. (Center)
5. Close the case and place it in a convenient location, like under a chair. (Right)



Now I noticed some things I need to solve. When all cables are connected I'm pulling to much current from the USB adapter and it tends to run hot. Also some devices appear to be charging but are in fact not.

Thursday, April 3, 2008

Pandora is dead, long live Deezer

Pandora is not dead but to me it might as well be, it's no longer available outside the US. You could use these tricks to get it going but it's to much pain for me.

Now I've discovered Deezer and I like what I see. It is not as intuitive as Pandora yet but it has some nice features. I can for instance share music I like in a simple player like this:

free music



That's Boards of Canada by the way.

Thursday, March 27, 2008

Still alive!

Don't worry I'm still alive, I just haven't had time to finish any posts on my blog. I recently started my new job at Sogeti.

As you can see in the graph below the amount of visitors keeps growing since feb. 2007. Thanks for the nice reactions!