May 15, 2013

XDebug

So - followed the steps to paste the phpinfo() output into the following webpage: http://xdebug.org/wizard.php. Pasted the instructions, followed the step where it said "add the following line to php.ini".

Few notes:

  1. XDebug needs the full path.
  2. The link above will say to just add zend_extension="path to dir". That is wrong. It needs to be the full path, including the directory, to  the xdebug dll.

Apr 10, 2013

WAMP MySQL Data File Location

Took me a few minutes to realize the default location for MySQL installation is under C:\wamp\bin\mysql\mysql5.5.20\data, whereas I was expecting it to be located under the C:\ProgramFiles\MySQL\ folder.

Mar 22, 2013

Creating SSL Certificates

Needed to do a bit of searching on the exact steps to create a ".cer" certificate. The default ssl-keygen will generate public and private keys, but this isn't enough for some applications. Some need a signed X509 certificate, which involves a couple extra steps. Note, because the certificate will not be signed by a trusted certificate authority, your browser/application may throw a fit and complain the certificate has errors. If that's the case, you can purchase an actual certificate from Verisign (very expen$ive) or from GoDaddy or some other lesser priced Certificate Authority your computer trusts. (Note, you could become your own certificate authority if you have complete control over the machines using your certificate. In which case, you can sign your own certificates and the browsers/apps will never complain).

Okay - let's get started. The following steps worked for me, and since I'll forget them, I've written them down as I'll likely need them again in the future.

First, run the ssh-keygen tool. 
cachedmemory>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cachedmemory/.ssh/id_rsa):
(Press Enter to accept the default location)
Enter passphrase (empty for no passphrase):
(Enter a passphrase if you like - it's more secure if you do)
Enter same passphrase again:

Your identification has been saved in /home/cachedmemory/.ssh/id_rsa.
Your public key has been saved in /home/cachedmemory/.ssh/id_rsa.pub.
The key fingerprint is:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx cachedmemory@localhost
The key's randomart image is:

You should have two files created in the default folder: id_rsa and id_rsa.pub. These are your private and public keys. Woo hoo!

Okay - lets get cracking on generating that certificate things like browsers use, the X509 certificate.

cachedmemory> cd .ssh
cachedmemory> openssl req -new -x509 -key id_rsa -out unsigned-cert.csr -days 1095
(Enter whatever values you feel are necessary.)

You now have a .csr file you can use. All set!



Mar 7, 2013

Good to have when editing icons for Android:


  • drawable-ldpi (120 dpi, Low density screen) - 36px x 36px
  • drawable-mdpi (160 dpi, Medium density screen) - 48px x 48px
  • drawable-hdpi (240 dpi, High density screen) - 72px x 72px
  • drawable-xhdpi (320 dpi, Extra-high density screen) - 96px x 96px

Mar 1, 2013

InputStream vs. InputStreamReader

Came across this lovely gem. When reading a binary stream in Java, don't use an InputStreamReader. The issue I ran into is when casting a read() into a byte, the value wasn't always what it should be. Luckily when I ran the checksum it failed, otherwise I problably would have never realized this. Reading the start of each packet was working, as did reading the expected number of bytes after the start of the packet. "Works" is a loose term, it was returning data, just not what I expected.

Feb 25, 2013

Android Database

Seems the process to import an Android database isn't as simple as just dropping a SQLite database into your project. If the database doesn't reside in the "/data/data/<project name>/" directory, Android may have issues reading the database correctly. In addition, the primary key column names need to be "_id". Finally, there needs to be a table in the database that has some additional metadata:


CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')
INSERT INTO "android_metadata" VALUES ('en_US')


What needs to be determined is how this will work in locales outside en_US.

Final thought is in regards to file size. It seems if you don't give the database a specific file extension, Android prior to 2.3 will not decompress assets in your APK if it is larger than 1MB. The 300k word dictionary looks to be about 6MB, so this would fall under that restriction. I'd have to rename it to something like "mp3", so that the android packaging tool will not try to compress it.

Note, copying the database over to the "/data/data" may only be necessary if the database is intended to be written - if the database is read-only, this may not be necessary. I'll need to investigate this further.

Helpful resources:



Feb 22, 2013

SQLite Foray

In getting started with using Android and local storage, the simplest and most recommended approach is to use the SQLite database. This is the same technology used for HTML5 local storage and has been around for quite awhile.

I was curious about the performance, so I ran a simple test: Query 280k text records (inserted via alphabetical order).

Before I get to the results, here is a tool to avoid that I used: SQLite Database Browser. The reasons are simple:

  1. It freezes on you if the syntax is invalid.
  2. Importing 260k+ records was going to take over an hour (compared to less than 5 seconds with the tool I ended up with)

The best tool I was able to find, which is also free, is SQLite Studio. The website looks a bit sketch. Maybe that's how they roll in Poland, or maybe after they steal my credit card information by installing a keyboard sniffer, they'll be able to give it a facelift.