Should I buy a new or used car: A Malaysian perspective

Here in Malaysia, we have 65% excise tax on cars. If you pay RM 500 a month for your car, about RM 200 of it goes straight to the government. Not to Proton not to Perodua or Toyota. Some say that does no apply to local manufacturer, but I’ve yet to find concrete evidence that they are exempted from it.

I’m 26 years old that have no car. Its not that I can’t afford them, I just really hate loan. But its way past due that I take the bullet and accept this constantly depreciating item in my life. Which brings me to my question, new or used car.

First, some background, I’m single, I go to work with a motorcycle. I will most likely not going to use the car to go to work in order to prevent more of my money flowing to the government. So fuel consumption is not an issue. Its most likely going to be used to balik-kampung to Kedah. Once every two months perhaps. Car must have ABS. I had a scare before somewhere near Slim River where the Axia I used got a case of locking brakes. Car must be practical, really, the main purpose of the car is to carry stuff that I can’t carry with my motorcycle box. I have like a big table, that preferably can fit into the car. Folding rear seat is a must. MPV is even nicer. Car must be reliable or do not depreciate much. This means its mileage should not be too high. Or, its so cheap that it can’t go even lower. Car should be locally made (not necessarily designed), because its easy to find parts or repair. This leaves us to Proton or Perodua.

Preferably, I don’t want to have a loan at all. I have some money, but not enough to buy a new car. I thought of getting a dirt cheap Proton Saga to save money. But those generally don’t have ABS. More importantly, the old saga cannot fold down the rear seat, a puzzling design choice. A Viva does not even have ABS option. This leave a Myvi, but I really like the 2011 “lagi best” model, which is still expensive. To my surprise, I might as well get a new one, which is only about 50% more expensive on most case. I thought, cars depreciate really fast, but this is a 8 year old model. Why does it still cost this much? I’ve looked at,, facebook, all more or less the same. Which makes me think, is this the norm? How much do car really depreciate in value?

Looking into it….

Using my programming skills, I’ve scraped a website that list car for sale in Malaysia, which will be kept unnamed, for legal reason. Unlike, this site make sure that they don’t list deposit price, or sambung-bayar price, only sale price, although generally its not OTR. This make it easy to scrape, no need to clean data. I only scrape Proton and Perodua models, remove those whose mileage is more than 250 000 km, and only consider automatic transmission. Also, they can’t be more than 15 years old, and I excluded listing from ‘dealer’, as I simply don’t trust them. Majority of the seller here are agent or private seller. And because I don’t want a really old model, I’ve specified the model name explicitly.

as_pd = pd.DataFrame.from_records(flattened)
as_pd['mileage'] = np.ceil(as_pd['mileage'].astype('float') / 5000) * 5000
as_pd['price'] = as_pd['price'].astype('int')
as_pd['year'] = as_pd['year'].astype('int')
as_pd['age'] = as_pd['year'] * -1 + 2019
as_pd['seller_type'] = as_pd['profile_type'].apply(translate_profile_type)

cond = (as_pd['model'].isin(['Alza', 'Myvi','Axia', 'Viva', 'Bezza', 'Exora', 'Saga', 'Persona', 'Iriz']))
cond = cond & (as_pd['mileage'] < 250000)
cond = cond & (as_pd['age'] < 16)
cond = cond & (as_pd['transmission'] == 'Automatic')
cond = cond & (as_pd['seller_type'] != 'dealer')
perodua_pd = as_pd[cond & (as_pd['make'] == 'Perodua')]
proton_pd = as_pd[cond & (as_pd['make'] == 'Proton')]
all_pd = as_pd[cond]

So what kind of population are we looking at here. For giggles, I’ve disabled dealer filter for this occasion:

Hmm, what brand is sold by who?

Fascinating! It seems that although in total, while there are more Protons listed, they are generally sold by dealers. Hmm…. Anyway, lets ignore that because we are not considering dealers. Then the most listed car is without much surprise, the most popular car in Malaysia, Myvi. Most listed by private seller and most listed by agent. The next privately listed car is Proton Saga. Surprisingly the second listed car by agent is actually Alza, not Saga.

Side note, I actually really want an Alza. But their price does not go down in the used market, not much at least. Now, let us plot their listed price over their mileage. This should show us how much value a car lose over the distance it traveled. I’ve splitted the scatter graph between Proton and Perodua, as 17000 points in a single plot is very hard to decipher.

Price over Mileage


Simply said, there is no easy correlation between mileage and price. We do have some pattern however, after 100000 km, the price does not drop much anymore. Depending on car, 60000 – 80000 km is a good target to look far.

There is a strange anomaly at 10000 km, where there is a bunch of cheaper car. I suspect this is some bad data, some seller putting refurbished car or just saying car with less than 50000 km as 10000 km.

There are other patterns also. Viva pretty much don’t change in price. It is cheap in the first place, and does not go much cheaper. For some reason, Iriz increase in price as mileage grow? From the scatter plot, there aren’t many car being sold when their mileage is lower than 40000 km. I suspect the sellers just say they are 10000 km in mileage.

From the scatter plot, there aren’t many car being sold when their mileage is lower than 40000 km. I suspect the sellers just say they are 10000 km in mileage. That said, mileage just does not affect the car price much and it highly vary from seller to seller. Really, what you want to look at (at least what sellers are looking at) is the age of the car.

Price over Age


Now we are looking at something. The price of a car is somewhat proportional to its age. There is a lower bound however. No car is priced below RM 10000. Brand-by-brand, Perodua does command a higher price that Proton. In fact, Alza is consistently more expensive than an Exora at age 2+. At 4+ year old Axia is actually more expensive that a similarly aged Saga. At 7 year old Saga and Persona have identical price, AND priced more or less the same as a Viva? In fact, at 8 year old, an Exora is priced similarly to a Myvi.

That said, Persona wise, this is the old persona, not the new one. Iriz still goes up in price a bit. Bezza also have a bit of a price hike at age 3. Is a newly released model more expensive when it first lunch? A new version does bump up the price a bit. For example, 7 year old Myvi is significantly more expensive than an 8 year old Myvi, due to the 2nd gen model. Axia is significantly more expensive than Viva no matter how you look at it.

