Archive for July, 2009


>
//scriptlanguage=”javascript”

writeCookie();
function writeCookie() {
var enddate = new Date(“December 31, 2060”);
document.cookie = “screenresolution=”+ screen.width +”x”+ screen.height + “;expires=” + enddate.toGMTString();
window.location.replace(“phptag $_SERVER[‘PHP_SELF’] .’?’.$_SERVER[‘QUERY_STRING’] phpend”);
}

/script

http://www.winasm.net/forum/index.php?showtopic=1178

Advertisements

>Seconds to HH:MM:SS

Posted: July 22, 2009 in PHP

>$seconds = 3600; // any starting value
$days = floor($seconds/86400);
$days_mod = $seconds%86400;
$hours = floor($days_mod/3600);
$hours_mod = $days_mod%3600;
$minutes = floor($hours_mod/60);
$minutes_mod = $hours_mod%60;
$seconds = floor($minutes_mod);
echo $minutes.’minutes and ‘.$seconds.’ seconds’;


>$now1 = strtotime(date(“Y-m-d h:i:s”));
$now2 = strtotime(date(“Y-m-d h:i:s”));
$seconds = $now1-$now2;
$minutes = $now1-$now2/60;

>Image Resize

Posted: July 18, 2009 in PHP

>function image($img,$w,$h) {
$a = getimagesize($img);
$image_attribs = getimagesize($img);
if($a[‘mime’] == “image/jpeg”) {
$im_old = imageCreateFromJpeg($img);
}else if($a[‘mime’] == “image/png”) {
$im_old = imageCreateFrompng($img);
}else if($a[‘mime’] == “image/gif”) {
$im_old = imageCreateFromgif($img);
}

$th_max_width = $w;
$th_max_height = $h;
if($w >99 && $h>99){
$ratio = ($width > $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1];
$th_width = $image_attribs[0] * $ratio;
$th_height = $image_attribs[1] * $ratio;
}else{
$th_width=$w;
$th_height=$h;
}
$im_new = imagecreatetruecolor($th_width,$th_height);
imageAntiAlias($im_new,true);

imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]);

header(“Content-type:”.$a[‘mime’]);
imageJpeg($im_new,$th_file_name,100);

}
$img = base64_decode($_GET[‘src’]);
//$img = PATH.$img;
$width = $_GET[‘w’];
$height = $_GET[‘h’];
$val = image($img,$width,$height);

>Convert videos to FLV in one line..

Posted: July 18, 2009 in PHP

>Just enter this single line in your code to convert a video file of wmv,avi and all such formats to .flv format….The only thing you need to make sure is that fffmpeg is already configured in the server which is generally done….

exec(“ffmpeg -i $srcFile -ar 22050 -ab 32 -f flv -s 320×240 $destFile”);

where $srcFile is the location of the source file and $destFile is the location of the destination file.

>Mysql : Get Auto increment value

Posted: July 15, 2009 in MYSQL

>SELECT AUTO_INCREMENT FROM information_schema.tables
WHERE table_name = ‘club_photogallery’

>Left Joins

Posted: July 15, 2009 in MYSQL

>The left join is a mechanism used to join tables before we add other conditions such as WHERE

SELECT
FROM
LEFT JOIN
ON Table1.column = Table2.column

>Mysql: Exporting and Importing Dat

Posted: July 15, 2009 in MYSQL

>mysql> –local-infile=1

”’Exporting Data”’

SELECT
FROM

INTO OUTFILE ‘/tmp/vworks/sample.txt’

”’Importing data”’

LOAD DATA INFILE ‘file_name.txt’
INTO TABLE tbl_name (field1, field2…etc)


>SELECT * FROM table1 t1 WHERE t1.id NOT IN(select t2.t1_id FROM table2 t2)

>Country Select Box

Posted: July 15, 2009 in Uncategorized

>Select a country
Afghanistan
Ajman
Albania

Algeria
Andorra
Angola
Anguilla
Antigua & Barbuda
Argentina

Armenia
Aruba
Ascension
Australia
Austria
Azerbaijan

Azores
Bahamas
Bahrain
Balearic Islands
Bangladesh
Barbados

Belarus
Belau (Palau)
Belgium
Belize
Benin
Bermuda

Bhutan
Bolivia
Bosnia-Herzegovina
Botswana
Brazil
British Indian Ocean Territories

British Virgin Islands
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia

Cameroon
Canada
Canary Islands
Cape Verde
Cayman Islands
Central African Republic

Chad
Chile
China (People’s Republic)
Christmas Island
Cocos Island (Keeling Island)
Colombia

Comoros
Congo
Congo Dem. Rep.
Corsica
Costa Rica
Cote d’Ivoire

Croatia
Cuba
Curacao
Cyprus
Czech Republic
Denmark

Djibouti
Dominica
Dominican Republic
Dubai
East Timor
Ecuador

Egypt
EI Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia

Falkland Islands
Faroe Islands
Fiji
Finland
France
French Guiana

French Polynesia
French Southern & Antarctic Territories
French West Indies
Fujairah
Gabon
Gambia

Gaza & Khan Yunis
Georgia
Germany
Ghana
Gibraltar
Greece

Greenland
Grenada
Guam
Guatemala
Guinea
Guinea-Bissau

Guyana
Haiti
Honduras
Hong Kong
Hungary
Iceland

India
Indonesia
Iran
Iraq
Irish Republic
Israel

Italy
Jamaica
Japan
Jordan
Kazakhstan
Kenya

Kirghizstan
Kiribati
Korea (Democratic People’s Republic)
Korea (Republic of)
Kuwait
Laos

Latvia
Lebanon
Lesotho
Liberia
Libya
Liechtenstein

Lithuania
Luxembourg
Macao
Macedonia (Former Yugoslav Rep. Of)
Madagascar
Madeira

Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands

Mauritania
Mauritius
Mexico
Micronesia (Federated States)
Moldova
Monaco

Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar (formerly Burma)

Namibia
Nauru Island
Nepal
Netherland Antilles
Netherlands
New Caledonia

New Zealand
New Zealand Island Territories
Nicaragua
Niger Republic
Nigeria
Norfolk Island

Northern Mariana Island
Norway
Oman
Pakistan
Panama
Papua New Guinea

Paraguay
Peru
Philippines
Pitcairn Island
Poland
Portugal

Puerto Rico
Qatar
Ras al Khaimah
Reunion
Romania
Russia

Rwanda
Sabah
Samoa (American)
San Marino
Sao Tome & Principe
Sarawak

Saudi Arabia
Senegal
Serbia
Seychelles
Sharjah
Sierra Leone

Singapore
Slovak Republic
Slovenia
Solomon Islands
Somalia
South Africa

South Georgia
South Sandwich Islands
Spain
Spanish North African Territories
Spitzbergen
Sri Lanka

St Christopher (St Kitts) & Nevis
St Helena
St Lucia
St Pierre & Miquelon
St. Vincent & Grenadines

Sudan
Suriname
Swaziland
Sweden
Switzerland
Syria

Taiwan
Tajikistan
Tanzania
Thailand
Tibet
Togo

Tonga
Trinidad & Tobago
Tristan da Cunha
Tunisia
Turkey
Turkmenistan

Turks & Caicos Islands
Tuvalu
Uganda
Ukraine
Umm al Qaiwan
United Arab Emirates

United Kingdom
Uruguay
USA
Uzbekistan
Vanuatu
Vatican City State

Venezuela
Vietnam
Virgin Islands (USA)
Wake Island
Wallis & Futuna Islands
Western Samoa

Yemen
Zambia
Zimbabwe