Are you looking for my non-technical blog?

This is now my technical-only blog, my non-technical blog is here.

17 December 2013

We Preach by Spamming

Once upon a time, I stumbled upon an online Quran application, back then I was studying human-computer interaction as a part of my MSc. degree, so I commented on twitter that most of the online Quran readers need to reconsider their design from a usability point of view.

Since then, and I receive dozens of spam tweets each day. They come from different people, yet they all contain the exact same message.


My only interpretation for this is that Quran.ksu.edu.sa has an application that those pople trust and it uses their accounts to send those spammy messages to me.


I sent multiple spam reports to twitter, yet they don't even respond. Isn't it strange that some applications think that it is ok to abuse the trust of their users and spam someone in order to grab his attention to give them feedback about their application!? Isn't it disappointing that twitter don't give a shit to my daily spam reports!?

30 September 2013

A Quick Intro. to NumPy

For me, NumPy is a Python list on steroids. You can use it to create multidimensional arrays and matrices.

The convention is to import it as follows:

import numpy as np

To create an array of numbers between 0 and 9, you could use the following command:

x = range(9)

To convert that list into a NumPy array, you can write:

x = np.array(range(9))

And to make you life easier, there is a shorthand for the above command:

x = np.arange(9)

So far, we have been creating one dimensional array. However, there are ways to reshape the arrays. The reshape() method when applied on an array, it returns a reshaped version of it without changing the original object. To reshape the original object itself, then use resize() instead.

y = x.reshape(2,5)

The above command create a 2-dimensional array of 2 rows and 5 columns. You can create a much dimensional arrays as you want. See the command below for a 3*4*5 array.

y = np.arange(3*4*5).reshape(3,4,5)

The mathematical operations '+', '-', '/' and '*' are applied elementwise.

x = np.arange(10)

# To multiply each element of x by 10
y = x + 10

# To multiply each element of x by itself
y = x + x

To do a Matrix Multiplication though:

# Create a 3 * 5 Matrix
A = np.arange(15).reshape(3,5)

# Create a 5 * 2 Matrix
B = np.arange(10).reshape(5,2)

# Dot product gives you a 3 * 2 Matrix
y = y = np.dot(A, B)

Just like lists, you can get parts of arrays

For original lists:

A = range(10)
A[2:5] # [2, 3, 4]

For NumPy Arrays

B =  arange(10)
B[2:5] # array([2, 3, 4])

However, you can set some elements of the array as follows

B[2:5] = 1337

But, you cannot do the same to lists.

A[2:5] = 1337 # TypeError: can only assign an iterable

For statisticians, there are also the following functions

x = np.arange(5) + 1
x.mean() # 3.0
x.max() # 5
x.min() # 1
x.std() # 1.414

You can also access elements of the array using start, stop and a step:

x = np.arange(10)
x[2:7:2] # array([2, 4, 6])

Or access specific elements, let's say elements 1, 5 and 6

x[[1,5,6]] # array([1, 5, 6])

Similar to reshape() and resize(), ravel() converts a multidimensional array into a one-dimensional array, while transpose() turns rows into columns and vice versa.

If you program in R, you will not miss their way of accessing elements of array that meet a certain condition.

x = np.arange(10)
x[x>4] # array([5, 6, 7, 8, 9])
x[x%2 == 1] # array([1, 3, 5, 7, 9])

If you are having an array of elements that are either True or False.

x = np.array([True, False, True, True])

x.all() # Only True if all elements are True
x.any() # Only True if any elements are True

Finally, there is a repeat() that repeats each element of the array n times

x = np.array([1, 2])
x.repeat(3) # array([1, 1, 1, 2, 2, 2])

That's all folks for today.
Check the following tutorial for more information.






26 September 2013

Middle East Relationships Infographics

The Radio Free Europe - Radio Libre (RFE/RL) published an infographic summarizing the political relationships between the Middle Eastern countries. The graph comes after a similar one that was made by the Egyptian blogger, The Big Pharaoh (@TheBigPharaoh), and was published in the Washington Post.