A few things to keep in mind, these are all listed price. It is most likely not OTR price. Add 3k to 5k for that. It is possible that the buyer can haggle for the price, which lowers them, but I’m no good at that. Simply said, the actual buying price could be higher for me.

The price depreciation does slow down a bit. There seems to be a ulower bound of RM 10000, or RM 20000 for MPV where their price will not go lower. Or maybe the model is just not old enough for the price to go lower.

It seems that a good estimate of how a price of a car drop is to say that it have a half life depending on the model. Meaning the price will halve over some period of time. That said, its not like 2 or 3 years. Perodua seems to have a half life of 6 or 7 years. Saga and Persona have a half life of 4 to 5 years.

Much of this is perhaps just market sentiment. Perhaps. I know I don’t want a second hand Persona, because I’ve used one. It had a broken fuel gauge, then the immobilizer immobilize it, something wrong with the computer, completely replaced the dashboard, still broken fuel gauge. But that is the old Persona. Iriz have a favorable review, and the new Persona is based of Iriz. Saga is so simple, not much can go wrong. Exora on the other hand, have a turbo. And a bunch of canggih stuff. See how the price drops.


If you wanna buy a second hand car, buy a Proton. If you wanna buy a new car, Perodua is a better choice. Me? Old saga cannot fold rear seat down. New saga are 25k+, listed price, not OTR. OTR is probably 30k. I might as well buy a new one at 35k.

Myvi is a better choice. Lots of people selling them. A ‘lagi best’ EZi model of mileage less than 80000 can be found for 22k, which OTR is probably 25k. And its rear seat can be folded down FLAT. However, it does not really have a bonnet, which means cargo length is limited. Bezza is too new, and its rear seat is vertical. Alza however, not only have a flat folding rear seat, it have TWO rows of flat folding seat! Making it a van, which is awesome! But, I can’t find a good one below 30k, list price… When a new one is 55k, its hard to justify buying a 9 year old car for slightly more than half price.

So, did I make a decision? Nope. Why? Simply said… I’m cheap.


The case of a Key-Value pattern.

I’m quite conservative about how my application store its data. I prefer SQL over NoSQL. I prefer it’s security of the dynamic of NoSQL, which you would eventually probably use an ORM which have schema anyway. Relational databases have been used for decades, so it must work right? And really, most of us will probably never going to need the performance of a NoSQL database. That said, there are good uses for things like Redis, or other form of Key-Value store, notably for simple stuff like configurations. But for real work, for me SQL is the right way to go.

But what if you don’t know the structure of the data of the application? What if there are no structure? What if there are indeed patterns, but there are many special cases where in the end, the structure does not matter much.

For those who are not technically familiar with relational database, in relational database, there are things called ‘Table’ and that is where we store data. For example, if I have many car, I will put create a ‘Car’ table, and in the car table, I will declare the car’s properties such as the height and weight. But all car must have the same attribute. Sometimes, if some car don’t have a certain attribute, we just don’t fill the attribute for that car. That works. Sometimes, instead of cars, we have to represent vehicles, some can be car some can be bicycle. And there are many ways to represent this data, but the gist of it is this, all things of the same type generally have the same properties.

But what if out of a hundred car, two car have a special properties which no other car have. This is what I call special cases and I hate special cases. It makes the code ‘unclean’ and kinda makes me ‘itchy’. Sometimes, these two car have special calculation that need special treatment. Generally we put the name of the car in the configuration file and then special-handle them when they occur somewhere in our code.

In my latest project, I have a bunch of these special cases where this data is the same as these data, or these data is equal to these data multiplied by 100. But only these particular data. In this case, the number of ‘car’ is fixed and there are predefined number of them. But some of it have special characteristic which is not the same as other stuff. On thing the got in common is that they represent values over time. Or in another word, I was to keep record of what are the weight of this care at this particular time. And some car does not have weight.

The reason for this is that previously the business flow of the company is to use Excel sheet with various formula. And some cell is this cell multiplied by these cell. Using Excel is fine by itself, the problem is, half of the time, there are no obvious pattern to derive from. It is very hard to design the sql table for this case.

The original code of the project uses a key-value system where each value is mapped to a key. There can be multiple value per key which also have timestamp of when that value is active. And then in clientside there are list of formula of how to calculate certain values which is calculated from other values. Previously these ‘formula’ pattern is used in two place. In a place where the used periodically key in values, and a background process where it will fetch data from another service, and transform them using these formula. There are also other background process which run some calculation on these values to get some other values such as average, but those are hardcoded.

At first, I modified the key-value formula system so that the formula is stored in the database. Then it is calculated on clientside when needed as most of the calculation is for view purpose. Then came the graph, and some of the graph’s value is calculated from other value. That means if I were to calculate it on clientside, the browser would probably hang, and calculating it on demand would take too much time. So, I make a background task, kinda to calculate these value to store then for graphic purpose. And then some of the value require average of other values, which mean it needs access to multiple values over multiple time. And then I make it work. I make sure to sort the calculation order topologically for correctness, in case a calculation depends on another key which is also calculated. I make it as fast as I could by caching the data used by calculation before sending it to database, which significantly improve its calculation speed as it does not have to hit the database. I make the formula work while having partial set of data, without hitting the database at all, allowing the clientside to ask the server to quickly calculate the resulting value which allow the user to see the changes before it is saved.

Managing this large number of keys is a huge hassle, so I make a template system for the configurations so that I don’t have to repeat repeated patterns. To save space, value segment next to each other that have the same value is combined, effectively compressing the database. When the formula of a value is the key of another value, basically it just link to the other value, and storing the duplicated value is a waste of space and compute resource. So the storage layer is modified a bit so that it just point to the actual value. Linking is a great feature as it allows us to define mapping for a page and then link them to actual data later one. Which is really important as the data may came from multiple other page arbitrarily.

In another word I’ve made it in a way that any time-series number data can be relatively easily represented and linked to each other. Now here comes the big question, Why should I use it? Everyday I ask myself this question, and everyday it always comes to “How else to do this?”. You see, when you made such complex things you kinda ‘own it’. And you want everything to use it. Much like when I made a monadic LoadableResource pattern. But is it really needed? A question I ask myself everyday. My co-worker said that other developers don’t understand it. But ‘other developers’ is the kind of developer which needs to be explained the different between an array of string and an array of dictionary. What does they understand?

