[Meme] Some people really need a punch in the face

demotivition

License

Creative Commons License

Some people really need a punch in the face by Marco Leong is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Advertisements
Bluemix-Matrix-Banana

[Exploration] IBM Bluemix with PHP and MySQL

IBM Bluemix is a good platform if you need a fast testing and deploying in the cloud without going through the trouble setting up a proper cloud virtual machine like EC2.

Attended one of the recent workshop organised by IBM and University of Wollongong, I was trying to create a sample testing app using PHP and MySQL, but PHP keep failing to connect to MySQL.

Short answer

Create a file called .bp-config/options.json.

{
    "PHP_EXTENSIONS": ["mysqli"]
}

Long answer

PHP and MySQL(ClearDB) is not connecting well because for some reasons PHP runtime is not part of the choose able runtime, known as community buildpack on Bluemix. Meaning there is no sample codes or boilerplates on Bluemix. For some other reason, PHP buildpack does not by default supports mysqli (because obvious “nobody use php and mysql”, lol). So, if you want PHP and MySQL on Bluemix.

1. Create a PHP runtime by using the community PHP buildpack.

2. Add the service ClearDB (MySQL) to PHP app.

3. Add Git repository to Dev Ops (aka jazz hub), allows you to edit the code.

4. Edit the code, add

.bp-config/options.json

5. Input the above option so that mysqli is included.

6. In your index.php add the following and echo something

$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error){
echo "Something wrong"
} else {
echo "Hello world"
}

7. Build and Deploy!

Afterthought

The worst thing, failing at mysqli results in a blank page, absolutely nothing to help you to debug (you can using cf command line, but why!). The error message is shown only if php connects to mysql but wrong credential is supplied.

A few hours was spent to get a proper solution to this. Therefore, I am not totally sure how reliable Bluemix as a solution is if you are using PHP and MySQL. I can’t comment on other runtime such as Java, Node.js, Ruby as I haven’t got the time to try them out. However, the integration of git repo and deploy pipeline is amazingly good, Dev Ops deploys to Bluemix automatically once a change is committed and pushed, after some settings.

It doesn’t seems to me that Bluemix is any easier then Amazon EC2.

Either way, happy doing a lot of things before doing anything.

[Reference: Cloud Foundry / PHP Buildpack and Stack Overflow – your best friend]

[Review]  Apple Watch on the launch day. Why the white? Why the Cheap?

1. It just works!

I was surprised that Apple changed their mind and sent me an Apple Watch today instead of the expected June delivery. An SMS notification brought me the good news yesterday and the watch arrived today around 10:00. I literally unboxed it and put it on my wrist and rush to the bus stop. It just works!

IMG_5578

2. SIRI-ous

I posted a few pictures of the unboxing on my Facebook, and i found that I am already getting notification and SMS about it. So where’s the keyboard!? SIRI is your only choice. When you tap reply, it give you a few default options with emoji and dictation. The default replies are “Ok”, “Yes”, “No”, “Call me later.”, etc. For those who think the default reply doesn’t encompass our language, it is clear that you are arguing emoji is kill the skill of painting. Anyway, dictation work, i suppose, better than what i thought. For all the message i have send so far, i just have to re-speak one of them. I only gave English a try, yet for Cantonese, Chinese and Japanese, I suppose they work the same. Bottomline, you can just dictation what you have to send.

IMG_5594

3. Why the white?

I didn’t pre-order the Apple Watch on day one, instead took advantage and manage to get a session of try-on on day 3. I thought I was going to get black aluminium large size. The session make me understand 2 things:

  • Small size looks equally good compare to the large size in my case.
  • Leather strip is irresistible, but the price is not one that I wish to pay.
  • White look better with the leather strip I like.

The Apple employee show me the leather with white and black watch. To me the white one works better with the leather colour I like. The conclusion to this is, get the white aluminium and a third-party leather strip <3.

4. Why the cheap?

Obvious I can’t afford the gold watch, so it comes down to stainless steel and aluminium. As an iPhone Developer (now watch as well), it is always good to learn the new tech. However, the Apple Watch is at it first generation. The past experience of Mac and iPhone show that it is not wise to get the more expensive version for the first generation. Macbook Pro Retina is the completed product, so as the iPhone 4. An Apple Watch will worth the price if the technology is stable. All in all, the cheapest on for the first gen is a logical choice for a developer like myself.

