Trying To Code

Must be doing something wrong.

Wrestled with rewrite rules to get http://sgentrepreneurs.com/the-ultimate-start-up-space/ pointed to http://sgentrepreneurs.com/tag/martell-the-ultimate-start-up-space/ without the URL changing.

Couldn’t figure out a rule for .htaccess so in the end, wrote the rule in the nginx.conf location context just before proxying the request to Apache.

Trying To Code

|

Comments (2)

Permalink

Football Fans Of Singapore – Show Your Football Knowledge

A few days before World Cup 2010 started, I started noticing people calling out the results of upcoming games on Twitter.

I thought it would be interesting to run a game where fans make predictions using Twitter and a little application runs in the background to collect these tweets and tabulate success rates.

There are 3 prizes sponsored by Nike football thanks to a friend who helped obtained them.

Definitely not as profitable as betting on ladbrokes, but probably less of a hassle considering that it seems there isn’t an easy way for Singaporeans to deposit money into a ladbrokes account.

So, if you have a Twitter account, and love football, head down to football.onthereddot.com and participate by tweeting the results you expect.

Further notes:

Over the course of coding the site and the backend, I learned a few things about the Twitter API:

Going to update them over the course of the month as I tinker a little more with the scripts.

Back-end script to retrieve data from Twitter was written using python and:

1. The library tweepy as an interface to Twitter’s API.
2. SQLAlchemy to connect and deal with database stuff.

Front-end:

1. Built with Sinatra

Gaming
Soccer
Trying To Code

|

Comments (3)

Permalink

Hibernate Annotations – Mapping Inheritance

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name=”planetype”,
discriminatorType=DiscriminatorType.STRING
)
@DiscriminatorValue(“Plane”)
public class Plane { … }

@Entity
@DiscriminatorValue(“A320″)
public class A320 extends Plane { … }

is different from

@MappedSuperclass
public class BaseEntity {
@Basic
@Temporal(TemporalType.TIMESTAMP)
public Date getLastUpdate() { … }
public String getLastUpdater() { … }

}

@Entity class Order extends BaseEntity {
@Id public Integer getId() { … }

}

Trying To Code
Whispering from the Cubicle

Comments (0)

Permalink

Using FLARToolKit

So, never coded in ActionScript before. What to do?

Downloaded the starter kit from Saqoosha.net.

Went through the samples.

First step was to print out the marker that came with the started kit. Tested the SimpleCube sample. Everything works.

Now, try to generate a marker using my own image.

Found this online generator.

Substituted the name of my marker’s pattern in the code. Marker does not register now.

Why?

A little searching led to this:

new FLARCode( i_width:int , i_height:int , i_markerPercentWidth:uint = 50 , i_markerPercentHeight:uint = 50 );

I need to change the values passed to the constructor in the SimpleCube sample code because I had generated my marker with different settings.

After changing the values, the sample code works again.

Trying To Code

|

Comments (0)

Permalink

A Blank Canvas

What do you give a blog who is about to turn 3?

A Blank Canvas

Just in case the settings need to be changed so that the camera can be accessed:

Notes:

Never did any Flash ActionScript coding before this little project.

It was a good chance to learn a little about:

1. Papervision3D
2. FLARToolkit

Trying To Code

| | |

Comments (2)

Permalink

Facebook Connect & Facebook Share

There is a difference between using the “fb:share-button” (XFBML) tag for a Facebook Connect site and using Facebook Share.

When using the “fb:share-button” tag on a Facebook Connect site, it is important that the site takes into account the Facebook login status of the user. When using Facebook Share, it is not necessary. If the user is not logged in, the user will be prompted to log into Facebook before sharing can occur.

Trying To Code
What I Learned Today

Comments (0)

Permalink

Creating A Job Board For Programmers and Designers

For the last few months, I’ve been working on creating a job board for programmers and designers.

The design for the site was heavily influenced by 37signals’ job board. Right before launching, something about our site’s look still didn’t feel right. For want of a better phrase, I felt the site ‘wasn’t us’, where ‘us’ referred to Gwen and me.

One of the changes was to add the photo of the Lego figures taken by Ansik with a quote by Steve Jobs to the site’s design.

