while($alive) LiveAndLearn();

JavaScript, PHP, C# and Life in Viet Nam

After upgrading to Mountain Lions problems

without comments

After installing Mountain Lion my MacPorts installation started acting funny, and my Apache server (installed through port) didn’t work anymore, the installation of Mountain Lion had re-activated the built-in web sharing Apache server.

A guide to install MacPorts on Mountain Lion is available here: http://www.macports.org/install.php

I followed the guide upgrading Xcode to version 4.4.1, then installed the command-line tools, but then I kept receiving this error message when I continued with the MacPorts installation:

Error: Can’t run /Developer/usr/bin/xcodebuild (no such file).

I could not call xcodebuild from the terminal anymore, but then I stumbled upon a setting in Xcode’s preferences where I could choose which command-line tools I wanted to use, a bit silly since there were only one option:

Screen Shot 2012 08 16 at 11.54.34 PM 300x212 After upgrading to Mountain Lions problems

If the drop down box appears empty, then click on it once to activate the command-line tools for 4.4.1

I found this to be the easiest way to restore my command-line tools, and now I’m going to continue my MacPorts installation, perhaps I’ll run into more problems as I continue…

2012.08.19 3:47 – Update: Still not done with MacPorts installation icon sad After upgrading to Mountain Lions problems it stalled at Gimp, turned out that:

sudo xcodebuild -license

was necessary to install Gimp.

It wasn’t long before I was stucked again, because the latest version of MongoDB from MacPorts is not compatible with version 1.50 of the boost library, so now I’m downgrading using these references:

https://trac.macports.org/ticket/35118#comment
https://trac.macports.org/ticket/35726

Still building boost 1.49… might as well get some sleep while its getting done.

2012.08.21 2:20 – Update: MongoDB running again, Gimp still not working, and the Apache server cannot be started, which apachectl keeps pointing to /usr/sbin/apachectl, have a strong feeling that it should be pointing to /opt/local/apache2/bin/apachectl. Attempted to start my apache server, some configurations errors, too tired, must fix tomorrow… oh yeah MacPorts all updated now weeee, but Gimp oh Gimp come back!

2012.08.21 2:52 – Update: Grrr… I never listen to myself should be sleeping, but Apache config fixed, so I can start the Apache server manually, hooray for a bit of progress. Tomorrow I’ll have to re-install Gimp I guess… and figure out how to get the right apachectl to respond, already updated my PATH, but apparently I’m too tired to figure it out right now.

2012.08.21 3:05 – Update: Okay I get it… after restarting my Mac all web-sites are loaded, the Apache server is running weeee! But I want to control my server with apachectl, so I’ve made a softlink in /opt/local/bin which is first in my PATH already, now the right apachectl is used! Had to open a new terminal afterwards though, but I’m satisfied.

sudo ln -s /opt/local/apache2/bin/apachectl apachectl

I figured out why Gimp is not loading, X11 is not included in Mountain Lion: http://support.apple.com/kb/HT5293, so I have to download XQuartz from here: http://xquartz.macosforge.org/landing/ and it’s almost ready to install…

2012.08.21 3:28 – Update: XQuartz installed, that was easy enough, logout and login, trembling… Cmd + Space, typing… gimp, Enter weeee, it’s loading, I have my Gimp back, how could I forget, that it’s running on X11 icon smile After upgrading to Mountain Lions problems Now I even think I deserve a bit of sleep! I hope that was my last hurdle after upgrading to Mountain Lion… then again perhaps not, because I’ve just ordered the largest beast of an SSD extension kit for MacBook Air 2011 from Other World Computing, 128 GB simply isn’t enough (for me), and I want dual boot (work requires Windows 7 installed).

share save 171 16 After upgrading to Mountain Lions problems

Written by Thomas Bindzus

August 17th, 2012 at 12:50 am

Posted in Mac

Grasshopper?

without comments

This afternoon I found a strange insect swimming around in our fish pool. At first I thought it was a gecko which had lost its tail because it made similar motions as it tried to get out of the water.

Taking a closer look it looked more like a grasshopper, but I’m not sure about that either, perhaps someone could help me with more information about this insect?

It measured around 3 cm long, I took the following picture after rescuing it out of the water:

Insect Vietnam 300x126 Grasshopper?

Some sort of grasshopper?

share save 171 16 Grasshopper?

