#!/bin/bash while [ true ] do echo "quering bearerbox" sleep 1 count=$(ps -C "bearerbox" | wc -l) echo $count if [ $count -eq 2 ] then echo "attempting to kill bearerbox" killall bearerbox else sleep 1 echo "======= bearerbox killed ========" break fi done sleep 1 bearerbox /etc/kannel/kannel.conf smsfox /etc/kannel/kannel.conf
Internet is vague. It has nothing left to be covered now. However, things get messed up sometimes and I forgot where I used to find the materials I had just searched for some days ago. So, I am now gathering all those into this blog. This is just my bookmark or my scrapbook or anything you wish to say. If you think these are helpful, you can take references, no any rights to be defined here. No styles and no colorful designs, just an area to jot down some scraps and all. Enjoy
Pages
Wednesday, June 23, 2010
Kannel restart script | Attempting to Kill a process in linux until it gets killed
Altering system default timezone in linux
http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/
Change Linux timezone
Select the method as per your Linux distribution:If you are using Fedora / RHEL / Cent OS Linux
Type the redhat-config-date command at the command line to start the time and date properties tool.# redhat-config-dateOR type setup and select time zone configuration (good for remote ssh text based Linux server sessiob)
# setupSelect timezone configuration
Now, just follow on screen instructions to change timezone.
Set timezone using /etc/localtime configuration file [any Linux distro]
Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory.Generic procedure to change timezone
Change directory to /etc# cd /etcCreate a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtimeOR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)
# ln -sf /usr/share/zoneinfo/EST localtimeOR if you want to set up it to IST (Asia/Calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtimePlease mote that in above example you need to use directory structure i.e. if you want to set the timezone to Calcutta (India) which is located in the Asia directory you will then have to setup using as above.
Use date command to verify that your timezone is changed:
$ dateOutput:
Tue Aug 27 14:46:08 EST 2006
Use of environment variable
You can use TZ environment variable to display date and time according to your timezone:$ export TZ=America/Los_Angeles
$ date
Sample Output:
Thu Aug 27 11:10:08 PST 2006
Tuesday, February 16, 2010
runlevels in redhat
ntsysv --level
eg. ntsysv --level 016 edits runlevels 0, 1, and 5
Sunday, August 16, 2009
not in the database
select "node/1" as src
union select "node/2" as src
union select "node/3" as src
) temp where src not in (select src from drupal_url_alias)
Saturday, July 11, 2009
checking the distro name in linux
or
$ cat /etc/*-version
Wednesday, May 6, 2009
low level formatting in linux
Source: http://tldp.org/LDP/LGNET/issue37/tag/38.html
dd if=/dev/zero of=/dev/hda
... to wipe out the whole first IDE drive, or
dd if=/dev/zero of=/dev/sda
... to wipe out the whole first SCSI drive.
Actually you could just blow away one sector on these drives using
dd if=/dev/zero of=/dev/sda count=1
It wouldn't make sense to do this to other drives (/dev/hdb, /dev/hdc, /dev/sdb, etc) since their boot sectors aren't referenced as code and you can reformat those drives with normal DOS or Linux commands to re-make your filesystems on them. However, you can issue this command for all of your drives if you like. In fact you should be able to do something like:
for i in a b c d; do
dd if=/dev/zero of=/dev/hd$i
done
... to get four IDE drives or
for i in a b c d e f g ; do
dd if=/dev/zero of=/dev/hd$i
done
... to wipe out all seven disks on a SCSI chain.
Friday, January 23, 2009
Sound in MSI VR 420 Laptop
dmesg produced this error
hda_codec: Unknown model for ALC883, trying auto-probe from BIOS..
... ... ...
lots of headaches
... ... ....
And finally,
This was how I made it working.
modprobe -r snd_hda_intel
modprobe snd_hda_intel model=3stack-dig
And it worked.
The first thing I played was
http://www.meronepalma.com/song/425
Sunday, March 9, 2008
Error:1235- This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
SELECT
COUNT(*)
FROM
TABLE_1
WHERE
ROW (PK_PART_1, PK_PART_2) IN
(
SELECT
PK_PART_1, PK_PART_2
FROM
TABLE_2
LIMIT
10 -- This is the basis of the whole idea
)
AND
Whatever;
The above fails with the warning ...
ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
However, you can get the desired behaviour with a slight rewrite...
SELECT
COUNT(*)
FROM
TABLE_1
INNER JOIN
(
SELECT
PK_PART_1, PK_PART_2
FROM
TABLE_2
LIMIT
10 -- HEY HEY!
) AS VIRTUAL_TABLE_2
ON
TABLE_1.PK_PART_1 = TABLE_2.PK_PART_1 AND
TABLE_1.PK_PART_2 = TABLE_2.PK_PART_2
WHERE
Whatever;
And it works like a charm!
Sunday, March 2, 2008
Swap in Linux
So what I did was,
- checked the swap partition first
- added the entry in /etc/fstab file as
- /dev/sda3 none swap sw 0 0
- sudo swapon -a
- checked by using cat /proc/swaps and it was found the following
- /dev/sda3 partition 1052248 423616 -1
Thursday, January 3, 2008
965 Boards sound configuration in linux
#!/bin/sh
wget -c http://archive.ubuntu.com/ubuntu/pool/main/l/linux-backports-modules-2.6.22/linux-backports-modules-2.6.22-14-generic_2.6.22-14.10_i386.deb
wget -c http://archive.ubuntu.com/ubuntu/pool/main/l/linux-meta/linux-backports-modules-generic_2.6.22.14.21_i386.deb
Saturday, December 22, 2007
PHP: Dynamic Image Generation
| PHP: Dynamic Image Generation | | |
| Creating images on the fly can be a very useful skill. PHP has some built-in image generation functions, further more, to generate new images or edit existing images on the fly using PHP, we need to have the GD library installed. In this tutorial we will show you how to get quite interesting and useful effects using image handling functions. We will review two practical tasks: creating security images (captcha) on the fly and building a bar chart using numerical values retrieved from MySQL database.
Creating security images on the fly At first, have a look at the following script that creates captcha image. Next, we will consider each step of image generation in details. //Send a generated image to the browser create_image(); exit(); function create_image() { //Let's generate a totally random string using md5 $md5 = md5(rand(0,999)); //We don't need a 32 character long string so we trim it down to 5 $pass = substr($md5, 10, 5); //Set the image width and height $width = 100; $height = 20; //Create the image resource $image = ImageCreate($width, $height); //We are making three colors, white, black and gray $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $grey = ImageColorAllocate($image, 204, 204, 204); //Make the background black ImageFill($image, 0, 0, $black); //Add randomly generated string in white to the image ImageString($image, 3, 30, 3, $pass, $white); //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image,0,0,$width-1,$height-1,$grey); imageline($image, 0, $height/2, $width, $height/2, $grey); imageline($image, $width/2, 0, $width/2, $height, $grey); //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); } ?> To create a new image or edit an existing one, we need to create image identifier. In the preceding example we created an empty canvas by calling ImageCreate() function, passing it width and height of a new image as a parameters. Another way to do it is to read the existing image from the file. Depending on the file format you can do it using one of the following functions: ImageCreateFromPNG(), ImageCreateFromGIF(), ImageCreateFromJPEG(). Parameter of each function is a file name. Then, we need to choose colors to be used while painting. For this we can use ImageColorAllocate() function and image identifiers for red, green, and blue (RGB) components of necessary color will be passed as parameters. On the next step, we will generate our image. First, using ImageFill() function we will create black background. Parameters of this function are: image identifier, initial coordinates of the area to be filled and fill color. Then, we will use ImageString() function to add text to the image. Its parameters are – image identifier, font, coordinates for the first text position and text color. Finally, we will draw two lines and a rectangular to protect our image a little bit. Please note, that the final point of the rectangular has the following coordinates: $width-1 and $height-1. If they were equal to $width and $height, than the rectangular would have exceeded canvas frame. When we had created the image, we can output it either to a browser, or to a file. Our example shows how to output it to the browser. We need to inform the browser, that we will output the image, not the text or html-code. To do it, call Header() function, setting image MIME-type. It’s worth mentioning that Header() function can not be executed if HTTP header has already been sent. After sending the header we can output our image using ImageJpeg() function, passing it image identifier as a parameter. When we have finished working with the image we need to free up resources using ImageDestroy() function. In the example below, using graphic functions we will build a bar chart based on the values stored in MySQL database. In our case, values represent poll results. In this example we will use poll database. To create it run the following SQL script in your MySQL server: CREATE DATABASE `poll`; USE poll; CREATE TABLE `results` ( book_type VARCHAR(50), num_votes INT ); INSERT INTO `results` values ('Classic', 15), ('Fantasy', 7), ('Humor', 32), ('Mystery', 12), ('Poetry', 25); Script building a bar chart is quite long, so let's divide it into two parts and discuss them separately. The first part of the script connects to MySQL database and requests data that will be represented in the bar chart. //Querying the database to get poll results //connection to the database $dbhandle = mysql_connect("localhost", "root", "") or die("Unable to connect to MySQL"); //select a database to work with $selected = mysql_select_db("poll",$dbhandle) or die("Could not select examples"); //execute the SQL query and return records $result = mysql_query("SELECT * FROM results"); $num_poller = mysql_num_rows($result); $total_votes = 0; //fetch the data from the database while ($row = mysql_fetch_array($result)) { $total_votes += $row{'num_votes'}; //calculating total number of votes } //nulling the pointer $result mysql_data_seek($result,0); //close the connection mysql_close($dbhandle); In the second part of the script first of all we will calculate variables needed to build the chart. Then, we prepare primary image and actually output data. Results for each genre are picked from the database one by one, percentage of votes is calculated, and then bars and explanatory notes are outputted. In this script we are using TrueType fonts to get anti-aliased text. Functions that work with the TrueType fonts have its own peculiarities. First, you need to point where the fonts are located. For this, system variable GDFONTPATH is set. Then, we need to set the font name. TrueType fonts are rendered using ImageTTFText(). We have already discussed above all functions used for drawing, the code has been commented and is quite clear, so you shouldn’t have any trouble. //Tell gd2, where your fonts reside putenv('GDFONTPATH=C:\WINDOWS\Fonts'); $font = 'arial'; //Set starting point for drawing $y = 50; //Specify constant values $width = 700; //Image width in pixels $bar_height = 20; //Bars height $height = $num_poller * $bar_height * 1.5 + 70; //Calculating image height $bar_unit = ($width - 400) / 100; //Distance on the bar chart standing for 1 unit //Create the image resource $image = ImageCreate($width, $height); //We are making four colors, white, black, blue and red $white = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); $red = ImageColorAllocate($image, 255, 0, 0); $blue = imagecolorallocate($image,0,0,255); //Create image background ImageFill($image,$width,$height,$white); //Draw background shape ImageRectangle($image, 0, 0, $width-1, $height-1, $black); //Output header ImageTTFText($image, 16, 0, $width/3 + 50, $y - 20, $black, $font, 'Poll Results'); while ($row = mysql_fetch_object($result)) { if ($total_votes > 0) $percent = intval(round(($row->num_votes/$total_votes)*100)); else $percent = 0; //Output header for a particular value ImageTTFText($image,12,0,10, $y+($bar_height/2), $black, $font, $row->book_type); //Output percentage for a particular value ImageTTFText($image, 12, 0, 170, $y + ($bar_height/2),$red,$font,$percent.'%'); $bar_length = $percent * $bar_unit; //Draw a shape that corresponds to 100% ImageRectangle($image, $bar_length+221, $y-2, (220+(100*$bar_unit)), $y+$bar_height, $black); //Output a bar for a particular value ImageFilledRectangle($image,220,$y-2,220+$bar_length, $y+$bar_height, $blue); //Output the number of votes ImageTTFText($image, 12, 0, 250+100*$bar_unit, $y+($bar_height/2), $black, $font, $row->num_votes.' votes cast.'); //Going down to the next bar $y = $y + ($bar_height * 1.5); } //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); ?> Using dynamically generated images on the other pages Since the header can be sent only once and it is the only way to tell the browser that you are going to send image, it is not so easy to insert automatically generated images to the regular pages. There are three ways to do it:
Related Articles |
Tags: DYNAMIC IMAGE GENERATION GD CAPTCHA GRAPH STORE CACHE
Add To: dzone |
digg |
del.icio.us |
stumbleupon
- Comments (16)
- Blog It
Becoz the functions here referred is not identified in my PHP. So pls help to Configure it in WAMP 1.4 . Pls any body know it,pls mail me with details,
Thanks alot ....
Use the latest stable version.
To Make Charts, However, I Use The PHP/SWF Charts Found Here: http://www.maani.us/charts/index.php. I Try To Add In One Or Two Of Those Into Every Backend I Create. It Really Makes The Admin Go, "Wow!" Every Time.
when i run this program,
i got an error
Warning: imagettftext() [function.imagettftext]: Could not find/open font
how to find it in my php.ini file
im using WAMP5 1.6.6 version.
i went to php.ini file and uncommented php_gd2.dll to enable gd
and also commented to generate images dynamically.
;tidy.clean_output = Off
this tutorial is very useful for me.
I am stuck on this problem - I need to know how to deal with this issue - what I am trying to do is modify the original image's size and location, while keeping it's physical size. For example, a 200X200 image of a cat will be resized by $percent, BUT be imagecopyresampled() into an image of the same size as the original, or 200X200. This is necessary for my project. So, my problem is that, when imagecopyresampled() at 98%, the image actually looks like it is resampled at 102%. Can someone please tell me what I've done wrong?
Thank you!
if (isset($_GET['image'])) {
move_save_image($_GET['image'], $_GET['x'], $_GET['y'], $_GET['percent']);
}
else {
echo "Could not load image";
}
function move_save_image($image, $x=0, $y=0, $percent=100) {
$image_withpath = "../dynproducts/dynimages/" .$image;
if (file_exists($image_withpath)) {
header('content-type: image/jpeg');
$modified = imagecreatefromjpeg($image_withpath);
$modified_size = getimagesize($image_withpath);
$width = $percent / 100 * $modified_size[0];
$height = $percent / 100 * $modified_size[1];
$visible_image = imagecreatetruecolor($width, $height);
$dest_x = $x;
$dest_y = $y;
$dest_a = $x * -1;
$dest_b = $y * -1;
imagecopyresampled($visible_image, $modified, 0, 0, $dest_a, $dest_b, $modified_size[0],$modified_size[1], $width, $height);
imagejpeg($visible_image, '', 80);
imagedestroy($visible_image);
imagedestroy($modified);
}
else {
echo "File does not exist.";
}
}
you php notes very useful and easy to understanding.please send quiz program using php
can i use different color for each Strip?
and how i can create image for vertical graph
thx
thank you
Thursday, December 20, 2007
Flip the text using unicode
Sunday, December 16, 2007
Partitioning by script
A reader requested a demonstration of automatic partitioning. The task was to create partitions of fixed size and allow the last partition to consume remaining space. Since the calculations used in this exercise are revelatory of partitioning issues, the first version of the script is included below, in the hopes that it might be of use. This section will be expanded in Version 4 of this HOWTO.
#!/bin/sh
partitionSizes=( 1000000000 256000000 NA ) ; # size in bytes, NA=unspecified
partitionTypes=( 83 82 83 ) ; # see available types: sfdisk -T
partitionFlags=( bootable NA NA )
blockSize=1024
start=1
#---------------------------------------------------------------#
# Do not modify contents below this line
#---------------------------------------------------------------#
function GetGeometry ()
{
numberOfBlocks=`sfdisk -s $1` || exit 1
bytes=$(($numberOfBlocks * 1024))
geometry=(`sfdisk -g $1`) || exit 1
cylinders=${geometry[1]}
heads=${geometry[3]}
sectors=${geometry[5]}
cylinderSize=`echo "scale=4; $numberOfBlocks / $cylinders" | bc` || exit 1
}
function WritePartitionInfo
{
let partitionNumber=$index+1
partitionFlag=${partitionFlags[$index]}
[ $partitionFlag != NA ] || partitionFlag=
partitionType=${partitionTypes[$index]}
[ $partitionType != NA ] || partitionType=
if [ ${partitionSizes[$index]} = "NA" ]
then
cylindersNeeded=
else
cylindersNeeded=`echo "${partitionSizes[$index]} / ( $cylinderSize * $blockSize )" | bc`
fi
echo "${1}$partitionNumber : start= $start, size= $cylindersNeeded, Id= $partitionType, $partitionFlag"
echo "${1}$partitionNumber : start= $start, size= $cylindersNeeded, Id= $partitionType, $partitionFlag" >> $outputFile
[ -z "$start" ] && start=0
[ -z "$cylindersNeeded" ] && cylindersNeeded=0
start=`echo "scale=4; $start + $cylindersNeeded + 1" | bc` || exit 1
}
# ---------------------------------------------------------------------- #
# ------------------------ MAIN ------------------------------ #
# ---------------------------------------------------------------------- #
[ $# -eq 1 ] || { echo "usage: auto_partition.sh device (e.g. /dev/hda)"; exit 1;}
[ -b $1 ] || { echo "$1 not a block device"; exit 1;}
outputFile=${1#/dev/}_proposed
GetGeometry $1
echo "bytes: $bytes"
echo "blocks: $numberOfBlocks"
echo "cylinders: $cylinders"
echo "heads: $heads"
echo "sectors: $sectors"
#echo "unit: cylinders" > $outputFile
> $outputFile
for index in `jot ${#partitionSizes[@]} 0`
do
WritePartitionInfo
done
# This is it! Write the partition table
sfdisk /dev/sda --no-reread < sda_proposed
Saturday, December 8, 2007
Compiling opengl with libraries solved
g++ rect.cc -o rect -lGLU -lGL -lglut
OpenGL 2.1 Reference Page Official
OpenGL 2.1 Reference Pages
| A |
|---|
| glAccum |
| glActiveTexture |
| glAlphaFunc |
| glAreTexturesResident |
| glArrayElement |
| glAttachShader |
| B |
|---|
| glBegin |
| glBeginQuery |
| glBindAttribLocation |
| glBindBuffer |
| glBindTexture |
| glBitmap |
| glBlendColor |
| glBlendEquation |
| glBlendEquationSeparate |
| glBlendFunc |
| glBlendFuncSeparate |
| glBufferData |
| glBufferSubData |
| E |
|---|
| glEdgeFlag |
| glEdgeFlagPointer |
| glEnable |
| glEnableClientState |
| glEnableVertexAttribArray |
| glEnd |
| glEndList |
| glEndQuery |
| glEvalCoord |
| glEvalMesh |
| glEvalPoint |
| F |
|---|
| glFeedbackBuffer |
| glFinish |
| glFlush |
| glFog |
| glFogCoord |
| glFogCoordPointer |
| glFrontFace |
| glFrustum |
| H |
|---|
| glHint |
| glHistogram |
| I |
|---|
| glIndex |
| glIndexMask |
| glIndexPointer |
| glInitNames |
| glInterleavedArrays |
| glIsBuffer |
| glIsEnabled |
| glIsList |
| glIsProgram |
| glIsQuery |
| glIsShader |
| glIsTexture |
| L |
|---|
| glLight |
| glLightModel |
| glLineStipple |
| glLineWidth |
| glLinkProgram |
| glListBase |
| glLoadIdentity |
| glLoadMatrix |
| glLoadName |
| glLoadTransposeMatrix |
| glLogicOp |
| M |
|---|
| glMap1 |
| glMap2 |
| glMapBuffer |
| glMapGrid |
| glMaterial |
| glMatrixMode |
| glMinmax |
| glMultMatrix |
| glMultTransposeMatrix |
| glMultiDrawArrays |
| glMultiDrawElements |
| glMultiTexCoord |
| N |
|---|
| glNewList |
| glNormal |
| glNormalPointer |
| O |
|---|
| glOrtho |
| R |
|---|
| glRasterPos |
| glReadBuffer |
| glReadPixels |
| glRect |
| glRenderMode |
| glResetHistogram |
| glResetMinmax |
| glRotate |
| T |
|---|
| glTexCoord |
| glTexCoordPointer |
| glTexEnv |
| glTexGen |
| glTexImage1D |
| glTexImage2D |
| glTexImage3D |
| glTexParameter |
| glTexSubImage1D |
| glTexSubImage2D |
| glTexSubImage3D |
| glTranslate |
| U |
|---|
| glUniform |
| glUnmapBuffer |
| glUseProgram |
| V |
|---|
| glValidateProgram |
| glVertex |
| glVertexAttrib |
| glVertexAttribPointer |
| glVertexPointer |
| glViewport |
| W |
|---|
| glWindowPos |
OpenGL Miscellaneous State Variables
- GL_LIST_BASE
-
Description: Setting of glListBase Attribute group: list Initial value: 0 Get command: glGetIntegerv - GL_LIST_INDEX
-
Description: Number of display lists under construction; 0 if none Attribute group: Initial value: 0 Get command: glGetIntegerv - GL_LIST_MODE
-
Description: Mode of display list under construction; undefined if none Attribute group: Initial value: 0 Get command: glGetIntegerv - GL_ATTRIB_STACK_DEPTH
-
Description: Attribute stack pointer Attribute group: Initial value: 0 Get command: glGetIntegerv - GL_NAME_STACK_DEPTH
-
Description: Name stack depth Attribute group: Initial value: 0 Get command: glGetIntegerv - GL_RENDER_MODE
-
Description: glRenderMode setting Attribute group: Initial value: GL_RENDER Get command: glGetIntegerv -
Description: Current error code(s) Attribute group: Initial value: 0 Get command: glGetError