Posts Tagged ‘tricks’

MySQL: Replacing URL Escape Sequences

By Augusto Bott September 26th, 2008 at 3:22 pm
Posted in MySQL
Tags:

So you want to store URLs in MySQL, and the URLs have those annoying %20%27%7C%26%5E%2B%2D%25 symbols? And you want to be able to show your users some kind of human-readable information. You might want to consider using this trick. Take this list of commonly escaped characters as an example:

%20 - space
%27 - '
%7C - |
%26 - &
%5E - ^
%2B - +
%2D - -
%25 - %

So, how about we do some search’n'replace on that?

mysql> SET @url:='%20%27%7C%26%5E%2B%2D%25';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @url as original,
    ->        REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
    ->        REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
    ->        @test,'%20',' '),
    ->        '%27','\''),
    ->        '%7C','|'),  -- REPLACE() is case sensitive
    ->        '%7c','|'),  -- so we have
    ->        '%26','&'),
    ->        '%5E','^'),
    ->        '%5e','^'),  -- to repeat
    ->        '%2D','-'),
    ->        '%2d','-'),  -- ourselves
    ->        '%2B','+'),
    ->        '%2b','+'),  -- sometimes
    ->        '%25','%') as replaced;
+--------------------------+----------+
| original                 | replaced |
+--------------------------+----------+
| %20%27%7C%26%5E%2B%2D%25 |  '|&^+-% |
+--------------------------+----------+
1 row in set (0.01 sec)

mysql>

We can easily turn this into a function: (more…)

MS Windows Vista Tips for Administrators

By Jan Polnicky July 23rd, 2008 at 1:00 pm
Posted in Not on HomepageSysAdmin
Tags:

I found myself, as a fresh member of The Pythian Group, losing precious moments just to change a few standard administrative settings on my new laptop with Microsoft Windows Vista. Having found the answers, I’m sharing them with you so that you can save some time, or spend it more pleasurably out in the summer.

User Account Control (UAC)

Too many prompts and confirmations for admin tasks? Set “Elevate without prompting” for “User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode” under Start -> Settings -> Control Panel -> Administrative Tools -> Local Security Policy -> Security Settings -> Local Policies -> Security Options. Ref: UAC on Wikipedia.

Windows Vista Features

By default, telnet is not installed with Windows Vista. To (re-)enable it, select the Telnet Client check box in Start -> Settings -> Control Panel -> Programs and Features -> “Turn Windows features on or off”. Then, Windows Features dialog -> Telnet Client. Now you may use telnet from the command prompt as you are used to in XP. Ref: FAQ on windowshelp.microsoft.com

(more…)