Friday, September 9, 2011

coming soon: memory-mapped db for OpenLDAP

short version:



I just ran across a site with news of a new database backend for OpenLDAP that's designed to be completely mapped to memory and is supposed to be faster, more memory efficient, and much easier to configure:

Memory-mapped Database for OpenLDAP


long version:



I'm a huge fan of OpenLDAP. not only is it the fastest and most scalable implementation of LDAP (see at the bottom for sources), best of all it's open-source. configuring it for optimal performance, however, is easier said than done. you have to configure indexes, the database cache size, the IDL cache size and of course the good ole entry cache size. Howard Chu, the current chief architect of OpenLDAP, describes the process pretty well:

"...it requires careful tuning to get good results and the tuning aspects can be quite complex. Data comes through three separate layers of caches before it may be used, and each cache layer has a significant footprint. Balancing the three layers against each other can be a difficult juggling act."

the good news: that quote comes from a site I just ran across where Chu announces a new database backend that's designed to be completely mapped to memory, known as "back-mdb". in Chu's description of back-mdb, he uses words like "extremely fast," "memory efficiency," and my favorite, "trivial configuration." I can't wait! (yes, I'm a giant nerd)

Chu said back-mdb will be ready sometime this month at the earliest, but whenever it comes, it will be worth waiting for. here's the link if you want to check out the details:

Memory-mapped Database for OpenLDAP

and here are those sources I promised you, ripped entirely from my wiki:

Wednesday, August 31, 2011

A few good open-license Arabic fonts

Edit: I went ahead and put these here so I can maintain them more easily: Open-license Arabic fonts

Did you know the Arabic script is the second most-used writing system in the world? (source)

In case you happen to be looking for a decent Arabic font for your website, software, or publication, I've run across a few good ones that have an open license:
  • DejaVu Sans and DejaVu Sans Mono
    These fonts support a lot more than just Arabic, but they do Arabic quite well. They come bundled with most GNU/Linux distributions. There are other DejaVu fonts, but as far as I can tell they don't support Arabic.

  • Droid Naskh
    This font was created by the Arabic typographer Pascal Zoghbi for Google. You can read more about it here: http://www.29arabicletters.com/foundry/?m=1-1-1&fid=26

  • DroidSansArabic
    This is the Arabic font for the Android OS. it was commissioned by Google and created by Ascender Corporation.

  • Kacst
    A font from the folks behind the Arabeyes project supporting Arabic on *nix. More about this font and other fonts by Arabeyes here: http://projects.arabeyes.org/project.php?proj=Khotot

  • SIL Arabic fonts
    SIL has released two fonts under an open license: Scheherazade and Lateef. Note that these fonts don't contain individual glyphs for all of the forms (initial, medial, final), and so if you use them in an environment that doesn't support the advanced shaping features of OpenType or AAT (such as Android), the letters won't be properly connected.
Currently unreleased fonts:
  • Shasha
    Yet another Google commissioned font, this one appears to still be in progress. Interestingly, it bears a strong resemblance to DroidSansArabic. You can read more about its development here: http://shashafont.com/

  • Ubuntu Arabic font
    (Thanks to Phil R for pointing out this one)
    It looks like Canonical (the company behind Ubuntu) has commissioned Dalton Maag to create an Arabic font for Ubuntu. Nothing released yet, but here are some previews:
    Ubuntu Arabic, in print!
    Hebrew and Arabic on track
Pretty cool to note that Google commissioned 3 of the font families mentioned. Certainly Google isn't perfect, but they do contribute quite a bit back to the community.

Wednesday, August 24, 2011

How to save money when shopping online

I thought since I referenced it in my last post, albeit subtly, I should mention retailmenot.com, which has saved me a ton of money when I shop online.

Just shop like you normally would from your online retailer of choice. When you're checking out, stop by retailmenot.com, type the name of the site in their search bar, and see if there are any available coupon codes for that site before you complete your purchase. It's completely free.

No, I'm not getting paid by retailmenot.com to say this (not that I would turn down such an offer ;)), but there are a lot of coupon code sites out there, and most of them are garbage. retailmenot.com is the only one I've found that isn't worthless.

So try it out. The worst that could happen is you'll save some money. (Actually I suppose it'd be worse if you didn't save any money, but I digress...)

Monday, August 15, 2011

Cheapest way to unlock GSM phones

Looking to unlock your GSM phone? One word: ebay.

