Blog

Because knowledge matter

Explore, comment, share. Knowledge is best given to others.

Google Drive and many disks

So, you are the new happy owner of Google Apps Unlimited, and can store tons of files in your Google Drive. Then you have several computers you want to sync between. To make this easy, let’s say you have 2 computers, where both have 2×1 TB disk. But you do different stuff on the different computers, and you want to make the most of your Google Drive, so you still have the files if you computer(s) crashing. So how do you do this?

Well, your first problem is that Google Drive reside on only one disk, usually under c:\Users\<username>\Google Drive. How do you make use of your brand new shiny 1TB disk which you have mounted on D:, and use the space on C: as well?

The answer to this is first to sort your stuff by different directories. So let’s say you have some videos you’ve made. What you do is to make a directory D:\Videos. There you put all your shiny videos. You can even use up all your 1 TB space for those videos. Then you start up a command prompt as administrator [win-X Command Prompt (Admin)], and you type:


mklink /D "C:\Users\<youruser>\Google Drive\Videos" "D:\Videos"

And voila, you have a symlink in your google drive to the D:\Videos, which is now available as Google Drive\Videos. Give it a minute before you see Google Drive start to sync it.

But you don’t want to have the videos on your other computer? Easy, just turn off the directory in your Google Drive->Preferences->Sync options.

Chess VM 2014 analyser

For those following Chess VM with Magnus Carlsen and Viswanathan Anand, I suggest you try http://analysis.sesse.net/.

The site is made by Steinar H. Gunderson. Chess analysis by Stockfish (main analysis: 20×2.27GHz Haswell-EP, multi-PV search: 12×2.3GHz Sandy Bridge). Moves provided by FICS. Hosting and main analysis hardware by Studentersamfundet i Trondhjem. JavaScript chessboard powered by chessboard.js.

Changing files in a directory structur

Had to help a friend which was moving his site from an “ancient” php version to a new one, where you have to change all the <? to <?php. This had to be done on all sub directories, and only on .html and .php files. I felt a one-liner tingling in my head, so here it is:


find . \( -name "*.html" -o -name "*.php" \) -print | xargs sed -i 's/<? /<?php /gm'

Happy changing.

List a directory with millions files on linux

I needed to list all the files in a directory which had a lot of files, actually 4060276 to be exact. Usually I do this with ls or find, but with ls it used over 600 MB memory, and a lot of time. So I set out to find a better way of doing this. I found a post “You can list a directory containing 8 million files! But not with ls..” which explained the problem. But I wasn’t happy with compiling a C program to do this. That’s not very easy to do on all servers, so, as the Perl guy I am, I resorted to Perl to find an easier way. And as usually, Perl ftw 🙂

Turns out the readdir function can do this directly:


#!/usr/bin/perl

my $dir = $ARGV[0];
opendir(my $dh, $dir) || die;
while(my $file = readdir $dh) {
   print "$dir/$file\n";
}
closedir $dh;

The nice part about doing it this way is you get the files right away. With ls you have to wait until it has read all the files before it starts to dump the content to disk.

Viewing DVDs in programs like ProPresenter

Sometimes you want to be sure that the DVD works through your presentations. That’s when you rip them first, and play the files instead of the DVD directly.

So, how do you do it. There is a ton of programs to do this for you. One program is Any Video Converter Ultimate, which will cost you money. If you don’t want to pay for it, one way would be to to first rip the film with MakeMKV to make a .mkv file. Then you install the Any Video Converter Free and convert the .mkv file into eg .mpg (choose output Video Files, MPEG-II Movide (*.mpg)) . The .mpg file can be used directly in ProPresenter.

But you don’t want the adware, so remember to choose “Custom Installation (Advanced)”, and turn off “Download and install SafeFinder toolbar” when you install Any Video Converter Free.

 

Failing to play mp3 and video in chrome on Android

I run a download site for a choir where they can download the songs the conductor has recorded for them to learn. The site is password protected so only the members can reach it. A couple of days ago I got a message than some of the users hadn’t used the site on their phone lately, since it didn’t work. I hadn’t done anything, so I was curious why. I started to investigate and found a post:

https://code.google.com/p/chromium/issues/detail?id=110309

This issue is an old bug where chrome didn’t read large mp3 files, so though some say it was the bitrate, it actually was the size of the file. But after trying to change the files without any luck, I was wondering if it was something else. And after awhile I found the real problem.

https://code.google.com/p/chromium/issues/detail?id=319885

Chrome didn’t forward the authentication for the site to the music/video player, and therefore the music player wasn’t allowed to read the mp3 file. I tried some workaround, but didn’t find any good solution which was transparent for the admin and users.

But, the next day I got an update for chrome on my phone, and it worked again. So, if you have this problem, you need to upgrade chrome to the latest version on your phone.

First post

Hey, I got the first post on my blog. Impressive. There will be more to come. Hopefully you will find something of interest here.

%d bloggers like this: