Wednesday 10 December 2014

Recording desktop session in Gnome

I came across this by accident some time ago, but some reminded me of this again today.

Within gnome-shell you can record you desktop session by simply pressing ctrl-alt-shift-r, this will place a red dot in gnome-shell and to stop again press ctrl-alt-shift-r. A file will be created in your home directory called Screencast from .

Thursday 23 October 2014

openwrt on Actiontec DSL modem

Sorting out some old hardware recently I found a number of old DSL modems and routers and I was curious to know which ones I could re-flash.

One of these was an Actiontec GT701-WG DSL modem, which I was surprised to find would actually take openwrt (after a small hiccup) rather easily and has also got me interested in this piece of hardware.

This particular modem uses AR7-SoC and has an ADAM2 bootloader which can be used to flash the device. This bootloader will listen for ftp connections on 192.168.0.1 for a short window immediately after boot, once connected we can use this FTP session to upload and reflash.

The basic steps I found on the following blog entry and consist of

1. power on DSL modem
2. ftp to 192.168.0.1
3. login using adam2/adam2 for username/password
4. set ftp client to use binary and passive
5. set environment variables for mac_port to 0 (to specificy first ethernet port, this modem only has one ethernet port) and creating a new partition which spans the location of the old kernel and filesystem (this detail is listed in openwrt wiki)
6. set MEDIA to FLSH
7. upload new firmware to new partition we created in step 5
8. Reboot modem

The above instructions looked fairly straightforward so I set off to do this, but I forgot one minor detail, I needed to make sure I was allowing connection through firewall on my machine. After spotting this minor detail, things seemed to be going well until upload to modem ground to a halt. I assumed there might be an issue with the firmware on this device so I tried to flash original firmware back onto it using openwrt instructions. This also failed.

At this point the modem failed to boot, however I was still able to get to ADAM2 FTP.
Doing some searching on related models I came across the following setting when connecting to ftp from linux (from openwrt gt704 page)
# echo 0 > /proc/sys/net/ipv4/tcp_frto

I did not recognise this option from the top of my head, this disables F-RTO, an enhanced recovery algorithm for TCP retrans‐mission timeouts.
Once I had disabled this, the steps above worked perfectly.

This modem now has openwrt installed on it :-)

Next steps (for a future blog once I have a few minutes)
1. update version of openwrt
2. run my own custom application/binary on the modem

Wednesday 9 July 2014

Pretty print JSON

I really need to spend some time looking at things like JSON, however I came across a quick way to pretty print JSON, using json.tool python module.

example from top of script (or from help once imported json.tool module)

$ echo '{"json":"obj"}' | python -m json.tool
{
"json":"obj"
}


Tuesday 1 April 2014

psql - expanded mode

I was looking at some postgresql tables trying to diagnose a problem, the amount of data in the table was making it difficult to see the separate records and not being familiar with what data I needed I could not just select the columns I was interested in.

I had see someone produce some output from a similar table where it was clearer laying out the records and so I was curious how this could be achieved a quick search through the docs mentioned "expanded mode". This can be enabled using

\x on


This gives the output to queries in the following format

select * from random_table;
-[ Record 1 ]------+------------------------------------------
column_1   | some data
column_2   | some other data
-[ Record 2 ]------+------------------------------------------
column_1   | some data 2
column_2   | some other data 2
--------------------------------------------------------------


This was much clearer for me to see what was going on on the terminal.

Friday 21 February 2014

Launching Javascript from new tab in firefox

I had a piece of javascript that would take a case id as an argument and open a page on a ticketing tool and to make use of it I created a bookmark in firefox and assigned it to a keyword.

This means I could use the keyword with the case id in the url bar and open up the case directly, similar to setting up proxy bookmark.

However in the versions of firefox I was using, when a new tab was opened it loads a new tab which did not allow me to run javascript.

One solution to this is to change what loads in the new tab, preferably you do not want to load a webpage every time a tab is opened.
To set what to open in the new tab, open about:config, click on the "I'll be careful, I promise!" button and then search for "tab" in the search box.
There should be a setting browser.newtab.url, right click on this and select Modify and enter the url you want to have in each new tab.
As mentioned you don't want this to load a webpage every time, so I use about:blank.

First post of 2014

What no posts in 2014 yet.

I have been really busy with work and therefore have not managed to play with much fun stuff outside of work.

I aim to add some posts as often as I can.