Tag Archive for hack

firefox 3.5 vertical scrollbar

/* firefox Browser*/
body { overflow-y: scroll; }

/* ie Browser*/
body { overflow:visible; }

source

wordpress – automatically create Greybox imageset from images attached to post

<!--Automatic Greybox-->
<?php
//Die zum Post gehoerenden Bilder ins Array $images schreiben
//Put images from post in to array $images. Order by menu order defined in post gallery
$images = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );

//Pruefen, ob dem Beitrag Bilder angehaengt wurden.
//check if there are any images attached to the post
if (isset($images))
{
//Den Zaehler auf 0 setzen
//set counter to 0
$count=0;
//Alle Bilder im Array $images nacheinander durchlaufen
//go through all images in array $images
foreach( $images as $image )
{
$imageID = $image->ID;
//fuer jedes Bild im Array die URL von sowohl der Mittleren, als auch der grossen Groesse ermitteln.
//get medium and large image url for image
$medImageSrc = wp_get_attachment_image_src($imageID, $size='medium', $icon = false);
$largeImageSrc = wp_get_attachment_image_src($imageID, $size='large', $icon = false);

//Wenn es sich um das erste Bild im Array handelt...
//If it's the first image in the array
if ($count==0)
{
//Den Greybox-Code mit einem Vorschaubild ausgeben
//output Greybox Code with medium size preview
echo"<a href='$largeImageSrc[0]' rel='shadowbox[Bilder]'><img src='$medImageSrc[0]' border='0'></a>";
}
//alle Bilder ,die nach dem erstern Bild kommen
//this is for all the images that come after the first one
else
{
//unsichtbare Greybox-Verknuepfung darstellen.
//create invisible Greybox-Links without preview image
echo"<a href='$largeImageSrc[0]' rel='shadowbox[Bilder]'></a>";
}
//Zaehler erhoehen.
//increase counter
$count++;

} //foreach
}

?>

<!--ENDE Automatic Greybox -->

source

WordPress – Get current category name and / or ID

<?php
//AKTUELLE Post-KATEGORIE-ID ermitteln
foreach((get_the_category()) as $category)
{
$postcat= $category->cat_ID;
$catname =$category->cat_name;
//echo $postcat;
}
?>

source

WordPress display content of a category on a page

<?php if (is_page('pagename')) { query_posts('cat=yx') } ?>

<!--or use query_posts like this:(full loop)-->

<?php
$displayposts = new WP_Query();
$displayposts->query('cat=5');
while ($displayposts->have_posts()) : $displayposts->the_post();
?>
<?php the_content('read more...'); ?>
<?php edit_post_link('edit', '', ''); ?>

<?php endwhile; ?>

source

Hacky screen clearing through printf

#include <stdio.h>

int main(){
printf(" 33[2J 33[0;0f");
printf(" 33[%d;%df", 0, 0);

return 0 ;
}

source

Fluid high-quality image scaling with CSS and JS

/*

<a href="http://unstoppablerobotninja.com/entry/fluid-images/" >http://unstoppablerobotninja.com/entry/fluid-images/</a>

var imgSizer = {
Config : {
imgCache : []
,spacer : "/path/to/your/spacer.gif"
}

,collate : function(aScope) {
var isOldIE = (document.all && !window.opera && !window.XDomainRequest) ? 1 : 0;
if (isOldIE && document.getElementsByTagName) {
var c = imgSizer;
var imgCache = c.Config.imgCache;

var images = (aScope && aScope.length) ? aScope : document.getElementsByTagName("img");
for (var i = 0; i < images.length; i++) {
images[i].origWidth = images[i].offsetWidth;
images[i].origHeight = images[i].offsetHeight;

imgCache.push(images[i]);
c.ieAlpha(images[i]);
images[i].style.width = "100%";
}

if (imgCache.length) {
c.resize(function() {
for (var i = 0; i < imgCache.length; i++) {
var ratio = (imgCache[i].offsetWidth / imgCache[i].origWidth);
imgCache[i].style.height = (imgCache[i].origHeight * ratio) + "px";
}
});
}
}
}

,ieAlpha : function(img) {
var c = imgSizer;
if (img.oldSrc) {
img.src = img.oldSrc;
}
var src = img.src;
img.style.width = img.offsetWidth + "px";
img.style.height = img.offsetHeight + "px";
img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
img.oldSrc = src;
img.src = c.Config.spacer;
}

// Ghettomodified version of Simon Willison's addLoadEvent() -- <a href="http://simonwillison.net/2004/May/26/addLoadEvent/" >http://simonwillison.net/2004/May/26/addLoadEvent/</a>
,resize : function(func) {
var oldonresize = window.onresize;
if (typeof window.onresize != 'function') {
window.onresize = func;
} else {
window.onresize = function() {
if (oldonresize) {
oldonresize();
}
func();
}
}
}
}

*/

img,
object {
max-width: 100%; /* Automatically scales height proportionally in FF, IE8, Safari >2 */
}

img { -ms-interpolation-mode: bicubic; } /* IE8 scaling of JPEG */

source

IE6 Only CSS. Also make IE6 use PNG backgrounds

#Logo{
Width: 100px;
Height: 100px;
Background-Image: URL("Logo.png");
Background-Repeat: No-Repeat;
/*---IE6 Only--*/
_Background-Image: URL("");
Filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='Logo.png', sizingMethod='scale');
/*-/-IE6 Only--*/
}

source

IE7 only star html hack

/* the following rules apply only to IE7 */ *+html .foo{ }

source

force word-wrap in IE

.wrapme
{
word-wrap: break-word;
}

source

Easiest way to make HAML use double quotes instead of single quotes

# On line 63 of haml-2.1.0/lib/haml/engine.rb, change

:attr_wrapper => "'",

# to

:attr_wrapper => """,

source