Passing current or last page full URL as a part of URL

By using five separate PHP functions, in correct order, you can easily pass (code and decode) entire page’s URL as a parameter of any other script call, redirect etc. And be sure that it will be read (decoded) correctly, no matter, how long your URL is or what kind of characters it is using.

You can encode any URL (current page, last visited page or any otherwise important) and pass it in another URL in the way that your user won’t notice that you’re actually passing an URL.

Presented solution can potentially be used as URL shortening service. Generated URLs aren’t that short (as maybe expected), but for really long URLs it does provides some shortening.

Read More “Passing current or last page full URL as a part of URL”

CMarkdown usage examples

You can use CMarkdown class as typical Yii widget:

[code language=”php”]
<?php $this->beginWidget(‘CMarkdown’); ?>
_Markdown_ *example*
<?php $this->endWidget(); ?>
[/code]

or directly as a function:

[code language=”php”]
$text = ‘_Markdown_ *example*’;
$md = new CMarkdown;
echo $md->transform($text);
[/code]

That’s pretty much everything, folks!

Convert CActiveDataProvider to associative array

Here is an example on how to convert CActiveDataProvider to a simple associative array.

[code language=”php”]
$dataProvider = new CActiveDataProvider(‘Users’);
$data = array();

foreach($dataProvider->getData() as $r)
{
$rowArray = array();

foreach($dataProvider->model->tableSchema->columns as $c) $rowArray[$c->name] = $r[$c->name];

$data[] = $rowArray;
}
[/code]

Columns names are read from table schema, so you don’t have to know table (model) structure to use this.

Missing colon in field’s labels

By default, Yii renders all forms with field’s labels not containing colon after label. This may be unwanted effect for some. The easiest way would be to change field’s label to contain that missing colon. But, that would produce an even more unwanted side-effect of having that colon included (as part of field label) in error message, when validation fails. Here is my simple workaround for this problem.

Read More “Missing colon in field’s labels”

Correcting code completion in NetBeans

General code completion in NetBeans works quite good (expect for its speed), but since NetBeans was made for Java and has only “added” support for PHP then it has some issues code completion for PHP and for coding in Yii framework it fails nearly completely.

Here you’ll find approach to fix this and make Yii developers using Netbeans life a little bit easier.

Read More “Correcting code completion in NetBeans”

An app-like full screen layout in CSS

Usually mobile applications have a header and a footer, both of a fixed height, and remaining body, that fills the rest and contains entire application content. No matter if main application content is long enough to produce vertical scrollbar or not, header and footer are always visible and always have fixed height.

A layout like this can be build in pure CSS and HTML. Thus it is useful for PhoneGap applications developers.

Read More “An app-like full screen layout in CSS”

Too long URLs in Apache

It turned out that in current version of Apache you’re limited to 255 characters at most between each pair od slashes (after URL decoding is done). This short article discusses this issue and maybe useful to all developers, who are dealing with “beauty” (SEO-optimized) URLs, like for example URLs to blog posts containing entire title inside.

This is a rare situation (255 characters limit between slashes, not for the entire URL), but still worth exploring.

Read More “Too long URLs in Apache”

Hot areas on your website

Today I have came across Piotr Konieczny’s presentation on Google SEO Hacking and I found page 60 out of it quite very interesting. It includes map of ho areas of your website, that is places, where your visitor’s eyes are placed at first and where they stays the longest period of time.

It is taken form Google and is made purely for SEO, but you can also use it to enhance design of your website, i.e. put the most important elements of your layout there, where they will be found fast and for sure.

Read More “Hot areas on your website”

Normalize.css. A modern alternative to CSS resets

Nearly every webdeveloper knows, what CSS reset is. Basically, this is a carefully crafted CSS file that makes browsers render all elements more consistently and in line with modern standards. In other words, they try to make your page look similar in all browsers. Today, I came across Normalize.css, a project by Nicolas Gallagher and Jonathan Neal, and wanted to share my thoughts.