Written by Thomas Bindzus

August 11th, 2012 at 5:14 pm

Posted in Vietnam

Curious about Javascript? Visit Codecademy

without comments

A lot of people – most, really – can’t write code. In the new millennium, this is no longer a normal thing – being able to handle any sort of technical job, from fixing some HTML to delving into and contributing to an open-source project, is a desirable trait in anyone, especially those looking for work! So how do you go about learning it if you can’t afford a course or you’re not really into the idea of leafing through a textbook?

Codeyear does what it says on the tin – in a year, they will teach you to be a coder. Maybe not the best one, but with their current Javascript, HTML and CSS lessons, they’re aiming to help you understand what goes into making a site like partypoker or Facebook work. For all you know, you may even end up building your own, or turning your newly acquired skills into improved ones in order to change careers.

The great thing about it is that it’s aimed at the total beginner. All you do is type, and the clear instructions will explain what you’re doing and why you’re doing it, giving you small objectives to accomplish. Sounds like a textbook job, right? Wrong. You also get points and win badges as you go along, which can be a really great way to keep yourself motivated when things get tricky.

Best of all, it’s completely free. That’s right – you don’t pay a single cent, and there’s not a shred of advertising anywhere on the site. This is created by people who want to help others to learn to code, and that’s a grand ambition for those who could be spending that time on their own work. If you want to learn some Javascript, then take advantage of Codeyear and their community’s generosity, and get stuck in.

share save 171 16 Curious about Javascript? Visit Codecademy

Written by Thomas Bindzus

April 27th, 2012 at 12:15 am

Posted in HTML5,JavaScript

Cannot represent NaN properly using JSON

with one comment

Gosh, this took me almost 2 hours to figure out… gotta write it down, so I’ll never forget it again!

I am working on a project where I communicate with a WCF service using jQuery. The service methods return state objects serialized to JSON which I expect jQuery to correctly parse into JavaScript objects.

One of my state objects contained a property of type double? which were sometimes initialized with double.NaN as the value.

Let’s assume that the state object is called d and the property in question we call Value, so server-side Value was initialized like this:

d.Value = double.NaN;

And when serialized to JSON by the WCF service it turned into a string looking like this:

"{ \"d\": NaN }"

Perhaps I am the only person in the whole world who thought this would be okay, since JavaScript does have the concept of NaN, but JavaScript is not able to parse the JSON string above.

I tried to write a small script to clarify this a bit:

<html>
   <head>
      <script type="text/javascript">
         document.writeln(NaN);
         document.writeln(Number.NaN);

         document.writeln(NaN.toString());
         document.writeln(Number.NaN.toString());

         var jsob = { d: Number.NaN };
         document.writeln(JSON.stringify(jsob));

         var json = '{ "d": NaN }';
         document.writeln(JSON.parse(json));
      </script>
   </head>
</html>

The page above yields the following output:

NaN NaN NaN NaN {"d":null}

And in the console:

JSON.parse: unexpected character
document.writeln(JSON.parse(json));

I found this a bit surprising, however in my case I was able to fix it fairly easy by not using double.NaN, but I still don’t understand why, perhaps it’s simply because it’s not part of the JSON specification.

share save 171 16 Cannot represent NaN properly using JSON

Written by Thomas Bindzus

October 26th, 2011 at 11:17 pm

Posted in JavaScript

Dad draw me a superman!

without comments

Oliver is moving on from YouTube on his iPad, now we are drawing together, well I do most of the drawing and Oliver decides what the motive should be.

We used Brushes to draw the Superman below, it’s a really cool app which let you replay the drawing process.

superman Dad draw me a superman!

Drawed using Brushes for iPad

share save 171 16 Dad draw me a superman!

Written by Thomas Bindzus

July 17th, 2011 at 3:32 pm

Posted in Family,iPad

Glowing shuttlecocks?

without comments

I’m on my way home by taxi from Pham Ngu Lao street where I’ve been all day working and receiving signatures from former employees.

Driving along the park which is squeezed in between the streets running on both sides I see people playing badminton, it’s around 7:30 PM and already dark, I can imagine it must be difficult to see the shuttlecock sometimes.

So it occurred to me, why not create a device to mount on shuttlecocks which would light up on impact with the racket, or perhaps even build shuttlecocks with such a device build in so the weight were matched correctly? Does it already exist?