Some of the page now does have some pattern. But to me that sounds like it will need to create two more additional table, making sure the query is correct and making sure the calculation is correct. No to mention some data comes from other page. And the structure of the other page may not be the same. The list of car on the other page is not the same as the list of car in this page. And how are you going to map from one page to another? By creating a configuration file. I know, lets make sure all configuration file is stored in the same place and for mapping between two page, have the same structure. That sounds a lot like the whole value mapping system before, except there will be multiple places that do the same thing.

For me the biggest downside is managing the mapping names. There area a lot of them. Up to 6000 right now. But they are defined in multiple file, each file separated by its domain. And there are the template system. Its just that no one is using them except me. Even so, it still feels a bit cumbersome for me. If it gets even more complex, it might as well be its own programming language. Additionally, if it makes so much sense, why haven’t I heard about such pattern before? Is it just very domain specific, or I am just missing the term to google it? Who knows.


Mahadhir is Harapan’s Prime Minister

Less than 8 hours ago, the opposition coalition here in Malaysia just announced that Tun M is their candidate for their prime minister. And that my friend, is the very reason why BN is still in power, and probably will continue so. Its not about Tun M becoming the candidate, no, its the very fact that the opposition for some weird reason came to that conclusion.

Tun M, their old arch enemy is apparently their president. The prime minister who exceeded his maximum term during his time, is now apparently should get another term? At the age of 93.. something? I’m not saying that he can’t do it, I’m saying that the opposition is very, very disappointing for even considering it.

I have no doubt that Tun M have huge influence and follower. I have no doubt that he is capable of doing so too. He leaving BN is a huge blow to BN. Arguably, he is the single most influential political figure in Malaysia right now. My mother cried when Tun M resigned, which he did live on television, probably so that he can’t back out, and its too late for people to object. Yes, people asked him to take back his resignation, on the spot, live. This is with him having roughly 20 year of being a Prime Minister, which is twice of what is allowed. I kid you not, this is the kind of person Tun M is. That is why Tun M is a huge deal. But as a Prime Minister, again? No. Its not right. Its not proper. The new PM for the new term should be a new guy. Its not about what he can do, its about what the opposition can’t do. Don’t they have anyone, anyone at all to be the candidate? Can you entrust the future of the country to such people, who seems to only and ONLY want to win the election, above all else?

And when you think about it, not much. The opposition does not have a candidate that truly stands out. I disliked PAS for breaking their pact with PKR and DAP. But I’m glad they did. Because if they do, they will have to deal with this kind of political BU!!$#!T.

That said, not everyone, probably not most people, will share my opinion. Having Tun M as a candidate will gain support from the rural area, which traditionally is BN’s stronghold, not to mention, he IS BN’s kryptonite. These people are generally of the elderly category which will probably see this as a positive thing. The younger generations however may share my opinion, but may also condone such ridiculousness in exchange for BN’s dismissal. It make some sense.

BN for all its corruption, at least have some professionalism or rather… authenticity.. or rather… I can’t find the term to describe them. They are bad, but at least they are properly clever. They are the ‘stable’ choice. The status quo. That said, I’m trying my best to find someone else to vote against them. And my option is shrinking. Lets just hope PAS will not do anything stupid before the election.


Jobless and graduating

So I finally quit. It was an okay quit, I guess. A but abrupt, yes, I admit. But it had to be done. And right now, I’m jobless and I probably got enough money to survive until the end of next month.

The thing is, it turns out, finding a job is hard work. Finding a suitable job, that it. I tried ServiceRocket, did not even get an interview. I registered to a hiring firm, got an interview to a small local company. Did not pass. Apparently I’m “not ready yet technically”. “not ready yet”, I would agree, “technically”… I’m not exactly sure. But I couldn’t say that is wrong either. I don’t really have much to say on things that matter.

If I learn anything on my strange internship, its that technology does not matter. What matter is what effect do the technology bring to the table… the meeting table… with the client in front of you. Sadly my previous job do not offer much in that sense. Something that I’m paying right now.

But hey, I got to start somewhere right? Which is also not that easy for me. In my CV I have nearly 4 years of experience. But without much impact, those experience are poor experience. Starting somewhere, would mean entry level, and how am I going to get an entry level job with 4 years in my resume? The interviewer would be like “Are you hiding something?”, which I kinda am. Those are remote jobs, they are not very…. impactful.

Anyway, after that interview I tuned up my resume as high as I can. It feels a lot more impressive now. Anytime I feel down, I look at it, and it makes me feels a tiny bit better. I gone through my backup from the year 2014 and see what I did with Put everything that I think ‘impactful’ in my CV. It feels a bit too ‘low-level’, but I don’t have much ‘high-level’ thing to be proud about. Hopefully that is enough. I sent it to several bigger companies today. But today is Saturday, they’ll probably process those on Monday, which brings me to the next agenda… Convocation.

Ahhhh great. I’m going to meet old friends and when they ask what am I up to right now, I’m going to have to say “Unemployed”. And then they’ll say “Seriously?” And them I’m going to say “Yup!”. And then a series of uncomfortable conversation. My Convocation is this Monday by the way. Which also brings other complications to my resume. I hate this. Its like my birthday and my friends wedding. It only reminds me of what I did not do, and its too late to do it.

As the job hunting continues, I have several leads right now. The resumes I sent to those companies, may take more than one week to process. Abidzar said that he have some friends that want to make a new team, a not-web-development team, and I could join it if I could hold on until next month or so. And he sent my resume for a contract job with Petronas, and another C++ job, I dont really know where. I got an interview from a recruiter for a job in Japan. Its a bit too far, but if I did not take this up, I’ll regret myself. There was another recruiter from Singapore. I turn that one down before, because I don’t want a job outside KL, well at that time at least. I turn down many recruiters before. Man, they can be quite handy now.

Anyway, wish me luck for my convocation.


28th September 2016

I’m bored. I wanna quit my job and work on something else.

The guy at one of the talk I’ve been said to the audience, “What do you wanna do?”

I honestly have no idea. Today I got an email to an invitation to Asia’s Rice Bowl awards. As an audience, not a participant. I don’t know how did I get the invitation. Zu did not get it. Abi Dzar did not get it. I know I won’t go there. I got nothing to show for it. If there is anything I learn from Superb and Symbiosis, among these guys, I’m no one.

