Category Archives

27 Articles

English to Arabic Vocabulary

by Abu Lewis

English to Arabic Vocabulary makes it easy to practice and learn both the english & arabic language. The application contains a big list of english words and their arabic translation. After searching for a certain word, you are able to hear the pronunciation of the word in both english and arabic.

SQLite Maker

SQLite Maker is a small utility that makes the creation of SQLite databases simpler and more fun. Create a database, its tables and columns using your fingertips. You can then easily transfer and/or send the created database to you or to the person who will have it.
Notice that the tool does not contain functionality for executing SQL queries against the created databases. The only purpose of the tool is to create plain sqlite database files.

For support & bug reporting, click here to contact me

A simple Configuration class in Ruby

by Abu Lewis

Just in case you never heard of OpenStruct…

And this is how it can be implemented…

IceCube => Ruby Date Recurrence Library

by Abu Lewis

I love that i found it :). Check it at ice_cube github repo.

This is my first playing around code;

The output would look like this

When to write modules in Ruby!?

by Abu Lewis

To be short and concise, As soon as you have identified a behavior that is or may be shared between different objects, at that time it is a good idea to push that behavior in its own module.

So lets fabricate a use case;

You are given the task to write a little program for a zoo. They need to register the type of food and the time for which the different animals are fed. The zoo has a wide variety of animals, like big cats, fishes, reptiles etc.

So as a good programmer, we do know that all these animals ”eat” (Common behavior). So eating is a good candidate to be separated in a module. The different animals may implemented differently depending on the type, race etc.

So if we define an module and call it EatingBehavior that would look like this;

We can later define a Lion and a Fish class that may look like these;

The both objects are now ”eaters” and if we would define more animals, we should just repeat the same ”including” process….

To test the implementation;

Creating a Ruby service using the dRuby module to be called within a Rails application

To simplify things, lets fabricate a use case scenario;

Imagine that you have to control a password’s strength when the user is registering a new account. The controlling of the password is done using a password list file obtained from I’m using the best available one according to the site, which is rockyou.txt.bz2.

To use the list, I have extracted the list and copied it to /usr/share/wordlists/. Once that is done, the shell command ”grep” can easily be used;

The command will check if the password ”hacker” exists or not in the file. And to use the same command in our ruby applications, we can construct a class like this one.

And to make things look like beautiful, We write an dRuby runner class as this one;

To bootstrap and run, we will do so;

Now the server part is up and running. To test our client, we can do so;

The client part can be implemented in your rails application as well!

Connecting IOS socket client to a Ruby socket server using Swift & Ruby’s eventmachine gem.

To demonstrate, I have written a server that has one task. It reads a word and sends it back to the client in a reversed form.

The server code in few lines ;/

The client, which is written as a part of an IOS application in Swift;

The demo application that I wrote is a single view-based IOS-application, with 1 textfield, label and button.

An instance of ReverseClient is created in the ViewController…

And when the button is pressed;

Do not forget to start the server!

Monitor your ruby server process using bash scripting.

After writing a server socket in ruby, I had to find out a solution to monitor its process in any way. I knew that there is a gem for that called God. I also new that scheduling jobs in NIX systems are quit easy using the crontab tool. The problem was though how I would handle the process monitoring part. I had heard of Bash scripting but never buried myself in it.

After a day or so, I ended up with the script below. It is well documented and in case of learning, this is a nice tutorial. The use case of this script would be to schedule it using the crontab tool.

Concurrency in Objective-C using Grand Central Dispatch (GCD)

by Abu Lewis

To demonstrate execution of concurrent Objective-C code, I wrote this simple example below. The two functions you have to read about to understand the code are; dispatch_get_global_queue and dispatch_async.

Example of output you may get, may look like this. And notice that the output may vary. To understand what is happeneing, run the code several times.

TDD and JavaScript

by Abu Lewis

I felt that I had to do this for my own good.:) To do TDD, the easiest way is to have nodeJS installed and up and running.

What I shortly did is to create my project skeleton

Then, you have to work in that folder

Create now two folders lib & test

Bring the package.json to your project by:

To do the testing, you will need mocha & chai

Now when everything is setup, lets start coding.
Suppose now that We have to implement the class Person, in which the method getFullName() will return concatenated firstName & lastName passed to the class constructor.

Create a test file and place it in the test folder. Also, create the person.js and place it in the lib folder.

Lets do the TDD now. The person.test.js may look like this for instance!?

To run the test:

The tests will fail for sure. Code your person.js in the lib folder:

Now, you have your first passed test case when running:

Now you are good to go with the rest. Read the documentation about chai & mocha and write your other test cases!