One could imagine that the feathers should be exchangeable to reuse the probably more expensive hard part containing the glowing device.

That way it would be easier to see the ball when playing badminton, outside in the park, at 7:30 PM or later, when it’s dark in many equatorial countries around the globe.

share save 171 16 Glowing shuttlecocks?

Written by Thomas Bindzus

July 9th, 2011 at 7:36 pm

Posted in Vietnam

Tagged with , ,

A possible alternative to JS Bin

without comments

Today while rumbling around with some JavaScript and HTML I accidentally stumbled upon another JavaScript lab similar to JS Bin which I mentioned in my previous post. It’s called JSFIDDLE and it looks very promising, and it has more features than JS Bin.

You can type in your CSS and HTML in separate windows for starters, and one really cool feature is the TidyUp which helps you reformat unreadable code into readable code whether it’s HTML or JavaScript, really nice.

JSFIDDLE uses JSLint to validate JavaScript and you can include your favorite JavaScript API to code up against, although it doesn’t seem like you can select more than one at a time, and it’s not shown in your code which framework you are using, however it’s visible in the sidebar on the left which also contains a number of examples by the way.

So far I’ve tested it in Google Chrome and Internet Explorer 8, and it works a lot better in IE8 than JS Bin does, so I might have found a replacement for JS Bin. Furthermore there is also support for testing AJAX requests.

Happy hacking!

share save 171 16 A possible alternative to JS Bin

Written by Thomas Bindzus

May 21st, 2011 at 2:21 pm

Posted in HTML5,JavaScript

JS Bin the perfect JavaScript lab

without comments

How often haven’t I created that infamous test.html page to verify that my JavaScript manipulated the DOM in the way I expected it to? Often such experiments include usage of jQuery or other commonly used JavaScript libraries. Precious time lost creating similar test files over and over again, okay well perhaps a bit exaggerated, but still a pain.

However now I’ll never need to create another test.html page again thanks to JS Bin. It’s the perfect JavaScript lab at least for me; the screen is split in two, and on the left you have a JavaScript editor on the right an HTML editor, both with Syntax Highlighting, and other nice to have features. From a drop down list in the top you can include your favorite JavaScript libraries and you are ready to hack away!

24 02 2011 11 37 31 JS Bin the perfect JavaScript lab

It is in my opinion a perfect learning environment if you are new to JavaScript, HTML5 or both, you can play around with new ideas, more abstract aspects of JavaScript, or what-ever you want. JS Bin was built by Remy Sharp who you can follow on Twitter here @rem, that’s how I found out about JS Bin. Remy tweets about JavaScript, HTML 5 and other such gems very useful stuff indeed.

I also recommend reading John Resig’s blog, John Resig is probably already well-known to you as the creator and lead developer of the jQuery library, but he has also written some books about JavaScript programming and created a very useful tutorial for learning more advanced JavaScript topics. You can follow John on Twitter here @jeresig

share save 171 16 JS Bin the perfect JavaScript lab

Written by Thomas Bindzus

February 24th, 2011 at 11:41 am

Posted in HTML5,JavaScript

Importing a PST-file to Thunderbird without using Outlook

without comments

It is in situations like this that I really appreciate my virtual Ubuntu!

I was preparing an old hard disk for reuse, I mean it was really old, 7 years old minimum. I found a PST-file on it from when I used Microsoft Outlook, and I got curious, what old emails would I find there?

Oh but behold, Thunderbird required Microsoft Outlook to import the PST-file, so what to do :-S? Ubuntu please rescue me! Ta-daaa, after some search I found a command utility called readpst, which can convert a PST-file to a folder hierarchy of plain text-files, one for each email in the PST-file, thank you Ubuntu (well actually Linux command utilities in general)!

First of all you might not have readpst installed, but that’s only an apt-get-call away, running the following command from the terminal:

> sudo apt-get install readpst

It doesn’t really matter if you already have the utility installed or not, you can use the command above to confirm whether the utility is installed and if it isn’t, well then you saved yourself a bit of time since it will be installed icon smile Importing a PST file to Thunderbird without using Outlook

My first few attempts with readpst didn’t turn out so well, but after some fine-tuning I came up with the following set of options for the readpst command:

> readpst -D -M -b -o pst thomas.pst

