Friday, April 3, 2020

hamster-time-tracker hack

We use Hamster Tracker to keep track of our hours here at work (then we have a script to copy them into our timesheet database).

I didn't like the upgrade, but our work machines were upgraded to debian 10.

I ported the copy over following these steps:

1) copy from working system:
- /usr/bin/hamster-time-tracker
- /usr/lib/python2.7/dist-packages/hamster/
- /usr/lib/python2.7/dist-packages/gtk-2.0/
- /usr/share/hamster-applet
2) install packages:
- python-gtk2
- python-dbus
- python-dirspec
- gconf-service

Thursday, March 3, 2016

Simple Kodi installation from Minimal Ubuntu

First go here to Download a minimal ubuntu cd:
Debian also will work, but I'm used to ubuntu...

Then run the following script:

# First do a minimal ubuntu install
sudo add-apt-repository ppa:team-xbmc/ppa  && \

    sudo apt-get update && sudo apt-get upgrade && \
    sudo apt-get install openbox nodm kodi xorg
sudo sed -i 's/NODM_USER=.*/NODM_USER='$USER'/' /etc/default/nodm
sudo sed -i 's/NODM_ENABLED=.*/NODM_ENABLED=true/' /etc/default/nodm
echo -e '#!/bin/bash\nopenbox &\nkodi' | sudo -u $USER tee /home/$USER/.xsession

This will set up Kodi to automatically start when you turn on your computer.

Saturday, August 29, 2015

Setting up Retoshare to share files

There are plenty of guides out there about setting up Retroshare06, but I'll add my own.

Setting up Retroshare

1) Download retroshare here:

2) Install it

3) Set up the key
As it says, the name is what your friends, and their friends, will see you as. This name is not public, unless you go out of your way to connect to large groups of people.
For Node, I've usually used my computer name, since I give all my computers names.

4) If you know how to set up a port forward in your network, doing that is advised to help your friends connect to you better. If you do that, then go to:
Options -> Network
Then set "Automatic UPnP" to "Manual Firewalled", and type in the port that you forwarded.
If you don't do this, you will probably be fine if you connect to at least one friend who sets up port forwarding. If you connect to me, you'll probably be fine.

5) Go to "Add" and choose either "Enter Certificate manually" or "You get a certificate file from your friend". In the case of the former, you'll copy and paste the key. In the case of the later, you'll import and export a file. The later seems simpler, so let's use that.

6) So you need to exchange keys at this point. You need to give your key to your friend, and they need to give you their key. Click the "Export My Certificate..." button, and save the key to your desktop.
If you're curious, this is your public key. This can be shared safely with anyone who you want to send you data.

7) Send this key to your friend, perhaps via email.

8) When they give you their key, (let's assume a file) go back to the Connect Friends Wizard (Add, if you closed the window) and drag the key to the text box near the "Browse" button.

9) Click Next. The default options are good (and you can always change them later), so click Finish.

Downloading and browsing files:
You're connected to your friend, and assuming they've set up file browsing up properly, you should be able to search their files. Let's look through their files, first, and then you can see how to share some of your own files with them.

1) Click File Sharing
2) Click Search: Here you can type in a file name to search across all collections.
3) Click  "Friends Files" and you can see a list of all the files that are browsable.

You can then right click on a file to download it, and it'll show up in your "Downloads" tab.

Retroshare does a lot of other things, that are interesting, and a pretty cool way to do distributed communication etc. But sharing files directly between computers is pretty powerful.

Saturday, September 27, 2014

Download and merge multiple video files (from twitch or youtube)

Last year I posted how to download and merge clips manually, recently I threw together a script that takes a twitch video, downloads the mp4 files, and them merges them all.

You'll have to download and compile ffmpeg which is a hassle, but since I use this script often it's worth the trouble.

tempfolder=$(mktemp -d --tmpdir=./)

pushd $tempfolder
read -p "Input the date (YYYY-MM-DD): " date
echo "files:"
youtube-dl -e $@    # lists the file titles
echo "choosing one"
default_name=$(youtube-dl -e $@ 2>&1| head -1)
read -p "Name is $default_name. Override?: " name
if [ -z "$name" ]; then

