I was doing some dev work, as usual in ZF, and I was surprised to find out that there’s no Zend_Validate_Url or Zend_Validate_Uri class among the framework’s default validators. Which is a bit weird, as validating URLs in a very common task in web development, much more common than, let’s say, validating a barcode or an IBAN.
Do you know what a web designer is? A guy that wasn’t man enough to become a software developer yet not gay enough to become a fashion designer. Leaving the joke aside, design is an important part of web development. As with everything, looks do matter.
And you truly see the value of a designer when you don’t have one on the team. Like me now. I needed some graphical changes and didn’t have anyone to do them. Big problem. But I’m quite good at solving problems, and I’m not scared to try new things, so I dove in. I had some Photoshop and Illustrator files from the previous the previous designer and I thought it shouldn’t be too hard to change some colors.
The only problem was that I didn’t have Photoshop installed on my laptop. Given that Photoshop is quite pricey and I don’t want to spend money on a piece of software I use once every 6 months, I started looking for alternatives to Photoshop that work under MacOS. And the first one that popped into my mind was GIMP. Which is a good piece of software, but it comes with X11, so all MacOS shortcuts don’t work – CMD + C / CMD + V have to be replaced with CTRL + C / CTRL + V and so on, which is a bit annoying, but hey, it’s free and it does the job. Or not.
I had to open an .ai file – Adobe Illustrator – which GIMP does not support. I know that this might sound stupid, but I never used image editing software. After some googling around, I found out that GIMP is not supposed to open .ai images as these are vectorial. So I needed something that can open vectorial image formats, was free or extremely cheap. And I did: Inkscape.
So, for all developers out there, if you want to open an .ai file and don’t have Photoshop / Illustrator, install GIMP and Inkscape, open the file in Inkscape and then import it in GIMP. Maybe it will save you several hours of googling around.
I had a weird problem today with my VPN connection: when I was connected, my Cisco VPN client seemed to block all other HTTP connections. Skype & Yahoo! Messenger were working but all HTTP(S) connections on both browsers (Chrome & FF) were down. Which is extremely weird and I couldn’t pinpoint to the core of the problem.
So I did what any responsible IT person would do: googled. But I couldn’t find anything relevant. One article suggested going to “Modify » Transport” and check the “Allow Local LAN Access”. Which I did but didn’t work.
So I started playing with the network settings and at some point I got it working by changing the DNS servers to 8.8.8.8 – Google’s DNS. While I’m not sure what cause the problem or if this is the right solution, I’m posting it here so maybe it will work for somebody else.
I’m quite sure that by now everyone has heard of ACTA. It’s an international treaty negotiated in secret by a bunch of spineless, unelected wankers set to fulfil the wishes of their Hollywood paymasters. Just read my previous post to find out more.
Under ACTA everything we do online will be tracked and our privacy will be violated just to enforce the IP rights of some media giants. Big Content companies will have the right to ask ISPs for our data directly, without any judicial supervision, without having to even consider obtaining a search warrant. The only way our privacy would be violated more is if the government – or private companies to follow ACTA’s trend – install video cameras in our apartments.
And, for the time being, the European Parliament is okay with ACTA.
I’m not saying that European MPs are complete idiots, not all of them anyway, just the majority required to pass a bill. And not any bill, I’m talking about the 2009/136/EC Directive or the so called “Cookie Law”. This law prevents websites from using cookies without asking for user consent. If you’re a tekkie, you know what a cookie is and what impact this law will have on the internet. If you’re not, well, just trust me on this one: over 90% of sites are illegal under this law. And complying with the law is a messy, expensive and time consuming process that will cripple EU technology companies trying to compete with their American or Asian counterparts.
And why this directive, you ask!? Well, to protect the average EU citizen’s right to privacy. Yes! The same body – EU parliament – enacted both ACTA and Directive 2009/136/EC. Just to put things in perspective, the last EU election was held in June 2009 and the directive was passed in November 2009, so the exact same people that passed the Cookie Law are thinking of passing ACTA. It’s not even a different legislature.
This is how I picture a normal day in the European Parliament:
I think that we should vote a new law in place, so all members of the EU parliament to be forced to take an IQ test before being sworn in office. Just to see whether they’re smarter than door knob or not. A regular door knob, not a fancy electrical one!
This is a post I’ve wanted to write for a long time, perhaps it will be useful to others. It’s about using Zend_Db_Table_Select and the SQL LIKE statement. I remember it giving me some headaches in the past, so here it is:
The problem is that Zend’s implementation is a bit counterintuitive, as the % sign is part of the query – as it has a special significance in SQL – and not of the string being search. So the first thing in my mind was:
My_Table_Example extends Zend_Db_Table
{
public function search($value)
{
$select = $this->select();
$select->where('column LIKE ?%', $value);
// ...
}
}
Which doesn’t quite work. Of course, one can always use good ol’ string concatenation, do it like this:
My_Table_Example extends Zend_Db_Table
{
public function search($value)
{
$select = $this->select();
$select->where('column LIKE "' . $value . '%"');
// ...
}
}
…and risk an SQL Injection attack. Definitely not the best approach! In the end I found the best solution to do it is:
My_Table_Example extends Zend_Db_Table
{
public function search($value)
{
$select = $this->select();
$select->where($this->_db->quoteInto('column LIKE ?', $value . '%'));
// ...
}
}
…which, as previously stated, it’s quite counterintuitive. But hey, it works
Few days ago I was asked if I can review on of uCertify prepkits. I wrote a review some time ago for a different prepkit – full review here XK0-002: Linux + PrepKit – and at the time I was impressed with the quality of the kit. So I agreed to do it again. This time, I picked the prepkit for the Certified Ethical Hacker or CEH certification. For those of you who don’t know it, this is the Chuck Norris of security certifications.
I downloaded the Windows executable version of the prepkit, in hope that I will be able to make it work on my Macbook. No such luck. I tried Wine and CrossOver, but it kept on crashing. After several hours of frustration I emailed back the guys at uCertify with the issue. They suggested using the web version of the prepkit – at the the time I didn’t know there was a web version – which worked like a charm on all platform. So, first lesson learned – if you have a Linux / Mac system – go straight to the web version.
Usability, look and feel
I found the prepkit to be particularly easy to use. The interface is really straight forward, very clean, with good typography that doesn’t tire your eyes. Typography is particularly in this case, as geeks – myself included – wear glasses and don’t like hard to read “artistic” fonts.
The information is structured in a logical manner, everything is where you expect it to be. Just have a quick look to the screenshot on the right!
Maximum score to usability & ease of use.
Features
The information is divided into 3 main areas: Learn & Practice, Study Material and Performance Assessment and Analytics and each section is divided into multiple sub-sections.
The Learn & Practice section is comprised of various tests, which can be used to mimic a real life exam (Test mode), study (Learning mode) or to review your knowledge (Review mode). Screenshot to the right!
Study Material is comprised of:
Subject/Exam Standards & Objectives
Study notes
Articles
Flash Cards
Key Terms
Glossary
Online Reference Library
Study Tips
…and Performance Assessment and Analytics of:
Study Planner
Progress reports
My Activity
Daily Snapshot
My Focus
Performance on Practice Tests
Readiness Report
Some of the features are really cool, I especially liked the Study Planner, which helps you plan and keep track of your progress, a very important tool as we all know that IT guys are generally lazy and don’t like reading manuals.
Although getting messages like:
Your preparation is about 0.5% complete. You took 1 days to complete 0.5%. At this pace you will need another 6 Months, 2 Weeks, 5 Days, to be fully prepared for the exam.
might be a bit demotivational.
Usefulness
To make things clear from the start, this is not an online course for beginners. The prepkit targets experienced professionals, not learners or script kiddies. But that’s not necessarily bad, as the last two categories are not even eligible for certification according to EC-Council’s eligibility form.
As I have yet to take the CEH exam, I can’t say how accurate or useful the questions are in a real life scenario, but given uCertify’s vast experience in the area of preparation kits for top IT certifications, I’m sure it’s useful.
Conclusion
I found the prepkit easy to use, filled with high quality information and well structured. I think it’s a good deal for $119.99 (aprox. €91 / £75), especially since uCertify offers a full refund if you fail the exam. Give it a try. Or if my review didn’t convince you, try it for your self. There’s a demo version available here.
Once again I’m ashamed of my government. Disappointed and enraged at it.
And this time it’s not about spending public money on crap, increasing taxes to pay astronomic salaries to some lazy ass MPs or being generally worthless. It’s much worse!
Today Romania signed ACTA. An international agreement which is so broad in scope and so evil that makes SOPA look like a plea to save the whales.
At least I’m not the only one.The following EU countries also signed it: Austria, Belgium, Bulgaria, the Czech Republic, Denmark, Finland, France, Greece, Hungary, Iceland, Ireland, Italy, Lithuania, Latvia, Luxembourg, Malta, Poland, Portugal, Slovenia, Spain, Sweden and the UK. Shame on them too.
Unlike SOPA / PIPA, ACTA was negotiated in secret. The public was deemed “too ignorant” to be involved in the talks. For the first time in modern history, democracy was left out on a global scale. If you’re unfamiliar with ACTA, just take a look at the clip below:
In a world where technological progress should be used to improve the quality of life for everyone, ACTA enslaves us all.
Cheap medicine could be banned under ACTA in order to protect the intelectual rights of big pharmaceutical companies. Under current legislation, a government in difficulty, for example facing an epidemic, if it can’t get the required medication at a reasonable price, can break patents and produce the drugs in order to save its population without fear of retaliation. Under ACTA, this will no longer be possible.
All internet traffic will be monitored in order to detect possible breaches in copyright. All confidential medical information, all the love letters sent via email, all the chat conversations in which you’re flirting with your hot co-worker, all your bank details, everything – and I do mean everything – will be scanned and recorded by your ISP.
Open source programs could be banned. Even if you’re a M$ fanboy / fangirl that only uses Winblows™, you still have to understand that the Internet runs on Linux and open source. Popular services such as Google, Facebook, Wikipedia or WordPress run on open source and the Apache web server powers 60% of all the sites on the Internet.
You might even end up in jail for posting a video from your birthday party because some copyrighted music is playing in the background.
Don’t get me wrong, I’m not a lazy-ass socialist. I truly believe in capitalism, but I also believe that everybody should have a fair chance of making a good living by hard and honest work. If legislation like ACTA gets enacted, the world will be split in the chosen few, wealthy individuals that will use legislation to kill any newcomer in their field with patents and copyright issues, an army defending them and the rest, with
Respect to Germany, the Netherlands, Estonia, Cyprus and Slovakia for not signing ACTA today. But for the rest of us, the fight is not yet lost. All international treaties have to be ratified so we can still stop this.
If you want to help, contact your representative and tell him / her that you don’t want such legislation ratified. The MPs are there to represent you and usually they tend to give in when they see their political carers threatened. If enough people contact them, they will not ratify ACTA and risk not being voted again.
Go to protests, if there are some in your area.
Do not engage in fights with the police. Do not attempt to DoS government agencies. Hacktivism is for hackers and security experts. Downloading the LOIC doesn’t make you a hacker and flooding some government website won’t help that much. And if you don’t really know what you’re doing, you’re going to get caught and thrown in jail.
I wrote yesterday an article introducing Cosmin’s blog. His most recent article is on multiple inheritance and how easy it would be to implement that into weakly typed like PHP. Just have a look at the article.
Having learned OOP in Java, I am generally against multiple inheritance. I believe that if the answer is multiple inheritance, you’re asking the wrong question. But, for “academic” reasons, I tried to implement multiple inheritance in PHP. And I came up with the following abomination.
First, create a parent class from which all classes in need of multiple inheritance extend. The parent classes will be placed in the $_parents array as strings. When the main object is instantiated, the constructor creates objects from all the parent classes. And by using __call() I’m just going to redirect method calls on the main object to the first suitable parent object. I know it sounds complicated, so long story short, just read the code! I’m a developer, not a writer!
/**
* Abomination class implementing multiple inheritance via
* __call magic method
*/
abstract class MultipleInheritance
{
/**
* List of parent classes
*
* @var array
* @access protected
*/
protected $_parents = array();
/**
* List of parent objects - generated automatically
*
* @var array
* @access private
*/
private $_parentObjects = array();
/**
* Constructor (thank you captain Obvious)
*
* - init the parent objects
*
* @access public
*/
public function __construct()
{
foreach ($this->_parents as $parentClass) {
$this->_parentObjects []= new $parentClass();
}
}
/**
* __call magic method
*
* @param string $name
* @param array $arguments
* @access public
* @return mixed
*/
public function __call($name, array $arguments)
{
foreach ($this->_parentObjects as $object) {
if (method_exists($object, $name)) {
return call_user_func_array(array($object, $name), $arguments);
}
}
throw new Exception('No such method: ' . $name);
}
}
Now, some very sexist implementations of Mom and Dad classes:
class Dad
{
/**
* Can parallel park
*
* @access public
* @return void
*/
public function park()
{
echo 'Look, I can parallel park' . PHP_EOL;
}
/**
* Can ground the kids
*
* @access public
* @return void
*/
public function ground()
{
echo 'Grounded by DAD' . PHP_EOL;
}
}
class Mom
{
protected $_parents = array('GrandMa');
/**
* Makes sandwiches
*
* @access public
* @return void
*/
public function makeSandwich()
{
echo 'Just making a sandwich' . PHP_EOL;
}
/**
* Can grounds the kids
*
* @access public
* @return void
*/
public function ground()
{
echo 'Grounded by MOM' . PHP_EOL;
}
}
$child = new Child();
$child->park();
$child->makeSandwich();
$child->ground();
And it works. And when two parent classes have the same method – ground() in this case – the method belonging to the first encountered class is executed. And voila, multiple inheritance in PHP. Well, sort of.
Now there’s a small problem with the instanceof operator. And by small problem I mean it doesn’t work and there’s no way to fix it. The following code
if ($child instanceof Mom) {
echo get_class($child) . ' class inherits from Mom' . PHP_EOL;
} else {
echo get_class($child) . ' class does not inherit from Mom' . PHP_EOL;
}
will always go on the “else” branch, although in my application’s logic, the Child class extends from the Mom class. And since PHP doesn’t allow overloading the operators, there’s no clean way to do this. Of course, there’s a hacky way around it, by adding an isInstanceOf() method to the MultipleInheritance class:
abstract class MultipleInheritance
{
// ...
/**
* Check inheritance
*
* @param string $class
* @access public
* @return bool
*/
public function isInstanceOf($class)
{
if (in_array($this->_parents, $class)) {
return true;
}
foreach ($this->_parentObjects as $parent) {
if ($parent instanceof MultipleInheritance) {
if ($parent->isInstanceOf($class)) {
return true;
}
}
}
return false;
}
}
…and using it to check inheritance:
if ($child->isInstanceOf('Mom')) {
echo get_class($child) . ' class inherits from Mom' . PHP_EOL;
} else {
echo get_class($child) . ' class does not inherit from Mom' . PHP_EOL;
}
But the abomination is not completed yet. Because I used method_exists() instead of is_callable(), magic methods in the parent class will not be detected. To fix this, just change the code from:
if (method_exists($object, $name)) {
return call_user_func_array(array($object, $name), $arguments);
}
…to…
if (is_callable($object, $name)) {
return call_user_func_array(array($object, $name), $arguments);
}
…and it will work. At last, the abomination is ready. Doctor Frankenstein would be proud! Here is a gist with the entire example: https://gist.github.com/1652646.
PS: DO NOT USE MULTIPLE INHERITANCE IN REAL LIFE APPLICATIONS!
Meet Cosmin. He’s my dev partner at StoreBeez. He’s a software developer who recently turned to the light side of the Force by making the switch from .NET and other M$ technologies to PHP and open source.
While he still uses Windows – which bears testimony of his former allegiance with the evil empire – he’s moving up the ladder and started a blog on PHP and other FLOSS technologies. Check him out.
Today the anti-SOPA blackout came into action. Wikipedia was partially out – users just had to hit escape before the page finishes loading or disable Javascript, Google, Reddit, 9Gag and other well trafficked sites joined the protest. Unfortunately not everybody did it, although I would have expected it, as SOPA threatens the entire industry as a whole, not just a few company. YouTube, Facebook as well as other online giants stayed on the bench. Sad!
I was curious whether GoDaddy will join the protest, after the recent scandal which forced them to withdraw their support for SOPA / PIPA. They had the decency to stay out, which is good.
And a short clip outlining why people should support SOPA.