$content = preg_replace('/protected \$classes = array *\(.*?\)/s', 'protected $classes = '.var_export($classes, true), file_get_contents(__FILE__));
file_put_contents(__FILE__, $content);
2/21/2011
php modify self content
http://trac.symfony-project.org/browser/branches/1.2/lib/autoload/sfCoreAutoload.class.php#L122
2/20/2011
Command-line CSS spriting / Stoyan's phpied.com
Command-line CSS spriting / Stoyan's phpied.com
CSS Sprites generation tool / Stoyan's phpied.com
What?
So the imagemagick command is generally something like:
$ convert image1.png image2.png image3.png -append result/result-sprite.png
But we can also replace the list of images with *s:
$ convert * -append result-sprite.png
Or as in the previous case, limiting to *.gif and *.png.
How about a horizontal sprite? All it takes is changing -append to +append:
$ convert *png *gif +append result/result-sprite-horizon.png
The result:
Also note how the source images can be any format - GIF, PNG, JPEG and the result is PNG. Actually I'd recommend always trying PNG8 first:
$ convert *png *gif -append PNG8:result/result-sprite-horizon.png
CSS positions
Imagemagick to the rescue. `identify` gives you the basic image info:
$ identify 1.png
1.png PNG 16x16 16x16+0+0 DirectClass 8-bit 260b
`identify` also has a `-format` option and supports *. So getting all the info in a neat form is easy:
$ identify -format "%g - %f\n" *
16x16+0+0 - 1.png
16x16+0+0 - 2.gif
6x6+0+0 - dot.png
10x16+0+0 - phoney.gif
16x16+0+0 - tw.gif
%f is filename and %g is geometry.
\n is a new line as you would expect and sometimes - is just a -.
So if you want to figure out the Y position of the fifth element, well, it's the sum of the heights of the previous: 16+16+6+16
.last {
width: 16px;
height: 16px;
background: url(result-sprite.png) 0 -54px
}
Some complicated math! 'scuse me while I ask my second grader if she can handle it
And some smushing
Or how about.... smush.it on the command line:
$ curl http://www.smushit.com/ysmush.it/ws.php
?img=http://www.phpied.com/files/sprt/result/result-sprite.png
Result is JSON:
{"src":"http:\/\/www.phpied.com\/files\/sprt\/result\/result-sprite.png",
"src_size":1759,
"dest":"http:\/\/smushit.zenfs.com\/results\/5a737623\/smush\/%2Ffiles%2Fsprt%2Fresult%2Fresult-sprite.png",
"dest_size":1052,
"percent":"40.19",
"id":""}
Oh looky, almost half the filesize. Let me at it! Copy the `dest` URL:
$ curl http:\/\/smushit.zenfs.com\/results\/5a737623\/
smush\/%2Ffiles%2Fsprt%2Fresult%2Fresult-sprite.png > result/smushed-sprite.png
CSS Sprites generation tool / Stoyan's phpied.com
$cmd = 'convert ' . implode(' ', $coord)
. ' -background none -mosaic -bordercolor none -border '
. $half . 'x' . $half
. ' ' . $output_dir . '/result.' . $this->output_format;
system($cmd, $ret);
return $ret === 0;
2/13/2011
Internet Explorer User Agent Style Sheets
Internet Explorer User Agent Style Sheets
Standalone sandboxed IE6, IE7, IE8 executables (Recovered after a takedown)
Utilu IE Collection
A UA Style Sheet is a simple set of css styles that each web browser uses before any other css styles are applied.
This chart lists and compares the different default style sheets used to render HTML in the four major versions of Internet Explorer; IE6, IE7, IE8, and IE9 Platform Preview.
Standalone sandboxed IE6, IE7, IE8 executables (Recovered after a takedown)
Utilu IE Collection
There is another package called "Utilu IE Collection"[1] which I have found more stable than Spoon.net versions. You can even install IE 1.0
2/12/2011
Bookmark Backup - Pike's Mozilla Firefox Extensions
Bookmark Backup
Automatically export bookmarks from Firefox
tag: firefox bookmark dropbox
Version 0.4.11
Install
Install Bookmark Backup 0.4.11
Description
Bookmark Backup is a simple extension that helps to keep your bookmarks (and optionally other Firefox settings) safe. Each time Firefox is closed, a copy of your bookmarks file will be made to a backup location. If Firefox's bookmarks become corrupted or lost, find the most recent uncorrupted backup and copy it into your profile folder. By default the backups can be found in the Backups folder inside Firefox's profile folder, though this location can be changed in Bookmark Backup's Options dialog.
Additionally, thanks to code contributed by Nickolay Ponomarev, other files may also be backed up along with the bookmarks file. You can specify which files to backup in the Options dialog. Just check the box for each type of setting you want backed up, any other files can be listed in the following text box separated by a | character. Please refer to the MozillaZine Knowledge Base for details about what data is stored in each file.
Please remember, this extension should be used in addition to a regular profile backup not as a replacement.
Automatically export bookmarks from Firefox
Compared to Firefox 2, Firefox 3 uses a new manager for bookmarks. Bookmarks are no more stored in the bookmarks.html file (in the directory of your Firefox profile), but in a SQLite database (places.sqlite).
If the performance is much better, you can not read this file directly (eg in another browser).
However, you can automatically export bookmarks to bookmarks.html from Firefox 3. Here's how:
* In the address bar of Firefox 3, type: about:config
* A warning will appear: Click "I will be careful, I promise!"
* In "Filter", type autoexport, then double-click the "browser.bookmarks.autoExportHTML" to pass the value to true.
* Firefox now automatically export your bookmarks in the files bookmarks.html
(Just look for the file bookmarks.html in C: Documents and Settings ....)
tag: firefox bookmark dropbox