Read More “Normalize.css. A modern alternative to CSS resets”

Scanning all incoming traffic. Proper use of tcpdump

I had to do some strange listening stuff with even more strange Chineese GPS locator, that was weird enough to use UDP protocol only. Since there was absolutely no technical guide for these devices (at least, when I was looking for them), I had to listen for everything on every port of my local server to see, what this damn box is actually sending.

Since I’m kind of Linux newbie, I asked this Unix & Linux question and got answer enough worth for me, that I decided to put some summary of them to my own blog.

Read More “Scanning all incoming traffic. Proper use of tcpdump”

Things for which I trully hate PHP and its creators

PHP is the most popular programming language for development of webpages and web services. With addition of a good framework it can even produce a professional results. However, this does not change the fact, that it is also the most shitty programming language in the world, full of garbage and with number of stupidities beyond imagination. And professional programming (without a good framework) is impossible.

Even though this is a language of my choice (only after cleaning it from all the shit, by using a good framework), I decided to write this article, where I’m pointing out most annoying and stupid things, I ever found in PHP.

Notice, that I’m not talking here about things that some may see as wrong, while other will see as good. For example, I’m not talking about types auto-declaration and auto-change, which ones (mostly newbies) takes as ease of coding and others (mostly profs) as source of mess.

I’m talking here only about pure madness, confirmed piece of shit and horrible pain in the ass, this language is.

Please, take also into consideration that this text was written under strong emotional influence and thus it (intentionally!) contains a lot of harsh language and words or phrases that some readers may not accept.

Read More “Things for which I trully hate PHP and its creators”

Get rid of Police-blocked computer or other type of ransomware

Your computer has been blocked by a police due to serious crimes you did and the only way to unblock it is to pay a ransom? Even a complete moron should understand that real police (or any other legal, law-oriented forces) has nothing to do with it. Here, you’ll find, why and most important — how to get rid of this problem, without loosing your data (in most cases).

Read More “Get rid of Police-blocked computer or other type of ransomware”

Some SQLite Rowid Issues

Rowid is a special, hidden column added to each SQLite database table (and to many more RDBMSes), which uniquely refer to a row. But, there are some things about rowid, that some people may not be aware of.

I know, that for some this could be a trivial. But it was not so obvious to me and since this is my blog, I can decide, what will be published here, right? :]

Read More “Some SQLite Rowid Issues”

screen: Force program to continue after logging-off from the console

So, there I was… needing to have any solution, that will allows me to write my very own port listener. Since the only language, in which I am handy is PHP, I was forced to be able to run PHP script without interruption, 24 hours a day, 7 days a week. That was a bit of challenge for me, given my quite very limited Linux knowledge, but — as they say — the only thing not possible in IT is to open an umbrella in your ass! :>

Read More “screen: Force program to continue after logging-off from the console”

Running Google Chrome in app mode [updated!]

If you have a web application, you can run it on any computer equipped with Google Chrome, in so called “app mode”. Chrome will display your page in a regular way, but will limit its own user interface to absolute minimum. If you’re web application has user interface somehow similar to Windows, you can even pretend, that this is not a web browser showing web page, but a regular Windows-based application.

Read More “Running Google Chrome in app mode [updated!]”

Remote access directly from your browser — SSH and RD in Chrome?

Well, I’ll be honest. I personally dislike (sometimes even hate) all these things, fireworks, plugins, tools and other kind of addings, people adds to their browsers. I can’t understand (or even imagine) where there is a fun to play a game or draw some pictures in browsers. It is even a bit irritiating, as Google gives us everything in their products and soon, we won’t be using anything else.

But, for Chrome extensions, I must admit, that I made an exception. Mainly because these exts I’m using (from time to time, let’s be honest) have actually nothing to do with the browsers and browsing the Internet. Each time I’m using them, I’m asking myself: is it still a simple webbrowser or does Chrome magically changed into a home or work command center, from which you can do nearly anything?

Read More “Remote access directly from your browser — SSH and RD in Chrome?”