Crunchytoast.com

What’s better than toast? Crunchytoast!

crunchyt sez:

This is my first website ... after 15 years of making them for everyone else! Hope you enjoy it too.


Having used the iPhone 3G since August 2008, I am definitely a fan (fanboy?) I am currently addicted to Tap Tap Revenge 2, and I probably spend most of my traveling time glued to mobile Safari. However, since the iPhone 2.0 upgrade, I have noticed that only people who don’t ride subways could possibly have designed the “out of range” error alert!

3G or Not 3G, that is the question!
Whilst all men were created equal, some men created 3G networks more equal than others! My carrier in Japan (Softbank) has terrible reception in subway stations. In between stations, don’t even bother (apparently only Seoul, Korea has this Super-3G ability). Since iPhone 2.0 I get endless prompts every time I move between stations saying that I am out of range (duh!) Maybe they can also set the acceleromator to tell me when I’ve fallen over too! The iPhone software designers obviously don’t ride the subway, heck California doesn’t even have one!

Read the rest of this entry »

Microsoft has released it’s vision of the future, circa 2019. This vision centers around ubiquitous touch panels on everything from credit cards to kitchen tables. Whilst futuristic and wow-worthy by today’s standards, will it become another forward looking relic, a la the House of the Future, 1950’s style?

Or check out the original article here… http://www.psfk.com/2009/03/microsoft-2019.html

Here are some of the key technologies needed to make Microsoft’s vision possible:
1. Really big, high fidelity touch panels with fast refresh rates
2. Complex 2D/3D GUIs
3. Speech to text conversion
4. Human language machine translation
5. Location / Touch aware devices
6. Universal short range, wireless communication
7. Digital paper
8. Digital displays integrated into all sorts of furniture
9. Really big “floor arrows”
10. Faded pastel colors (lightsteelblue or olivegreen, I can never decide!!?)

Overall I must say, they have made some excellent eye candy. However I am always impressed by the cleanliness and sparsity of future visions, and constantly disappointed by all the trash that surrounds me in the present.

If anyone sees Microsoft’s vision of the future kitchen, let me know. As an idea I really liked Star Trek food “replicators”, so I wonder what Microsoft has cooking in their culinary labs!?

Well if 0.9.8.1 was tough, this troubled me so much I considered switching to Xapian. Don’t get me wrong, Xapian is a great looking search engine! But after playing with Sphinx for many months, I didn’t want to start from scratch!

The problem started with multi-value attributes (MVA). Basically they don’t work on SUN Solaris in Sphinx 0.9.8. MVAs worked fine on OS X 10.4.x, but the exact same indexes failed on Solaris 10.

For searching lists of related numerical attributes, MVAs are awesome (read: v.v.v.fast). So I gave it a few hours and finally got it working.

The main things to note here are:
** Sphinx 0.9.9-rc1 cannot find libmysqlclient.so.15 without adding it to LD_LIBRARY. On Solaris you use the crle tool to add directories to this list. the ldd command displays the runtime linkages for you. Being a runtime linkage, Sphinx will compile without doing this, but will fail at runtime.

** Linkage to the pthread library was actually the first failure. This library was not linked in previous Sphinx 0.9.8.1.

user# wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9-rc1.tar.gz
user# su
root# crle -l /lib:/usr/lib:/opt/csw/mysql5/lib/mysql

root# export PATH=$PATH:/usr/xpg4/bin
root# LDFLAGS="-R/opt/csw/mysql5/lib/mysql/" CFLAGS="-m64"
root# ./configure --prefix=/opt/csw --with-mysql --with-mysql-includes=/opt/csw/mysql5/include/mysql/
      --with-mysql-libs=/opt/csw/mysql5/lib/mysql/ --libdir="/lib/libpthread.so"
root# make & make install

Okay, so the Sphinx Freetext Search Engine is a game changer. Easy easy to index, easy to integrate into PHP / Rails / Django, unbelievably fast (esp. compared to database freetext engines) and easy to install.

Okay, so the easy to install thing doesn’t apply to Solaris! The main issue is linking differences because Solaris library and bin directories and more common Linux variants. Here are my notes on installing on a Solaris 10 accelerator running on Joyent.

user# wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
user# su
root# export PATH=$PATH:/usr/xpg4/bin
root# LDFLAGS="-R/opt/csw/mysql5/lib/mysql/" CFLAGS="-m64"
root# ./configure --prefix=/opt/csw --with-mysql --with-mysql-includes=/opt/csw/mysql5/include/mysql/
        --with-mysql-libs=/opt/csw/mysql5/lib/mysql/
