Freitag, 22. Juni 2012

Easy rounding with Javascript round() wrapper

Really simple method to easily round with javascript:
function round (number, fractionalDigits) {
    "use strict";
    if (!number) {
    var multiplicator = 1;
    while (fractionalDigits--) {
        multiplicator *= 10;
    return Math.round(number * multiplicator) / multiplicator;

Just pass in the number to round and the number of fractionalDigits you'd like to keep, like:
round(95.12345, 2); will return 95.12
round(95.54555, 4); will return 95.55

If you omit the last param, you'll get no fractionalDigit, like:
round(95.12345); will return 95
round(95.50000); will return 96

One last call: Don't use it as is, create a namespace for it to reside in! 

Or append it to Number, then you can remove the number param. ;)
Number.prototype.round = function(fractionalDigits) {
    "use strict";
    var multiplicator = 1; 
    while (fractionalDigits--) { 
        multiplicator *= 10; 
    return Math.round(this * multiplicator) / multiplicator;

Call it like:
var number = 8.12345;
number.round(2); will return 8.12

Have fun! 

Donnerstag, 21. Juni 2012

Aw, snap when searching with omnibox on chromium

For some days now I get that annoying "Aw, snap" window when I try to search with the omnibox in chromium. What I tried so far:
- clear /tmp
- rm ~/.config/chromium
- rm ~/.cache/chromium
- install another version (19, 20, 21..)

Nothing helped. In a fit of despair I rushed to the settings and checked "Enable Instant for faster searching" (even if I really really don't like that feature). This seems to be a good workaround because the "Aw, snap" page stays away...

Montag, 18. Juni 2012

No longer Skype beta on Linux - Skype 4.0!

Skype 4.0 has been released.
Of course, there's no Slackware-Package available from the Skype homepage. (Who knew? ;))

If you want to upgrade to Skype 4.0 today, you can use this Source-Package:

and build it by using this SlackBuild:

The SlackBuild script linked above has also been submitted to, but currently it's in the pending queue (and I've seen script in the pending queue for about two months, so don't count on that :)).

NOTE: If you're on a 64 bit Slackware you need to add 32 bit librarys. See this page for further information:

Have fun... well, you have fun, I mean, you're using Slackware. :)

Edit: Ahh, finally there's a fresh, warm, approved Slackbuild available.

Sonntag, 10. Juni 2012

Beat me! (laptop power consumption)

- Display off (don't know why backlight still consumes power, any suggestions?)
- wifi blocked via rfkill
- powersave governor
- disabled cpu 123, only 0 active (on the fly)
- hdparm -B 1 -S 1
- vm writeback (60 seconds, stock Slackware)
- disabled fan (loading thinkpad_acpi module via options thinkpad_acpi fan_control=1 (yeah, I cheated :)))
- mounted root with 'relatime' param to reduce disk spin-up
- enabled GPU RC6 mode via kernel params (pcie_aspm=force acpi=noirq i915.i915_enable_rc6=1)

Look at the right to see what laptop I use!