Wednesday 19 August 2015

Getting usefull subscription notices from YouTube in Akregator and sorting them


I'm a big consumer of YouTube content, it has mostly replaced a TV for me. This has been the case for several years and I've been slowly disappointed by the direction taken by YouTube with regards to managing and following subscriptions. I'm not the only one that has had problems with this, and there are numerous articles/videos/blog posts etc. out there that talk about this.

After YouTube shut down the old subscription page which displaced your subscription as a grid, I've been using YouTube Center which made the subscription page into a grid as well as improving YouTube in so many different ways. But even with this script I was noticing that I was not getting all the content from my 100+ channels and browsing individual channels is a pain.
Therefore I made the switch over to an rss reader, in my case Akregator which works well for me.

In order to get the rss feeds from YouTube one has to get the opml feed from all of your subscriptions. This is done as explained here (NB: I haven't found a way to use the single channel approach).

I had a problem that the feeds, once imported to Akregator were not displayed sorted. This is known and I fixed this by using manually sorting the opml file:

grep "title=" feeds.opml | sort -k2 > test.opml

And then go into vim and remove the lines with "title=" in the original file (feeds.opml) and insert the sorted part
:r test.opml

Now when imported into Akregator the file is sorted.

Friday 14 March 2014

Creating colourmaps enhancing small changes around a centre

Data

The data used for this test is a 2 by 2 matrix made from a sin(x) * sin(y) function plotted on a meshgrid (x and y between -4 and 4). This function has been divided by 10 or 11 on the off diagonal elements, in order to show small variations around 0.

Default colourmap


 

Divergent colourmap

This is the seismic colourmap, which is designed to show bright colours at large values. It does a better job of displaying the data, but it still has some problems


 

My black colourmap

This is my solution to the problem.
I've started with the jet colourmap (could have been any other colourmap) and then added a black part in the centre, which creates a nice contrast in the figure.
In order to not get a nice gradient, the number of colour steps in the map has been increased to 512 compared to the default 256.

Shifting the centre

The method allows for shifting the centre to an arbitrary place, here 0.4


Sunday 27 October 2013

New setup for my raspberry pi

As I described in an earlier post, I have an raspberry pi, which I was running a vpn service, ssh and mumble on. This was working for roughly half a year, though Arch Linux somehow stopped working after not updating properly.

I tried to reinstall everything, though since Arch Linux does not work with BerryBoot I guess it was no surprise.

There has been an update to Debian, so I decided to do the easier step of installing Debian using BerryBoot (over vnc as described in my last post), which worked perfectly.

I could then connect to the server via ssh, user pi, password raspberry.
Change the password with passwd when you have logged in.
Setting up mumble was easily done by
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mumble-server
sudo dpkg-reconfigure mumble-server
sudo iptables -I INPUT -p tcp --dport 64738 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 64738 -j ACCEPT
sudo iptables-save > /etc/iptables/iptables.rules

Remember to forward traffic on port 64738 through your router. The server can be administrated thorough mumble client by setting user name to SuperUser and using the password set above in the reconfigure.
Then I set up the VPN server according to the description from Debian, though with a different config file.
port 1194
proto udp
dev tun
ca      /etc/openvpn/easy-rsa/keys/ca.crt    # generated keys
cert    /etc/openvpn/easy-rsa/keys/server.crt
key     /etc/openvpn/easy-rsa/keys/server.key  # keep secret
dh      /etc/openvpn/easy-rsa/keys/dh2048.pem # I used 2048 bit key
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS routerIP" # Put your router IP in here
server 10.9.8.0 255.255.255.0  # internal tun0 connection IP
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo         # Compression - must be turned on at both end
persist-key
persist-tun
user nobody
group nogroup
status log/openvpn-status.log
verb 3  # verbose mode
client-to-client
Remember to also do forwarding of the VPN trafic.
In addition  the router needs to forward port 1194 (UDP) to the raspberry pi.

If you want to access the vpn server on your android phone you need to generate the key with
./build-key-pkcs12 keyname
From /etc/openvpn/easy-rsa
The resulting keyname.p12 file contains the key and certificate and is the only file you need to transfer to your phone. See this page.


Now you hopefully have a working server.

Saturday 26 October 2013

Not working anymore: My first post is about .... My new Raspberry PI setup, running OpenVPN, ssh and murmur (mumble server)

 This will be my first blog post ever :O, so bear with me in this experiment.

I bought a Raspberry PI a year ago, though it took me nearly 8 months to start it for the first time.

My current setup is what one would call, unnecessary complicated.
Due to the lack of a 4 GB SD card I decided to install the OS on a 4GB USB stick and use a 512 MB SD  card. Also I don't want to connect it to a screen, so I decided to install BerryBoot on the SD card and enable vnc remote management (with the router handing out a static IP) headless BerryBoot.

This worked very well, and allowed me to install Debian on the USB stick.

I got Debian running with remote login via ssh and murmur. Though it didn't want to upgrade properly and I couldn't get openvpn to work properly.

Therefore I deleted the Debian installation and installed Arch Linux through Berryboot (image from http://archlinuxarm.org/platforms/armv6/raspberry-pi), using these instructions which in short and updated are:

sudo kpartx -av archlinux-hf-2013-07-22.img
sudo mount /dev/mapper/loop0p5 /mnt
cd /mnt
sudo rm lib
sudo mv usr/lib lib
cd usr
sudo ln -s ../lib lib
cd /tmp
sudo mksquashfs /mnt Arch_Linux.img240 -comp lzo -e lib/modules
sudo umount /mnt 
sudo kpartx -d /dev/loop0


I made the Arch_Linux.img240 image on my Linux Mint system and copied it to a different USB stick, such that I could use the custom operating system in BerryBoot option.

This worked perfectly and I now had a system running Arch Linux.
I got rid of the root user, and added a normal user with access to run sudo.

Now I went ahead and installed murmur (mumble server) which runs, though it gives a warning at startup related to the qt4 package:

Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)"

In order to get it to work with openvpn, iptables needs to be configured:

sudo iptables -I INPUT -p tcp --dport 64738 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 64738 -j ACCEPT
sudo iptables-save > /etc/iptables/iptables.rules

The last line is to save the rules such that they are persistent on reboot.

Openvpn was set up according to NyxBox – OpenVPN Server on Raspberry Pi
 

Tuesday 18 June 2013

How to visulise the changes in a LaTeX file or project in mercurial

Using mercurial to keep track of changes and share a LaTeX project is very useful and I've had good use of it writing scientific articles with colleagues. The only problem I've found with this is that it is hard to visualise that changes made.  There is a tool for doing something similar,  latexdiff  though it does not integrate into mercurial. One integration for git can be found at Yngve's blog, though it only works for git.

Therefore I decided to write my own python program, using latexdiff,  for comparing changes across different mercurial revisions or the current change. This python program can be found on SourceForge under the project named Hg Diff Latex.
It requires latexdiff (should come with any normal latex installation) and python. It is designed to work on Linux, Mac and Windows, though I haven't had the time to test it thoroughly on anything else then Linux. It should be set as executable for the commands below to work (if not add python in front)


Help for the program can be found using

diffLatex.py -h

If you want to compare the current version in the repository with a previous one, here number 23, and display it in Okular the command would be

diffLatex.py -r 23 -o main.tex

where main.tex is the main file in you latex document.
If you instead want to use the viewer acroread the command would be

diffLatex.py -r 23 -v acroread main.tex

Comparing the changes currently made to the latest in the repository, and opening in Okular
 
diffLatex.py -o main.tex

A neat thing that can be done is to compare to old versions, old1 and old2, (remember to commit your changes before you do this) :

hg update -r old1 # Changing the repository state to old1
diffLatex.py -r old2 -o main.tex
hg update # To get back to the newest  

Here it doesn't matter if old1 is larger than old2, just keep track of what the colours represent.

If there are any issues or comments I would really  like to hear them either here, or on SourceForge.