5. Best features

To me it is all about integration, I believe in both integration and customisation. But you don’t build your own car, you buy one and drive, it should just work. Apple Watch just works, perhaps using iPhone, Mac OS X and Apple Watch is the reason. Best feature is integration and the health data collection. It works with the Health Apps and later on with Research Kit. That’s something that I want to develop on. It remind you to move a bit if you are at you seat for too long.

IMG_5595 2IMG_5591IMG_5593

6. Boxing pictures

I know, I know, here you go:

FullSizeRender 4FullSizeRender 5FullSizeRender 2FullSizeRender 7

IMG_5580IMG_5581IMG_5585IMG_5586IMG_5587IMG_5588IMG_5589IMG_5591IMG_5593IMG_5592
IMG_5594IMG_5595 2

At last, the above is just one-man opinion

 Thank you for reading ❤

[Tutorial] Google Analytics with WordPress.com – Step by Step

There’s a walkthrough to share the experience of Google Analytics with WordPress.com as a first timer, since not many of them existing on the internet yet. First of all the only way to get Google Analytics for WordPress.com is a WordPress Business Plan (see plans). WordPress make everyone sign up for a free account and the Business Plan is added as a paid feature. Currently there is not way to sign up for a Business Plan directly, but I don’t see too much of a problem here.

Again, a WordPress Business Plan is needed for Google Analytics to work. Attempting to connect Google Analytics with Free WordPress.com account is not possible as this walkthrough is being written.

There a few things you need to know before you get started:

  • Google Analytics is free to use
  • WordPress Business Plan is required and it is a paid service.
  • A Google Account is needed.
  • Get yourself a coffee and start the walkthrough.

 

With all that said, let’s get started:

1. Go to Google Analytics or Google Analytics AU and Sign in with your Google Account. We assume that you have a Google Account.

 

 

Wordpress dot com Google Analytics 1

 

2.  Enter your Gmail Address and the Password and select Sign In.

 

3. In this screen, you just have to select Sign up to enrol yourself with Google Analytics.

Wordpress dot com Google Analytics 3

 

 

4. Since you are linking with WordPress.com, tracking a Website is the default setting you want. Provide the detail for Account Name, Website Name, Website URL, Category and Reporting time zone.

  • The Account name does not need to be the same as the Website Name, in fact one account can manage a few website.
  • The website added must be right. Since you have a Business Plan WordPress, you should have your own domain name. e.g. BeautifulWordpressSite.com
  • Nominate a category of your WordPress.com site.
  • Set the time zone.

Wordpress dot com Google Analytics 4

 

5. Regarding the Data Sharing Setting, a lot of reading you have to do here. For the tutorial purpose we will choose keep the default.

Wordpress dot com Google Analytics 5

 

6. After the previous step, you will be here at the home page of your Google Analytics. The Tracking ID of your WordPress.com site can be found in this page, refer to the image below.

Take note of the number and the Google Analytics part is done.

Wordpress dot com Google Analytics 6

 

7. Next step is to link them up. Head to WordPress.com and Sign in Accordingly.

 

Wordpress dot com Google Analytics 7

 

8. Select My Site. (For some illogical reason, WordPress.com always start the content creator with the Reader tab!)

Wordpress dot com Google Analytics 8

 

9. Now Select settings

Wordpress dot com Google Analytics 9

10. Finally, Select Analytics on top and enter your Tracking ID from Step 6.
Remember to Save the Settings.

You just have yourself a WordPress.com site with Google Analytics enabled.
Time to have a cup of hot chocolate ❤

Wordpress dot com Google Analytics 10

[Media] Using VLC to Convert multiple files on OS X

One of my project requires multiple wav file to be converted to mp3. This is how it was done using command line with VLC on OS X. Change the path to the directory which contains the files.

for file in /path/to/files*.wav; do /Applications/VLC.app/Contents/MacOS/VLC -I dummy "$file" --sout="#transcode{acodec=mp3,vcodec=dummy}:standard{access=file,mux=raw,dst=\"$(echo "$file" | sed 's/\.[^\.]*$/.mp3/')\"}" vlc://quit; done

The original command (see reference) works on mp4 to mp3, and it work on wav as well by changing the *.mp4 to *.wav.

Happy converting.

[Reference: https://khom.wordpress.com/2010/04/21/convert-mp4-and-flv-video-to-mp3-with-vlc/%5D