ZyeLabs http://zyelabs.net WEB APPS, STRATEGY, MASHUPS & OPTIMIZATION posterous.com Thu, 23 Feb 2012 04:30:54 -0800 Cropping, Resizing & Converting Images for the lazy coder http://zyelabs.net/cropping-resizing-converting-images-for-the-l http://zyelabs.net/cropping-resizing-converting-images-for-the-l

Recently we had to crop, resize and convert a bunch of images for a project. It's always wise to put in some initial effort for repetitive tasks which will save you time down the line.  

Here's a little script using PIL that let's you crop & resize images automatically. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from PIL import Image
from glob import glob

pwd = os.path.dirname(os.path.abspath(__file__))
ext = '.png'
ext_new = '.jpg'
fpath = os.path.join(pwd,'*'+ext)
img_list = glob(fpath)
left = 450
top = 263
width = 1026
height = 636
size = 300,190

# Crop , Resize, Convert
for img_file in img_list:
img_name = os.path.basename(img_file).replace(' ','_').strip(ext)
img_name = img_name.replace('_&_','_').lower() + '_tmb' + ext_new
img = Image.open(img_file)
box = (left, top, left+width, top+height)
area = img.crop(box)
area = area.resize(size, Image.ANTIALIAS)
area.save(img_name, 'jpeg')
print img_name, img_file

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Mon, 30 Jan 2012 00:20:00 -0800 [Infographic] PHP vs. Python vs. Ruby http://zyelabs.net/infographic-php-vs-python-vs-ruby http://zyelabs.net/infographic-php-vs-python-vs-ruby

Programming-language-3-620x3450

via RWW

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Fri, 20 Jan 2012 05:46:00 -0800 Why (some) programming languages are actually designed well http://zyelabs.net/why-some-programming-languages-are-designed-w http://zyelabs.net/why-some-programming-languages-are-designed-w

I came across this article on twitter, "Why Aren't Computer Programming Languages Designed Better?"

Which say's: 

 According to findings by researchers from Southern Illinois University, this reaction isn’t just because you’re a n00b: they found that Perl, a major programming language used by untold zillions of developers, is no more intuitive to novices than a language with a randomly generated syntax.

and

So why aren’t all programming languages designed this way? "I doubt that most language designers meant for their languages to be hard to understand or use," Stefik says. "The problem is that programming languages are created either by committee or by extreme technical wizards with magical math powers. The broad computer science academic community has not paid a tremendous amount of attention to programming language usability. I think that our discipline mostly uses anecdotes to argue about programming languages. As such, it is no wonder that the arguments get heated."

...

Why shouldn’t those "interfaces" be as humanely designed as the ones we tap and swipe?

First, it's no real surprise that perl would be more difficult to learn than a randomly generated language. Perl is often regarded as one of the most difficult languages to maintain.  I am not going to rehash all of the commentry against perl again, you can read this excelent article for that. A few extracts:

One of the first things I discovered I didn't like was the syntax. It's very complex and there are lots of operators and special syntaxes. This means that you get short, but complex code with many syntax errors that take some time to sort out. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
sub soundex
{
  local (@s, $f, $fc, $_) = @_;

  push @s, '' unless @s; # handle no args as a single empty string

  foreach (@s)
  {
    tr/a-z/A-Z/;
    tr/A-Z//cd;

    if ($_ eq '')
    {
      $_ = $soundex_nocode;
    }
    else
    {
      ($f) = /^(.)/;
      tr/AEHIOUWYBFPVCGJKQSXZDTLMNR/00000000111122222222334556/;
      ($fc) = /^(.)/;
      s/^$fc+//;
      tr///cs;
      tr/0//d;
      $_ = $f . $_ . '000';
      s/^(.{4}).*/$1/;
    }
  }

  wantarray ? @s : shift @s;
}

However, even this isn't really bad. The Perl Journal has conducted an Obfuscated Perl contest. The winners are here . Be warned, though. These programs gives the word unreadable entirely new and previously unimagined meanings. (And no, this isn't an argument for Perl being unreadable, but mainly included as a funny and curious item.)

Programmers and readability

Some people reading this have complained that 'But anyone can write unreadable code in any language!' and this is certainly true. However, some languages seem to encourage hard-to-read code, while others seem to discourage it. 

If we were comparing Perl & Python, i would say that Perl is actually the more 'Human' language (But more difficult) Why?

