Ainakaan ero ei ole kaksinkertainen

8. lokakuuta 2015 klo 14.47
Sijainti: Blogit: kieli
Avainsanat: matematiikka

”Jos lukuarvot ovat 1,8 % ja 3,7 %, niin onko ero pari prosenttiyksikköä vai kaksinkertainen?”

Ainakaan ero ei ole kaksinkertainen. 1,8:sta kaksinkertaisen päässä on 1,8 + 2 * 1,8 = 5,4. Tämä muistuttaa sitä, miten usein näkee kirjoitettuna ”kaksi kertaa enemmän”, vaikka tarkoitetaan pelkästään ”kaksinkertainen”. (Esimerkkilukujasi käyttäen 3,7 % on noin kaksinkertainen 1,8 %:iin verrattuna, muttei kaksi kertaa enemmän kuin se.)

Vastaa viestiin sen kontekstissa (kieli)

A smart weapon for a specific use

6. lokakuuta 2015 klo 12.03
Sijainti: Muut: Mozilla Add-Ons
Avainsanat: Firefox

I prefer to use anchors closest to the point when communicating links. Unfortunately on many websites those anchors are hard to pick up using basic browser features. Typically, you’ll have to dig into the page source and manually copy the element id you want.

This add-on does that for you. That’s all it does, and for such specific use the no-frills approach is perfect.

As a bonus, the developer is friendly and issues can be easily raised through Github. (Not that such a simple tool should have many, but the one I had was fixed in no time.)

Vastaa viestiin sen kontekstissa (Mozilla Add-Ons)

Just tested it and can confirm it works.

6. lokakuuta 2015 klo 11.54
Sijainti: Vianhallintajärjestelmät: Github
Avainsanat: Firefox

Just tested it and I can confirm that it works. Thanks a lot! I’ll post a review on AMO right after this.

Vastaa viestiin sen kontekstissa (Github)

720p original from NASA: Missions Take an Unparalleled Look into Superstar Eta Carinae

5. lokakuuta 2015 klo 19.10
Sijainti: Muut: reddit
Avainsanat: NASA, tiede

720p original from NASA: Missions Take an Unparalleled Look into Superstar Eta Carinae

Vastaa viestiin sen kontekstissa (reddit)

My first quick implementation of the ”full page as key” idea

4. lokakuuta 2015 klo 10.46
Sijainti: Keskustelupalstat: Library of Babel

Here’s my first quick implementation of the ”full page as key” idea:

Save page as key:

(function () {
    localStorage.setItem('libraryOfBabelKey', document.getElementById('textblock').textContent);
}());

Decrypt using previously saved key:

(function () {
    var alphabet, c, i, m, text, key;

    alphabet = 'abcdefghijklmnopqrstuvwxyz,. ';
    key = localStorage.getItem('libraryOfBabelKey');
    if (!key) {
        alert('No key has been saved.');
        return;
    }
    text = {
        original: document.getElementById('textblock').textContent,
        decoded: ''
    };

    for (i = 0; i < text.original.length; i += 1) {
        c = text.original.substr(i, 1);
        if (c === '\n') {
            text.decoded += c;
        } else {
            m = alphabet.indexOf(key.substr(i, 1));
            text.decoded += alphabet.substr(((alphabet.indexOf(c) - m) % alphabet.length), 1);
        }
    }
    document.getElementById('textblock').textContent = text.decoded;
}());

Vastaa viestiin sen kontekstissa (Library of Babel)

Already noticed the first mistake

4. lokakuuta 2015 klo 9.03
Sijainti: Keskustelupalstat: Library of Babel

You’re right Jonathan, using one whole page to decipher another would also be interesting. It’d take a bit more code (temporary storage is needed for keeping the previous page) but it still shouldn’t be too difficult. The pages could then be considered as having been encrypted with a one-time pad, which is unbreakable and thus a cool idea in itself.

I already noticed the first mistake in my code above: I forgot to strip the page number from the title prior to use, but it should be, as numbers aren’t part of the alphabet. Here’s a fixed version that takes out the page number and whitespace preceding it:

(function () {
    var alphabet, c, i, m, text, title;

    alphabet = 'abcdefghijklmnopqrstuvwxyz,. ';
    title = document.title.replace(new RegExp('[^abcdefghijklmnopqrstuvwxyz,\. ]', 'g'), '');
    title = title.substr(0, title.length - 1);
    text = {
        original: document.getElementById('textblock').textContent,
        decoded: ''
    };

    for (i = 0; i < text.original.length; i += 1) {
        c = text.original.substr(i, 1);
        if (c === '\n') {
            text.decoded += c;
        } else {
            m = alphabet.indexOf(title.substr(i % title.length, 1)); /* add "+ 1" if you want A = 1, B = 2,... instead of A = 0, B = 1,... */
            text.decoded += alphabet.substr(((alphabet.indexOf(c) - m) % alphabet.length), 1);
        }
    }
    document.getElementById('textblock').textContent = text.decoded;
}());

Vastaa viestiin sen kontekstissa (Library of Babel)

Vigenère cipher

3. lokakuuta 2015 klo 15.09
Sijainti: Keskustelupalstat: Library of Babel

Here’s a piece of JavaScript I made that uses the book title as a Vigenère cipher keyword to decrypt the page content. You can paste it directly into the browser’s URL bar on a library page to decrypt. (I made it in a hurry so it comes with no warranty!)

javascript:(function () {
    var alphabet, c, i, m, text, title;

    alphabet = 'abcdefghijklmnopqrstuvwxyz,. ';
    title = document.title;
    text = {
        original: document.getElementById('textblock').textContent,
        decoded: ''
    };

    for (i = 0; i < text.original.length; i += 1) {
        c = text.original.substr(i, 1);
        if (c === '\n') {
            text.decoded += c;
        } else {
            m = alphabet.indexOf(title.substr(i % title.length, 1)); /* add "+ 1" if you want A = 1, B = 2,... instead of A = 0, B = 1,... */
            text.decoded += alphabet.substr(((alphabet.indexOf(c) - m) % alphabet.length), 1);
        }
    }
    document.getElementById('textblock').textContent = text.decoded;
}());

Vastaa viestiin sen kontekstissa (Library of Babel)

mah trypophobia!

3. lokakuuta 2015 klo 12.17
Sijainti: Muut: flickr

mah trypophobia!

Vastaa viestiin sen kontekstissa (flickr)

Thanks for looking into this

3. lokakuuta 2015 klo 10.34
Sijainti: Vianhallintajärjestelmät: Github
Avainsanat: Mozilla, yksityisyys

All right, thanks for looking into this — whatever the outcome.

Vastaa viestiin sen kontekstissa (Github)

Ah, James Jeans

30. syyskuuta 2015 klo 19.15
Sijainti: Videosivustot: YouTube
Avainsanat: James Jeans

Ah, James Jeans. I’ve worn the trousers invented by him!

Vastaa viestiin sen kontekstissa (YouTube)

« Uudempia - Vanhempia »