
Hi all,
Just got back from the second Dubai Twestival that took place today at 8 PM. Organized by a wonderful team (PK, Woo, esperanca, Stephanie and Baher and Abhamalpani – please let me know who I missed), it was a success.
Thanks all,
Michael

Hi all,
Just got back from the second Dubai Twestival that took place today at 8 PM. Organized by a wonderful team (PK, Woo, esperanca, Stephanie and Baher and Abhamalpani – please let me know who I missed), it was a success.
Thanks all,
Michael
For several Ruby on Rails projects I had to come up with “similar” results. These are often results (video’s, products,places, hobbies, etc) with the greatest number of tags.
Say, you are tagging car pictures on a website, and have the following:
image1.jpg -> ["honda","s2000","convertible","black"]
image2.jpg -> ["honda","civic","blue"]
image3.jpg -> ["lexus","is300","blue"]
image4.jpg -> ["s2000","honda","convertible","silver"]
image5.jpg -> ["toyota","starlet","black"]
Seeing this, you’d know that image1.jpg and image4.jpg are similar pictures. Or rather “more similar” than , say, image1.jpg and image3.jpg. For this, I wrote below snippet of code. This goes in the model file, and can be called as “object.similar”. It returns an array of similar “things”, sorted on most similar to less similar (hence the results.reverse at the end)
For example:
img = Image.find(params[:id])
@similar_images = img.similar[0..10]
Will give you the 10 “most similar” images as img. Well, it gives you the files with the most similar tags.
def similar
tags = self.tags
results = []
tags.each do |tag|
results = results + tag.pictures # or tag.things, tag.products, ...
results.delete(self)
end
# make array into hash
h = Hash.new
results.each do |r|
h[r] = h[r].to_i + 1
end
# sort on values
tmp = h.sort {|a,b| a[1]<=>b[1]}
results = []
tmp.each do |t|
results << t[0]
end
results.reverse # return all items, products, ...
end
This was written for a new project coming up, and will be used to do better "similarities matching" for places.ae, though for the latter we also had to sort on distance. (For it's vicinity)
Gulfnews tells us that those who are willing to start a business (LLC, Limited liability company), do not have to cough op the 150.000 AED (40.000 USD). With the current economic situation, this is not a bad step at all.
More than 80 % of businesses in the UAE are LLC’s, so it’s a good step. Often, entrepreneurs were put off by setting up a business in the UAE, because of it’s rules and monetary requirements.
I hope this will result in a growth of entrepreneurship in the UAE.
As places.ae is maturing to it’s 500 days being online and growing… It’s also awfully painstaking how cumbersome a framework (it’s written in Ruby on Rails) can be. Agreed, I am not the most seasoned rails programmer, and my ruby code sometimes makes people cry, but still. Note that this rant is about web based frameworks, though it might apply in other environments also.
Web developments Frameworks have one main advantage: it’s a framework. You don’t have to write 90% of your code anymore. If you want user-login-forgot-password functionality, or a nice captcha, you often only has to enable one module, et voila, you’re rolling. Great to advocate so-called agile development. I wrote a audit tracking tool (points raised in a systems audit and outlining their risks) at work in Rails in a few hours, needless to say, it was impressive.
The downside of a framework is that it is a framework, you are bound by it’s rules and bend yourself often to make it work.
The first 90% of your applications gets done in 10% of the time, and you’ll be debugging for the remaining 90%. As said, it’s my personal opinion as a non full fledged rails guy, but a project that matures over time seems to give problems with frameworks. (Database migrations tend not to work well in the/my real world)
Sorry just a rant. It’s 3 AM, and these migrations are driving me up the wall, to an extend that I downloaded MDB2 and smarty, and am assessing how long a rewrite would take.
Good night,
Michael
A small bash script I wrote to have incremental backups done on a unix server, and then pushed to a Windows File system. On the fileserver, we add this directory to the normal backup.
This is on a mail server, where emails are stored in MailDir format. We create weekly full backups on sunday, and daily incremental. This script is called daily at night from a cron job. Gotta love the scripting abilities of bash.
It might help you out, so here goes:
#!/bin/bash
# backup script is doing following items
# dump all incremental email into a backup file, gzip the backup file and
# move the file to an external file server
START_TIME=`/bin/date`
echo "backup started at: ${START_TIME}"
DOW_N=`/bin/date +"%w"` # number, 0 (sun), 1 (mon)
DOW_T=`/bin/date +"%F"`
TO_BACKUP="/opt/maildata/"
TEMP_FILE="/tmp/${DOW_T}_mail_backup.tar"
BACKUP_LOG="/tmp/mail.backup"
FILE_SERVER="/mnt/fileserver/" # mounted over SMB
# if it's a sunday, delete the incremental file and take a full backup
if [ ${DOW_N} -eq "0" ]; then
/bin/rm ${BACKUP_LOG}
fi
/bin/tar -c -f ${TEMP_FILE} --listed-incremental=${BACKUP_LOG} ${TO_BACKUP}
/bin/gzip -f ${TEMP_FILE}
FILE_SIZE=`/bin/ls -lah ${TEMP_FILE}.gz | awk '{ print $5 }'`
/bin/mv ${TEMP_FILE}.gz ${FILE_SERVER}
## report, this goes in an email through cron
END_TIME=`/bin/date`; export END_TIME
echo "backup ended at: ${END_TIME}"
echo "data moved: ${FILE_SIZE}"

In Nakheel we have a maximum email quota which gets filled up pretty quickly if you receive large attachements, such as presentations, manuals and silly movies. I wanted to build a macro that imitates Gmail awesome archiving method.
Based on the lifehackers’s article, my version had to move the my selected mails to a PST file on my disk, freeing up space on my “online mailbox”.
I won’t repeat how to make the macro and all, the lifehacker’s article does a very good job in that. I just made a few changes to the code, and that is below:
Sub Archive()
pst_file = "C:\Backup\archived.pst"
Set ns = Application.GetNamespace("MAPI")
ns.AddStore (pst_file)
Set ArchiveFolder = ns.Folders("archived")
For Each Msg In ActiveExplorer.Selection
Msg.Move ArchiveFolder
Next Msg
End Sub
If you read it, you’ll notice that 15 degrees Fahrenheit is 6 degrees Celcius or 60 degrees Celcius. In reality, 15 degrees Fahrenheit is -9 degrees Celcius. I guess this memo wasn’t really talking about Abu Dhabi’s sunshine.
Let’s assume that you don’t want to open the windows for a while when driving in -9 degrees. And that the gasoline fumes you get while filling up at a petrol station are bit more dangerous (or more fun?) then your average plastic seat covers.
I’m very sorry I haven’t updated my blog for a while. I went on a holiday, and fell sick when I got back in Dubai. Give me a few days, and I will update this again!
Thanks,
Michael
Yahoo overhauled it’s image search, and some say it’s a better search than Google now. I wouldn’t hurt for Yahoo, as they have to re-gain some market share in the world of search engines.
For the UAE, the bad part though, is that most of the images are feeded from Flickr, which is blocked here.