Because perl was designed like a language the inventor was actually a trained linguist, see this :

 

Multiple ways to say the same thing

This one is more of an anthropological feature. People not only learn as they go, but come from different backgrounds, and will learn a different subset of the language first. It's Officially Okay in the Perl realm to program in the subset of Perl corresponding to sed, or awk, or C, or shell, or BASIC, or Lisp, or Python. Or FORTRAN, even. Just because Perl is the melting pot of computer languages doesn't mean you have to stir.

 

All of these 'features' of perl, make it difficult to learn, difficult to read, and difficult to maintain. People who program in perl actually see it as a matter of pride to write Obfuscated code. It can also be used for Art.

Now, lets compare this to Python:

  • It forces you to write readable code, by using whitespace as part of the language
  • There is usually only one way to do something, avoiding confusion , ensuring you get expected results, resulting in reliability
  • See a like for like comparison between perl python and ruby
  • There are too many advantages to list

From the history of python blog (Highly recommended for an inside look by Guido on the design of python)

Although I will discuss more of ABC's influence on Python a little later, I’d like to mention one readability rule specifically: punctuation characters should be used conservatively, in line with their common use in written English or high-school algebra. Exceptions are made when a particular notation is a long-standing tradition in programming languages, such as “x*y” for multiplication, “a[i]” for array subscription, or “x.foo” for attribute selection, but Python does not use “$” to indicate variables, nor “!” to indicate operations with side effects.

 

Python was created first and foremost with usability in mind.

While i agree, languages should be more 'usable' to make things easier for non coders to pickup, it should not be easy at the expense of flexability and features.

There is nothing wrong with a language designed by a mathematician as it follows the principals of logic, which is the only language computers speak. They should not be designed to be more 'Human', as you could end up with programming languages that look like spoken languages such as Perl.

Python

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Fri, 30 Sep 2011 02:05:00 -0700 Optimizing mobile device detection for your mobile site http://zyelabs.net/optimizing-mobile-device-detection-for-your-m http://zyelabs.net/optimizing-mobile-device-detection-for-your-m

Just read this on RWW, on how FaceBook optimized their mobile applications.

The cornerstone of this is detecting what your phone is going to be able to do. Capabilities, then you can start the right experience. You guys heard of WURFL at all? Wireless Universal Resource File? This is one of the projects out there that attempts to map a user to a user-agent set of capabilities. You know, what is your screen size? What is your JS? Can it do cookies? These are all pernicious, nasty problems that need to be solved. And the use-agent, as you guys can tell, doesn't do the job. So, you need an open database for manufacturers and concerned citizens to be able to tell you what is up. We sponsored this project and this project is continuing to evolve as an open source data site.

Last year while we were working on a mobile project based on the django framework (We were sub contracted so cant mention the client Hint: International Takeaway franchisor ;).

We needed to do some mobile device detection and change the templates based on features the device supported i.e Javascript.

We implemented the a solution based on WURFL, PYwurfl and the mobile.sniffer libraries. Other than some strange side effects on caching caused by django template switching based on a user agent everything worked fine for the most part(I may cover how we resolved this in a later post).

However, due to how some of these libraries were implemented, there was a significant hit in responsiveness & increase in memory usage when mobile device detection was enabled.

We did optimize this and get around the issue, however in January i presented this as a problem to MIGSA 2011 (Mathematics in industry Study Group) at WITS University. You can find the paper below.

Also well done to the students involved.

mobile_device_detection.pdf Download this file

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Wed, 14 Sep 2011 05:58:00 -0700 gangr.co.za http://zyelabs.net/gangrcoza http://zyelabs.net/gangrcoza

Mags & Tyres Johannesburg

Permalink | Leave a comment  »

]]>
Wed, 14 Sep 2011 05:46:00 -0700 startupafrica.com http://zyelabs.net/startupafricacom http://zyelabs.net/startupafricacom

Startups in Africa

Startupafrica

Permalink | Leave a comment  »

]]>
Fri, 26 Aug 2011 06:59:18 -0700 Elsham.co.za http://zyelabs.net/elshamcoza http://zyelabs.net/elshamcoza Elsham Hookah Tobacco

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Thu, 25 Aug 2011 10:46:00 -0700 Bait and switch + Social Media = not a good combination. http://zyelabs.net/bait-and-switch-is-a-big-no-no-in-social-medi http://zyelabs.net/bait-and-switch-is-a-big-no-no-in-social-medi

