Moving to github pages!

My new homepage will be http://ocramius.github.com

Please visit me there!

I’ve also posted why I moved to Github Pages

I will keep this domain for my experiments, but anything dynamic will probably be built on Github pages and connected to this site via JSONP or generally REST APIs icon smile Moving to github pages!

Posted in github, Programming | Leave a comment

PHP Security Exploit: MySQL as a Backdoor with Load Data Local Infile

Yesterday I stumbled on a piece of code shown me by my friend Andrea Guglielmo.

It is an exploit that could affect mostly shared hosting solutions, and which I’ve never seen before, even if it has not been invented recently.

Continue reading

Posted in 5.3, DBA, Development, Exploits, IT, MySQL, PHP, Programming | Tagged , , , , , | 2 Comments

LessPHP Minify Integration for faster LessCSS development

Today I’ve been working on some addition to the Minify Project to support LESS CSS integration throug LessPHP.

Why do I need LESS CSS?

As you probably have noticed, your CSS files are becoming huge, especially when working on great projects, avoiding sprites, adding gradients, box-shadows, animations, keyframes, etc:

That’s where LESS CSS comes into play.
LESS CSS is just another way of writing CSS, not that repetitive and “LESS” confusing in big projects.

Continue reading

Posted in CSS, Design, Development, IT, LESS CSS, PHP, Startup Projects | Tagged , , , | 35 Comments

Google Releases new Webmaster Tools Features!

As you probably noticed yesterday, Google released some very interesting and new features for his very useful Webmaster Tools utility…
Before the change, to view variations in the Search Queries Webmaster Tools and evaluate your result in SERPs, you had to work it out with the fantastic, but not so much user friendly Webmaster Tools API. Not that useful if you’re not a Geek, a Zend_GData or a Java/Java Web developer…
You now just have to click on the “Your site on the web” > “Search Queries” tab in your browser…
Here’s the result:

google new search engine results positioning optimization features 1024x967 Google Releases new Webmaster Tools Features!

Google makes SEO easier with some new features added to Webmaster Tools!

As you can see, we now have 9 sorting features instead of 5 icon smile Google Releases new Webmaster Tools Features!
Very useful to see if you’re doing SEO the right way (just sort your results by their Average Position in SERPs), or if the period for a search term is not the right one (to be compared with Google Insights).
You can take a look at the impressions count change, to see if you can get some more visitors from Search Engines for a certain Keyword on which you should focus on because it is trending right now. Otherwise you can just leave the SEO work you’re doing on some key words because it is no more a trend!
This is surely going to change the way SEO experts works on positioning optimization (don’t tell me it’s not an affidable tool… It works great, also if displayed values are only relative! Everyone out there who’s not a developer should find these features vital for their success in SEO!)
That’s not all, we’ve not finished yet!
There’s more for web developers! icon smile Google Releases new Webmaster Tools Features!
You probably didn’t notice it, but if you take a look at the “Site configuration” > “Settings” > “Parameter handling” tab in your Webmaster Tools, then you’ll notice that you can now decide what parameters google should use for your urls containing GET parameters! Great, I’ll no more get duplicate content from wrong in-site-search results being crawled by Google!
That’s very useful for developers too lazy to implement the Canonical meta-tag for their websites ^_^
If you want to discover more, you can find out great news on the Google Official Webmaster Central Blog

Good luck and have fun!

Posted in Google, Search Engines, SEO | Tagged , , , , , | 5 Comments

MySQL Custom Sorting Rules

Today I was facing troubles with the administrative dept of the web agency where I’m working in… They wanted to have their receiptive structures sorted by a custom role…

What I first thought about was a MySQL Union query where I had to fetch all distinct types of receiptive structures (Hotels, B&Bs, Campings, etc…) in the desired order in different parametrized queries… Something like the following:

(
  SELECT
    1 as sorting_column,
    *
  FROM receiptive_structures
  WHERE type_id=4
) AS a
UNION ALL
(
  SELECT
    2 as sorting_column,
    *
  FROM receiptive_structures
  WHERE type_id=2
) AS b
UNION ALL
(
  SELECT
    3 as sorting_column,
    *
  FROM receiptive_structures
  WHERE type_id=7
) AS c
UNION ALL
(
  SELECT
    4 as sorting_column,
    *
  FROM receiptive_structures
  WHERE type_id=1
) AS d
ORDER BY sorting_column ASC

Althrough the ‘sorting_column’ shouldn’t be necessary, I had too many bad experiences with mysql and its sorting features (expecially when merging together resultsets, like in this case).

Nasty solution…
I decided to continue looking for a more elegant way of doing this…

I decided to use some kind of on-the-fly generated function in the ORDER BY clause of my MySQL Custom Sorting Query:

SELECT
((type_id=4)*1
+(type_id=2)*2
+(type_id=7)*3
+(type_id=1)*4) AS sorting_column,
r.*
FROM receiptive_structures AS r
ORDER BY sorting_column ASC

Still looks ugly…
Digging into the MySQL manual, found out that there’s a faster way of doing that!

SELECT * FROM receiptive_structures
ORDER BY FIELD(priority, 4,2,7,1);

And here’s a quick overview of the MySQL FIELD() “weight” function icon smile MySQL Custom Sorting Rules

Database changed
mysql> select id, FIELD(id,4,2,7,1) AS sorting
    -> FROM l10n ORDER BY sorting DESC limit 5;
+----+---------+
| id | sorting |
+----+---------+
|  1 |       4 |
|  7 |       3 |
|  2 |       2 |
|  4 |       1 |
|  3 |       0 |
+----+---------+
5 rows in set (0.00 sec)

I hope this will be useful for you icon smile MySQL Custom Sorting Rules

Posted in DBA, Development, IT, MySQL, Tricks | Tagged , , , , , | 1 Comment

Starting a new website with WP…

Hello there, and welcome to my first post!

This website will be my toolbox containing tools, tips and tricks about web development, my story and all the troubles of a web developer who starts becoming a very angry developer…..

I’m really sorry to present it as a WordPress blog, but I didn’t have any time to work on a new application written in J2EE or Zend Framework… Continue reading

Posted in IT, Startup Projects | Tagged , , , , | 5 Comments