youtube-dl $@
file=$(mktemp --tmpdir=./)
for i in *.flv; do
    echo "file '$i'";
done > $file
ffmpeg -f concat -i $file -c copy "$date - $name.mp4"
mv "$date - $name.mp4" ..

rm -r $tempfolder

The script will actually take multiple links as well, and concat them in order according to the twitch IDs.

Psql Snapshot

Ever want to make some temporary changes to a (test) database, that you can't do with just commits? I can't remember why I needed this, but it looks handy.

# This was to create a quick snapshot of the database, make the changes I
# wanted, and then revert the database to exactly the way it was before I
# snapshotted it.

/etc/init.d/postgresql stop
umount /var/lib/postgresql/
lvcreate --snapshot --size 1G --name postgres-snap /dev/vg0/postgres
mount /dev/vg0/postgres-snap /var/lib/postgresql/
/etc/init.d/postgresql start

read -p "Press enter to start watching. And then ^C to drop the snapshot and switch to the old database" zzz
watch lvs

/etc/init.d/postgresql stop
umount /dev/vg0/postgres-snap && /sbin/lvremove --force /dev/vg0/postgres-snap
mount /var/lib/postgresql/
/etc/init.d/postgresql start

Transwiki copying

I was working with someone to set up another copy of a wiki, and I found that there was a way to download the wiki pages (/wiki/Special:Export/), and that using this it was possible to import them also:

So I thought I'd try scripting it.

Downloading the pages was the "easy" part. I had to toy around with some things, but I managed to throw together a wiki downloader.

It scans all the pages (from /wiki/Special:AllPages) generates a list of files (which can be cached) and then goes through and downloads each one individually in a folder that you specify.

The three main chunks to download are:
- categories
- files
- templates
- pages (main)

There's a switch for each one on the script. For the complete thing, include all 4.

You can merge the files into one file:
(echo ""; cat *.xml | grep -Ev "^<\/?mediawiki.*?>"; echo "" )  > ~/xml-download.xml
And transfer that to your host, but I had problems loading the large file with mediawiki's php script, so I just transferred each small file. (It crashed part way through, and I had to start over, I wasn't watching so I don't know why)

I'm doing the import on hostmonster, so I had to modify the php.ini file. I added the following to a local configuration:

Then I changed directory to the folder with the folders I uploaded and ran this:
find . -type f | while read f; do echo "processing $f"; php -c /home/user/php.ini /home/user/public_html/site/maintenance/importDump.php < "$f"; sleep 1; done

I added the 'sleep' because I was afraid over clocking might kill the process on hostmonster. But that might not be needed.

Rebuild recent changes (as requested) after loading everything.
php -c /home/user/php.ini /home/user/public_html/site/maintenance/rebuildrecentchanges.php

I also ran 'rebuildall' but I can't remember why.
php -c /home/user/php.ini ./maintenance/rebuildall.php

Import the images:
php -c /home3/user/php.ini /home/user/public_html/site/maintenance/importImages.php /home3/user/public_html/site/path_to_files/

Thursday, December 26, 2013

Installing Armory

The Armory installer isn't quite up to date. The installer I found on their website: had RAM leaking issues.

sudo apt-get install git-core build-essentials python-dev \
    python-psutil swig pyqt4-dev-tools bitcoind

git clone
cd BitcoinArmory/cppForSwig
make swig
cd ..

Note: '' is run by 'make swig'. I ran it first just to make sure I have all the dependencies, since make swig swallows the errors in ''

Now you can run, just to make sure everything works:

I decided that I wanted to "install" it, so I copied the folder to /usr/lib/
cd ..
sudo mv BitcoinArmory /usr/lib/armory

Adding the desktop icon:

I decided to update the armory icon, since it was pointed to an icon pack I didn't install.
cd /usr/lib/armory
sed -ie "s/Icon=.*/Icon=\/usr\/lib\/armory\/img\/armory64x64.ico/" \

chmod +x dpkgfiles/armory.desktop

Then copy it to your list of local applications:
cp /usr/lib/armory/dpkgfiles/armory.desktop ~/.local/share/applications/

Now the a launcher shows up in unity, with the right icon.