Baitswitch_twitter
I don't think any company would want something like this. Actually make that, any smart company. You would more then likely just piss of the users since they never actually followed you. 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Tue, 16 Aug 2011 03:06:00 -0700 Hello World http://zyelabs.net/hello-world http://zyelabs.net/hello-world

1
2
3
print "Hello World"
print "Welcome to Our Blog"

 

Welcome to our new blog.

* Posts prior to this were imported in from other blogs we have posted to.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Wed, 23 Jul 2008 10:45:00 -0700 Has muti made a fundamental mistake in community management? http://zyelabs.net/2008/07/has-muti-made-fundamental-mistake-in.html http://zyelabs.net/2008/07/has-muti-made-fundamental-mistake-in.html

So muti in the last few days has been in flames. It all started when someone posted a link on muti to a screenshot from Coda of apparent spam from blueworld. Imod stirred the pot asking a few questions on his blog in response. Both the submissions to muti hit around 35 votes very quickly, but were then removed. (Following the link comes back with a 404)

Let me be clear, i am a fan of muti and find it extremely useful, i access it so many times a day i actually created a desktop application for it and the guys from blueworld seem to be doing a lot of cool things as well. Though i am going to ask the questions that need to be asked. Has muti made a fundamental mistake when it comes to community management?

Granted that the noise being made may be a bit loud regarding the spam, though just recently the blogging community made a similar noise against deal-a-day email spam which hit muti as well. Charl is a respected member of the SA blogging community and they did come out with a response and the issue should have died there.

However both the submissions were then subsequently pulled from muti, one at the request of Chris. The other i have no idea why? Coda then asked the question on why was the second post pulled? I find myself asking the same thing. Why?

Once muti starts making decisions on censoring content of what people submit it's heading down a slippery slope. The thing is you can never please everyone. Google themselves refuse to censor search results. Even on Youtube, only content that is clearly hate speech is removed. So where does this leave muti?

I think the guys at muti need to decide if they want to cater for a small group of people, all of whom have the same opinions and that way censoring of content that differs from the general group consensus is fine. However if muti wants to cater for a larger community, censoring and pulling submissions should only be done in extreme circumstances of Hate Speech. Also note, with previous submissions of hate speech the vote count was merely cleared, the spam posts however were completely deleted including comments and the discussions around it.

We need to realize that since muti currently caters for large number of people, there are going to be differing view points and you really do not want to play the adjudicator, judge or take sides. Muti has clearly done this, and as the facilitator of the blogging community at large i believe this is a fundamental mistake.

As an example this raises questions like:

  • Someone posts something that is factually incorrect and paints me in a bad light, could i request the post be removed?
  • Or maybe this post could be pulled at the request of Yasser since it was clearly critical?

As you can see, the questions this action raises could go on and on, and you would never get to the end of it. This is a problem faced by many companies, Google, Facebook, Twitter. Even telecoms companies like Vodacom and Cell C where people complain falsely of harrasment via sms. Unless the community is extremely small it becomes increasingly difficult to be the judge, therefore the best response is to set clear guidelines on what is not accepted(i.e hate speech) and can be removed, anything that does not meet the criteria of unacceptable stays.

muti needs to 'grow up' and realise it does not just cater for a small group of people any longer with the same opinions, and with that nobody, no matter who they are (including shareholders) should be able to influence the content that gets removed. Let's just hope this is something that will not be repeated again and we can take away a lesson from this.

Update: Mandy De Waal has a post regarding this as well

Permalink | Leave a comment  »

]]>
Mon, 21 Jul 2008 09:34:00 -0700 Business opportunity for SEO http://zyelabs.net/2008/07/business-oppurtunity-for-seo.html http://zyelabs.net/2008/07/business-oppurtunity-for-seo.html

Doing a search earlier i came across something interesting. If you search for "CellC Ussd Recharge" the top most link is MTN which is actually a direct competitor of Cell C. Jeremiah Owang say's Google is actually your coporate homepage. Considering that, do you really want to drive people doing searches for your brand to competitors?



This would make a good pitch for SEO business.

Permalink | Leave a comment  »

]]>
Sat, 10 May 2008 14:01:00 -0700 Twitter Business Model, Why google is scared http://zyelabs.net/2008/05/twitter-business-model-why-google-is.html http://zyelabs.net/2008/05/twitter-business-model-why-google-is.html

