I’ve started writing code for a SMS application server microframework I intend to use for one of my personal project. I need it to run as a daemon and must be fast to receive and respond to SMS messages. I decided to use NodeJS. Pushing to my github repo when done.
Posts Tagged: Programming
26
Apr 10
underscore.js
Underscore.jsmade my server side javascript coding easier. I don’t need to write my own buggy implementation of map-filter-reduce routine anymore.
26
Apr 10
node-stomp: STOMP client for NodeJS
I wanted to teach myself NodeJS so I wrote a library/module called node-stomp that talks to a STOMP server. That was a fun experience.
31
Aug 09
jqtouch
trying out jQTouch again. i remembered when i first got my iphone 3G, i tried to write a better webapp version of my favorite bus schedule app for iphone. i was torn between iUI and jQTouch. being a jQuery fanboy, choosing jQTouch was a no brainer. the animation wasn’t as smooth as a native app but it’s easier to work with. the project? like most of my toys, it’s in limbo.
13
Aug 09
ruby-like syntax for javascript array functions
At work, we recently decided to use YUI (Yahoo UI) to generate our user interface. YUI is great. It got almost all the widgets we need. Tabs, tree, carousel... As a result, we have consistent look all throughout. We dump the javascript framework that came with Ruby on Rails and use YUI instead.
Now, here's the problem. If you've use prototype or jQuery, you must be used to using the utility functions these frameworks provide. I go big on jQuery's each function for iterating through arrays and array-like object. Unfortunately, YUI - in version 2.x, at least - does not provide these array functions.
In a course of an hour, I wrote a handy set of functions to get me through. It could've been easier if I just include jQuery since the noConflict function makes it work with any js framework but then I got a mandate to focus on YUI.
-
Array.each = function(a, fn){
-
for(var i=0; i <a.length; i++){
-
fn(a[i]);
-
}
-
};
-
-
Array.prototype.each = function(fn){
-
Array.each(this,fn);
-
};
-
-
Array.collect = function(a, fn){
-
var new_array = new Array();
-
a.each(function(e){
-
new_array.push(fn(e));
-
});
-
return new_array;
-
};
-
-
Array.prototype.collect = function(fn){
-
return Array.collect(this, fn);
-
};
-
-
Array.inject = function(a, init, fn){
-
a.each(function(e){
-
init = fn(init, e);
-
});
-
return init;
-
};
-
-
Array.prototype.inject = function(init, fn){
-
return Array.inject(this, init, fn);
-
};
-
-
Array.detect = function(a, fn){
-
for(var i=0; i <a.length; i++){
-
if(fn(a[i])){
-
return a[i];
-
}
-
}
-
};
-
-
Array.prototype.detect = function(fn){
-
return Array.detect(this, fn);
-
};
-
-
Array.select = function(a, fn){
-
var new_array = new Array();
-
a.each(function(e){
-
if(fn(e)){
-
new_array.push(e);
-
}
-
});
-
return new_array;
-
};
-
-
Array.prototype.select = function(fn){
-
return Array.select(this, fn);
-
};
-
-
Array.reject = function(a, fn){
-
return a.select(function(e){
-
return (!fn(e));
-
});
-
};
-
-
Array.prototype.reject = function(fn){
-
return Array.reject(this,fn);
-
};
-
-
Array.reduce = Array.inject;
-
Array.prototype.reduce = Array.prototype.inject;
-
Array.map = Array.collect;
-
Array.prototype.map = Array.prototype.collect;
Use it like:
-
>>> var a = [1,2,3,4];
-
>>> a.reduce(0, function(x,y){ return (x+y); });
-
>>> 10
Basically, almost all functions are built on top of Array.each so I'm not sure how fast it'll go.
Happy hacking.
10
Jul 09
programming clojure
just acquired programming clojure book which i've been waiting for months (really, that long?). i'll be a happy hermit for weekends to come.
28
Jun 09
objective-c and clojure
spending my weekends context switching between Clojure and Objective-C/Cocoa. Clojure for filling my functional programming needs. Objective-C/Cocoa for creating pretty user interfaces for Mac and, hopefully, iPhone.
21
Jun 09
productive sunday
felt that this sunday is my most productive in recent months. it's even a father's day.
13
Jul 07
Trying out CakePHP
When I was evaluating PHP web frameworks that I would focus on and use on a regular basis, I didn't go with CakePHP. Instead, I went with CodeIgniter for reason that I was able make and run a sample app with CodeIgniter a few minutes after install while I was pulling hairs with CakePHP.
But not anymore. I had a pleasant experience experimenting with CakePHP over the last couple of days. It might be that I have I already know Rails which made Cake's approach fits my brain easily as Cake and Rails have lots of similarities.
Deciding which PHP framework to use on the next project will be a very hard decision to make for me. Cake's ActiveRecord implementation is better than that of CI. On the other hand, CI gives me full control of almost everything.
25
Nov 06
Rails vs Django Comparison
Scratching your head which one to use? Read this comparison document. Yes, I was even more confused after. Why can't people take sides nowadays.