Do you want to spend the rest of your life selling sugared water or do you want a chance to change the world?

The quote resonated with us, especially me, because there are just so many great companies trying, or rather doing, great things that it doesn’t make sense to be stuck in a job you’re not satisfied with or a mundane job where you’re just a cog in the wheel.

So, if you know that you can make a difference, do check out the available jobs over at Triple Point’s Job Board.

2 other considerations were made when designing the front page of the site. The first was not to group the job listings by category. The other was not to include the ‘standard’ categories found in other Singapore job sites. This was done to prevent a ‘ghost-town’ effect where there are too many categories with little or not job listings for them.

The job board is still a work in progress. If you have any comments on how to make it better or what is lacking in the current job boards, do share it.

The influence and the result:


Tangled Web We Weave
Trying To Code

| |

Comments (0)

Permalink

Eclipse Builders

Old article, but still useful to understand what’s going on above:

Incremental project builders provide a mechanism for processing resources in a project and producing some build output. The builder framework makes it easier to incrementally maintain that built state as the input resources change

Trying To Code

|

Comments (2)

Permalink

Selenium + HTTPS + Firefox

These two links were invaluable:

Selenium and HTTPS:

Create a new Firefox profile (firefox.exe -profileManager). In this case the name of the new profile is selenium-https-profile.

java -jar selenium-server.jar -firefoxProfileTemplate

Dealing with self-signed SSL certificates when running Selenium server with Firefox:

Delete everything in the directory except for the cert_override.txt and cert8.db files.

Trying To Code
What I Learned Today

|

Comments (0)

Permalink

Xvfb + Selenium

Xvfb:

In the X Window System, Xvfb or X virtual framebuffer is an X11 server that performs all graphical operations in memory, not showing any screen output. From the point of view of the client, it acts exactly like any other server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to even have a screen or any input device.

Running Selenium on a Solaris server so that can run Cucumber tests via Hudson daily after each successful build. The problem was Selenium + Firefox had no display to output to.

The solution was to use xvfb and output to it.

Trying To Code
What I Learned Today

| |

Comments (0)

Permalink

Problems With MySQL and Rails 2.3

From here:

As I understood the client MySQL library doesn’t work well with Rails 2.3. We can resolve this by using the older MySQL client library (libmySQL.dll). You can get it here http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll.

Just put it in \bin\ and restart MySQL service.

http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll

Trying To Code

|

Comments (0)

Permalink

Problems With Logging-1.2.2

Was having problems with logging-1.2.2,

In utils.rb, this section of code was having issues.

rescue LoadError, NoMethodError
retry if $use_rubygems and require('rubygems')
if $whiny_require
name ||= string
$stderr.puts "Required library #{string.inspect} could not be loaded."
$stderr.puts "Try:\tgem install #{name}"
end
raise
end

Solution:

1. Set the global variables $use_rubygems & $whiny_require in environment.rb to false and true respectively.
2. Comment out the retry line.

Trying To Code

Comments (0)

Permalink

Varargs

Varargs:

As a client, you should take advantage of them whenever the API offers them. Important uses in core APIs include reflection, message formatting, and the new printf facility. As an API designer, you should use them sparingly, only when the benefit is truly compelling. Generally speaking, you should not overload a varargs method, or it will be difficult for programmers to figure out which overloading gets called.

Object[] args versus Object... args

Trying To Code
What I Learned Today

Comments (0)

Permalink

GymFu

GymFu:

At GymFu, we’ve made a series of unique motion-detecting iPhone apps which will help you make progress wherever and whenever you want.

The apps:

* PushupFu – our flagship application, attach it to your upper arm and train on the way to achieving 100 consecutive pushups

* CrunchFu – hold it to your chest and gain feedback and support as you train towards a 200 crunch goal

* SquatFu – put it in your pocket then see how many squats you can do. Improve your fitness and work towards 200 reps

* PullupFu – our newest app extends our collection to include our most hardcore of muscle workouts yet. Show off to your friends by achieving 50 pullups in a row

What I love about this app is that it highlights a way of thinking that programmers should shift to. When designing a way for users to enter data into an app, is the ubiquitous form the only way to get data in? What data is the app actually trying to record? Is there a way to capture this data with the new capabilities found in phones?