root# make && make install

Okay, so it wasn’t so hard. But it’s hard breaking the Windows Installer addiction after so many years.

Return to acts_as_taggable_on

February 15th, 2009

The Rails tag plugin acts_as_taggable_on is a handy drop-in feature set for adding tags to your RoR applications.  The documentation is slightly more than minimal, and upon peeking under the hood, you find almost no comments.

I am in the process of adding a caching table that will be updated asynchronous to the user request life-cycle. In doing so I documented EVERYTHING in the main file.

If this helps, please leave a comment or trackback.
I’ll get round to publishing the caching system once it’s done and dusted.

The original plugin is here:

http://www.intridea.com/2008/6/9/acts-as-taggable-on-grows-up
http://github.com/mbleigh/acts-as-taggable-on/tree/master

Alternatives I passed over are here:

http://www.juixe.com/techknow/index.php/2006/07/15/acts-as-taggable-tag-cloud/
http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids

The plugin’s functions re-documented:

###################
# acts_as_taggable_on
###################

# EXAMPLE
####################

class Record  "archive"
@rec.mytag_list = "boring, boxy, brown"     # Sets tag list
@rec.tags                                   # => [,,]

# AR RELATIONSHIPS:
####################
@rec.mytag_taggings   # References related records on "taggables" table
@rec.base_tags        # References related records on "tags" table

# INSTANCE METHODS:
####################
@rec.tag_types                  # [:associations, :tags]
@rec.is_taggable?               # true
@rec.is_taggable?               # confirms if tags can be added?
@rec.custom_contexts            # ??
@rec.add_custom_context(value)  # ??
@rec.set_tag_list_on(:mytags, "some, tags")   # Context version of tag_list=
@rec.tag_list_on(:mytags)                     # Context version of tag_list()
@rec.tags_on(:mytags)                         # Context verison of base_tags()

# Dynamically created based on tag contexts
@rec.#{tag_type}_list                                   # Context :mytags ... mytag_list()
@rec.#{tag_type}_list=(new_tags)                        # Context :mytags ... mytag_list=
@rec.#{tag_type}_counts(options = {})                   # Context :mytags ... mytag_counts()
@rec.#{tag_type}_from(owner)                            # Context :mytags ... mytag_from()
@rec.find_related_#{tag_type}(options = {})             # Context :mytags ... find_related_mytag
@rec.find_related_#{tag_type}_for(klass, options = {})  # Context :mytags ... find_related_mytag_for()
@rec.find_related_on_#{tag_type}                        # Alias of find_related_mytag
@rec.tag_counts_on(:on => :mytag)                       # Returns tags of the provided context

@rec.related_search_options                             #
@rec.reload_with_tag_list                               #
@rec.save_cached_tag_list                               # called by :before_save filter
@rec.save_tags                                          # called by :after_save filter

# SINGLETON METHODS:
####################
Record.tagged_with("awesome", :on => :skills)     # Get all tags
Record.find_tagged_with("comp", :on => :tags)     # same but does not uses "named_scope"
Record.caching_tag_list_on?                       # Is it in the cache
Record.tag_counts_on(:on => :skills)              # Get counts for tag context
Record.find_options_for_find_tagged_with          # Gets query options for retrieving
Record.#{tag_type}_counts(options={})             # Context :mytags ... mytag_counts()
Record.find_options_for_tag_counts(options = {})  # Gets query options for counts

# CACHING METHODS (incomplete!)
#######################
@rec.caching_#{tag_type.singularize}_list?
@rec.caching_tag_list_on

** Looks for column called "cached_#{context}_list" on the acts_as_taggable record table
** Not tested much by the original author, but should update before saving via filter

###################
##    acts_as_tagger
###################

# EXAMPLE
####################
class User  "cabinet, document", :on => :mytags)   # adds the tags to @rec in the specified context
@rec.mytags_from(@user)                             #  returns taggings applied by user to @rec

# AR RELATIONSHIPS:
####################

@user.owned_taggings        # Returns all "taggings" belonging to user
@user.owned_tags            # Returns all tags by join "taggings" belonging to user on "tags"

Pretty easy stuff eh? If only I didn’t have an urge to share my working notes with the world.

Cluster Commands

mongrel_rails cluster::stop
mongrel_rails cluster::start
mongrel_rails cluster::restart

Stand Alone Commands

mongrel_rails restart
mongrel_rails stop

As many of you know, languages such as Japanese, Chinese & Korean use more than one byte (8-bits) to represent single characters. Because there are so many of them, 8-bits simply does not provide a large enough code space to map them all.