Of course you should always shop around and do some googling, if for no other reason than the fact that some phones can be unlocked for free, in particular many nokia models:

Free Nokia Unlock Codes

But if you do end up having to pay, ebay can save you a lot of money. For instance, I recently unlocked a Motorola Defy using a code I bought off ebay for $8 by searching "motorola defy unlock code." By comparison, this is what some of the unlock sites charge for a code to unlock that same phone (I'm including ebay in this list in case people skip right to this part of the post):

ebay: $8
cellunlock.net: $15 ($30 before coupon code)
cellunlocker.net: $30
cheapunlocks.com: $20
gsmliberty.net: $25
unlockgenie.com: $30
unlockitnow.com: $30

I'll let you do the math ;)

Tuesday, August 9, 2011

re-enable second monitor in linux after it goes blank

solution:



  1. if your resolution was also changed, restore the original resolution:
    xrandr -s 0

  2. re-enable your second monitor:
    xrandr --auto

  3. restore any special setup. for example, I have my second monitor to the right of my first, extending my desktop. this is what I did to get it to work:
    xrandr --auto --output DFP2 --right-of DFP1



DFP1 and DFP2 are the names of my monitors, so that command probably won't work for you. in order to get the names of your monitors, in a terminal, run this command to list the connected monitors:
xrandr -q | grep " connected"

if you run this command before you run xrandr --auto, your disabled monitor should show up in the list without a resolution. for example, in my case DFP2 is the name of the disabled monitor:
$ xrandr -q | grep " connected"
DFP1 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 473mm x 296mm
DFP2 connected (normal left inverted right x axis y axis)


to get the possible options for the --output parameter, just run xrandr --help to list them all.


details:



I have a dual-monitor linux setup, and in particular when running full-screen apps using Wine, my second monitor will go blank. once I close the app, my second monitor stays blank, and all my windows are moved to the first monitor.

up to this point I've been too lazy to figure out how to re-enable my second monitor, and I'd just reboot, which always fixes it. today I finally took the time to figure it out.

of course the best solution to any problem is preventing it in the first place. here's a great article I found on preventing this while I was looking for a solution to my problem:

How to Run Fullscreen Games In Linux With Dual Monitors

Monday, July 25, 2011

an intriguing look at software patents

When Patents Attack!



Why would a company rent an office in a tiny town in East Texas, put a nameplate on the door, and leave it completely empty for a year? The answer involves a controversial billionaire physicist in Seattle, a 40 pound cookbook, and a war waging right now, all across the software and tech industries.

listen to it online now, or you can download the podcast for free for a short time:

http://www.thisamericanlife.org/radio-archives/episode/441/when-patents-attack

Monday, July 18, 2011

Python mysqldb UnicodeDecodeError: 'ascii' codec can't decode byte

Solution:

If you run into the error mentioned in the title of this post using python's mysqldb module version 1.2.1 or less, decode your data/query first:

mydata.decode('utf8')

(modifying 'utf8' to whatever encoding your data happens to be in)

Details:

So I was writing some code in python on Ubuntu, and it was working just fine. When I went to run it in RHEL, I got this error:

Traceback (most recent call last):
File "", line 50, in ?
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 146, in execute
query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 223: ordinal not in range(128)


My first thought was that it was due to the incredibly old version of Python that ships with RHEL 5 (Python 2.4), but it didn't take me long to realize the problem was with the MySQLdb module itself. Ubuntu 10.10 ships with version 1.2.2 of that module, while RHEL 5 ships with version 1.2.1. A minor difference, but apparently in that time this bug was fixed:
http://sourceforge.net/tracker/index.php?func=detail&aid=1521274&group_id=22307&atid=374932

Apparently MySQLdb 1.2.1 tries to indiscriminately encode the data to be put into the database to utf8 (well, at least when you specify utf8 as the database character set), without checking whether the string is already utf8 or not. My solution was just to decode my data from utf8 (to unicode) before passing it to my mysql query, at which point the encoding works just fine.

Like so (the first line's the relevant one):

mydata.decode('utf8')
query = ('INSERT INTO %(database)s (%(column)s) VALUES (%(value)s)' % {'database': database, 'column': column, 'value': mydata})
cursor.execute(query)


Of course, you should modify the 'utf8' part to whatever encoding your data is in.

Edit: If you're using MySQLdb.escape_string(), make sure you run that first before doing the decode, like so:

MySQLdb.escape_string(mydata).decode('utf8')