Midgets standing on the toes of others

Happy coding

AngularJS - Delay Controller Initialization for Asynchronous Operations

In an AngularJS web application, a controller requires some data for initialization, but this data needs to be retrieved from server. One solution is that after controller is initialized, use $http service to get the data and returns a deferred. But this will change the usage of data to asynchronous operation, which may not be possible for all the operations. People usually prefer to synchronous operations. Another solution is to delay initialization of controller until data is retrieved from server successfully.

To do this, we need to use a run service to start retrieval of the data.

Jekyll - Bootstrap Navbar Active Status for Different Pages

When using Jekyll to create websites, Twitter Bootstrap is a very good choice for styling. Typically there will be a layout template for all the pages. When using Bootstrap’s navbar, the basic markup of the navbar is put into the template, each page’s content is put into separate markdown files. Then we need to add active class to the correct <li> element in the template to make sure that in each page only the corresponding <li> element has the active class.

To solve this issue, I created a small Jekyll plugin to correctly generate the class name for navbar.

CoffeeScript Notes and Tips

CoffeeScript is a popular language used by many frontend developers, I collected some useful notes and tips.

Find first/last element in array

CoffeeScript’s destructuring assignment can be used to easily get array’s first and last element.

1
2
3
[first, ..., last] = 'a,b,c'.split(',')
[first, ...] = 'a,b,c'.split(',')
[..., last] = 'a,b,c'.split(',')

Gridlines for Google Maps

View GitHub repo

This is a small JavaScript file to create latitude/longitude gridlines over Google Maps.

The original version was made by Bill Chadwick and then other contributors continued to improve it. Refer to the file’s comment for more information.

I made some improvements and made this library available in Bower.

  • Fix JSHint errors.
  • Fix the issue that this library causes map to freeze in Chrome/Safari on Mac.

OAuth Signature Base String Decoder

When I was debugging an application used Xero’s API, I found out it’s hard to see the request content once some errors happened. The only thing I can get is the signature base string. But this string is encoded, so I need to decode it first. Then I wrote this small web page to do the decoding.

To use it, see this page.

To see the source code, go to GitHub.

Magmi Indexing Issue With MAMP

When using Magmi to import products into Magento, you may use Magmi Magento Reindexer plugin to re-index, but you may encounter following error if Magento is run by MAMP.

1
SQLSTATE[HY000] [2002] No such file or directory

To solve this issue, use following command

1
2
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

Use Web Service to Get Magento Categories

Magento’s web service can be used to retrieve data from Magento. Magento support SOAP/XML-RPC and REST service. SOAP/XML-RPC web service is discussed in this example.

Before using the web service, make sure a user and its role is created in Magento. Username and API key is used for authentication. The user’s role should have the required permission to access certain resources.

Some Linux Management Tips

During daily operations, I found following tips may be useful.

DNS resolve error in Amazon EC2

I found a Amazon EC2 instance cannot resolve DNS names. It turned out that the /etc/resolv.conf file is empty. Modify the file to look like below

1
2
3
nameserver 172.16.0.23
domain us-west-2.compute.internal
search us-west-2.compute.internal

The configuration may be different. You can copy it from other EC2 instances.

新西兰IT技术移民个人经历

本文同发OurCoders,版权所有@成富_Alex,转载请保留

对我个人而言,移民新西兰完全上是机缘巧合。在过来之前,移民这件事情并没有提上我的议事日程。机缘是我之前的一个同事在新西兰读书并工作。他工作的单位因为项目原因需要招聘更多的员工。被推荐之后,经过Skype上的面试,就顺利拿到了Offer,接着申请了2年半的工作签证过来。过来之后很快就申请技术移民,几个月之后拿到PR。

技术

由于我也就在两个公司工作过,所以了解得也不是特别全面。就我个人的了解,这边.NET技术使用得比较广泛,不少项目都是用.NET做的,相应招聘的人也比较多。Java和Web前端也有一定的需求。iOS和Android开发也经常会需要。由于这边的公司一般人都比较少,因此普遍会要求对各种技术都有一定的了解,包括开发、测试和运维等各方面。

在招聘时,这边的公司比较重视之前的项目经历和其他人的推荐。一般都会要求打电话给原来的单位做reference check。所以一份好的CV是很重要的。招聘的职位方面可以从Seek或LinkedIn等招聘网站上找到。

由于公司小,对于SaaS和开源技术用得会比较多。