Tuesday, July 29, 2008

O/RM and templating

i have a problem. i'm sending text messages to people based on data in a table. but people being who they are, they want to change the message structure at will. and the structure is currently hardcoded. so if i want to make the structure dynamic, i need a template system. i also need to map specific table fields to those template variables, then make the template changeable at runtime. that requires O/RM, so i can map table fields (relational) to objects i create in my code, and all the SQL is generated on my behalf by the O/RM engine. so far, i'm going with ActiveRecord and NVelocity from the Castle Project. i've used NVelocity, so i hope i'll get the same level of success from ActiveRecord (so many dependencies though :)

IQ tests are warped

Warning: shameless plug coming up! i added the IQ test application in Facebook. later on, the Advanced IQ test was recommended, so i added it and took the test. when i completed it, i found out of 15 questions, i only answered 13 and only got 6 right. yet when my IQ was calculated, it was rated over 100 (no, i am not telling you my computed IQ), which is not bad. in fact, it was higher than what was calculated using the regular test. hence my think they are warped. oh, 70 is idiot territory, so i guess i'm okay

Saturday, July 26, 2008

Avatar is over!

finally, i've watched all the episodes of Avatar: The Last Airbender. i have to say that all in all, the series was good. yes, there were some parts that really could have been cut out (like Season 3 Episode 17, The Ember Island Players) or modified, in my opinion, but then that's just my two cents.

stepping into Subversion

i've been joined by two other developers at work, so i needed to give them access to the code i'd written. i saw it as a great opportunity to try out version control, so i gave one of them the task of learning Subversion. he hadn't gone very far with actual implementation, and then my boss put him on something else, so i thought to myself, "what the heck" and started reading about subversion myself tonight. i installed the Collab.Net Subversion server, then TortoiseSVN and began scanning through the book (what? you expect me to actually read it? maybe on your time, not mine. it's past 2am here, for crying out loud).

i set up a repository, checked out, added a new file, tried to commit, then boom! authorization error! now the subversion book didn't say anything about this. so i downloaded HydraIRC, connected to Freenode, and joined #svn and ##csharp and asked. after some time with no answer, i went googling and found that a default repository allows anonymous reads and no writes, especially if you're connecting using svnserve. later on, someone gave me the same answer i got while googling. also got some useful tips, from the channels and the TortoiseSVN manual. in short, if you're going to use Subversion using the svn:// protocol (using svnserve, that is), you're going to need to configure your repository correctly. since it's in the TortoiseSVN manual, i'll refer you Windows users to it. please read Chapter 3, Section 2: Svnserve Based Server. everyone else, please look here for a few tips on configuring your repository for read/write access.

Saturday, July 19, 2008

i didn't go with .NET configuration files...and would like your input

i've been working on an application that needs to get some configuration parameters at runtime. at first, i thought of using configuration files, but then i realized that i would need to create another application that would be used to change the config. usually, an application config file is "tied" to the specific executable that it is created for, so - not being comfortable with XML in .NET - and having a tight schedule, i looked into other options. one was the registry and another was a custom config file. right now, i'm using SQLite as my storage medium, with the advantage that i can use the relational model if i need it. obviously, it has some drawbacks, but so far, i've got used to it. let me know what you think - assuming you do think anything.

Rant: why is Opera taking a long time to open Blogger - with no activity whatsoever? it's happened twice already...

Friday, July 18, 2008

The past week in review

hiya. been almost a week since my last post here. ah well. just wanted to bring you up to date with what's going on here, "here" being my life. grrrr. my neighbours decided today to have a party (an all-nighter by the sound of it), meaning there's going to be quite a bit of noise around.

in case i didn't mention it, i was in school last week. saw a couple of the guys, stayed over at Biyi's place while i was there. he seems to be getting along with his final year project and other stuff in his life. i'm happy for him. anyway, while there, i got some anime and have started watching Black Lagoon and Katekyo Hitman Reborn. i've also started Monochrome Factor and almost completed Hayate The Combat Butler. however, the anime series that currently has occupied my time is Code Geass. i started on Saturday and have almost completed season 1. i don't think i'd want someone like Lelouch as my opponent. my current fantasy revolves around a showdown battle of wits between Light Yagami (of Death Note) and Lelouch Lamperouge. sadly, this just reminds me of just how far behind i am with anime. Bleach, Eyeshield 21 and D.Gray-Man are all examples of abandoned anime projects. maybe you now understand one of the reasons i hate my job.

Wednesday: some local government people came around the building where i work and started complaining about the environment. so i don't bore you, they locked me and some other people in the compound. i had to jump over the gate to get out. i heard they later opened the gate - which is good, since almost everyone left in is female. every time i look at my right arm i remember - because i got scratched getting out. fro crying out, it's over 10 years i last did something like that!

