Thursday, April 23, 2009

God, please don't do something!

Saturday was not the nicest day I've spent in a while. Church had a program that day and the next, and I had a number of responsibilities to handle, including the ones I normally have at home. On the good side, my brother was home for the weekend, so he could handle some of the chores at home. On the minus side, he had to go out, and I was just informed that morning that painters were supposed to come to the flat that day :(

So the day basically progressed…after the church program in the evening, I was supposed to go somewhere with some other folks — when the clouds turned dark for the umpteenth time that day — but they meant business this time. it started raining, and we weren't able to get bikes where we were headed because of the rain. Everyone fired up his "Legediz Benz" and started hurrying while being pelted. Someone then said, "God do something", and I (jokingly) remarked that what if God, acting mischievous, decided to turn the knob controlling the rain to "Heavy Rain"? It started as a joke, but the rain did indeed get heavier — we all got soaked through and through. Still being pelted by the rain, I brought up the issue, and we all agreed, "God, don't do something! Turn off the rain!"

Moral of the story? Don't ask God to do "something". Ask Him to do something specific. :D

Thursday, April 16, 2009

Software gripes

this post is fairly ordinary — it's just a rant about some software i've had to deal with today. this morning, i was using my brother's computer when iTunes informed me that there was an update. great. i decided to update it, only to be reminded why i no longer use iTunes — it's bundled with QuickTime. you can get QuickTime by itself, if memory serves me, but you can't get iTunes by itself. shame.

something similar happened today when updating Aptana Studio. i'd installed the basic distro quite all right, then i wanted to update it to get some functionality (Javascript libraries, etc). most everything went smoothly when i only installed functionality for the latest version of the Javascript libraries except YUI and MooTools. i'd install support for the latest supported version, restart Apatana Studio, and it would prompt me again. the problem went away for MooTools when i decided to install support for the older version as well. the problem for YUI is that the download is large, so installing support for older versions will just eat disk space and not give me any returns. sigh.

UPDATE: yes, installing support for versions 2.4 through 2.7 of YUI for Apatana Studio left no more complaints. whoopee.

Thursday, April 09, 2009

I envy Python programmers

I've sort of settled with a programming language I generally use, C#. I know other languages too, and sometimes I wish I did more Python programming. Python really simplifies programming. As an example, I coded an application recently that automated pushing form values to a web page. In C# 3.0, the code would look like this:


