AngularJS minimal MVC example

Recently started to learn AngularJS, which is really a very good framework. It makes routes, Two way data binding and modular design easy.

I have created a minimal MVC example for beginners to get started with. This is a BMI calulator.

You can also try the jsFiddle here.

Properly execute shell commands and return errors in PHP

Sometimes you want to run a command on your server through PHP. There are couple of ways to do it, system()exec()shell_exec(), passthru(). All of them pretty much works alright with some slight differences. I would like to share my method which I think is more “programmatic”. Continue reading “Properly execute shell commands and return errors in PHP”

Convert Webp image to png under osx/linux

You can find the open source project here : http://www.webmproject.org/code/

To build the tool from source

You can find the dwebp utility under “examples” folder

You can test it out using the test.webp in the same folder

 

Compile Tex document into PNG with single command

This tutorial let you compile your tex into png with a single command, the png produced will have transparent background.

Prerequisite

you should have Tex compiler installed on your machine, Continue reading “Compile Tex document into PNG with single command”

Freebie: “Keep Calm and Keep Coding” wallpaper

This is a free wallpaper I made for you guys. (Click to Enlarge and Save as to your device) Enjoy! If you like this leave a comment down below.

p.s. Black in color so that your eyes won’t hurt when switching to the desktop.
Continue reading “Freebie: “Keep Calm and Keep Coding” wallpaper”

Getting started with Tex/Latex on Mac/Linux

This is some notes I’ve learnt after hours and hours trying to figure out how Tex/LaTex works! I found it very hard to find a beginner’s guide, so I decided to write down what I’ve learnt in the simplest way I can explain. Continue reading “Getting started with Tex/Latex on Mac/Linux”

Install Tex on CentOS linux

Actually it’s pretty easy with Yum group install, a lot of people didn’t even notice this

There you go! run “tex” or “latex” in the shell and it’s up and running.

Sometimes you also need dvipng to compile Tex into PNGs

Something about yum groups

if you want to see what packages is in this group, you can run:

If you want to see what other Package groups in yum, you can run

 

Define a Catch-all Named Virtual Host in Apache

Let say you have 2 virtual hosts A.com and B.com on your web server, do you know that it is possible that your visitor may accidentally access A.com while browsing B.com? As a best practice, defining a catch-all Virtual host can prevent such scenario. Continue reading “Define a Catch-all Named Virtual Host in Apache”

How to hash a string to integer with a range in PHP

Here is a simple way in PHP to hash a string to an integer. That is, mapping a string to a specific number.

This function has a default range of 100. (That means the outcome can be 0 – 99 )

Continue reading “How to hash a string to integer with a range in PHP”