Tuesday: i found that Visual Studio's debugger is superior to SharpDevelop's in one respect: if you're debugging applications within the environment, SharpDevelop's only catches uncaught exceptions. So if you're using System.Timers.Timer.Elapsed (for example), you'll never catch any exceptions. Visual Studio's, however, has no such compunctions, and will show exceptions even though the Elapsed event handler suppresses all exceptions. i can tell you that that's what saved my bacon on the current project i'm handling.

Monday: this project is my first experience with Oracle (even though i've had the express edition for almost a year), and if there's one thing i've learnt: always use 4-digit date literals in Oracle, especially if (like me) you're from a MySQL (or other database) background! i spent the whole weekend plus the greater part of Monday wondering what bug in Oracle i uncovered, only to find it wasn't a bug, just an Oracle quirk.

i've a custom class in my application that stores database connection parameters (previously in individual variables) - server, port, username, password and whatnot. since i'm moving to deploying the application solely on SQL Server 2005 Express (maybe PostgreSQL when i have the time to learn it) for now (no thanks to the many quirks of Sybase), i'm now simply hosting a SqlConnectionStringBuilder in the class. you really can't beat KISS.

while i'm still a newbie at regular expressions, i can definitely say they're great when they're used rightly. if i had to write custom code to validate phone numbers, i'd probably have a minimum of 20 lines of code, plus new if clauses (or similar) to write if the networks change. thanks to regexes, i can validate Nigerian GSM numbers - with or without country code - with about 3-4 lines - including creating the System.Text.RegularExpressions.Regex objects i want to use. and if i need a new case, i'll just have to change the pattern string. a pity more Nigerian developers don't seem to know about regexes - unless i'm wrong.

i need sleep! 'nuff said.

Saturday, July 12, 2008

Working with malware

hi. it's been a long time since i was last here. one month, eh? that's pretty bad. anyway, the point of this post is that i was recently in school, and came across some malware - one of which isn't picked up by any antivirus program i know as at now. this worms spread via USB storage (flash drives, external hard disks and so on). each copies itself to a clean device and also creates an autorun.inf entry in the device if it does not already exist (i can't tell what happens if it already exists). the one detected by AVG 8 Free has an executable named asp.net, and the one that isn't detected as at now has an executable named EXPLORER.EXE.

when i got to school, i had the 'privilege' of cleaning out two of my friends' computers. one was infected by the EXPLORER.EXE worm - which is easier to deal with if you don't have any antivirus installed - and the other was infected with the asp.net worm (if you have an antivirus that detects this, this is much easier to clean than without any antivirus, or one that doesn't detect it). let's start with the first.

EXPLORER.EXE worm in Process Monitor normally, a Windows machine has a process called explorer.exe. this process usually serves both as the shell (the program you use to launch applications) and the file manager. the executable for this is located in C:\Windows, has version information that comes from Microsoft, has the 'My Computer' icon and is about 1MB on a Windows XP machine. this worm is about 36kB, has no icon, has the same version information as the legal explorer.exe and runs from C:\Windows\system32. to get rid of this worm, you'll need a couple of applications from Windows Sysinternals, specifically Autoruns and Process Explorer (you can also download the entire suite if you want - it contains both). launch Process Explorer (an excellent task manager for Windows), accept the license agreement if you need to, and kill the EXPLORER.EXE process that doesn't have the My Computer icon and is running from C:\Windows\system32. next, launch Autoruns, allow it finish scanning, then delete the entries containing C:\Windows\system32\EXPLORER.EXE (use Ctrl-F) if you need to search). lastly, get rid of the worm executable itself. open a command prompt, and run attrib -h -r -s C:\Windows\system32\EXPLORER.EXE; del C:\Windows\system32\EXPLORER.EXE. this gets rid of the executable in its default location. your mileage will vary if Windows isn't installed on C:. EXPLORER.EXE worm in Autoruns

the other one is much harder to deal with because it creates a 'non-existent' process, according to Process Explorer. in fact, the process won't even be displayed in the processes list. i had to search for it manually. going through the console to use taskkill with the process id won't work either. so we're going to do it in the reverse flow. first, run Autoruns. search for appearances of asp.net autorunning, and disable, don't delete them. that's because if the worm is still running, it will simply recreate those entries. once you've disabled the entries, you can note the locations of the worm and reboot so you can delete it from all its hiding places (for me it was C:\Windows\system32 and C:\Program Files\Common Files\Microsoft Shared\MSInfo. again, this worm is hidden and probably has a system attribute set, so you need to remove those flags first. i'd personally recommend getting a recent (and decent) virus removal tool to remove this particular nasty, as it not only infects removable drives, but also fixed drives on your computer.

well, hope this is of some use to someone. have fun!

UPDATE: After a couple of days carrying around the EXPLORER.EXE worm on my external hard drive, i found that McAfee picks it up when i connected it to a colleague's computer. as at that time, neither AVG 8 Free nor PC Tools Antivirus was detecting it as a worm.