Wednesday, January 09, 2013

Nano find and replace

Nano is a great little tool for doing quick stuff on linux. (vi is too!).

To do a find and replace using nano use "Ctrl + \"

Tuesday, December 11, 2012

9 Books on UX Design for the Budding UX Designer

Essentially my UX skills suck and I need to start reading some books on UX design. According to the internets these are where I should get started.

1. A Project Guide to UX Design
Russ Unger
(NLB Singapore | Amazon)

2. The Elements of User Experience
Jesse James Garrett
(NLB Singapore | Amazon)

3. Don't Make Me Think (Seems Highly Recommended)
Steve Krug
(NLB Singapore | Amazon)

4. Content Strategy for the Web
Kristina Halverson
(NLB Singapore | Amazon)

5. Information Architecture for the Web
Peter Morville / Louis Rosenfeld
(NLB Singapore | Amazon)

6. Designing Web Usability
Jakob Nielsen
(NLB Singapore | Amazon)

7. Modular Web Design
Nathan Curtis
(NLB Singapore | Amazon)

8. The Inmates are Running the Asylum: Why High Tech Products Drive Us Crazy and How to Restore the Sanity
Alan Cooper
(NLB Singapore | Amazon)

9. Observing the User Experience
Mike Kuniavsky
(NLB Singapore | Amazon)


If you know any others, or have any comments on the above, I'd love to know.

Linux recursively find and replace in files from command line using sed



find ./ -type f -exec sed -i 's/original_string/string_to_replace/' {} \;


As found on this page: http://www.jonasblog.com/search-and-replace-in-all-files-within-a-directory-recursively

Monday, November 26, 2012

Magento getShippingRatesCollection Methods



Magento: Show all shipping options for the item in your cart.

Because sometimes you might need to do this:

$quote = Mage::getSingleton('checkout/cart')->getQuote();
$rates = $quote->getShippingAddress()->getShippingRatesCollection();

foreach ($rates as $rate)
{
echo "
Shipping Method: " . $rate->getMethod();
echo "
Shipping Method Title: " . $rate->getMethodTitle();
echo "
Shipping Method Description: " . $rate-> getMethodDescription();
echo "
Shipping Price: " . $rate->getPrice();
echo "
Carrier: " . $rate-> getCarrier();
echo "
Carrier Title: " . $rate-> getCarrierTitle();
}

Tomcat WEB-INF on Ubuntu

Is here on my machine:

/var/lib/tomcat6/webapps/ROOT/WEB-INF

Sunday, November 25, 2012

Dynamic Canonical Links in PHP and RackSpace Cloud Issue with Google indexing "static.cloud-ips.com"


Using RackSpace cloud as a server is pretty sweet. One thing you need to look out for is Google indexing your server space from the "static.cloud-ips.com" reference rather than your domain name.

RackSpace suggest setting the canonical URL link, as do Google:
http://googlewebmastercentral.blogspot.sg/2009/02/specify-your-canonical.html



When you've already made a site with thousands of links this might be a bit of a problem. Never mind, here's a dynamic way of setting the canonical link in PHP:


Get Country Name from Magento Checkout/Billing Details

Like so: $checkout = Mage::getSingleton('checkout/session')->getQuote(); $billing_addr = $checkout->getBillingAddress(); $country_name = Mage::getModel('directory/country')->load($billing_addr->getCountryId())->getName(); echo $country_name;

Tuesday, November 20, 2012

Help Needed On Decision to Upgrade to a Mac Book Pro

I have an old MacBook from the 2007 era. At the risk of being labelled as a fan boy, I really really like it. I've pimped it out with a 7200rpm drive which I dug very very hard to find in Sim Lim Square, Singapore, and 4 gig of RAM which is about as pimped as it will allow me to. Don't ask me if I'm a Mac or a PC because my straight answer is that I'm more of a Commodore 64/ZX Spectrum and Atari ST520 guy. With its age, it does get me funny looks from the schoolkids doing their homework on much newer machines in the Coffee Bean & Tea Leaf where I spend my days coding and crafting up silly tech ideas.

In a few years time it will be awesome enough to be ironic but, like Georges St Pierre of the MMA, it has seen better days and is causing me problems in the departments of 1) MS Word crashing ever 10 minutes and 2) needing a fan/heatsink thing to sit underneath it. It does do me well, and it can run XCode as well as a bunch of other apps pretty smoothly (so long as the heat sink & fan are used underneath it).

Here's a picture of the beast in action with my 1Tb, Sonic the Hedgehog drive.




So here's what I'm thinking, I'm thinking that the new MacBooks are gonna be wayyyyy better than my current old beast which is almost six years old. That's ancient for Singapore standards.
On that note, I went to the lovely Apple website and found a shiny new entry level MBP for SGD$1688. I don't need the retina display since I use my laptop mainly plugged into an external LCD monitor. So it should be good enough for me.

