The blog has moved. Go there!

torstai 28. elokuuta 2014

Honor to give a prize to Dr. Richard Stallman #eikönäin

In the Happy Hacking Day 2012 I got the honor to give a prize to Dr. Richard Stallman on the behalf of Haaga-Helia Free Software Group (HHFSG). This was my speech in short:

Dear students, teachers and doctor Stallman. It's been a real honor to have you here as our guest at HAAGA-HELIA. For me personally it has been enlightening to hear some thoughts from the father of the idea that I and Haaga-Helia Free Software Group stand for. For Haaga-Helia this visit is a great opportunity to consider rocking in the free world. Doctor Stallman, thank you for coming!

How to watch YLE Areena videos abroad #eikönäin

How to find out the character set of a database (MySQL) #eikönäin

I was updating my MediaWiki software and just didn't remember what the encoding of my database uses.

How to find out the character set of a database (MySQL) #eikönäin

I was updating my MediaWiki software and just didn't remember what the encoding of my database uses.

Save old Google hits using URL rewrite #eikönäin

Now I'm going to tell you how to save all the Google hits when migrating from domain.com/Article to domain.com/wiki/Article URL structure. I bumped into a situation in which I needed to change a wiki's URL structure to domain.com/wiki/Article. It used to be domain.com/Article.

It's not tricky to change the URL structure but in some cases it may be tricky to avoid losing all the Google hits and backlinks. There is a way to redirect people automatically to the new address including the page they wanted to see when they hit the link on site X.

The natural way to do this is to use .htaccess file because the pretty URL for mediawikis is most commonly done using .htaccess. This is how my .htaccess file looks.


# Enable the rewrite engine
RewriteEngine On

# Apologetiikka.org -domainista luopumiseen valmistautumista
RewriteCond %{HTTP_HOST} ^apologetiikkawiki.org$ [OR]
RewriteCond %{HTTP_HOST} ^www.apologetiikkawiki.org$
RewriteRule (.*)$ http://www.apologetiikkawiki.fi/$1 [R=301,L]

#RewriteCond %{REQUEST_URI} !^/(excluded|index.php|Logo.png|images)
# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]
# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]
#RewriteCond %{DOCUMENT_ROOT}/$1 !-f [OR]
#RewriteCond %{DOCUMENT_ROOT}/$1 !-d
RewriteCond %{REQUEST_URI} !^/(excluded|google64caab6e60d4b917.html)
RewriteRule ^(.*)$ http://www.apologetiikkawiki.fi/wiki/$1 [R=301,L]

Simple form validation with JavaScript #eikönäin

function validateTilaus()
{
if (/.*@.*\..*/.test($('#tilauslomake_email').val()) == false)
{
alert("Sähköpostiosoite on virheellinen.");
}
else if ($('input[name=tilauslomake_amount]:checked').val() == null)
{
alert("Lisää tilaukseen haluamiesi rollappien määrä, kiitos!");
}
else if (/^\D*(?:\d\D*){10,}$/.test($('#tilauslomake_phone').val()) == false)
{
alert("Puhelinnumero on virheellinen!");
}
else if (/.*\ .*/.test($('#tilauslomake_name').val()) == false)
{
alert("Nimi on virheellinen! Tilaukseen vaaditaan sekä etu- että sukunimi.");
}
else if (/.{5,}/.test($('#tilauslomake_address').val()) == false)
{
alert("Toimitusosoite on virheellinen!");
}
else if ($('#tilauslomake_spamfilter').val().toLowerCase() != "2")
{
alert("Täytä myös spämminestokohta, joka estää robotteja lähettämästä lomakkeella spämmiä. Oikea vastaus on kamera.");
}
else
{
document.forms["tilausform"].submit();
alert("Tilauksesi on lähetetty! Palaamme pian asiaan.");
}
}

torstai 31. heinäkuuta 2014

"App not installed" error message on Android #eikönäin

If you got the "App not installed" error message when installing an APK manually, you are probably a software developer who accidentally run cordova build --release android instead of cordova build android.

The problem is that you try to install an APK which claims to be release version but is not signed. If you don't want to sign the package, the you should create a debug package. Not a big difference, but in Android's point of view release package that isn't signed looks like fraud.

So, just run cordova build android and you should be fine.