I will just briefly walk through the command options:

  • The -D option tells readpst to include deleted emails
  • The -M option tells readpst to include attachments in the mail-files and not as separate files in the file system
  • The -b option tells readpst to omit the RTF version of the email, which would otherwise be included as attachment in the mail-files
  • The -o pst option specifies where the output goes
  • And last but not least include your PST-file which needs to be converted

Voila! That was a huge step in the right direction, after running the command above I had a folder structure mirroring the original folder structure from the PST-file, well at least I assume that it’s pretty close to the same. However in the conversion all the email-files were given a number and nothing else, no extension, nothing!

I renamed one file from 1 to 1.eml and dragged it into a folder in Thunderbird installed on my native Windows 7, and the email was imported to Thunderbird, the email even got all of it’s attachments intact, super! I could just drag’n'drop import all my emails.

My next problem turned out to be, how on Earth do I add the eml-extension to all of these files? Should I do it manually? No no no, not in a million years, Ubuntu, rescue me again, please!

I needed to find a way to recursively scan through all the folders created by readpst and add the eml-file extension to the name, after a bit of Googling I found a shell script for recursion (sorry for my ignorance, not a master of shell scripting, not yet at least). I found the shell command for renaming, funny enough it’s called rename, and it allows you to use Perl regular expressions when searching for files to rename, sweet!

#!/bin/bash
rename_fun()
{
   # For each folder do
   for i in `ls -ltr | grep '^d'| awk '{print $8}'`
   do
      # Output the folder's name, to track progress
      echo $i;

      # Move down into the sub-folder
      cd $i;

      # Add the eml-extension to all files with numeric names
      rename 's/([0-9]+)$/$1.eml/' *

      # Recurse deeper down into the folder structure
      rename_fun

      # When done move up from the sub-folder
      cd ..
   done
}

# Call to rename files
rename_fun

WARNING: The script is not child-safe, start from the wrong working directory in the prompt and suddenly you have added the eml-extension for a whole lot of files, which were never supposed to be changed. Furthermore it assumes that no mail folders use spaces in the folder name, I only had to folders which contained a space in the name, so I opted for the lazy solution: I removed spaces from my mail folders.

The only setback about this setup, is that I had to manually drag’n'drop the converted emails into my Thunderbird, that did take me some time, but I ran out of good ideas to how I could get the eml-files into Thunderbird in a smarter way, if you know just how to do that, then please add a comment below, thank you in advance!

It goes with the story to tell, that these emails turned out to be from the period of 2000 – 2004 and they were not that interesting actually, so perhaps this was just a waste of time for me, but I thought it might help someone else. Feel free to comment on this post, good ideas and constructive critique are always welcome!

I have listed some references below, which helped me in the right direction, I thank everyone who has unwillingly or unknowingly contributed to set my curiosity at rest! Among the links below you will also find a Thunderbird plugin, but according to the comments it doesn’t work, and I didn’t try. I decided to pursue the readpst solution instead based on the Ruby project at Google Code, which by the way didn’t work for me either.

http://code.google.com/p/ruby-msg/
http://www.five-ten-sg.com/libpst/rn01re01.html
http://kb.mozillazine.org/index.php?title=Import_.pst_files&printable=yes
http://freshmeat.net/projects/pstimportplugin/?branch_id=72191&release_id=265973
http://www.unix.com/shell-programming-scripting/84210-recursive-call-find-files-directories-shell-script-current-path.html

 Importing a PST file to Thunderbird without using Outlook
share save 171 16 Importing a PST file to Thunderbird without using Outlook

Written by Thomas Bindzus

September 12th, 2010 at 2:07 am

Desktop cleaning and uh-lala

without comments

Oh man my desktop is a mess, once again, I can’t believe it! I try to keep it clean, but sometimes my downloads control me, and yeah well, then it’s just easier to put it on the desktop, my Eeec’s desktop is chaos.

In the past I cleaned up once or twice on my old laptop simply by moving everything to a folder called “Must clean-up”, didn’t help much, before long I had a folder called “Must clean-up part II”.

Anyway during my recent look-at-and-throw-away session I came across another sketch I made with Harmony:

Sketch e1283922997364 226x300 Desktop cleaning and uh lala

share save 171 16 Desktop cleaning and uh lala

Written by Thomas Bindzus

September 8th, 2010 at 12:13 pm

Posted in Doodles,HTML5,JavaScript

Tagged with , ,

Switch to our mobile site