Then I looked at the specs. Compared to my six year old MacBook there doesn't seem to be much of a difference. Worst still, the hard drive in the newer Mac is a 5400RPM one. Do 7200RPM drives not exist anymore? Here's how they compare:



So my question is: Should I bother upgrading to an entry level MBP and then pimp it out? Or is it not going to be worth the effort and just stick to plodding along with my trusty old MacBook and save up S$5000 for the monster of a 12 core desktop Mac? Apart from aesthetics, what will the benefits be if I change my current MacBook to a new MBP? How much better is the bus speed, hardware, etc in the new MBP? Is it gonna change my life and make me 10 times more productive?

Or should I just spend my money on coffee and more cooling apparatus for my workhorse?


Friday, November 16, 2012

javascript replace space

str = str.replace(" ", "-"); or, better: str = str.replace(/\s/g, "-");

Wednesday, November 14, 2012

Restart Apache on Mac

If I had a dollar for every time I forgot how to do this.

I'd have a lot of dollars.

How to restart Apache on a Mac:

sudo /usr/sbin/apachectl restart



Friday, November 02, 2012

Find network prefix length for Android Galaxy Note

If you know the subnet mask, it can be translated by these values:

 255.255.255.255 = 32

 255.255.255.0 = 24

 255.255.128.0 = 17

 255.255.0.0 = 16

 255.0.0.0 = 8

More about subnet masks and prefix lengths here: http://www.cisco.com/web/about/ac123/ac147/archived_issues/ipj_9-1/ip_addresses.html

Wednesday, October 17, 2012

Hey, the BlackBerry 10 Might Not Suck


Ok, so RIM have released a demo for the BlackBerry 10 and it looks like it won't be as big a 'fail' as all your hipster friends might try to convince you. Yes BlackBerry is associated with crudgy businessmen. Yes you're still probably thinking they have keyboards (and keyboards are apparently uncool now), or worse - clunky attempts at touch screens, and yes RIM is Canadian. Does this stop it from being able to launch a smartphone that can push it back into the bleeding edge of innovation once again? Perhaps. Does it stop the BlackBerry's chances of being a smartphone leader again? Not at all. RIM is here to stay and will keep fighting to, at least, stay with the competition for now. Maybe there's an opportunity for RIM to dominate the business apps market and cater for hyperlocalized killer apps in various regions around the world. From watching the video, here's a couple of thoughts that passed through my mind.

Trying Too Hard For Social?

From the demo posted on TechCrunch, it looks like the phone is heavily geared towards integrating all your social feeds and just about everything into one shared inbox. Nice idea but it seems that they are trying just a bit too hard with this to keep up with the social media wave. Where has your innovation gone BlackBerry?

Interface Looks Good

With its fluid transitions and seemingly well engineered (note: engineered not 'designed') interface it looks like accessing all the features on the device will be convenient. Let's hope that it doesn't get slower over time like its ancestors did.

Ok, so it doesn't have a keyboard.

Ok so this might be the deal-breaker for me. The BlackBerry 10 has an on-screen keyboard. I'm not a fan of these at all, as you've probably gathered from reading this couple of blog posts where I've been yarping on about it. They've tried to put in some features such as predictive phrases which seems interesting. If they manage to make the on-screen keyboard 80% as good as a physical keyboard then they're onto a winner for me.

Ahhh. A webkit enabled browser

RIM have finally gotten the idea that a webkit enabled browser is the way to go. No more memory leak riddled BlackBerry internet browser. Awesome.

Don't let me forget the scumbag BlackBerry Though

Ok so my BlackBerry Bold 9700 was a great phone for the keyboard and the battery life. It also gave me the easiest email management system I've ever used. Although I'm not going to forget all the 'UGH' moments I had with it. Such as: having to use a firmware flash to delete the sample pictures (I just wanted them gone), difficulty in getting the phone to work with multiple languages, lack of apps, the crappy 'below standard' 256mb memory card it came with, constant crashing, difficult set-up to get my wifi working, STUPID MOBILE PROVIDER BIS PLAN, and the end-of-life 'pretending to be out of memory' all the time issue. Ok rant over.

BlackBerry are not dead yet and don't seem to be dying. The BlackBerry 10 puts me in mixed emotions. It is good to see that they are still trying, but I'm not 100% sure if they are trying in the right direction. If the battery life lasts as long as the Bold 9700 I had, then I'm gonna be halfway sold.


Saturday, October 13, 2012

Friday, October 12, 2012

Download failed.: Failed writing body (415 != 13032)

You need to free up some space on your server or web hosting service.

So I Upgraded from A BlackBerry to a Samsung Galaxy Note... and Here's How It Went

So after months of people making fun of my BlackBerry Bold 9700, which in my opinion was a fine phone and still would be if it didn't crash to heck (and have all sorts of other silly problems), I upgraded to a Samsung Galaxy Note. Here's how it went.

BlackBerry Bold 9700 Smartphone

