Dynamic image resizing in PHP
Friday, April 4th, 2008Via Darren Hoyt we found a reference to TimThumb, a quick and fast PHP script for on-the-fly image resizing. Once the script is on the server, and named timthumb.php, you can use the following reference to launch it:
<img src=”/scripts/timthumb.php?src=/images/whatever.jpg&h=150&w=150&zc=1″ alt=”" />
Here’s the source code for timthumb.php:
// TimThumb script created by Tim McDaniels and Darren Hoyt [...]
Spiraling quine in Perl
Wednesday, February 20th, 2008#!/usr/bin/perl
$_=’
$q ="\ 47"; wh
ile ($ ;=
$z += .5 ){
[...]
PHP imagefilter without GD
Thursday, March 15th, 2007Recursive quicksort
Thursday, March 1st, 2007#include<stdio.h>
#include<conio.h>
void qsort(int a[],int,int);
void partition(int a[],int,int,int *);
void print(int *,int);
void swap(int *,int *);
void main()
{
int a[30],i,n;
flushall();
clrscr();
printf(”
enter how many data u want :”);
scanf(”%d”,&n);
printf(”
enter the data :”);
for(i=0;i<n;i++)
{
printf(”
%d .”,i);
scanf(”%d”,&a[i]);
}
qsort(a,0,n-1);
printf(”
SORTED DATA:
“);
print(a,n-1);
getch();
}
void qsort(int a[],int lb,int ub)
{
int j;
if(ub>lb)
{
partition(a,lb,ub,&j);
[...]
Nice CSS tab menu with PHP
Thursday, March 1st, 2007<?php
if (isset($_REQUEST[’tab’])) {
$tab = $_REQUEST[’tab’];
} else {
$tab = 0;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Controling CSS Tabs Using PHP</title>
<style type=”text/css”>
/*Credits: Vijit Patil */
.tabZ{
padding: 3px 0;
margin-left: 0;
font: bold 12px Trebuchet MS ;
text-align: left;
border-bottom: 1px solid gray;
list-style-type: none;
}
.tabZ li{
display: [...]
A vertical menu done in CSS
Thursday, March 1st, 2007body{
background: #fff;
line-height: 1.1;
color: #666;
font: small Verdana, Geneva, Arial, Helvetica, sans-serif;
}
#Navigator {
width: auto;
background: #fcfcff ;
padding: 0 6px .5em 12px;
overflow: visible;
min-width:750px;
clear: both!important;
top:1em!important;
margin-bottom:1em!important;
}
.fixclear {
display:block;
position:relative
}
#NavData {
float:left;
clear: [...]
CSS message quoting
Thursday, March 1st, 2007<style type=”text/css”>
img
{
border: 0;
vertical-align: middle;
}
.quotetop
{
border-right: 1px dotted #000;
border-top: 1px dotted #000;
background: #DDDDDD url(’include/css_img_quote.gif’) no-repeat right 50%;
border-bottom: 0;
border-left: 4px solid #FF9900;
color: #000;
font-weight: bold;
font-size: 10px;
margin: 8px auto 0 auto;
[...]
Fading alerts in JavaScript
Thursday, February 15th, 2007<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”en” xml:lang=”en”>
<head>
<title>Fade In Text</title>
<style type=”text/css”>
body, table, div{color:#333;font:bold 11px Verdana, Arial, sans-serif;}
.title{background:#F2F2F2;border:1px #CCC solid;padding:5px;text-align:center;}
.tblFade{border:1px #333 solid;width:150px;margin:175px;}
.fadeElem{height:20px;display:block;position:relative;border:1px #CCC solid;padding:3px 10px;}
</style>
<script type=”text/javascript”>
<!–
var fadeSteps = 20;
var fadeDelay = 20;
var nextSetDelay = 1000;
var loopPrepend = true;
var arMessage = new Array(”Fade-In Message 1″, “Fade-In Message 2″, “Fade-In Message 3″, “Fade-In Message 4″, [...]
Find the square root of a number with any precision
Wednesday, February 14th, 2007function bcgetscale(){
return strlen(bcadd(1,0))-2;
}
//Version 0.2 of BCRoot
//By Chao XU
//From www.webdevlogs.com
//Change Log: It uses a lot bcsqrt() to make the speed fast
//fix a small decimal bug, where the last decimal could be wrong
function bcroot($a, $n, $scale=’default’){
$default = bcgetscale();//Get the scale
if($scale == ‘default’){
$scale = $default;//use [...]
Measuring the speed of MySQL replication
Saturday, May 27th, 2006#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use DBI;
use Time::HiRes qw/ usleep gettimeofday tv_interval/;
use English qw( -no_match_vars );
my $username1 = ‘user1′;
my $password1 = ‘user2′;
my $username2 = ‘pass1′;
my $password2 = ‘pass2′;
my $host1 = ‘host_IP1′;
my $host2 = ‘host_IP2′;
my $port1 = ‘3306′;
my $port2 = ‘3306′;
my $dbh1=DBI->connect(”dbi:mysql:test;host=$host1;port=$port1″,
$username1, $password1,
{RaiseError => 1})
or die “Can’t connect: $DBI::errstr\n”;
my $dbh2=DBI->connect(”dbi:mysql:test;host=$host2;port=$port2″,
$username2, $password2,
{RaiseError => 1})
or die “Can’t connect: $DBI::errstr\n”;
my $loops [...]