I'd like to discuss the two infographics from a design point of view here. So, let me start with the one made by RFE/RL.


The main point of the graph is to show the relationships between those countries, i.e. friends and foes. However, as you can see, it is not possible to tell this from the first look. All dots are the same, black dots of the same size. Well, may be they are inviting us to interact with those dots by clicking on them.


So, there are messages hidden behind the dots, but this is just text. Hmmm, couldn't those same messages be written in an article then, or in a table? What is the use of the graph then?

Why is it that the United Stated is there on one axis but not the other. Same for Iraq. Also relationships are supposed to be symmetrical, yet the chart isn't. You can track the lines between Iran and Israel, but there are no lines between Israel and Iran. I know, this is a sort of redundancy, however, it is either the graph is to be redesigned, otherwise, this way is confusing.

Here comes The Big Pharaoh's graph then.


This times relations are supposed to be clearer from the first look. Different line colours reflect different relationships. In this graph countries are represented by points while the relationships between them are represented by lines. While on the RFE/RF's graph, it was the other way round. Entities are placed in the form of a matrix where dots represents the relationships between them and the countries are represented by the horizontal and vertical lines.

In Jacques Bertin's paper, The Matrix Theory of Graphics, he explained that the network representation (e.g. The Big Pharaoh's graph) is more useful in representing the topographical structure of the elements and how each pair of them are connected on a micro level. While the matrix representation on the other hand is more flexible in reordering the element in order to show how the relationships between elements on a macro level. You can cluster your elements first to show groups of allies and foes. Changing the dots colours or sizes gives you a third dimension to move in. As you can see in the network graph above, lines are cluttered and a bit hard to follow.

Can you sketch a better representation of those relationships then?

28 May 2013

Git Forking

After our previous guide to github, now, let's say you want to contribute to a project already existing on github, how to do that?

First thing first, you go to the projects repository and fork it using the button shown in the figure below.


After that, you will be redirected to the page of the forked repository. You will also be given a URL for the forked repository as shown in the figure below.


Now, you create a new director, go there and type the following commands:

$ git init

$ git remote add origin [the URL show above]

$ git pull -u origin master


And, that's it!

19 May 2013

Nike+ first time user's experience

I really want to know if those people behind Nike+ running app on iPhone have ever heard of something called HCI/UX or not!?

Nike+ running app

Today I was using their app for the first time, and it asked me to login, giving me two options for that: A normal login with email and password or to login via Facebook. Despite the fact that I hate apps that contaminate my Facebook timeline with their updates once I sign in with Facebook, I chose the Facebook option as I struggle with remembering passwords for the endless apps one use everyday.

Signing with Facebook is meant to save us the effort of entering passwords for each application, right? Well, seems that Nike+ app doesn't agree with that. After signing with Facebook they asked me again to enter my birthdate, gender, and all those information they can simply grab from my Facebook account, and guess what, they asked me to create a new password too. What the eff!!? They didn't stop here, they even gave me a list of 5 criterion I have to adhere to when choosing my password. Choosing a weak password is my own problem, not theirs. They shouldn't tell me how my password should look like. Additionally, come on, I can choose a password that doesn't meet their password policy yet still stronger than the ones meeting it. So, again, I am the only one who have to decide how my password should look like here.

13 April 2013

True or False: Egypt's First Locally Produced Tablet

You might have read the news that the state-owned electronics firm Katron, has produced Egypt's first locally produced smart tablet, under the trademark 'Inar.' However, the debate now is whether the correct term is 'produced' or 'assembled'. There are two camps arguing now. On the one hand, there are those who find it a huge achievement and attacking local media for not shedding the light on such great news. While on the other hand, there are those who argue that it is just assembled from imported components, and it can hardly be called "an achievement". That's why I decided here to give my humble opinion about the issue.

Inar, assembled in Egypt