Read Write web recently ran a post on monetizing twitter with a business model using ads. The post was good, and i believe it makes sense However i believe they missed one key point. Twitter can be used from your mobile phone.

When Google launched image based mobile ads. i briefly covered what google mobile ads were missing and why context (what is the person doing?) is important. Twitter offers that context, add a location to that and your pretty much have killer mobile advertising. Its contextual to what the person is doing and localized.

No one out there can offer advertising for mobile as relevant as that right now , not even Google. This is the reason Google was quick to snap up Jaiku, they realise that twitter is actually a threat to their mobile advertising business. Some people may have been confused about why i sent this tweet, it seems a far fetched but Twitter is actually a threat to Google mobile ads business, which according to reports could be a larger market then internet advertising.

Permalink | Leave a comment  »

]]>
Tue, 06 May 2008 08:43:00 -0700 IPhone available soon in South Africa, Need cheap replicas for Africa http://zyelabs.net/2008/05/iphone-available-soon-in-south-africa.html http://zyelabs.net/2008/05/iphone-available-soon-in-south-africa.html

Fin24 reported this morning that the IPhone will be available in South Africa. Often i have conversations like this with people regarding the phone

Friend: So how is that phone?
Ismail: The best phone i have ever used
Friend: But you cant MMS / It doesn't have 3G / You cant forward SMS
Ismail: yes, but it's still the best phone i ever had

Now, please note i have never been an Apple Fan having said that, it is the best phone i have used thus far. Iphone is impacting on mobile internet usage like how blackberry did on mobile email.

Recently a guy ran the girl friend/wife/significant other usability test on Ubuntu Linux, basically to see how easy it is for a non tech savvy user to complete basic functions. The IPhone passes these with flying colours. All my previous phones (HTC, Nokia) failed dismally with functions other then calls and SMS.

I believe this is important. Lets take a look at how access to communications can stimulate economic growth and raise the quality of living.

In a study (PDF) by Harvard economist Robert Jensen he reported that when mobile phones were launched in kerala in 1997, Fisherman used the phones to call local markets while still at sea. This in turned helped raise profits by 8%, lowering consumer prices by 4% and reduced catch wastage from 6.5% to practically nothing.

This is just with access to voice communications, now imagine what easy access to knowledge and information (The Internet) would do?

Mobile phones have been available for a decade in most parts of Africa and there are more people with mobile phones then computers. Africa only has about 4% Internet penetration compared to 29% mobile penetration. Also remember that a number of people using mobile phones in Africa may never have had access to computers or the internet growing up. The environment in Africa may be best for mobile internet. Though mobile internet has been stifled by high data prices, cost of handsets and complicated interfaces.

So what does this mean?

I do not expect the IPhone to actually make a difference since Apple caters for the higher end of the market. Though Nokia has been been working in Africa and if they can develop something similar just as intuitive with easy access to the internet at a much lower price they would win back a fan. With data prices lowering this would allow masses of people access to the large body of knowledge found on the internet. Good times ahead!

Permalink | Leave a comment  »

]]>
Mon, 05 May 2008 16:47:00 -0700 Free Album from Nine inch nails, The future of music http://zyelabs.net/2008/05/free-album-from-nine-inch-nails-future.html http://zyelabs.net/2008/05/free-album-from-nine-inch-nails-future.html

Today Trent Reznor announced on the official Nine Inch Nails website that he would be giving his new album album "The Slip", free of charge under a creative commons license.

From their web site:
"We encourage you to remix it, share it with your friends, post it on your blog, play it on your podcast, give it to strangers, etc."

Now, this is not the first move like this, prince has been selling directly to the public for years. Last year we saw radiohead offering their album on the internet and you got to choose how much you wanted to pay. Now both these moves make sense, and are very significant.

Are we we seeing the end of the record labels as we know them?

I believe so. Take a look at the costs that go into producing an album, only a small fraction of that goes to the artist.

For years the recording industry have fought technology, refusing to embrace it yet technology and the internet allows you to bring down the distribution costs and lower prices.

With the internet most of these costs are zero, therefore artists can offer them at a fraction of the normal price or even free as NIN have. The future will be the democratization of music, previously artists had to make the right contacts and hope they would be noticed and get 'signed'. Now that wont matter anymore. The time from when music is actually recorded to when it will be released will be much quicker, and here is the best part:

