home

Quickies, by Andrea Olivato

text

Target #CSS to browser [ #IE fixes ]

How to target a single CSS instruction to IE and also to a single version of IE.

   
element {
   /* All Browsers */
   property: value; 
   /* IE 7 and below */
   *property: value;
   /* IE 6 and below */
   _property: value; 
   /* IE 6 only */
   _pr\operty: value; 
}

9 months ago

October 15, 2009
Comments (View)
text

Regex to change any BR in space in #PHP

This is a simple example showing how to change any <br> contained in an HTML string into a space, avoiding double spaces.

<?php
$string = 'Lorem <br>ipsum<br style="border:1px solid #CCC" />dolor<br /> sit<br style="height:1000px;">amet';

/* Stripping all other tags
 * [optional, depends on what you want to do 
 */
$string = strip_tags($string,'<br>');

/* Changing all <br> types into spaces */
$string = preg_replace('/<br[^>]*>/',' ',$string);

/* Avoiding double spaces */
$string = preg_replace('/[\ ]+/',' ',$string);

echo $string;

/* Will output: 'Lorem ipsum dolor sit amet' */

?>

9 months ago

October 14, 2009
Comments (View)
text

Optimize Tumblr title and meta tags #SEO

Simple way to improve SEO in tumblr blogs, by postponing general blog title to article titles in single post views, using the same title as meta description and putting tags as keywords.

<meta name="Description" CONTENT="{block:PostSummary}{PostSummary} - {/block:PostSummary}{Title}" />
<meta name="Keywords" content="{block:Tags}{Tag},{/block:Tags}" />
<title>{block:PostSummary}{PostSummary} - {/block:PostSummary}{Title}</title>

1 year ago

June 11, 2009
Comments (View)
text

Create html for imgs in a folder using filename as alt in bash

This scripts generates the html code for all the images in a folder. It will use the filename, without extension and with some mods, as Alt attribute for the image.

#!/bin/bash

PATH_WWW="/img";
EXT="jpg"

for i in *.$EXT; do
        fname=$(basename $i .jpg);
        fname=${fname/_/ };
        fname=${fname/-/ };
        fname=${fname/./ };
        echo "<img src="$PATH_WWW/$i" alt="$fname" />"; 
done 

1 year ago

June 9, 2009
Comments (View)
text

[PHP] How to retrive HTTP headers

codepuzzling:

Anyway response header returned by apache_response_headers() consists only of server signature in my case, but in firebug I can see a lot more of them.

$var = "REQUEST";
foreach (apache_request_headers() as $name => $value) {
    $var.= "$name: $value
"; } $var.= "RESPONSE"; foreach (apache_response_headers() as $name => $value) { $var.= "$name: $value
"; } echo $var;

1 year ago

June 5, 2009
reblogged via codepuzzling
Comments (View)