First of all, let's agree that we are not living in the Industrial Age anymore. We now live in the age of outsourcing and digital disruption. What I mean by this, is that the argument of technical components not made here is not really a valid argument. Apple, Samsung, Dell, Cisco, etc. do not make every single component of their products. Let's not forget that Apple use components made by its competitor Samsung. They may decide to produce a chipset or two, they may rely on home-made Operating System, but they also may decide to just rely software and hardware components made by others. In other words, we are in fact asking the wrong question here. What really matters is the following:

If the Egyptian company succeeded in producing a competitive product that it can use to go to the market and compete against other vendors, then I call this an achievement, even if none of the products' components is locally made. Whereas, on the other hand, if it is 100% locally-made, yet its producers cannot convince anyone to buy it, then I can hardly call this an achievement. The asian  electronics firms are open market to everyone. Any company can go to that market and get off-the shelf components, whether they are processors, LCD screens or any other components. Android, Windows and Linux are also available for any manufacturer to use them if they want to. In such market, where you and your competitors have access to almost the same resources, your competitive advantages can come from your low price, better design, more advanced features, or even brand name. That's why, the question now, whether 'Inar' is an appealing products to tablet customers, from price or features or whatsoever point of view, or it is just assembled for the sake of assembling a local tablet in Egypt? If it is the formet, then let's hurray the Egyptian achievement, if now, let's question the government's unwise spending, since Katron is a state-owned firm.

P.S. The first known tablet user in history was in Egypt, by the way. Hint, hint, Moses! ^_^

29 March 2013

Adjacent vs Incremental Innovation in Digital Age

I've just finished reading a book called "Digital Disruption: Unleashing the Next Wave of Innovation", by James McQuivey. I enjoyed reading it, and that's why I'd like to share a quick review for the book here.

"Instead of asking How can we make a new product that we can successfully sell? the disruptor asks: How can we give people something they really want". Replace "Make" with "Give", "Product" with "People" and "Sell" with "Want".

This sentence summarises the main idea of the book. In digital age, the cost of producing new products is much lower than it was one decade ago. And the author is not only talking about digital products, but analog ones too. Hence, it is all about innovation now. People want experience rather than products. It doesn't matter if you make it, or if you can partner with others and use free tools to give that experience to your users. Your focus should be on what your users want rather than on what you can produce and sell. The two concepts seem to be similar, but if you think about it, you will find them leading to different set of priorities when you are trying to innovate. The author added later on, "R& D teams have a tendency to confuse product features with customer benefits. They assume that more features equals more benefits. This is not true".

One other quote that I liked is, "When companies adopt technology, they do old things in new ways. When companies internalize technology, the find entirely new - disruptive - things to do".

He also set some differences between two concepts of innovation. Incremental versus adjacent innovation. Incremental innovations focuses on the the current product you have, the current customers you target, and the current process you use to make your products. Whereas, Adjacent innovation leads you to explore new markets, and new experiences to offer to new users. To do so, you need to think of competition differently, it is not those who sell the same products as you do, but anyone offering good experience to their users. Take Nike Runner app for example, they did not limit themselves to other shoe-makers, they rather explored new areas, they witnessed the likes of Apple and Facebook, they learnt from them how people want to share their activities, and how gamification is invading social services. Nike is not an app maker, it is not part of their production process, but this didn't stop them from moving to one new adjacency to explore new customers and new experiences to offer to those customers. They may choose to partner with Apple or compete against it in order to offer such experience to their users. It doesn't matter whether they choose the former or the latter. Because in the digital disruptive age, what really matter is offering your customer's value not products.



30 January 2013

10 Steps to Startup (or more)

