Posts tagged: ali almahdi blog
PHP Obfuscators and Encoders
A common problem with Interpreted Languages (eg. PHP, Javascript, Java, Python) is that its really hard to protect the source code. Today, I will talk about PHP Obfuscators and Encoders.
Two types of protection can be found for PHP, first type which is the easiest, Obfuscation. Making the code not human readable. An example of such product is ZenCrypt (I wrote a semi-review about it last year). However, a good developer or a reverse engineer can go about that, and alter the code to change its behavior, like bypass the license verification.
The second type is encoding, the encoder encodes the PHP script to some encrypted text (I don’t want to go into details here, but that’s the general idea). Those encoded scripts requires a loader, this loader decodes the script and runs it via the PHP Interpreter. Those loaders are simply PHP extensions. Example of those are ZendGuard and IonCube.
It is not hard to write a PHP extension, but it wont be adapted easily with most online hosts. Maybe Enterprise! But again, maintaining cross platforms is not an easy task.
Since IonCube and ZendGuard are widely supported with most hosts some came up with the idea of creating a hybrid obfuscator. The idea is to encrypt the code and have a php script to decrypt. But the decrypting script is encoded using ZendGuard or Ioncube. An example of such is phpCipher.
Last year in my post I wrote that I will be writing an encoder, I have been very busy since then. But last week I had the chance to start writing my encoder. I have most of the logic done. Once I am done writing my loader script, I will start writing the desktop app to encode the scripts. I am planing to release it on Mac App Store and online on my website for a small amount of money.
On a side note, I may offer my source for sale.
What is beauty?
This question popped up to my mind and it is inspired by the previous post (What is Love?).
Beauty is an interpretation of some kind of love or let me say liking. When we see something we like, we say its beautiful. Defining the word “like” will take another post, so I will stick with the word “beauty”.
When we see a person who is beautiful, it means that we either love this person, so we like everything about this person, then he/she becomes the most beautiful person in the world. Or we like something about this him/her, so it could be the shape of his/her face, the color of the eyes, or his/her hair cut/style. People sometimes look beautiful for the way they dress and depending on your mood.
If you notice, sometimes you see a beautiful person, and another day, they are just like the rest, the beauty is just gone. It could be that she/he was wearing something you like.
This word has a very complex meaning, I tried to express it in my own simple words.
What is love?
What is love? It is a question that have been asked by Hussain Nasser (@hnasr). So, here is my answer. Keeping in mind that everything I write here is my own opinion, some people may agree and some don’t.. So please don’t flood me with comments saying that I wrote the wrong thing or I have a weirdo opinion.
Love can be applied to everything, you can love a person, or a computer or even a pet. But I will define love based on loving people.
When I chat with my friends, we joke and we say that love is a band-pass-filter. What it means is that when we love, we only see what we like. Love is like glasses with filters, that makes us not only see what we like, it may even makes us like things we didn’t like.
Love is the butterfly effect when you see the person you love. Love is when you feel alone without this person around you, even though everyone else is around.
In love, beauty doesn’t count. It doesn’t matter if the person you love is beautiful/handsome or not, because love makes everything beautiful.
Love is when you want to spend the rest of your life with this person with no regrets! Love is happiness. Love is the most beautiful thing in this life. Love is what makes us. We can’t live without love…
Sometimes people mix love with sex, this is not true! Sex has nothing to do with love. Sex is a physical thing while love is a feeling. Attraction is not love. Liking an attitude is not love.
Viva Bahrain 3G network and Phone battery life!
If you haven’t noticed, using Viva 3G network consumes more battery than any other network in bahrain, zain and batelco to be specific. To make the story short, Viva 3G network is actually setup on HSPA+ which consumes more power than 3G.
Brief Technical Information: Quoted from Wikipedia:
High-Speed Downlink Packet Access (HSDPA) is an enhanced 3G (third generation) mobile telephony communications protocol in the High-Speed Packet Access (HSPA) family, also dubbed 3.5G, 3G+ or turbo 3G, which allows networks based on Universal Mobile Telecommunications System (UMTS) to have higher data transfer speeds and capacity.
zain and Batelco provide HSPA+, however, the phone has to switch to it when it requires high speed access, but on Viva, HSPA is the default.
I bought myself a Dell Streak
Few days ago, I sold my iPad.. For few reasons.. 1st, I couldn’t find a proper use for it. I used it for browsing, but its size was too big for me. I thought of purchasing the Galaxy Tab, since its 7-inch… I went and I grabbed one and I tested holding it and walking with it. Didn’t wasn’t good either. The Dell Streak is the perfect size, yet, good screen. I immediately fell in love with the Streak. So, I bought one.
Loading fixed width lines in MySQL
Today I required to load a file into a database, the file requires some parsing to be loaded. Normal developer would load the file using a programming language, do the parsing and insert into the table. However, for me, I thought I would do it using MySQL DATA LOAD, it is faster and yet, no programming language required to load the files.
I am posting a sample code on how to parse files line by line using MySQL.
LOAD DATA LOCAL INFILE ‘path/to/my/file’ into table [table-name](@line)set field1 = SUBSTR(@line,1,10),field2 = SUBSTR(@line, 11,12),field3 = SUBSTR(@line, 48,19)
Now, what I did, is I just parsed text, since the file was not delimited but it had fixed width.
Mac OSX Defrag
On my daily life, I deal with VM Images and File processing.. Large files.. This causes my MacBook to slow down due to Fragmentation… My solution was always to backup to an external drive and restore back, and it solves the fragmentation problem and the MacBook Performs better. However, this takes really long time. Especially with large disks. Today, I tried iDefrag from Coriolis Systems. I purchased the Application using Paypal and gave it a try. It worked like a charm. It took 4 hours to finish, but I can notice the speed of my VMs. And Apps load a bit faster. Good Application to keep the performance of your Mac OSX.
Keeping in mind that your Mac OSX defragments any file less than 20MB automagically, however, large files get fragmented, to defragment, you can move the files to external disk and move them back. However, this takes time and requires you to have an external disk to backup the files.
I got my self an android Phone!
Hmm, I couldn’t resist acually… So, I got my self an Android Phone… Its an Acer Liquid E Ferrari Special Edition. Its not the best Android Phone… However, since I love cars, its price is good for me… and it got everything I want..
Since I started Mobile Development for sometime now, it has been my excuse for Android development… This app is not a new idea, however, its a new implementation. I will release the details as soon as I start testing the app. Its going to be available for Android and iPhone.
Follow me on twitter
I have been a bit active on twitter.. I don’t know when I stop twitting.. However for the time being, you may follow me on twitter (http://www.twitter.com/alialmahdi/).