Here is a short treatise on how to deal with these issues!

The Simple Rules of Moji-Ba-Ke

Garbage In = Garbage Out ... if the data you send to the browser becomes mangled (moji-bake) your user will see trash characters. If you specify the wrong character set in your META headers, your browser will render the page incorrectly, again causing moji-ba-ke, sometimes in random places on the page. This can also affect your AJAX by destroying the integrity of DOM elements.

When handling CJK character sets, you must be sure to use UTF8 character encoding throughout the life cyle of your program. This includes database storage & retrieval, string manipulation in your code and  displaying in the browser.

So What is UTF8?

UTF8 handles binary streams of data, not strings. As you know characters are represented by combinations of 0s and 1s. ASCII characters have a maximum of 8 bits (a combination of 8 zeroes and/or ones). However UTF8 characters can be composed of 6bits, 8bits, 12bits, etc… As such, UTF8 is prone to what Japanese call “moji-ba-ke” …. roughly pronounced “moe gee bah keh”.

As a programmer, from database to codebase to browser, you should try and use UTF8 completely. For email you can use UTF8, but you will probably find most mail servers and clients are still old and use a mishmash of different character sets (e.g. ISO9022X for Japanese).

Database Settings

If you are a mysql user, then make sure you have to ensure all connections to the DB use UTF8, and that all tables/fields use UTF8. By default mysql uses Latin (Swedish) character sets. Those kooky swedes love their jokes!!

Checking your Codebase

In my experience editors like Notepad++, Notepad2, UltraEdit, e, TextMate, etc… all have UTF8 support problems. They mostly work, but since their developers don’t use CJK languages themselves, they are not perfected. Issues like turning off BOM (Byte Order Mark), mangled tabs, poor character set conversion, etc … all present problems.

I highly recommend using a proven UTF8 editor like Maruo. This is made by a Japanese company, but there is an English version (and a trial version) at http://hide.maruo.co.jp/software/bin/maruo614_signed.exe

Lastly, you may need to convert your source files into UTF8. Especially if the codebase itself has CJK language strings contained therein.

Manipulating Strings

Any string function need to multibyte safe. Notice I didn’t say double-byte. UTF8 is not a double byte but multibyte, depending on the total number of bits used to represent a character. In PHP you need to call the MB string functions specifically. Ruby and other languages have more transparent support, but you need to check the docs for your flavour of application server!

META Tags

Check out google.co.jp or yahoo.co.jp for their META headers. These are sites that know how to to it properly. Basically include the following META tag the doucment <HEAD>

<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>

It is usually safe to mix English HTML document type attributes with the above character too. So adding the META tag above seems to work in a HTML document that has:

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>

Email

This is a wholly different can of worms. UTF8 works a lot, but many older Japanese clients use ISO2022X more. This is not worth covering here (well, not for me!)

Debugging UTF8 Issues

Once you have a reliable UTF8 editor like Maruo, you can create static pages and resolve your issues.

Summer Sonic 2008

August 10th, 2008

MGMTThe Kooks kooking out!Coldplay busking at their own concert

Another rock festival under the belt, and it was definitely worthwhile. As promised the drab, uninspiring Chiba Marines Stadium was hot, massive and filled with some pretty awesome acts.

Starting with MGMT we got into festival mood and worked up a thirst. Later 311 went through their set with ease. Though not my cup of tea usually, the atmosphere was friendly, the music stimulating and hot, hot, hot!

The Kooks and the Japanese bilingual group “Radwimps” put all their youthful energy into it, making for a memorable late afternoon. Alicia Keys and Coldplay showed why they were top international acts, with the staging budgets to prove it! We were even treated to a Coldplay and Alicia Keys collaboration (Alicia on piano, of course).

Riding the train home from Summer Sonic 2008, I really come to appreciate how hard it is to type quickly on the iPhone. But with the day behind us, the feeling of satisfaction, drying sweat and general dehydration will send me off to dream land, in fitful slumber, just as
soon as we get home!

Thanks for Stopping By

August 9th, 2008

This is my first website … well not exactly. It is “my” first website. After more than 13 years of making websites, software, web systems - you name it - for everyone else for, I finally have made my own doormat on the web. Just for me, but you’re welcome to look.

Currently CrunchyT is using an off the shelf WP theme. Being a “time poor” perfectionist, I finally decided to just get on with it. Recently at work I have been doing a lot sales. This has made me very “judicious ” with my time. This blog is the result!

Stick around, there will be some interesting things from time to time. Thanks for stopping by.