My Reason for Upgrading BlackBerry to Samsung Galaxy Note

Ok so apart from the social pressure amongst my hipper, cooler, friends who all use either an iPhone or some sort of Android. The BlackBerry was starting to get really really really slow. Despite not having many apps, it was taking a long time to receive and open emails and it was starting to crash when composing them. I also guess it was time to move on to a larger, touch screen interface because EVERYONE ELSE has one. Oh the wisdom of the crowds.

Email Gripe

The first thing that struck me about the Android based phone is the lack of a decent email client. This is very striking when you have been spoiled so much with the BlackBerry mail service. Android is really lacking a great email tool. Especially for those who manage and maintain multiple email accounts. Later, I found a great tool for email on Android, called AquaMail. Which I'll be blogging more about in another post.

Keyboard Gripe

To me, the keyboard on the BlackBerry was 100% bonafide AWESOME. I could type on it whilst doing 5 other tasks at the same time. Yes I know I shouldn't be doing that but the deal is that I do want to be able to type messages to my friends while I'm walking down the street without the fear of walking into a lamppost. Typing on the Samsung was a real pain at first. Unfortunately, although I've gotten to grips with it a bit, two months later I still can't type anywhere near as accurately or as quickly as I could with the BlackBerry.

OK. Time to address the elephant in the room. The Samsung Galaxy Note is MASSIVE.

It doesn't fit in my pocket and it sure as heck doesnt sit comfortably in my hand. Carrying it around is like carrying one of those FiloFax things from the 80s. Maybe in 20 years time people will be blogging about doing things that remind them of this phone too.

Oh yeah, and the battery.

The battery on the Galaxy Note drains faster than the fuel tank of a Lamborghini. Leaving it on the bedside table at night, I always observe that it has drained by about half by the time I wake up. I sleep about 6-7 hours on average. I guess that's a tradeoff of having the huge screen. There are countless battery manager apps out there... but meh. The best investment for this is a good USB cable, so you can charge it constantly whenever you're at a PC or laptop, and an external battery pack (or car charger if you drive). Road-warriors might have trouble with this.

Saying all this though, there are some things that I really enjoy about the phone. Ok so here's why the Galaxy Note is awesome:

Samsung Galaxy Note

It's MASSIVE

It's not quite a tablet, but comes in close. It is really useful for surfing websites that are not optimized for mobile yet, purely because of its huge screen size.

Apps Apps Apps

This will seem really lame to anyone who has had a smartphone for a long time, but having the Google Play Store at my disposal has but me in contact with a load of apps. (Btw. I'm not completely app store naive, I do have an iPad). No longer do I have to wait and hope that BlackBerry will get a certain app in the next few months (which my hipper, cooler friends have already gotten bored of it).

The Camera is Great - But that's normal these days isn't it?

Maybe it is a sense of depravation from the crappy camera that my BlackBerry had, but the camera on the Galaxy Note is right up my street.

It has a stylus, and sometimes you just NEED a stylus

Ok so Steve Jobs, with all due respect for the man, abhorred the concept of having a stylus on any of his iProducts. He though that we were more comfortable using our fingers like primates to poke and point at the screen. I could argue that this is not true, because how many of us have been using a pen to write with rather than our fingers for most of our life? Sometimes we just need a stylus to write notes and scribble on things in a controlled way. Which is what the Samsung Galaxy Note, with its huge screen, excels at. The stylus is pretty nifty too, with its side button that is used for taking screenshots, and probably lots of other features that I don't know about yet.

Concluding Remarks - For Now

I guess I could write a much longer post about it. In essence, I'm pretty happy with my Galaxy Note. The only gripes are those that I've mentioned above. I hope upgrades to the operating system work on making the battery life last longer and some more intuitive keyboards could be released by third party developers.

Thursday, October 11, 2012

Empty log file for Apache on Mac

Sometimes the error log and the access log get a bit out of hand when developing.
To wipe the contents of the error log or the access log in Apache on MacOS. Open terminal and run the following commands:

sudo apachectl stop

cd /var/log/apache2/

sudo newsyslog error_log

sudo newsyslog access_log

Then delete the old ones if you need the disk space back:

sudo rm error_log.0

sudo rm access_log.0

You can then start apache again:

sudo apachectl stop

Mobile browser redirect htaccess dolphin


Dolphin on my Samsung Note doesn't give 'dolfin' as the user-agent. The user agent can be tweaked on the device itself by tapping on:

More->Settings->User Agent

You'll then be given the following options:


user agent of dolphin on samsung galaxy note
1. Android

2. Desktop. Which identifies as: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16"

3. iPhone

4. iPad

4. Custom (I guess you could set a custom user-agent such as 'dolfin' if you really want).






Monday, October 08, 2012

Where is the Application Loader on Mac?

Macintosh HD->Developer->Applications->Utilities->Application Loader

As in the image:

application loader mac snow leopard