Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Thursday, January 6, 2011

How to listen to a netradio channel when the firewall blocks the port

TCP port 8000 is being blocked in the customer's premises where I'm currently working. This is a Windows box. Putty resolves the problem easily for me, with some support from a remote FreeBSD setup. A GNU/Linux box would do the same.

1. Configure Putty to forward a TCP port to some local port in the FreeBSD machine.
From Putty configuration,
-> Connection -> SSH -> Tunnels -> "Add a new forwarded port"

  • In the Source port field, type some port, that is the port where you will be connecting to from your media player. Use for example, 8080.
  • In the Destination field, type for example, localhost:8000.

2. Now with Putty's SSH port forwarding configured, SSH to your FreeBSD/Linux account.

3. Now we need to forward the netradio data to the port what is being forwarded to the Windows machine. For that, I'm using wget and netcat. So in the Linux/FreeBSD account, command
 wget -qO-  http://relay5.slayradio.org:8000 | nc -l 8000
The above is redirecting wget's output to stdout and that is then piped to netcat that is listening to local port 8000. That was the port that is being forwarded. Note that in some version of nc, you may need to add the -p switch for it to work, e.g. "nc -l -p 8000".

4. Now, the netradio data is available from port 8080 from the Windows computer. You may now connect to http://localhost:8080/ using your favorite media player and start listening.

Wednesday, October 28, 2009

A good article on the problems in the Finnish startup environment

Finland is Missing the Bowling Alley or How to Find the First Pin

The linked article discusses well why it is hard for Finnish software startups to become major worldwide players.

Wednesday, September 9, 2009

Adding a license text to a set of files using sed

The problem: I needed to add (prepend) a license text to a set of source files.

I thought sed might be a good tool for this task. Having not done anything but trivial sed scripts in the past, I took a look in the web for advice.

I was faced with the following script (I already lost the original URL, I'm sorry):


1{h; r [file]
D;}
2{x; G; }



It needs some explaining. Sed works by maintaining two data buffers: the pattern space and the hold space. A sed execution cycle is performed for each input line. First the input line is placed in the pattern space. Then the commands are (conditionally) executed. Finally, the contents of the pattern space are printed to stdout (if not explicitly prevented). The hold space maintains its contents between two cycles. The pattern space on the other hand is cleared between two cycles.

The GNU sed manual explains the used commands as follows.

h - "Replace the contents of the hold space with the contents of the pattern space."

r [file] - "Queue the contents of filename to be read and inserted into the output stream at the end of the current cycle, or when the next input line is read. Note that if filename cannot be read, it is treated as if it were an empty file, without any error indication."

D - "Delete text in the pattern space up to the first newline. If any text is left, restart cycle with the resultant pattern space (without reading a new line of input), otherwise start a normal new cycle."

x - "Exchange the contents of the hold and pattern spaces."

G - "Append a newline to the contents of the pattern space, and then append the contents of the hold space to that of the pattern space. "


So the program is performing the job as follows. The first set of commands is executed only for the first line of the input. The first line is copied to the hold buffer. After that, the file [file] is queued to be printed to stderr in the end of the current cycle. Finally, the contents of the pattern space is deleted (so that the first line won't be printed just yet).

Now the file [file] (containing the license text) has been printed. Nothing else has been printed. Also, the first line has been saved to the hold space. Looks good. The second set of commands do the rest. These commands are executed for the second line of the input only. First the contents of the hold space and the pattern space are switched. Now the hold space contains the second line of the input and the pattern space contains the first line of the input. Now a newline and the contents of the hold space are appended to the pattern space. The pattern space now contains the first two lines of the input in correct order. Next, the cycle ends and the contents of the pattern space are printed.

No commands are executed for the remaining lines of the input. They are just printed by default. We have printed the license text, the first line of the input, the second line of the input and the rest of the input in correct order - effectively prepending the license text on the input files.

Now considering the license text is located at /tmp/license, the following code is exactly what is needed to do the job for each *.c and *.h files in the current directory.


sed -i '1{h; r /tmp/license
D;}
2{x; G; }' *.[ch]

Friday, June 5, 2009

Software recommendations

It took a while but I have now replaced grep with ack to satisfy my daily grepping needs.

Another tip of the day is that if you are a Vim user you will want to start using ctags to move around in your codebase.

Friday, May 8, 2009

mathURL

This is the greatest tool for a long time. Writing complicated equations in LaTeX can be syntactically tricky. Reinforcements have arrived. MathURL auto-compiles the equations while you write them and shows the result on top of the source code.

Additionally, you are permitted to embed LaTeX equations in your web page. You are provided with a URI to the image. For example, <img src="http://mathurl.com/?img=5euwuy" alt="" /> will emerge as

Wednesday, March 11, 2009

LaTeX: How to change the bibliography heading title

A few months ago I needed this information and now, certainly too late, I found the answer from Ki-Joo Kim's BibTeX guide. It is simply
\renewcommand\bibname{Foo}
Another thing: why must the scripting language used in BibTeX style files (.bst) be so confusing? Anyone knows what this language is, or is this just an adhoc language created for that single purpose? Anyhow, I'd like to find a manual for it.

Saturday, February 28, 2009

Vim users: subscribe to this blog

Regular Vim tips and tricks: http://dailyvim.blogspot.com/. It already saved me once as I had forgotten the very useful @@ sequence that repeats last used macro.

Friday, February 27, 2009

Vim cheatsheet wallpaper

I decided to put a beautiful vim cheatsheet in good use. Usually the right display is enough for my apps (irssi, shell, browser) and the left display is quite empty. So why not use this gorgerous cheatsheet as the wallpaper?

Sunday, February 22, 2009

Hello, autojump

Now everybody go and install autojump! It has quickly proved itself by improving my directory browsing experience in the shell.

Description:

* I remember the software name was "auto..." something, and all my code is in ~/koodi.

Before:
$ cd ~/koodi/auto<tab> <enter>

Now:
$ j auto <enter>

Tuesday, December 16, 2008

Tuesday, March 11, 2008

gltrail - realtime logfile visualization

At work I'm hacking on a software that manages a rather large number of servers over the internet. A month ago I was thinking that it'd be cool to be able to monitor the messages flow between the machines in realtime in some graphical format. I started to do it with Python and wx, but then my motivation went elsewhere and the project got stalled. Today I ended up at fudgie.org which introduces gltrail - a realtime logfile visualization tool, main purpose being Apache access.log monitoring. It's got a strikingly similar user interface that I had planned, although gltrail is way more cool than I could have come up with (just watch the video on the site). Fortunately the software is licensed under GPL so if I later have time and motivation I've got great help now. Thank s/god/rms/ for free software!