Removing the extra step of users having to manually record data will probably greatly increase an application’s usage because of the removal of friction.

Tangled Web We Weave
Trying To Code

Comments (0)

Permalink

Heroku Is Amazing

I had an idea for something, something which I had been procrastinating since last year to get started.

Within two hours, I got the app up and running, thanks to Heroku. Amazing ease of deployment.

Trying To Code

Comments (0)

Permalink

GAE, Python & JSON sitting on a tree …

Say you are writing a Twitter application, and the results from Twitter are returned using the JSON format.

Your application is written to be hosted on GAE.

You need:

from django.utils import simplejson
content = simplejson.loads(result.content)

&

{% for status in content %}

{{ status.text }}

{% endfor %}

Trying To Code

| |

Comments (0)

Permalink

Checking The MD5 For A Directory

find com -type f -exec md5sum {} \; >> out.txt

Copy the out.txt file to the other directory.

md5sum -c out.txt | grep -v OK

The reason why this was needed:

SmartSVN failed on me. The working copy was shown to be the same as the trunk copy, and while the trunk copy showed it was at the latest revision, the working copy wasn’t. So the wrong file was deployed. The solution was to re-checkout the code after nuking the whole directory. Only then would SmartSVN show the latest trunk copy (and working copy).

Trying To Code
What I Learned Today

Comments (0)

Permalink

Note To Self – Server.policy

When auto-deploying an app, remember about permissions, especially when get 404 errors.

grant codeBase “file:${com.sun.aas.installRoot}/domains//applications/j2ee-modules/hudson/-” {
permission java.security.AllPermission;
};

grant codeBase “file:${com.sun.aas.installRoot}/domains//generated/jsp/j2ee-modules/hudson/-” {
permission java.security.AllPermission;
};

Trying To Code

Comments (0)

Permalink

The Quiet Period Necessary For Continuous Integration

Quiet Period in Continuous Integration:

A Continuous Integration build should be run often, ideally every commit would result in a Continuous Integration build. But that’s often not possible or realistic or even desirable in the real world. For example, lets say that to fix an issue the developer had to modify two source files. He first commits one of the files forgetting for the moment about the other one. A few seconds later he realizes that the other file needs to be committed as well. This will result in two commits. Ideally, there should be a Continuous Integration build that captures both these commits. If there were a build between the two commits then such a build would fail.

To ensure that such a situation will result in a single Continuous Integration build, we can use a Quiet Period. The Quiet Period is a length of time that the source code repository must be without any commits before a Continuous Integration build can proceed. Ideally, this length of time will be long enough for the developer to make all commits that are part of the same change to the source code and short enough to still get quick feedback on commits. Chalrie sets his at one minute. The purpose of the Quiet Period is to make sure that the source code taken for a Continuous Integration build contains a consistent set of changes. AnthillPro fully supports a configurable Quiet Period duration.

Links Watch
Trying To Code

Comments (0)

Permalink

Localhost

http://localhost:3000/1

Ignore This
Trying To Code

Comments (0)

Permalink

code::XtremeApps:2009 – Kiasu Singaporeans Found!

This year’s competition’s theme was healthcare. From the competition site:

The theme for this year’s competition will be on healthcare. The possibilities are endless: mobile applications, web services, and even interfacing with Wii remotes (hint: Python can do it in just 5 lines). So put on your thinking cap and get those creative juices flowing!

It was actually quite trivial to guess some of the possible challenges especially looking at the description of the partners:

This year’s competition will be held in collaboration with the Health Promotion Board and the Singapore Anti-tuberculosis Association, to educate our youths and the public, through the competition, the benefits of healthy living and the harmful effects of smoking.

Like any well-trained product of the Singaporean Education System, my mind started racing when I read the competition’s site. I told my Vietnamese teammates during our first meeting that the people who will eventually win the competition are those who prepared for it beforehand.

They agreed.

Our main disagreement was the kind of preparation involved.

I shared with them that I understood how the Singaporean student’s mind generally works. There were definitely going to be teams who will attempt to spot the challenges, take a gamble and prepare a finished product before the actual competition leaving the day itself for the polishing of their work.