using System.Collections.Specialized;
using System.Net;
//...
var formData = new NameValueCollection { { "Var1", "Value1}, {"Var2", "Value2"}};
var webClient = new WebClient();
webClient.UploadValues("http://localhost/localapp.aspx", formData);

In Python 2.X, the code would look like this:


import urllib
#...
formData = urllib.urlencode({ "Var1" : "Value1", "Var2" : "Value2"})
urllib.urlopen("http://localhost/localapp.aspx", formData)

There's no error handling or anything special in this. This example is rather contrived, to be completely fair, but when you add other things like multivariable assignment, and take into consideration Python's standard library, you might understand why I'm envious. Ah well

Thursday, April 02, 2009

Remarkable service

Joel Spolsky has an excellent article on customer service. I didn't really think there was much to the article until someone shocked me by doing something like that for me

there are several ORM toolkits for the .NET platform, most notably NHibernate. i came across Habanero sometime back, and i can't remember how, but i tried using it for a project, and found out that the FireStarter tool didn't apparently support Windows authentication for SQL Server. i decided to send them feedback about this, and got an immediate email that my feedback had been received. nothing strange about that. what is remarkable was that i got an email from the Habanero team yesterday detailing some workaround that allowed me use Windows authentication with both Habanero and Firestarter. considering that i'm not a paying customer, i'm really impressed with this. here's a big one for the Habanero team!

Sunday, March 29, 2009

I made my first "hit"…I can now retire…(lol)

i've always had an interest in music. not merely as a listener and enjoyer of the audio arts, but i always wanted to make my own tracks. for fun and personal enjoyment. so i have a collection of VST instruments and effects, but i've never really gotten down to making any tracks. same as i've not done any 3D in a while :( anyhow, last night i got to being serious with at least making a 2-instrument track longer than 5 seconds :D so, in all its glory, i present to the world my lastest "hit" and expect those royalties to start coming in anytime soon (but i'm not holding my breath :D)

Get this widget | Track details | eSnips Social DNA

Thursday, March 26, 2009

Flop “Date”

it began with a call: “B's taking us to the movies, but insists O comes with a date, so…”. i'm a pretty solo kinda person. i don't really come into contact with people for the most part of the week. we're less than 10 at the office and only two in my area of it, and then i go home where it's just family — i rarely even see, much less talk to the neighbours. my phone rarely rings or beeps outside work hours. it's a life i'm used to — it sucks, but at least i know it.

but this date thing caught me offguard. even though i prepared for it, told my dad i would be having a sleepover, i was still reluctant to go. O called me on the morning, and thought i didn't have her number cause of the way i spoke. at any rate, i stayed late at the office. after waiting for the ladies to show up, we went to see Watchmen at the Palms. first time i ever went to the movies — and of all the movies to see, i just had to go watch Watchmen. as far as i'm concerned, very bad choice (plus some of my popcorn got lifted).

i basically glowered most of the movie, especially after the popcorn was gone. the ladies didn't seem to like it either, since they paid more active attention to me than the movie. i was basically regretting the waste of my time in something i didn't enjoy. i have my own timewasters — but i at least enjoy them. i pushed the feeling that i was the group wet blanket away several times, and did nothing to improve my mood or attitude (yes, i know. sue me — i'm a far more skilled jerk than nice guy). anyhoo, my date complains later that i ignored her. i keep my usual sarcasm in check and basically say nothing. she's basically saying something i already know about me: i suck at relating with humans. odd. because despite my fighting it i remain human.

Wednesday, March 25, 2009

The Middle Wife

my dad sent this to me, and i felt it was too good to pass up. here y'all go:

I've been teaching now for about fifteen years. I have two kids myself, but the best birth story I know is the one I saw in my own second grade classroom a few years back.

When I was a kid, I loved show-and-tell. So I always have a few sessions with my students. It helps them get over shyness and usually, show-and-tell is pretty tame. Kids bring in pet turtles, model airplanes, pictures of fish they catch, stuff like that. And I never, ever place any boundaries or limitations on them. If they want to lug it in to school and talk about it, they're welcome.

Well, one day this little girl, Erica, a very bright, very outgoing kid, takes her turn and waddles up to the front of the class with a pillow stuffed under her sweater. She holds up a snapshot of an infant. 'This is Luke, my baby brother, and I'm going to tell you about his birthday.'

'First, Mom and Dad made him as a symbol of their love, and then Dad put a seed in my Mom's stomach, and Luke grew in there. He ate for nine months through an umbrella cord.' She's standing there with her hands on the pillow, and I'm trying not to laugh and wishing I had my camcorder with me. The kids are watching her in amazement.

'Then, about two Saturdays ago, my Mom starts saying and going, 'Oh, Oh, Oh, Oh!' Erica puts a hand behind her back and groans. 'She walked around the house for, like an hour, 'Oh, oh, oh!' (Now this kid is doing a hysterical duck walk and groaning.)

'My Dad called the middle wife. She delivers babies, but she doesn't have a sign on the car like the Domino's man. They got my Mom to lie down in bed like this.' (Then Erica lies down with her back against the wall.)

'And then, pop! My Mom had this bag of water she kept in there in case he got thirsty, and it just blew up and spilled all over the bed, like psshh heew!' (This kid has her legs spread with her little hands miming water flowing away. It was too much!)

'Then the middle wife starts saying 'push, push,' and 'breathe, breathe. They started counting, but never even got past ten. Then, all of a sudden, out comes my brother. He was covered in yucky stuff that they all said it was from Mom's play-center, (placenta) so there must be a lot of toys inside there. When he got out, the middle wife spanked him for crawling up in there.'

Then Erica stood up, took a big theatrical bow and returned to her seat. I'm sure I applauded the loudest.. Ever since then, when it's show-and-tell day, I bring my camcorder, just in case another 'Middle Wife' comes along.

Now you have two choices...laugh and close this page or pass this along to someone else to spread the laughs.. I know what I did!!!

Monday, March 23, 2009

Provoking a Blessing

today, i was reminded about what it means to provoke a blessing. normally, the word “provoke” is used in a negative context; but i like what the Free Online Dictionary says: “to give rise to, to evoke; to bring about deliberately”. that's what happened today. i was rushing off to work this morning, and somehow dropped my wallet in the bus i took. there wasn't much money in the wallet, but it did contain my ID cards, some business cards and my ATM card. i was tempted to despair — just how deeply, i'll leave you to guess. but i decided that i'd walk in faith about it and remembered telling God that i give the tithe, and so the devourer is rebuked for my sake. i went back home and dropped my laptop off, then started coming over to work.

when i got to work, i found that someone had called my office saying i'd dropped my wallet. i wasn't sure about calling back since he might have called from a business line. when he didn't call most of the day — and i'd confirmed that he did call from a business line, i was tempted again to despair. i decided to keep trusting God's word instead, regardless of how i felt. i left the office not having heard from the finder. on my way home, my colleague sent me a text saying the guy had called from a business line and i should call him back. i set up a meeting, but it still didn't feel like the guy would return my wallet. after getting home, i waited till the meeting time then. i had mixed feelings — joy that i'd be getting my wallet back, and a temptation that it was just a game. to cut the story short, the person who found my wallet showed up. he was a secondary school kid. i gave him what i could, and wanted to clear off, but i didn't feel satisfied. i decided to pray for him there on the street, but i still didn't feel like i'd “hit” it. it's the second time in less than a week i've had this feeling. this first was when my sister came over when we were out and helped us with cooking and me with my laundry.

when i got home, i was still praying for him. i guess i kind of understand how God felt when Solomon offered a thousand burnt offerings to Him. there're just some things you do that make people want to bless you. i experienced God's blessing today, and someone was used by Him, and i felt provoked to share that blessing with him. that's all. except i got my wallet and its contents (complete with the N10 in it :D) without having to go to the police or do any funny stuff. and the wallet came back to me. i couldn't have gone looking for it anyway. coincidence? i think not.

Saturday, March 21, 2009

Refactored code...which is better?

this morning, i was editing some code, and Resharper warned me about a possible System.NullReferenceException. i'd been bitten before by this in the same code, but that was because i didn't understand how XmlReader worked then. here is the original code:


MessageDatabase messageDatabase = null;
MessageTable messageTable = null;

while (configReader.Read())
{
  if (configReader.NodeType == XmlNodeType.Element)
  {
    // ...
    if (configReader.Name == "messagedatabase")
    {
      messageDatabase = new MessageDatabase();
      messageDatabase.Name = 
        configReader.GetAttribute("name");
      MessageDatabases.Add(messageDatabase);
    }
    if (configReader.Name == "messagetable")
    {
       messageTable = new MessageTable();
       messageTable.Name =
        configReader.GetAttribute("name");
       messageDatabase.MessageTables.Add(messageTable);
    }
    if (configReader.Name == "identityfield")
      messageTable.IdentityFieldName =
        configReader.ReadElementString();
    // ...

as you can probably tell, it's supposed to parse an XML file and convert it into a bunch of objects. nothing wrong with that. it takes into account the structure of the XML and makes an assumption based on that, namely, the <messagedatabase> element is always processed before the <messagetable> element, so messageDatabase will be set to an existing MessageDatabase object before any MessageTable instance is created.

a more explicit version of the code is shown below:


while (configReader.Read())
{
  if (configReader.NodeType != XmlNodeType.Element) continue;
  // ...
  if (configReader.Name == "messagedatabase")
  {
    var messageDatabase = new MessageDatabase
    {
      Name = configReader.GetAttribute("name")
    };
    MessageDatabases.Add(messageDatabase);
  }
  if (configReader.Name == "messagetable")
  {
    var index = MessageDatabases.Count - 1;
    var messageTable = new MessageTable
    {
      Name = configReader.GetAttribute("name")
    };
    var currentDb = MessageDatabases[index];
    currentDb.MessageTables.Add(messageTable);
  }
  if (configReader.Name == "identitfyfield")
  {
    var dbIndex = MessageDatabases.Count - 1;
    var currentDb = MessageDatabases[dbIndex];
    var tblIndex = currentDb.MessageTables.Count - 1;
    var currTbl = currentDb.MessageTables[tblIndex];
    currTbl.IdentityField =
      configReader.ReadElementString();
  }

while this is more explicit, the code is simply more. for each property of the MessageTable, i must get the index of the last database and the last table in it, and then set the values accordingly. that plain sucks.

there was one good thing about writing this post: i finally thought about where i could optimize the loop that advances configReader, and added continue statements where they wouldn't cause exceptions. :D

Sunday, March 08, 2009

Done in very cleanly by Opera Mini

i had an emergency, and needed to send someone an email. i'd just installed Opera Mini, and decided to acutally use it instead of my phone's default browser. i logged into GMail, opened the mail i wanted to forward, and began forwarding it. i had to attach a file, so i copied it to my phone's memory card and attached it with no hassles. the problem was that every time i clicked 'Send', GMail would belch up an error concerning an invalid email address, which came to something like “/tmp/<gobbledygook>”. i resent this email thrice, to the same effect. Opera Mini is a great mobile browser. but i'm really shaken, as this is my first time using it, and i had this problem. ah well. since my main internet came up, i no longer needed to send the mail (which incidentally, was saved in my 'Drafts' folder).

Saturday, February 28, 2009

How I use Python

i love Python. i find it one of the most expressive programming languages i know. It's saved my bacon quite a number of times. for instance, when i generate test data for other applications i write, i generally generate the data (and usually the SQL to insert it into a database) with Python. also, when it comes to sorting data, it's much faster to write scripts to do basic data sorting (as an example, sorting out CDRs from Asterisk) in Python than it is in most languages. today was no exception. i had loads of numbers to send text messages to and i needed to weed out invalid destinations. for the first 50 or so, it was easy enough (but tiresome) to do by hand. when i started to look at just how many, i decided to write a script to help me sort out the numbers. abut 10 minutes later (mostly spent trying to create regular expressions that would do just what i wanted), i was done. and most of the program worked beautifully (well, there were some hiccups. i'm not perfect!)

Friday, February 20, 2009

The value of multiple cores

my laptop uses an AMD Turion 64 processor that clocks in about 1.8GHz. i've always thouht it was a pretty good one — at least until this morning. i've never been faced with the value of multiple-core processors personally as today. what happened is i was trying to get back into design & 3D, so i decided to model & render items i could find around me. so i started modeling this: after modeling and setting up the scene in Blender to render with Indigo, i started a render. almost six and a half hours into the render, it looks like this: then i take the scene to the office and try rendering on a Pentium Dual Core 2.0Ghz. about four and a half hours later, it look like this: obviously the second render is better. and it ran for a shorter time. i'm officially jealous! i want a multiple-core system now! :D

Wednesday, February 18, 2009

Accessing SQL Server (2005+) databases in .NET Windows services

just a simple quickie here. i completed my application (somewhat...do we ever really complete applications?) - and the service it was meant to configure — then found out that while it ran beautifully in console mode, it just sat there after connecting to the SMPP server. i kept wondering what the problem was. much later i realized that the service was created to run using the local Service account, which is a low-privileged account. as such, it cannot connect using Windows authentication to SQL Server versions that support it. in reality, this is the second time i've faced this issue. at any rate, all i needed to do was change the service to run under the local System account (a highly privileged account) and the problem was solved. another solution would probably be to use SQL Server authentication, which Microsoft doesn't recommend. yet running a service using the local system account is also seen as a bad idea. i guess you'll need to make a tradeoff to solve this problem.

by the way, this is the app i was complaining about. . many thanks to Component Factory for the excellent (and free) Krypton Toolkit.

Tuesday, February 17, 2009

Weird issue in Visual Studio

i was working on the config application for a service i wrote...but i ran into something really strange:

Thursday, January 29, 2009

The Matador

Just now I was having dinner, and the TV was on. We're subscribed to DStv, and while I usually don't watch TV, my computer was busy in the room, so I had to manage until I was done with dinner. M-Net Movies was showing The Matador, and I just happened to watch the scene where Bean (Hope Davis) wakes up and meets Danny (Greg Kinnear) having breakfast. They start kissing and then it gets heavier; Bean asks Danny if he has enough time, Danny already strips to his shorts when he shouts, "Tree!" — and a tree crashes into their kitchen. I could hardly stop laughing. I don't care how hard your hard-on is—a tree crashing where you want to have sex will put a stop to that quickly. No, I didn't stick around to watch the rest of the movie (it's still running now). Oddly enough, while reading about the movie, I found out that Danny asks Bean if she's still horny after the tree crashes. Is he an idiot or what?. Now if I were God...

Baby steps with Mono

Mono is definitely some great software. I downloaded and built Mono on our Asterisk server because it seemed I'd have to develop the application to handle the automated calling on Linux. Not wanting to hurt myself with PHP, Ruby or Python (time frame), I decided to continue using C# and .NET, since I knew enough about Mono to know it is cross-platform. What I wasn't prepared for is just how cross-platform it (and .NET) is. After downloading and building it, I created a "Hello, World" application in it and ran it on the Linux server. I then moved the compiled assembly to my Windows desktop and it ran with the Microsoft .NET framework! After I got home, I built one of my old programs, which had a reference to the excellent FileHelpers library. The library was probably built with Microsoft's tools, but I was able to build (and run) the application using Mono (for Windows).

That's pretty amazing, but the last part is even more amazing. I just tested the Devshock SMPP component (which was definitely built on Windows, using VB.NET), in a program I wrote using Mono on Linux. There's a text on my phone now that proves that .NET is an awesome platform, and Mono is a great cross-platform implementation of that platform. Mono rocks. Period.

Monday, January 26, 2009

Using the Asterisk Manager Interface (AMI) to make calls in C#

for some reasons, i've been interested in using Asterisk.NET (mostly because code completion in a GUI beats grokking code in a command line). one problem i'd always had, though, was making calls. for some reason, i'd just get the message 'Originate failed' returned to me. today i was working on my sample program again, when i got the same error. i then started looking through the Asterisk.NET code to find out what i could be doing wrong. i also dug out my trusty copy of .NET Reflector to analyze the assembly.

the main source of aggravation was that i could use call files, and they'd work. but with Asterisk.NET, at most i'd get a missed call. my code went something like this:

var myManagerConn = new ManagerConnection();
myManagerConn.Hostname = "asterisk-server";
myManagerConn.Username = "admin";
myManagerConn.Password = "god";
myManagerConn.Port = 5038;
var action = new OriginateAction();
action.Channel = "SIP/3595009";
action.CallerId = "3595009";
action.Context = "robocall";
action.Exten = "10";
action.Priority = 1;

myManagerConn.Login();

myManagerConn.SendAction(action);

myManagerConn.Logoff();
after some sniffing around in Reflector, i found the Timeout property for the OriginateAction class. i went looking in the code, and found that Asterisk would set it to a specific value (30000 milliseconds) if it wasn't set. knowing .NET initialization, however, i guessed that the underlying field was probably set to 0, and set the property explicitly to 30000. i ran the program again, and the call came in, the phone kept ringing (yay!) — but the program generating the call threw an exception complaining about a timeout. i increased the timeout to one minute to no avail. i then decided to set the timeout parameter for the SendAction() method of the Asterisk.NET.Manager.ManagerConnection. the resulting call was like this:
myManagerConn.SendAction(action, 30000);
. and the program worked. like that. so i guess i may just be able to get this automated call thing done without using a terminal to the Asterisk server.

Tuesday, January 20, 2009

Installing PEAR on Windows

i wanted to install PEAR on my Windows machine as a prelude to installing symfony. i'd installed PEAR before on Windows, no biee. but when i tried using the batch file to install PEAR today, i was greeted with a list of 12 options after deciding to install a system-wide copy. the last option specified C:\\. as the PHP executable path. every time i changed it to C:\\php.exe, i couldn't continue to install PEAR. i had to leave it as-is, install PEAR, then edit the pear.ini file to specify a correct path. ideas, anyone?

Monday, January 19, 2009

Shallow Relationships

as an example of just how shallow my relationships are, i just told my neighbour "Happy New Year". on the 19th. my neighbour. we live in the same building. and have lived every single day of this year in said building. pretty pathetic, don't you think?

Sunday, January 18, 2009

where's the cotton-pickin' "Undo" command in real life?

quite a bit has happened since i was here last. for one thing, it's now over 5 years since my mum passed on. and it seems that my dad is "officially moving on" — whatever that means in English. monday i was going home from work, and i saw this really hot (translate: hawt) chick getting out at Obalende. great body, pretty as a flower and had this really nice musical voice (i have no idea what that means either, but it sounds good ;)…and i started thinking about my life.

an ache i hadn't felt in a while came up (though i did the sensible thing and went looking for my next bus instead of gawking), an ache to have someone to hold, to talk to (don't act like you never felt it before! guys really want to have a beaty to rescue!)…and all that. there is no such person in my life. and in the last couple of months, i've been asked (subtly and non-too-subtly) quite a number of times about my "relationshipital" status. no, there's no one either here or on the horizon. so if i really want to hug someone, i'd better grab my pillow. and maybe weep into it. except i'm not that lame. or so i'd like to think. or maybe not. either way, it doesn't really matter since what i do with my pillow doesn't affect the price at which i buy fish in the market.

it's not like i've lacked opportunity to dig trenches and build bridges. at least i'm not in the "women are irritating" phase right now (on the contrary, they're currently interesting — but shall this soon come to pass also? i'm unhurried :D) it's just that for the most part — i get bored (ladies, seriously, it's got nothing to do with you. i easily get "bored" normally. so don't show up at my house with pitchforks, ok? ;), for lack of a better description. maybe they piss me off. maybe i piss them off. i dunno. rare has been the woman who held my attention for 6 weeks or more. i think i broke something. though i can't tell. few and far between are the friends with whom i share my secrets. that's another thing i realized. i've so many shallow relationships, i may just be scared of a real relationship. it's really easy to say, hi, bye. hey sweetie, you're looking good and all that crap, but…i need real relationships. not plastic people with vinyl smiles that are cracked and faded. i'm not even sure where this is coming from. despair? regret? but then, where exactly did i miss it? dunno. maybe this is just a random rant coming from a testosterone overload, but it doesn't matter. since it really doesn't affect the price of fish, anyway.

all said and done, i'll was over it in a couple of hours, then wonder why in the world i posted this anyway. since i wasn't the one who killed Jesus, and i'm not the third leg in humanity. just for fun, i wonder what kind of person would lose sleep thinking about me (ladies, here's an itty bitty cheat sheet: guys want to know you're thinking of them too. really. even though they act tough. guys like me, anyway. unless of course, i'm right and i'm in the minority ;). anyway, enough ranting. off to bed to start what i believe will be a glorious week. why? we two oddballs are going to be spending more time together. and it won't matter that there is no trench in progress. who's the other oddball? naisho da. have a great week!

PS: last year, i needed to do a head scan. i was somewhat excited about it because i believed that i would finally find out what nuts and whatnots were not in place in my head. the result came back…normal. seriously. i had a regular brain like everyone else. not a clockwork one. or an electronic one (might have fried a few circuits). it felt like a letdown. yet another proof that despite my best efforts, ore wa tada no ningen. ah well.