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:
http://retroshare.sourceforge.net/downloads.html

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.

#!/bin/bash
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
    name=$default_name
fi

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" ..

popd
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.

#!/bin/bash
# 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

Update, 2023-06-13: please refer to the github page for how to use the download and import.
The details on the page are out of date, and a recent import showed some of the issues.

Thursday, December 26, 2013

Installing Armory

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

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

git clone https://github.com/etotheipi/BitcoinArmory.git
cd BitcoinArmory/cppForSwig
./whereispy.sh
make swig
cd ..

Note: 'whereispy.sh' 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 'whereispy.sh'

Now you can run ArmoryQt.py, just to make sure everything works:
python ArmoryQt.py

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/" \
    dpkgfiles/armory.desktop

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.

Friday, September 13, 2013

Downloading and trimming clips

There are two ways to download the clips, and get them the converted for Mythtv (the right times, etc)

1) twitchtv:
# youtube-dl "http://www.twitch.tv/riotgamesoceania/b/457578762"
downloads many parts
# for i in *.flv; do echo "file '$i'"; done > inputs.txt
# ffmpeg -f concat -i inputs.txt -c copy output.mp4

Youtube doesn't need this, because they show up as one file. However, they do still need to be trimmed. If you need to trim it then, mark the times.

For example:
'input.webm' start: 5:27:00 end: 8:28:28
Then you can convert the file with ffmpeg:
# ffmpeg -y -ss 5:27:00 -t 3:01:28 -i 'input.webm' -c copy 'output.webm'

Monday, September 2, 2013

Django logging

Django has a pretty configurable logging facility.

The other day I had to customize error emails in django.

I did this by copying django's AdminEmailHandler, to a local file, and then pointing the logging utility to this.

The django guide has a large configuration that you can strip. Let's strip it down to this:

LOGGING = {
    'version': 1,
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
    },
}
 
Note the default configuration for the class. This is also where you copied the AdminEmailHandler. Point it to the new location that you saved it. I wasn't sure of a good place so I saved it in 'project/middleware/custom_email.py' and referenced it: "project.middleware.custom_email.AdminEmailHandler"

Now all you need to do is change the email handler to return emails the way you want. I stripped out the file so that it was just the classs and the required dependancies, because I didn't want to override other things that I didn't need to.