Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

echo

slow query extract
Saturday, 22 October 2011 01:46
// A cron to send extract of slow query log of 3 different servers by mail every day. Change the email address. It is assumed that the keys are saved to login to different servers.



35 23 * * * (ssh 192.29.0.214 mysqldumpslow /var/log/mysql/mysql-slow.log | head -200; echo "#########################"; echo "Slow query log from 121"; echo "#########################"; ssh 192.29.0.121 mysqldumpslow /var/log/mysql/mysql-slow.log | head -200; echo "#########################"; echo "Slow query log from 213"; echo "#########################"; ssh 192.29.0.213 mysqldumpslow /var/log/mysql/mysql-slow.log | head -200 ) | mailx -s "My City slow query log from 214, 121 and 213" shantanu.oak+ This e-mail address is being protected from spambots. You need JavaScript enabled to view it > /root/shantanu/dumpslowsuccess.txt 2> /root/shantanu/dumpslowerror.txt

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/spFGvdkoJ0c/13781

 
Kill tomcat by spec dir
Friday, 23 September 2011 05:40
//Kill tomcat by spec dir


#!/bin/sh
#kill tomcat pid
pidlist=`ps -ef|grep tomcat_foobar/conf | grep -v "grep"|awk '{print $2}'`
echo "tomcat Id list :$pidlist"
if [ "$pidlist" = "" ]
then
echo "no tomcat pid alive"
else
for pid in ${pidlist}
{
kill -9 $pid
echo "KILL $pid:"
echo "service stop success"
}
fi

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/unCiY-6SKRg/13641

 
Variable-length argument list in PHP
Tuesday, 23 August 2011 08:14
See the document for
func_num_args(), func_get_arg(), and func_get_args(). Auto Insurance | Auto insurance agencies closng in atlanta | nova scotia auto insurance quote | autoinsurance.apparels24.com


function foo()
{
$numargs = func_num_args();
echo "Number of arguments: $numargs
\n";
if ($numargs >= 2) {
echo "Second argument is: " . func_get_arg(1) . "
\n";
}
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
echo "Argument $i is: " . $arg_list[$i] . "
\n";
}
}

foo(1, 2, 3);
Car Insurance Rates - Get Free Auto Insurance Quotes Online | Auto insurance in sioux falls

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/YmymMkRq2zc/13581

 
FOR loop in windows commanline
Thursday, 04 August 2011 11:04
// description of your code here


FOR /L %G in (1,1,100) DO ECHO %G
FOR /R C:\temp\ %G IN (*.bak) DO del %G

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/yJx_HPnsEhI/13461

 
PHP Tip: Encode &amp; Decode Data URLs
Wednesday, 16 March 2011 16:30

Converting small images to data-URLs is a great way to eliminate HTTP requests and decrease loading time for your pages. Using PHP‘s base64_encode() and base64_decode() functions, we have the power to convert images to data-URLs and vice-versa.

Decoding Data URL Images

So we start with a small image named, say, “feed-icon.gif”:

[ RSS Feed Icon ]

We then convert to data-URL format by encoding with base64_encode()1:

<?php echo base64_encode(file_get_contents("feed-icon.gif")); ?>

This will output the image as a string of base64-encoded gibberish, which I will not utter here. It begins and ends with these characters:

R0lGODlhEAAQAPcAAP+JAP+LAP+vWf ... ceZECFAtPbhAkijCBVUAAOw==

And just keeps going for about 4KB-worth of code, which is actually larger than the original image. But that’s okay because saving an extra HTTP request is better for performance than a few extra kilobytes of code. Now that we’ve encoded the image, we can display it in our web pages like so:

<img src="data:image/gif;base64,<?php echo base64_encode(file_get_contents("feed-icon.gif")); ?>">

Or display in our dynamic CSS.php file:

background: url("data:image/gif;base64,<?php echo base64_encode(file_get_contents("feed-icon.gif")); ?>");

1 That’s sort of a “quick-n-dirty” technique but it works. Here is another encoding method using fopen() instead of file_get_contents():

<?php // convert image to dataURL
$img_source = "feed-icon.gif"; // image path/name
$img_binary = fread(fopen($img_source, "r"), filesize($img_source));
$img_string = base64_encode($img_binary);
?>

Then to display in your web page, use something like this:

<img src="data:image/gif;base64,<?php echo $img_string; ?>">

Decoding Data URL Images

The easiest way to decode a base64-encoded image is to just do a “Save as…” somewhere on your machine. Of course, you can also use PHP’s base64_decode function to convert encoded gibberish back into original shape. This works great for text content, but for images we need to include the proper header when displaying as web content:

<?php header("Content-type: image/gif");
echo base64_decode($img_string); ?>

© 2011 Perishable Press

Read more: http://perishablepress.com/php-encode-decode-data-urls/

 


Taxonomy by Zaragoza Online