Today I attended a session by Matthew Draycott (@DraycottMC) about how to start your own startup. I know, there are hell lot of entrepreneurial seminars, books and real-TV shows (Matt called Dragon's Den entrepreneurial pornography, because it has nothing to do with real life). Well, I was saying that I wasn't expecting much from the session, but that fact is, I found it very good and inspiring, so I wanted to share the main points of it here.

The first thing he said, is that unlike many other people, he finds recession a good opportunity for starting a business, it learns you how to start a learn startup, than can survive hard moments later on.

Now here are the steps:
  1. Research: You need to be an expert in your niche, and you need to research the following three things: Your customers, competitors and collaborators. Customers can be your best friends or worst enemies, and to sell your product you have to convince your customers why you are better than your competitors not why your competitors such. You still can learn from your competitors mistakes though. You need to ask "Who, what, where, when, why and how" about them, and keep a database of all them. A database can be your calendar, address book, twitter lists, but it has to be there.
  2. Business Model: He stressed that it is better seen as business model and business plan. Because market changes more quickly than you expect, so you need a model that is agile enough and can embrace those changes than a fixed plan. He referred to Alexander Osterwalder here, and his books about business models.
  3. Value: You need to create a value to your customers, and there are three pillars of value: Newsness (think of what makes iPhone 4S buys iPhone 5 ones it is out), Performance (think how Google Search just works as it promises to do) and a Brand (think of those people who pay £400 in a Johnny Cupcakes t-shirts, although they might cost few quids just because they like the brand and collect those tees).
  4. Channel: A business without a channel is just an idea. How are you connected to your customers? The channel can define your value:
    • Personal Assistance: Your value comes from knowing everything about your customers, they might be just few ones then, but you just know them that you can build custom products or services for them.
    • Self service: A lot of business nowadays, especially retails, are moving to make customers service themselves, cashiers are being replaced with machines. So, in this case, your value is to make people do their shopping quickly.
    • Co-creation: Your value is to sell your customers tools to build their products rather than selling the product itself. Think of 3d printing, Apple's app store from the developers point of view.
    • Automated Service: This sounded like Self service to me, couldn't get the difference.
  5. Revenue and Pricing: You need revenue to sustain as a person and as a startup as well, so be brave to step away when your business comes out not to generate a decent amount of money. As for the pricing, there are strategies for how to price your product:
    • Cost plus: Just add some margin to your cost
    • Skimming: You know there is a niche to buy what you make no matter what, so price based on that, to cover your cost, R&D, etc. Again, think of an iPhone.
    • Loss leaders: Be the cheapest ever. Think of Pound Land (now there is even 99P), but this is very risky strategy, and you cannot compete on prices all the time, and even worse, once people take you for that price, it is harder to raise your prices again to meet any future expenses
    • Penetration: Not below market value as Loss leaders, but below top market value. Think of LG to Sony, or Kia to Honda.
    • Freemium: Think of drug dealers, give you something for free, wait for you to get attached, then sell you more stuff. Play a game for free, but pay to download next level. 
  6. Resources: Know where to find them.
  7. Partners: No one can start a business on his own. 
  8. Break the model: Now after creating your model, you need to test it. Compare your assumption from the model to data from your research. And fee free to adapt the model.
  9. MVP: Minimum (start small, and keep it simple), Viable (Be cheap when it comes to your initial investment) and Product (Have your product ready). If you are into software development, think of it as Torvalds' "release early, release often". 
  10. Evaluate: Put your mode in the wild and test it. Look for criticism, because most of your friends, family and acquaintance are usually too decent to give you real criticism.
  11. Pivot or Persevere: Basically, if market reaction is negative pivot, if positive persevere. Yet, this is something you can only learn by experience from as much success as well as even more failures.
  12. Execute: Well, I am not live-blogging here, so I might have already explained some stuff in previous points.
  13. Scale: Always keep in mind that your aim is to grow. You don't need to be as big as Google or Microsoft, but just grow, and remember, cash is what keeps your business ticking, or capital is your new king.
  14. Repeat: If it is successful, do it again. But remember, market changes so copy your previous successes might not always succeed.
One final note, the session was way more useful and interesting than this post, and some points here might be more or less how I understod them not how they actually are, but I tried to summarise it for my own self. And here are the slides for Matt's presentation.

20 January 2013

MacPorts FTW

Being new to Mac OS X, I am still struggling to memorize its different keyboard shortcuts and to make my fingers tell the difference between the command and control button. However, another thing I have been struggling with lately is, installing my favourite python modules on it. I had some problems installing Scipy and Scikit-learn in particular. I gave Homebrew a try among other things, but it came out that MacPorts was the only way to install those modules successfully.

It's simple and straight forward.

Download and install the MacPorts package for your system here.

On the command line, type the following commands
$ sudo port install python
$ sudo port install py-scipy
etc...
You may aso specify a specific version for python to use, so, type 'python27' and 'py27-scipy' instead. For sure you can use it to download hundreds of other packages, see the list here.

If you, like me, messed a bit with your system paths, make sure to have a look at your '.bash_profile', or whatever shell you use, to see if any other paths set by brew are taking precedence or something.

There is also 'sudo port selfupdate' to make sure all you packages are up-to-date. Check the guide for other useful commands here.

12 January 2013

Ubuntu on Dell Inspiron 15R 5520

I am a true believer in Free Software, but I am really considering selling my soul to Apple sometime soon.

For the past four days I have been stuggeling with my laptop's wifi, I installed 2 versions of Ubunto, one Mint, one Fedora and one Debian on it in the past few days. None was able to identify its internal wireless. I bought an external USB wireless device, some were not able to detect it, some needed ndiswrapper, and few were able to detect it, but the latter two, never worked properly, and the wireless connection kept going down.

The sad truth, is that when I bought my Dell Inspiron 15r 5520 laptop, it came with Ubuntu 11.10 preinstalled on it. But when I upgraded it to 12.04 the wireless stopped working, I then realized that Dell was using a custom Ubuntu version with the wireless driver in there. I tried contacting Dell since then to send me the driver, but with no hope. I created a supprt ticket with them almost 6 months ago but with no hope. Just google "Dell Inspiron 15r 5520 Linux Wireless" to realize how Dell doesn't give a rat's shit to their customers. People keep on comming out with workarounds to solve the problem, and Dell simply don't care. But on the other hand, Ubuntu's site mentioned my Laptop among their certified hardware, yet they added that "the standard images of Ubuntu may not work at all on the system or may not work well". So, I still have an option to pick another laptop that is certified by them. However, new models (the one you probably are going to buy) are not on their list yet. So, I am still not sure of that option.

I've been using GNU/Linux since 2002, so may now is the time to switch to Apple, at least for some time, we need to separate for a while. As for Dell, I don'y think I'll buy anything from them again.

08 January 2013

Time-Series Data Classification

Time-series data are every where. They are important in stock market analysis, eco-
nomics, sales forecasting, and the study of natural phenomena such as temperature and
wind speed. The growing size of such data, as well as its variable
statistical nature, make it a challenging problem for data mining algorithms to predict, classify.

I've written this report as part of my postgraduate degree in data mining program in The University of East Anglia. In it, I focus on time-series data classiļ¬cation by shedding the light on the researches done in this area.

Time-Series Data Classification

06 January 2013

Git for dummies like myself

Well, I had an account on github since 2009, but I started using it recently. On the one hand, that was because I was a very lazy programmer, but on the other hand, it was because git used to confuse me.

Now, after watching some webcasts and reading some scattered documents, I made myself a cheat-sheet, and I'd like to share it with you here.

First thing first, git is not github. I mean, you can use your local git and never touch github, however, github is the de-facto git in the cloud nowadays, and sharing your code there is a very cool thing. Hint hint, some employers also value those who share beautiful code there.

Second thing second, I will assume you are using GNU/Linux, oh, I forgot to tell you, Windows sucks, and one of the main reasons I never understood git, was because I was using Windows back then. Mac should be fine too, however, I never touched an Apple laptop before, so I cannot really tell.

Initializing Git

Now. let's say you are writing some cool software in some folder. In your beautiful GNU/Linux terminal get into that folder and type the folloing command:

$ git init

This is a mandatory initial step, it tells git to creates a hidden folder there, ".git". This folder will be  used by git from now on to do all its black magic.

How are you? How are they hanging? Que tal?

Throughout your gitting life, you can use the following command anytime to check the status of your repository:

$ git statu­s

As opposed to status, log tracks history not the status current moment

$ git log

Still confused a bit, give them a try now, or you know what, let me give you one more hint.

Help! I need some help

The easiest way to ask for help, is to write git followed by the word help, then the command that you need to know more about.

$ git help status
$ git help log

Probably, it will give you some cryptic information, so let's skip it for now, at least, you now know that help it there whenever you need it.

Let's start the fun

Git respects your privacy, and gives you control on what to commit (their lingo for saving) at a certain moment. So, whenever you edit your code, you have to explicitly tell it which files you need to commit later on. To add a file to git:

$ git add file_name.txt

You can use wildcards too, written in quotes. Below you add all text and python files:

$ git add '*.txt'
$ git add '*.py'

Similarly you can remove file from staging

$ git rm file_name.txt

After adding comes the committing

To commit files from staging area to repository:

$ git commi­t -m "Some committing comment here­"

I know, 'staging', 'repository' and 'committing', all sound Chinese to you now. Well, if staging is like the RAM, some temp location or so, and the repository is like the Hard Disk, then committing is like saving. The text in quotes after the '-m' is mandatory, but it is up to you to write anything there, you can even write a single dot in there if you want to. However, it is useful for your reference later on in case you needed to revert to a certain version of your software. So, it is always a good practice to write down what you have actually done before this commit. 'Add a hocus_pocus method to my Magic class', 'Corrected a typo in README', etc.

Github FTW

So far, we have been doing thing on our local machine, let's see how to publish all that to github. In your github homepage, there is a button called "New repository", click on it to create a new repo. They will ask you some question about your project's name etc. When done go to that repo, and on top of the page, you will find a URL that looks like this:

https://github.com/[YOUR-USERNAME]/[PROJECT-NAME].git

Copy it, and go back to your GNU/Linux termina and write the following command

$ git remot­e add origin [URL]

Well, I believe origin can be replaced with any other name, but I still have no clue about it, so let's stick to origin for now, I am just a monkey-see monkey-do at the moment.

Publishing your work

Now you connected your local git to github, what to do next? Exactly, publish that changes you have just committed. Or in our case, we will be publishing everything from scratch since our github repo is still empty now. Once more, those git people use their own lingo, so they call publishing pushing.

$ git push origin master

Remember, we used origin before, so we use it again here, as for master, this is something called branches, but let's not confuse ourselves with it now, let's stick to origin and master for now.

You know what, I've got a short-cut for you. Let's add a '-u' to the previous command

$ git push -u origin master

Great, by doing so, from now on, git will remember your choices and you will not need to say origin and master in your pushes again again. I.e. next time, just write the following and it will work:

$ git push

You 3 useful commands

Most of the time from now on, you will be editing files locally, then pushing them to git hub, to publish your changes all you need to do is the following 3 steps. Adding files, committing then pushing.

$ git add '*.py'
$ git commi­t -m "Cleaned my code a bit­"
$ git push

Sharing is caring

Like any social network, github is mean for people to share code. So, most probably you will have some other friends working on the same project with you, and they do make their own changes to the code as well. So, how to synchronize your local repo with the changes they already published on githib. Easy peasy! If push was our way of pushing our code to github, then pull is the way to get the updates from there.

$ git pull -u origin maste­r

See, we added our magical '-u', so next time, we can simple write the following.

$ git pull

Well, that's enough for now, in the following section, I will list some other commands for your (and my) reference, but you can skip them for now.

To see difference between last commit and current files

$ git diff head

Also you can see differences for staged files

$ git diff --staged

To create a branch to play in

$ git branch branch_name

To see which branch you are in, just type:

$ git branch

To move to your new branch, type:

$ git checkout branch_name

To merge changes in branch_name to master, type the following wile on master

git merge branch_name