I was right.

On that day, I can pin-point at least 3 teams who finished their entry the minute they read the list of possible challenges to attempt. In the toilet, I heard one guy commenting to another that their friend had hit the jackpot with his project.

My teammates and I also decided to prepare for the competition. However, our preparation was confined to coding stubs that we could easily extend depending on the nature of the project. We also tested a basic system for communication between an Android application and a Django-powered portal.

Am I sore that other teams prepared beforehand. I’m not sure. I don’t exactly think they took the easy way out because the effort to prepare something before the competition isn’t trivial. What if I knew such a team won? Would I be sore? Probably. Because the efforts they took totally goes against the spirit of a 24-hour programming competition.

Yet I’m probably angrier with myself for not preparing better for the competition by writing more stubs and being more familiar with each platforms (i.e. Android and Django).

It would be a dumb-ass generalization to say that all Singaporeans spot questions and like to take the seemingly easier way out in preparation for such stuff and all foreigners do not. I do not have the temerity to assert that ONLY and ALL Singaporean students do this.

But I do know this, speaking as a recovering member of the Singaporean Education System, and that is our system does have the tendency to produce such students.

Regardless of the behavior of foreign students, it would be a total shame if Singaporeans only know how to exploit loopholes to win. Even more of a shame, if we do exploit such loopholes and do not win.

On Singapore
Trying To Code

Comments (2)

Permalink

code::XtremeApps:2009 – Reaching The Second Round

Last weekend, my colleague, his friend and I took part in the code::XtremeApps:2009 competition. The challenge we chose was to build a H1N1 contact tracing system. It was a grueling 24 hours and at the end of the time we had developed a Django + Android system that we were rather satisfied with. Apparently, the first 3 judges agreed and the team was selected for a second round to present in front of a larger panel of judges.

During the second round of presentations, from the questions that the judges asked, I realized that we had failed to comprehend the full scope of what it means to do ‘contact tracing’. While our system aided ‘contact tracing’, it was not a full implementation of the functionalities needed for that process.

Killed partly by missing business requirements.

An advice for teams taking part in future competitions – when choosing a challenge, it might be helpful to stay clear from those that require you to implement a system that facilitates very specific processes that the judges are already familiar with even though they might not have an application to aid their work.

So, if one of the challenges is to create a game that helps people stop smoking and another challenge is to create a system that allows health care workers to monitor the reporting of critical emergency cases, the smarter choice would be to choose the former challenge because it is less likely that you will miss out on a business requirement because of a lack of domain knowledge.

In any case, it’s a total bummer that we didn’t win anything. The two silver linings are that I found a team I really enjoy coding with and that I’ve become acquainted with the platforms Django and Android.

Trying To Code

Comments (0)

Permalink

Behaviour Driven Development

Dan North introduces BDD:

Story Template:

As a [X]
I want [Y]
so that [Z]

Story Acceptance Template:

Given some initial context (the givens),
When an event occurs,
then ensure some outcomes.

The fragments of the scenario – the givens, event, and outcomes – are fine-grained enough to be represented directly in code. JBehave defines an object model that enables us to directly map the scenario fragments to Java classes.

Dan North on stories:

It has to be a description of a requirement and its business benefit, and a set of criteria by which we all agree that it is “done”. This is a more rigorous definition than in other agile methodologies, where it is variously described as a “promise of a conversation” or a “description of a feature”. (A BDD story can just as easily describe a non-functional requirement, as long as the work can be scoped, estimated and agreed on.)

Trying To Code
What I Learned Today

|

Comments (0)

Permalink

Routing In Rails

A good series of blog posts to understand rails routing.

Links Watch
Trying To Code

Comments (0)

Permalink

The Power Of Inexperience

The power of inexperience or rather the lack of power due to inexperience – you don’t realize that there are better tools to do the job.

I’m pretty sure my team lead knew I was going down the wrong brute force path when he saw what I was doing. I guess if I didn’t feel the pain of what I was doing, i wouldn’t have realized the stupidity of that path as well as appreciate this.

Trying To Code
Whispering from the Cubicle

Comments (1)

Permalink