Category Archives: Programming

Zend Framework 1 Extension Library and Composer

Maybe I am a bit late to get on the Composer bandwagon, but a colleague was adamant about it and convinced me to use Composer in our projects. The benefit of using Composer with your PHP applications is that it will download any library dependencies for you, and take care of the autoloading of classes. So I enabled Composer in my Zend Framework 1 Extension library, with a Zend Framework 1.* dependency. Read on how to get the libraries using Composer!

Continue reading Zend Framework 1 Extension Library and Composer

Enumerations in PHP

In the C programming language, enumerations are handy little data types, which add more linguistic context to the code. They make code more readable, and enforce variables to have certain values. The latter is certainly true, if you have ever assigned string-valued codes to your variables and made a typo somewhere. For example assigning 'white' to the variable $color, and then make a typo somewhere in the code by using 'whiet' or something like that. The program would still compile or run, and not complain at all, while there is something fundamentally wrong with the code.
Continue reading Enumerations in PHP

Download Japanese stock market data into R

Traders who are interested in the Japanese market, and use the quantmod library in R to analyze the stock market, will find that there is no source for financial data on the Japanese market. This has changed with quantmod version 0.4-3, in which my code to download stock data from Yahoo! Japan has been added.

At the moment, version 0.4-3 has not been pushed to CRAN yet, but you can still install it from R-Forge. To do this, enter the following in your R console:

install.packages("quantmod", repos="http://r-forge.r-project.org")

Then, when you load the library with library(quantmod), you’ll be able to use the getSymbols() function to retrieve stock data from the Japanese market, using the src="yahooj" parameter. The ticker symbols you need, can be found in the URL of the stock information page on Yahoo! Japan. For example, if you open the Sony stock data page, you’ll see that there is a code=6758.T in the URL. This is your ticker symbol.

So in order to download Sony stock data from January 2013 into R, do the following:

getSymbols("6758.T", src="yahooj", from="2013-01-01")

This will download the data, and put them in a variable called YJ6758.T in your R environment.

For more information on the getSymbols function, you can check the online reference. When the online reference for the getSymbols.yahooj function becomes available, I will link it here, but until then you can check it in the R Help system if you have quantmod 0.4-3 installed.

Multi-lingual views in Zend Framework 1

Ever felt like this?

Build us a multilingual website

If so, do read on. Because it has become easier.

Do you want to quickly organize your multi-language website in Zend Framework, such that you can easily add languages without breaking the website? And from there, progressively translate pieces of your website? Imagine a website where you have a handful of static content – think of about pages, policy pages and disclaimer pages – and you want to easily add translated pages to your system, without having to go through programming the logic of selecting the right view for these pages.

Look no further, for the ZF1E library offers exactly that solution. Using the built-in MultiLanguage resource, it will determine which language part of your website your visitor is accessing, and grab the correct view for that language.

Continue reading Multi-lingual views in Zend Framework 1

The basics of 3D simulation in Java

Recently, I seized the opportunity to recreate a 3D simulation program that I made during my University years. Back then, I didn’t know about versioning systems, and there was nothing like GitHub, so the code has been lost. But as I still remember how I implemented different parts of the program, I started the task, and put it on GitHub.

Continue reading The basics of 3D simulation in Java