Robert Basic's blog

Archives for September, 2008

Smush your images!

by Robert Basic on September 30, 2008.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I just found a nice web site where you can “smush” your images — SmushIt takes an image and removes all unnecessary information about it: when was it last edited, what image editor was used etc., but keeps the quality of the image! This is more than useful for sites where there are lots of images.

There are several ways to provide images to SmushIt:

  • Upload an image
  • Provide an URL to the image
  • Use the Firefox SmushIt add-on

The first two ways are quite obvious; provide an image and it’ll process it in a few seconds.

The Firefox add-on is pretty cool: open up a web page where are the images you want to smush, click the SmushIt add-on icon (it’ll be in the right corner of the status bar), it will take you to their site and process all the images found on your web page.

When the processing is complete, there will be a table showing details about the smushing. Also a download link will be provided, to download the smushed images in one zip file.

Now run little lurker and smush your images :)

Tags: image, optimize, site, web.
Categories: Development, Places on the web.

Regular expressions with PHP

by Robert Basic on September 22, 2008.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I just want to write some real examples. These regexps are (and always will be, ‘cause I plan to write several posts on this topic) for the PHP’s PCRE library. Here’s a good PHP PCRE cheat sheet, it’s an excellent resource for regexps. If you know nothing about regexps, first read this Wiki page.

Regexps for anchor tags

A common case is when you have a source of some web page and you want to parse out all the links from it.
An anchor tag goes something like this:

<a href="" title="Some website">Website</a>

Also it can have more attributes, like class, target etc. Knowing how it’s built up, we can start writing a pattern, depending on what we want.
Here are some examples, some explanations are in the comments:

// Regexp examples for <a> tags

* Different combinations...
* $matches_comb[0] contains the whole <a> tag
* $matches_comb[1] contains what's inside the "href" attribute
* $matches_comb[2] contains what's after <a> and before </a>
* with the "s" modifier mathces <a> tags that are broken in several lines,
* ie. matches <a> tags with newlines
* without the "s" modifier, matches only <a> tags without a newline

* Match only what's inside the href attributes...

* Match only what's inside the href attirbutes,
* only when it starts with http:// and includes http://
* $mathces_href_http[0] contains some trash also, nevermind,
* $mathces_href_http[1] contains exactly what we need

* Match all Email addresses - mailto:


Play around with these patterns, see what’s for what, experiment, that’s the best way to learn regexps.

Do you have some more regexps for links? Some better ones than these here?

Happy hacking!

Tags: example, pcre, php, regex, regexp.
Categories: Development, Programming.


by Robert Basic on September 13, 2008.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

I don’t know about you, but I’m not really good with all the legal mumbojumbo. All these licenses and agreements, they sound to me like they are not written to be read by human beings. Not to mention a bunch of terms that sound similar, but are not at all. As a person who makes and uses all kind of software, I feel like I should know more about licenses; what can and what can not be done under a specific license.

There are 2 major group of licenses: for proprietary and for open source software. Currently, I’m not interested in proprietary licenses, so, I won’t write about them; you can read more on Wikipedia: Proprietary software.

On the other hand, I’m very interested in Open Source Licenses…

Some terms explained...

It is easy to mix terms like free software, open source software, freeware and such, so I’ll try to explain them as I understood them. My main reference for this is Wikipedia.

  • Free software (FS) “free” as in “free” speech, not as in free beer. FS must be free to run, copy, distribute, study, change and improve by users. With every distribution of a FS, it’s source code must be provided also. FS can be charged. Read more detailed about the philosophy of FS.
  • Open source software (OSS) — the difference between FS and OSS is very little: if I got it right, besides the philosophy, the difference is that OSS can not be charged. Read more about OSS definition and about the differences here and here.
  • Freeware software (FWS) — in most cases FWS is a proprietary software made available free of charge, but the source code is not published.
  • Shareware software (SWS) — this kind of software in most cases is available on a trial period, or it’s use is limited in some other way. To use the full software, without trial periods and limitations, users must buy the license for that SWS.
More about software categories can be found on the GNU Project page.

The reason we are here...

On the website of Open Source Initiative there is a list of (probably) all open source licenses out there. I won’t get into all of them, just the most popular ones and ones that interest me.

GNU General Public License

Probably the most used one is the GNU General Public License, with it’s latest version 3.0. The author of this license is Richard Stallman, the founder of the Free Software Foundation.

This license guarantees freedom for software authors and users; freedom to (re)distribute, modify, give and receive source code of the software and use parts of its code in other free software. If wished, free software can be charged, but must guarantee these freedoms to users of this software. Any redistributed or modified version of the original free software must stay under this license. If a free software is changed by another author, it must be marked as changed, so if any problem occurs with the changed version, the problems will not be attributed by mistake to authors of previous versions.

Software under the GNU GPL can be linked only to other software which is also licensed under the GNU GPL. Software that links to a software under the GNU GPL must also be under the GNU GPL.

If someone sees a violation of a GNU GPL, here’s what he should do: Violations of the GNU Licenses.

GNU Lesser General Public License

GNU LGPL is a more permissive version of GNU GPL. It is mainly used for software libraries, but can also be applied to some stand-alone applications. A software under the GNU LGPL can be linked with software that is not under the GNU GPL or GNU LGPL; that software can be another free software or even a proprietary software.

Using GNU LGPL for libraries is discouraged.

The BSD License

The BSD License is a permissive license; conditions are that the original copyright notice, the list of conditions and the disclaimer must be included with every redistribution of the software. The software can be, with or without modifications, redistributed and used. It can be used in other free software or in a proprietary software. Another restriction is that the author of the software can not be used to promote modified versions of the original software, without his or hers written permission.

The MIT License

The MIT License is also a permissive license; it is very similar to the BSD License. Difference is that the author of the original software can be used for promotion without permission, if not stated otherwise in the license.

Other licenses

I found these 4 licenses to be the most interesting ones. Others are very similar, so I will not go into them — maybe in some future post.

I hope someone will find this little reading helpful. Any thoughts on this topic?

Btw, I recommend a good documentary movie, Revolution OS. It tells about the free software movement and the open source. Notable speakers are Linus Torvalds, Richard Stallman, Eric Raymond, Bruce Perens and others. Enjoy :)

Tags: free, free software, licence, open source, proprietary.
Categories: Development, Software.

Look, Ma...

by Robert Basic on September 04, 2008.
Heads-up! You're reading an old post and the information in it is quite probably outdated.

... I have a Blog too! Well, it was damn time to get yourself one of those.

Actually, this is my third blog. The first lasted about a day or two. The second went alright for a time, but then the hosting company started to play around with settings, so the whole thing fell apart. This time, I'm serious. Kinda.

Until now I was foolin' around a lot. Tried this and that, experimenting. Heck, I even got a job. A real one. For real money. It lasted about 5 months, but then I quit, 'cause I still have some bloody exams @school, and I commuted every day to work, so it was pretty hard to concentrate on both. Now, I'm back to freelancing. Studying hard to get these exams off my back, and working on some projects; nothing big.

Sooo... What to expect from me and my blog? Tutorials, screencasts, reviews, freebies, random writings... Anything that is connected with the Internet, it's development and me. I'll try to show up with some quality and creative stuff, hopefully, on a regular basis.

Ramble on!

Tags: about, introduction, random.
Categories: Blablabla.