We get to choose who are the best artists, and which artists get played on the radio and not the record labels.

P.S Lets hope the other band that was 'subtly' referenced in this post follows suit
P.P.S if you figured out the band, give yourself a pat on the back
P.P.P.S Posts to this blog will be a bit sporadic as i am working on another project

Permalink | Leave a comment  »

]]>
Fri, 25 Apr 2008 11:30:00 -0700 What is Google mobile ads missing? http://zyelabs.net/2008/04/what-is-google-mobile-ads-missing.html http://zyelabs.net/2008/04/what-is-google-mobile-ads-missing.html

Google launched mobile image ads a few days back, and i have been asking myself will they work? Techcrunch also ran a poll and unsurprisingly a large portion of people selected that they would not follow a mobile ad. However Google does point out that with increasing usage of mobile internet & larger screen sizes this market will soon take off. This report from cellular news says it will be a 10 Billion market by 2010. Thats quite possible. Though is the ad placement technology currently ready for mobile internet?

Google has taken their current Ad system, and have adapted it for the mobile screen. When you consider how different the use of your mobile is compared to the use of a desktop computer this is not the best solution. For example:

You are most likely accessing the internet on your mobile phone when you are out & about, at the mall, on the beach, in your car, waiting in line at the bank, the point being you are currently doing something else. You are doing some sort of ACTIVITY and your mobile phone is just there to add value.

When you sit at your desktop/laptop you are most likely sitting down with the specific purpose of achieving something such as surfing the net, typing out a document, researching some topic,, catching up with social networks/email.

There in lies the fundamental difference in how we access the internet on PC/LAPTOP vs a mobile device. Just for a moment, analyse the psychology of this and the motivations behind it.

... got it?

With the traditional method of accessing the net we make the decision to set away time to spend at the computer and surf the internet, we are doing nothing else but sitting at the computer.

With mobile devices we are making a decision to DO something else. The mobile phone and by extension the internet is there purely to serve a purpose which is to add value at that specific time, in that particular context. It may be used to do all of the things we do on traditional desktops/laptops but it usually means we are also doing something else.

This is why mobile ads may not prove as lucrative with enough click through as your normal internet ads. The time you have when you are accessing a mobile device is of HIGHER value, then when you are sitting at your desktop surfing the net. Therefore you are less likely to click on a link for an AD. The AD has to be much more relevant than it is currently.

Yes, Google ads are currently relevant using the query, possibly the location of your IP and other factors but with mobile ads there needs to be another level of relevance and that is CONTEXT.

What is the user doing at that point in time? What is he actually looking for? Where is he?

And that's what's currently missing from Google mobile ads, Relevance + Context. I have ideas on how to achieve that but we can save that for another day.

Permalink | Leave a comment  »

]]>
Tue, 15 Apr 2008 06:21:00 -0700 iPhone Location Spoofing & Location based services http://zyelabs.net/2008/04/iphone-location-spoofing-location-based.html http://zyelabs.net/2008/04/iphone-location-spoofing-location-based.html

A team of researchers have found that your location can be spoofed on the Apple iPhone. This was bound to happen considering the technology being used (Skyhook’s WiFi Positioning System). You can read the full article at cellular news.

The use of sky-hooks system is a useful addition to the iPhone and makes sense when you consider that the iPod Touch does not have GSM capabilities. Though this is not the best and most reliable solution for the iPhone considering the GSM capabilities.

Permalink | Leave a comment  »

]]>
Wed, 09 Apr 2008 08:11:00 -0700 Unsurprisingly Nokia's market dominance is slipping http://zyelabs.net/2008/04/unsurprisingly-nokia-has-lost-favor.html http://zyelabs.net/2008/04/unsurprisingly-nokia-has-lost-favor.html

Recently one of the news agencies i subscribe to ran an article regarding a global survey on mobile phone usage by teenagers. Unsurprisingly, Nokia seems to be less popular.

"Nokia's dominance at the top of the global chart has been weakened over the last 18 months. In the survey, conducted across 31 countries by Habbo, it is clear that Nokia has lost some favour with teens to Sony Ericsson and Samsung since autumn 2006"

"Despite still being the favoured handset in 15 of the 31 countries polled, Nokia loses out to Sony Ericsson in markets such as the UK, Germany, Denmark and Switzerland. In all of these markets Nokia ranked first in 2006."

Permalink | Leave a comment  »

]]>