Archive for August, 2009

Gray Matter Matters

Aug 27 2009 Published by under Programming

I asked a question on probably one of the higher traffic forums, and it was answered within an hour. It still took 3 people to put together the answer because one line of code couldn’t work without the other. I had to have about the same level of technical knowledge to make use of the information and ask the question. What made this answer question style different was that the question was answered immediately unlike some other forums I’ve used. You can see it for yourself here:
Python FTP Most Recent File – Stack Overflow

Coincidence? It was on this website that I first heard of dive into python, the online book I used to learn the language. Except I learned dive into python 3 and asked the question from Google. A lot can be said about the use of the democratic process where knowledge matters.

No responses yet

Shifting Unicode Codepoints

Aug 26 2009 Published by under Programming

While working on a word search generator that translated letter symbols (sort of like cryptograms, except this one’s impossible to solve without the key), php ran out of memory on a rather ordinary function.

function uniord($c) {
    $h = ord($c{0});
    if ($h <= 0x7F) {
        return $h;
    } else if ($h < 0xC2) {
        return false;
    } else if ($h <= 0xDF) {
        return ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F);
    } else if ($h <= 0xEF) {
        return ($h & 0x0F) << 12 | (ord($c{1}) & 0x3F) << 6
                                 | (ord($c{2}) & 0x3F);
    } else if ($h <= 0xF4) {
        return ($h & 0x0F) << 18 | (ord($c{1}) & 0x3F) << 12
                                 | (ord($c{2}) & 0x3F) << 6
                                 | (ord($c{3}) & 0x3F);
    } else {
        return false;
    }
}
function unichr($c) {
    if ($c <= 0x7F) {
        return chr($c);
    } else if ($c <= 0x7FF) {
        return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
    } else if ($c <= 0xFFFF) {
        return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
                                    . chr(0x80 | $c & 0x3F);
    } else if ($c <= 0x10FFFF) {
        return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
                                    . chr(0x80 | $c >> 6 & 0x3F)
                                    . chr(0x80 | $c & 0x3F);
    } else {
        return false;
    }
}
function asc_shift($string, $amount) {
 $key = substr($string, 0, 1);
 if(strlen($string)==1) {
   return unichr(uniord($key) + $amount);
 } else {
   return unichr(uniord($key) + $amount) . asc_shift(substr($string, 1, strlen($string)-1), $amount);
 }
}

Now I understand why there is a need for a lower level implementation of UTF-8 strings by default in php 6. Python support of UTF-8 support has already been included in Python 3.0 released December 3rd, 2008.

No responses yet

A lot of steps for just getting one file

Aug 26 2009 Published by under Programming

If you ever wanted to include PEAR.php in a script, but never installed it before on a shared host, a google search for pear.php download should have solved the problem. On the contrary, following the first links on google is a huge waste of time. In my situation, I only needed pear.php to instantiate a class. The intuitive solution is to just download the file and ftp it to the same location as the file that includes it. That works, except the official installation guide never says that.

No responses yet

What Happened to Searchme?

Aug 09 2009 Published by under SearchJump

As far as searchme goes, it now redirects to google. It did a better job of showing search result previews than GooglePreview.

No responses yet

Python Development

Aug 08 2009 Published by under Windows

Just a few things to note on Quirks:

  1. IBM’s Eclipse x86-64 for Windows is hidden. I can understand that the majority of Windows users don’t care about x86 or x86-64, but why keep the download hidden so that there’s no way to find it through links on the website? Now, the x86-64 version works fine and requires Java x86-64. You won’t have trouble finding Java x86-64 for Windows. It’s a drop-down menu under Operating System.(… I doubt the one for Linux works.) If you google search eclipse 3.5 64 bit, you get Eclipse Downloads and Eclipse IDE for 64-bit Windows and 64-bit Java « LingPipe Blog on Jul 21. I’d pick the second choice.
  2. eclipse Python 3: Python Development with PyDev and Eclipse – Tutorial or Python development with Eclipse and Ant. Again, IBM’s links are outdated.
  3. Becareful, Don’t Look BACK! If you want to write code that can be used on most installations, you’d better write it in Python 2 and use 2to3 whenever you want it to run on Python 3. Try searching for it. You get junk. And more hard to spell stuff.

No responses yet

Setting Up Sabayon Linux Part II

Aug 03 2009 Published by under Linux

If you want to make your system rock solid it’s a long process, but you have to do it sooner or later.

  1. This step is optional if you know how to edit USE flags. http://www.gentoo-wiki.info/Euse
  2. add glibc-omitfp and nptonly to your USE flages in /etc/make.conf.                                        www.gentoo-wiki.info/HOWTO_Optimise_glibc#Enabling_further_optimizations
  3. if your are keen and want to save 90% of the space taken up by localization settings and some compile time, edit the locales. nano -w /etc/locale.gen http://www.gentoo.org/doc/en/guide-localization.xml
  4. delete unnecessary languages
  5. emerge glibc
  6. still staying very basic,  add -malign-double to your CFLAGS, and test it by emerging dillo. www.gentoo-wiki.info/CFLAGS_matrix

Type dillo at the console and press enter.

Tryout the powersave or “standby” in windows.
http://powersave.sourceforge.net/kpowersave/introduction.html#starting

If you still have time, you might like stable transparencies.
http://fluxbox-wiki.org/index.php/Transparency

No responses yet

Setting up Sabayon Linux Part I

Aug 03 2009 Published by under Linux

Do not use kuroo or emerge before completing the following steps :

Simply the console or terminal, type the commands, and hit enter.

su –

sabayon (sudo passwd to change)

emerge –sync

emerge portage

dispatch-conf

u (update)

layman -S

glsa-check -f all

dispatch-conf

u (update)

http://wiki.sabayonlinux.org/index.php?title=Tips

If you are bored with the above, start with detecting your hardware.

cat /proc/cpuinfo

http://www.gentoo-wiki.info/Detecting_your_Hardware

nano -w /etc/make.conf                NOTE: ^ is ctrl

http://gentoo-wiki.info/Safe_Cflags

No responses yet