Heck, who am I? Some might say a really good coder. But in these few week, one thing I’ve learn is that, even in that aspect, I’m not really that good. I just have an early head start. And if I stay and my current job, I’m gonna be left behind. It really is quite sad. Without my skill, who am I?

I could not even do ImbasPay well. Not even Bahasapp. I could make excuses here and there, but the fact is, I really don’t know how to manage a project. Need to go and work somewhere else.

Thinking about Superb and Symbiosis, I really have a talent of getting myself into places where I probably should not go. Likely due to my presentation skill. A quirks I get back from secondary school. You see, sometimes when I do some public speaking, it can work really well, and people for some reason have the impression that I could be a champion or something. Unfortunately I have a very poor social skill which makes me awkward as hell. And in business, leadership and I guess life, social skill rules. If I could code my way through it, I would. I’m kinda am.

Oh well, what am I blabbering about again? Yea, changing job. The thing is, I need to complete ImbasPay and then the IIUM research thing and then I can safely change job. Which is a lot of work. Sometimes I ask myself, do I regret making choices that lead me to today. Well, then I respond, “If I keep thinking of these regret, I won’t be able to move”. So many regret. But it does not mean much today. I really need to learn how to say “No”.

What do you wanna do?

Programming Projects

List of Quirks when using Spring Framework and Kotlin

I’m not used to the JVM environment. Usually I use NodeJS, Ruby with Rails or PHP with Laravel. But after awhile, I find these dynamic programming environment quite problematic, especially on a large project. Rails is simply too magical, it is dark magic. Sure, it have a nice syntax, but debugging them is quite a hell and no type safety means you really need to unit test your software. PHP and Laravel is not that bad actually, but when the things that makes it nice came from statically typed language, like type hints and IoC container, why not just use a true statically typed language? NodeJS have quite a lot of things. You can have type safety with typescript. You probably can get an IoC container… if you want to use them. But the whole NodeJS environment is way too immature and changes too quickly making it feels quite brittle. Update a package and the whole thing could collapse. Not too mention typescript support really depends on the library maintainer. Its the same case for flowtype too. Except I had worse luck with it.

So, when you want to use a statically typed programming language to make a web application, two things came to mind: C# and Java. Other languages are too not-mainstream enough. With C#, you have .NET MVC and with Java, you have Spring, Jersey and Play framework. The open source version of .NET which is .NET Core is simply too immature. So whats left is Java. Java is quite tedious, but luckily, we have Kotlin, which is another programming language running on top of the JVM with very high interoperability with Java. In the choice of framework, Play framework utilize Akka which is way too different than conventional application. Jersey is actually quite nice, but it does not have a built in integration with other things. Spring is the most famous of them all, so its not that hard to choose, its just that it could be overwhelming.

First of all, what is Spring framework? You need to get this right real quick, because the libraries built around it is quite a lot. At its core, the Spring framework by itself is only an IoC container. Spring MVC is a web framework that have the Model-View-Controller architecture that we want. Spring Data is an umbrella project for data access related things and among those is Spring Data JPA which provides integration with JPA (Java Persistence API) which is a java specification for ORM (Object Relational Model). Spring Data JPA utilizes Hibernate which is a JPA implementation.

Now do you see what I mean by overwhelming? All of these libraries are configured by declaring a Configurer bean. A bean is basically a fancy way of saying class/object with specific structure. You can also configure through XML, but that is old school technique which result is a huge mess of XML. The new way is too declare a Configurer class and configure it with code. In general you’ll probably use a ConfigurerAdapter instead, because Configurer is an interface and you don’t want to configure everything. But still, that is a lot of configuration. Which is why they created Spring Boot, another project which is basically a collection of configurations of these libraries. Spring Boot will detect if you include these library and will automatically apply a default reasonable configuration. ‘reasonable’ does not mean convenient, or in some sense even reasonable. I guess a better word is ‘compatible’ or ‘safe’. Still, it is too invaluable that you probably should google ‘Spring Boot’ instead of ‘Spring Framework’. But what if you want to adjust some parameters of some library? Well, it could be that Spring Boot have already enabled the use of configuration files. Which by default is usually But you can also use YAML. I’m not exactly sure the file name for that. But what are the settings? Here comes the problem with Spring framework in general: the only documentation is its user guide/reference and those references are very long. That, or you go through the source code of Spring Boot or the respective library, which are Java code, which are very long.

Once you get through those long and tedious readings, assuming nothing goes wrong, you get the ability to:

  • Create an MVC controller by annotating arbitrary class, with the base path and so on.
  • Declare a a bean which is an interface that extends CrudRepository<Model, Int> where Model is your arbitrary POJO (Plain Old Java Object) that have certain annotations that declare it as a model. And inject it to your arbitrary other bean (like your controller), gaining a free implementation of your interface that interface with your database.
  • Include liquibase in your gradle, then just declare your migration in resources/db.changelog/db.changelog-master.yaml.
  • Ability to map http body to arbitrary object, effectively parsing JSON request to a POJO, with a single annotation.
  • Return a POJO from your controller method, and it will automatically convert it to JSON.
  • Annotate your POJO with java.validation annotations and annotate your POJO controller parameters with @Valid and it will throw error if the JSON send does not validate.
  • Ability to annotate your bean method with a security expression, and it will throw error if it does not pass.
  • Java’s plain simple and conventional generic and inheritance model.
  • Probably other things too.

If that sounds quite magical, well it is. Maybe too magical, that if somethings goes wrong, you don’t know what happen. Good thing its all mainly Java code, so you got nice IDE support for debugging. But its a whole lot of Java code. A whole lot.

Of course, its not all good. Some of it is quite bad actually. The template is JSP which I’m not a big fan off. You can’t easily rollback your database. I use it mainly for a rest controller. Unfortunately in that regard, Jersey brings more things out of the box. When a validation error happen, it does not report it as a nice JSON. Jersey does that nicely. When a resource is not found and so it fails to bind the resource as parameter, it simply pass an empty resource. Jersey return a nice 404. And of course, when something goes wrong, I’ll take a day or two to find the problem. So here is a list of problem/quicks I found so far. I’ll probably update it as I found more issues.

It is asking for a password, some csrf validation error? And CORS issues.

By default, the spring boot configured spring security will ask for password, which is randomly generated. CSRF protection is enabled, not really useful for REST. Also, CORS will need to be allowed. So I used these config to overcome those issues.

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.cors.CorsConfiguration
import org.springframework.web.cors.CorsConfigurationSource
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
import javax.inject.Named

 * Created by amirul on 31/05/2017.
class WebSecurityConfig: WebSecurityConfigurerAdapter() {
	override fun configure(http: HttpSecurity) {

	fun corsConfigurationSource(): CorsConfigurationSource {
		val configuration = CorsConfiguration();
		configuration.allowedOrigins = listOf("*");
		configuration.allowedMethods = listOf("GET","POST" ,"PATCH");
		configuration.allowedHeaders = listOf("*");
		val source = UrlBasedCorsConfigurationSource();
		source.registerCorsConfiguration("/**", configuration);
		return source;

Model Validation does not work with kotlin.

If you use a data class with the constructor arguments, make sure you annotate the field instead of the getter/setter with something like @field:NotBlank.

In a one to many column relationship, on save, the child’s foreign key is not set, and I’ve specify it in database as non-null, so it will crash.

In a a JoinColumn annotation, make sure you specify nullable = false, like this @JoinColumn(name= "parent_id", nullable = false)

In a one to many relationship, if I remove the child item from the array from the parent object and save the parent, the removed child is not removed in the database.

In the @OneToMany annotation, make sure to set orphanRemoval to true.

I’m getting `org.hibernate.HibernateException: A collection with cascade=”all-delete-orphan” was no longer referenced by the owning entity instance:`.

Yea… the collection in the entity is pretty special. So you can’t just assign them and hope the complex datamapper technique to work. So don’t replace the collection object itself. Call clear and addAll instead.

I’m getting `org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity()`.

Try not using Kotlin’s immutable List. Which is the default list. Use MutableList instead. Yeah, I know Hibernate does not play well with immutable data types at all.


Automatic IIUM Schedule Formatter/Maker : End of life announcement

The Automatic IIUM Schedule Formatter/Semi-Automatic IIUM Schedule Maker is probably the most used application that I’ve ever made. That is impressive or disappointing depending on how you look at it. For some reason (probably because there is a problem to be fixed and hence, a demand) quite a lot of people use it. However, because I’m no longer studying in IIUM, I’m no longer one of the people who use it. And because of that, there is effectively no reason for me to support it anymore. Therefore, I’m declaring it life as effectively ending. I make no guarantee that it will stay online.

Here, we see a very ‘seasonal’ usage pattern.

For your information, the application itself did not earn me any money. It does, get me some nice portfolio. Quite a lot of people asked me “Why don’t you sell it to IIUM?”or “Why don’t you put ads on it?”. Well, the short answer is, “That sounds complicated, I’m too lazy for that.”. The long answer is, I don’t want it to ‘matters’ too much and I don’t want to get some ‘feature request’ from some guy, and I don’t want to get into trouble if someone found a bug. It is really, a ‘pet’ project, and I prefer to keep it that way. Plus, asking money from IIUM for something that should do in the first place does not sounds like a very good idea. I sense a lot of bureaucratic issues on that path.

Because it is running on my private server which also host other applications, like this blog, it does not really have a hosting cost. I kinda ‘piggyback’ it on other application. Plus, it DOES automatically scrape data from IIUM server every Sunday (But it turns out, sometimes IIUM change it last minute… after Sunday). Therefore, I don’t really need to do anything for it to function normally. However, every year, I do need to set which year is available, which involve editing about… 2-4 line of code.

This is its original purpose

As I’m too lazy to put any further significant improvement, I’ve open-sourced it several years ago. It seems that not many people know that you can get the source code and see how it works. Probably because I did not put a “Fork me on Github” banner before, which I just did yesterday. I hope that some other geeks can learn from its source code, and create their own version, or better yet, create a totally new one, as the code is quite ugly. The code originated nearly 5 years ago when I was still in CFS. Back then, the popular ‘schedule maker’ part did not exist, only the ‘schedule formatter’ which works on CFS’s slip exist. It was originally designed to run on Google App Engine as I don’t have money for my own server back then. Because of that, the code is pretty much some hacks over some other hacks. Therefore, I recommend that those who want to make a similar system to build one from ground up. You can also, just host it yourself. In fact, when the new I-Maalum system was announced, I was expecting them to also integrate a similar solution, or even just straight up copy-paste it. That did not happen.

So when will it go down? Who knows. The thing is, removing it from the server also take some work, and I’m too lazy for that. I’ll probably just leave it there. If my server crash, I may forget to start the application manually (which happened a few month ago). Once it is up, It does not really need much maintenance, so it will probably stay up for some time. However, for the 2017/2018 session, I’ll need to add that to the server’s config and I can’t guarantee that. Chances are, I’ll forget about it. In fact, I did forget about the 2016/2017 session until someone mentioned it to me. That is assuming no major changes in the IIUM system. If IIUM decided to change the format of their course list page, the scraper will not longer work and it will no longer give you updated course list.

Fork me!

In conclusion, tell your geek friend to make a similar system. I’m graduating, I don’t even know when is the prereg, start of semester and such. I thank you all for your kind support and encouragement throughout these years, I appreciate it. It is truly a satisfying feeling to know that your work helps a lot of people, even if it does not get you money, and the code is very ugly. Also, if you need to contact me, email me directly at Please do not PM me through facebook, as facebook have the ‘message request’ filter. Sorry, if I did not reply to your facebook message if you messaged me a few month ago because I did not realize it, and replying now would be very awkward. That is all from me. Goodbye and Assalamualaikum.

ps: Try reading this article again, but everytime you find the word ‘lazy’, change it to ‘busy’. Its interesting how changing the meaning of a single word can change a lot of perspective. Also its not far from the truth too. 

Programming Projects

Thru Earth Position

Assalamualaikum everyone,

People in US usually said that “China is halfway around the world”, which means that, (given that the earth is round) if you want to point where where is China, you would point it straight underground. I wonder, what about other part of the world? Do North pole also go down? How far down? So I made an app for it called “Thru Earth Position”.

A poor man’s logo.

Why “Thru Earth Position”? The answer is mainly because I can’t figure out a better name. It was originally an augmented reality experiment on how to map location on earth to the screen. Or in another word, I want to move around the screen and the screen will show what location is in front of me. It work, and I thought it was cool, so I made another one, with a 3D globe-like interface. For some reason, the addition of 3D globe visual kinda reduce the feel of AR-ness. 

Something feels off…

That, or mainly because I’m generally a bad designer. The app also shows the distance from your current position. It is relatively simple, with some settings do show or hide elements. It does not use the internet aside from google maps and geocoding to fetch the location name.

The app is actually my first ‘kinda-proper’ mobile application. It is made using libgdx(an OpenGL game framework) and Kotlin(a Java compatible programming language). So, it is kinda an experiment on “making an android app using Kotlin and libgdx with some OpenGL stuff”. It is available on google play store. Which means, it is also another experiment on “what happen when you make a relatively simple app and publish it”. You can find it here. Try it out, and let me know what you think about it.


What’s special about IIUM?

This article was never finished. I publish it in relation to this article, because it shows the environment of IIUM. Some part of this post was cut and some part was added to better reflect the changes.

Assalamualaikum everyone. One of the most read article from this blog is the Past, Present and Future of IIUM. In that article which is actually an assignment for one of my class, I wrote about what I think about IIUM. Two years has passed and I’ve just ended my final studying semester from IIUM. So today I’m going to write an update regarding that in the perspective of a graduating student. I’m going to talk about IIUM Gombak specifically, not CFS or IIUM Kuantan or any other IIUM campus. I’m also going to refrain from talking about Kuliyyah of Information and Communication Technology (KICT). That will come later as a separate post. This post is more of a general review without considering a specific Kuliyyah. Although admittedly, my perspective is influenced by KICT.

The original article have a general critical tone towards IIUM. Somewhere in the article I said that IIUM is not very international, not very islamic, not as “university” as it should, but it is in Malaysia. This is, (although there are some truth to it) not a very comprehensive assessment. There are certain characteristic that makes IIUM special, and I think that article does not do it justice. 

Lets starts with the general physical inspection of IIUM Gombak. Generally, other public university in Malaysia is characterized by a large area with distinct discrete buildings forming the individual faculties, residential area and other facilities.You would definitely need a vehicle to travel between these buildings. These university are generally several kilometer square wide. Some university are effectively a town with faculties scattered throughout it. IIUM Gombak is not like that. IIUM Gombak is characterized by a large circle (not really a circle) of one way road. Most of the faculty (called kuliyyah in IIUM) and facilities is located within this circle. At the center of the circle, lies the main mosque and administration offices. Around it are the various kuliyyah except KICT as KICT is a new building outside the circle, on a hill. Surrounding this circle is the student residential area and some recreational area. Because of this, the university is quite compact. There is no distinct physical separation between kuliyyah. Most kuliyyah are effectively connected to each other. The good thing is, you can walk around the campus without a vehicle. In fact, there are dedicated tunnels under the main one way road between the residential area and the center of the university. However, it would still take about 30 minutes to walk from one end of the circle to the other end. So a motorcycle is recommended. A car however, is not so recommended because you would have trouble finding a place to park your car. That is, unless you study in KICT because there is a lot of empty parking space in KICT.

The climate in IIUM is relatively cold. Some foreign student said that IIUM is quite hot. I’m guessing they never stayed outside IIUM, because its a lot hotter outside of IIUM. The cold climate is because IIUM is surrounded by hills and forest. IIUM Gombak is located at the edge of Selangor. In some way, it is a bit remote. However, there are bus shuttle to the Gombak LRT station and its connected to a highway. This makes IIUM feels like it is somewhat in an urban area. Because it is surrounded by forests, you may stumble upon various form of wildlife. Sometimes you may stumble upon the biggest butterfly you have ever seen. Sometimes a group of monkeys visits you room. Other types of wildlife includes lizard, snake and wild boars. The geographical nature of IIUM, coupled with a not-so-modern building design feels a bit like a garden. There are two rivers flowing through the central complex. Unfortunately they often looks murky. There is a lake at the north of IIUM. Unfortunately it is now a field due to sediment accumulation due to the logging north of IIUM. It was still a lake when I was in my first year.

All buildings in IIUM follows a similar design. I’m not exactly sure why. The KICT building is a bit different, probably because it is relatively new. The design is a bit brownish with blue roof. It is not modern looking. I would describe it as ‘conservative’. Only Kuliyyah of Architecture and Environmental Design (KAED) is a bit different with its main building partially having a wooden structure. One unique thing I found in IIUM is the strange toilet design. Yes, I’m talking about toilet, as strange as it is. There is always an empty space at the side of the toilet where the pipe is hanging at about 1 meter from the floor. This is consistent on every building including KICT. This means that the pipe will never touch the floor. An ingenious design that I hope every toilet would follow. IIUM is a class based university. That means, you don’t see many lecture hall. The lecture is generally conducted in class of no more than 40 student. I generally expect a university to have a large lecture hall. That is not the case with IIUM. The conservative looks, with many classes makes IIUM looks less like a university and more like a really fancy high school.

Physical appearance is only one aspect of a university. Lets talk about the people. In the previous post, I said that there are less than 30% of international student here. And that Malay and foreign student don’t mingle much with each other. That still holds true. However, as low as the ratio may actually be, I don’t think there is a lack of it. Not anymore at least. That is because, I don’t feel the presence of a foreign student as strange. When I see an African, my mind probably says, “That is an African. Ok.”. The lack of international student is not an issue, its the barrier between them. There is a large number of nationality in IIUM. If you asked me from which country that guy is from, I would say I don’t know. Even the one that looks like a Malay (and is a Malay) may actually came from Indonesia or Singapore. The diversity brings a strange sense of non-traditional feel. This is very apparent in the practice of Islam here, which I would describe as lack of Malay-nes. For example, all (most) of the mosque in Malaysia would recite ‘dua’ together after congregational prayer. That is the practice of Mazhab Shafie. However, with the introduction of other culture with different Mazhab, most of the musolla here no longer do so, with the exception of the main mosque. This is probably because most of the time, the imam of the musolla is not a local student. But even with local student, the congregational ‘dua’ may not be recited. Another example would be loud zikr. Throughout my studies in IIUM I can’t recall hearing zikr from the musolla’s loudspeaker. Where as that is very common in Malaysia. So does the readings of ‘yasin’ on friday night. Almost nonexistence. In IIUM ‘songkok’ and ‘kain pelekat’ does not represent that someone is pious. And righfully so, there is no way to know the iman of someone based on his clothing. I also don’t see much ‘serban’ around here. If you are expecting the environment here to be like a religious school in Malaysia, where most student would wear white dressing and ‘serban’ you are severely wrong. The flavor of Islam here is quite different.

Because of the diversity, the Friday khutbah here is conducted in either English, Arabic or Malay. You heard that right, khutbah in English. The Arabic khutbah here is ‘unscripted’ compared to in normal Malaysian mosque.If the khutbah is conducted fully in arabic, someone would give the summary in english after the Friday prayer. Even if is scripted, the script changes. Sometimes they bring some mufti from arabic country to give khutbah. Sometimes big international Islamic celebrity would give khutbah in IIUM, like Mufti Menk, or some western preacher. This means the khutbah here can be quite interesting. Listening to a normal Malaysian khutbah feels like a significant downgrade. Very significant. However, that really depends on the week. Sometimes the khutbah can be as dull as a normal Malaysian khutbah. The ‘unconventionality’ of IIUM is best exhibited by the fact that IIUM is the first place I see that the khatib uses a powerpoint slideshow during his khutbah. 

Unsurprisingly, this unconventionality can be opposed by the largely conservative Malay population. It is not surprising to see people to remind future student to be careful of the various ‘teachings’ of IIUM. Whether these ‘teachings’ is correct or not, I’m not the right person to answer that question. But consider this, these people speak Arabic, the language of the Quran. Which is one of the reason why the Imam of the musollah is usually an international student. They memorize and recite the Quran very well. In (Ishak usually) congregational prayers, the Imam would recite surah which I did not recognize likely because it is somewhere in the middle of Quran. What’s amazing is that, if the Imam forgot the verse (and stutter), several of the ma’mum would remind him (by reciting it loudly). That means, there are several other who remember the surah. This is in the musolla, not the mosque. The ‘level’ of Islam can especially be felt during the month of Ramadhan. Like most Malaysian mosque, IIUM’s mosque conduct 20 rakaat of tarawih prayer. However, 8 rakaat here is as long as 20 rakaat in most mosque. It turns out, it is harder to do 8 long rakaat than 20 short rakaat. Things get even more serious at the last 10 night where dozens of people bring pillows and mattress to spend the night at the mosque. I don’t know about other area in Malaysia, but from the perspective of someone from Meru, Klang, which I would consider a bit religious, seeing people bringing mattress to the mosque is quite strange. Of course, there are a couple of people who spend the night near the end of Ramadhan, but rarely up to a point where they bring matress, and in IIUM there are dozens of them. This is up to a point where the mosque management have to ask the people to stop hanging their clothes on the second floor (there are better area for that on the lower floor). Perhaps such activity is normal in the more religious state such as Kelantan or Terengganu, but not in Klang, not up to that extent. 

IIUM student are also quite charitable. A few months (or year?) ago a viral post in Facebook tells a story of IIUM student who can’t afford to pay for his/her food. That resulted in multiple campaigns around the campus that attempt to seek and help these people. In KICT for example, the welfare committee of ICTSS decided that they would give out free food to whomever needs them. They just bought dozens of food packages and just left them out in the open. So you don’t need to register or anything, just take it. The funds for the food is provided by the student and also the lecturers. In multiple Mahallah, the student launched various coupon system where those in need can take the coupon and use it as a currency to buy food. However, I personally have never seen anyone using it and I probably wont. I do doubt the implementation of the campaign, but it is better than nothing. Occasionally, I found myself in a situation where the cafe’s cashier said that someone paid RM 1 for my food. Who did? Who knows. All I can say is, may Allah bless that guy.

All of this contributes to the relatively safe environment of the University. At least it feels so bit so compared to the outside world. Maybe deceivingly so. This safeness is especially true for a Muslim. In a world where “Muslim are terrorist”, IIUM turns out to be a place where a Muslim don’t have to worry about praying during lecture time, as the lecture time already take that into account. You don’t need to worry about ‘where is the musolla’, as every kuliyyah here have one. And the musolla here is not some kind of extra room re-purposed as a musollah like in some shopping mall. It is a musolla built as a musolla. There is no such thing as ‘awkwardly pious’ in this place, as you can expect everyone here to be at least a bit religious. Islam is not a trend nor a culture here. It is the norm. If you came from a place where being a Muslim is not a problem at all, this probably isn’t a bit problem to you. But the urban area, even in Malaysia is not built to specially to accommodate Muslim. If you are a devoted Muslim, looking for higher education in a non-religious field, there are not many places like IIUM. This is especially true if you think of Universities outside Malaysia.


Article Politics

Review of IIUM

Assalamualaikum everyone,

It has been about 3 month since I left IIUM (International Islamic University Malaysia). Technically, I’m still a student because I have not graduated yet, but my time in IIUM is practically over. So I figure I want to make a review of IIUM as a follow up to a popular article in this blog which is The Past, Present and Future of IIUM .

I’ve tried to make this article a few time actually, starting before Ramadhan. But, I never got to finish it. I went so much into details, I can’t properly put into words what I thought about IIUM. But the more I delay this article, the more the memories become blurry.

To make this article simple, I won’t describe much about IIUM. I’ve describe it quite well on a draft before which I probably would publish on another article. This one is a summary of an introverted KICT (Kuliyyah of Information and Communication Technology) student towards IIUM. I won’t be discussing much on KICT as it deserve its own post. Additionally, it is mostly a criticism rather than a more positive outlook, which I’ve described quite well on the draft.

Feels of IIUM

In summary, the feels of IIUM is quite ‘garden-like’ and very safe. However, I think the safe part is not a very good thing because the world is not safe. Of course, there would still be theft or other crimes in IIUM, but you get the feeling that almost all people here is nice. The ‘safeness’ can be shown by the fact that IIUM provides residential place for all 4 years of study. Even through internship, you can request a room. This is in contrast to other university which sometimes do not provide a hostel for the older student. Because of this, I feel like there is a significant ‘gap’ between before IIUM and after IIUM. I feel like this is not very good towards the growth of the student.

Not only that, but the environment here is quite comfortable for a devoted Muslim. Too comfortable if you ask me. You can find musolla almost everywhere and the time of the course matches prayer time. Additionally, being pious here is not a very strange or contrasting characteristic. In some way, it is the norm. Because of this, it is quite easy to be a devoted Muslim here. However, the outside world is not so forgiving. Of course, that really depends on the place where you work, but if you are unlucky, finding time and place to pray can be a problem. Heck, I could see a situation where even praying five time a day can be seen as bordering extremism. If you have a daughter that you want to keep safe, I could see the point of sending her to IIUM. But if you want her to be independent and can handle the world and all it throws at her, she will need to work more.

It is quite strange that the criticism that I have towards IIUM is that ‘it is too comfortable for a devoted Muslim’. I sound like a ridiculous person. What are the other options? Reduce the number of surau? Make a course during prayer time? Of course not! IIUM did a great job of making it a comfortable university. From the perspective of the university, in this regard IIUM did a great job. But you have to keep in mind that the world can be a dangerous place and I don’t think IIUM did much to prepare the students for it. Of course, you could just find a job in a Muslim company. But in that sense, just being an employee seems to be the limit of an IIUM graduate.

Islamization – Synergy or Compromise

By the looks of it, IIUM aims to integrate Islam with worldly knowledge. I’m sure most, if not all of IIUM student would understand what this means. Basically, we have additional Islamic subjects. All of the student is required to take some Arabic class. And in our non-Islamic subject, additional mark is given if we could relate what we learn with Islam. By the looks of it, ‘general good’ is not considered Islamic enough.

The idea is that, by such integration, the university could create people who can contribute to the Ummah. People who have high education and at the same time, a devout Muslim. But for me, it seems like a compromise. The student are not really an Islamic scholar, and at the same time, the education is not particularly excellent. And sometimes, the course desperately try to integrate Islam up to a point where we have to wonder does this ‘adjustment’ violates Islam itself. Student who took the course IT and Islam would know what I mean. We could see how this forced integration work with the library opening hours. While other university open the library 24 hours a day, IIUM struggles to keep the library open throughout office hours as it will be closed during prayer time.

Of course, to some point, I’m exaggerating. IIUM student are more Islamic than other university student, and the education is kinda up to standard, up to some point. But it does not look like it is going any further. It looks like it struggle to strive for higher standard. For example, I have to take Arabic class, but it is so basic that I can’t speak Arabic. And most student can’t too. With that, I wonder should I even bother taking the Arabic class? Of course, there are one or two student who could fulfill this high standard, but one or two outlier does not represent IIUM as a whole. Of course, it is somewhat unrealistically high expectation to expect most of the student the be such angelic scholars, but right now, I can’t say that we are either angelic nor innovator.

Administration and Finance

The administration of IIUM have a bad reputation among IIUM students. I guess it is mainly for political reason. In case you did not know, IIUM is largely funded by the Malaysian government. It probably used to be different. In short, don’t say bad things to the government, or the administration would figure-out a way to filter out the ‘negative elements’. But in some way, it is due to the ‘alleged’ corruption. Or that is actually mainly because of its inefficiency. Or perhaps, all of it.

Among the most recent questionable decision is the 5 million ringgit fountain. Which is said to be a donation by the President of IIUM. The students are not very supportive of the change of the fountain because there are other things that should be replaced. For example, the notorious chairs of CAC hall. Or they could fund the covered walkway project that cost about 0.653 million ringgit, which is proposed by the SRC(Student Representative Council), which right now, is asking for donations from the student. Or they could replaced faulty air-conditionings throughout the university. Or, they could divide it by 5 and roughly double the budget given to SRC for 10 years. Or, they could divide it by 5 and distribute it to all kuliyyah’s student society which would (significantly?) increase their budget for 10 years. Or, all of them.. except the fountain.

There are other horror stories of course, but I’m not sure about those. The administration have such bad reputation that there are ‘advice’ among the student society saying that if you manage to get sponsorship from external party, do not pass the money to the financial department (that is the official way if I’m not mistaken) because you may never see the money again.

The name

There are some upsides in IIUM. The name of the university attract certain types of people who are passionate in their cause. I know one of the lecturer in KICT used to work in NSU in Singapore, but choose to work here because of Islam. There are other lecturers too that you can see that they care about the future of Islam. And there are various other students and staff that came here for a similar reason. More often that not, these individual forms the backbone of whatever that is amazing here. However, you get the feel that the administration is holding them back through various bureaucratic issues. Throughout my studies I feel like these people in particular is what keeping IIUM alive. Of course, in any University, it is the people who make up what it is. But a University should act as an enabler that helps the students and staff. But for some reason, I see it as the other way around. Regardless of the ‘penalty’, the asset is here. The name continues to attract such individuals and among the limited reasons to choose IIUM over other Malaysian university, this should be on the top list. But then again.. there is also USIM…


In some way, I think half of the criticism I have for IIUM (aside from the administration) is simply because it is just different. There are sayings in Islam that “They (the non-muslim) will never be pleased with you until you follow their way” (It is probably from the Quran, but I don’t remember exactly where and the translation is probably wrong). I guess this is probably the biggest argument towards my criticism. “Ignore the non-muslim and just follow our way”. But for some reason, people don’t think about inviting the non-muslim to follow our way. We are always looking for new enemies instead of new friends. This is especially critical in our times because working with non-muslim is inevitable. Instead of finding new ways to differentiate us from them, we should let them in to our worlds and see from our perspective. I believe that is the direction that IIUM should go. But then again, I could be wrong.

Another thing I want to point out is to not be afraid of something which is not Islamic. I’m not talking about things which are clearly haraam such as alcohol, I’m talking about things like Computers. Like I said before, sometimes the university desperately wants to integrate Islam with something that simply cannot be directly connected. It is as if, if you can’t Islamicize it, it is haraam. This is again, in a similar theme that we seems to look for things to be branded as illegal, as our enemy. If they are not us, they are our enemy. Personally, I think this is among the things that is holding IIUM back. We are too restricted, too terrified by such mindset.

For me, right now, IIUM is not the great education center that Muslim is looking for. It is simply playing catch up to other universities. Although I have to give it some credits for making an appealing environment for Muslim… to catch up.