Posted
on October 2, 2018, 9:43 am,
by admin,
under
php.
<?php
function convert($from,$to,$amount) {
$url = "https://www.google.com/search?q=".$from.$to;
$request = curl_init();
$timeOut = 0;
curl_setopt ($request, CURLOPT_URL, $url);
curl_setopt ($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($request, CURLOPT_USERAGENT,"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML
, like Gecko) Chrome/68.0.3440.106 Safari/537.36");
curl_setopt ($request, CURLOPT_CONNECTTIMEOUT, $timeOut);
$response = curl_exec($request);
curl_close($request);
preg_match('~<span [^>]* id="knowledge-currency__tgt-amount"[^>]*>(.*?)</span>~si', $response, $finalData);
return floatval((floatval(preg_replace("/[^-0-9\.]/","", $finalData[1]))/100) * $amount);
}
echo convert("USD", "GBP", "1");
?> |
Posted
on September 10, 2018, 3:24 pm,
by admin,
under
mysql.
SHOW COLUMNS FROM Tablename WHERE FIELD = "Fieldname"; |
Posted
on September 10, 2018, 10:38 am,
by admin,
under
linux.
Use all lowercase for technical / system or development related folders:
/srv/machine1/inbox
/srv/machine1/scripts |
Use Capitalized names for personal, desktop-facing, or user-interface symlink folders:
/home/username1/Documents
/home/username1/Projects |
Find and rename files uppercase to lowercase
find my_folder -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \; |
Find my pattern and rename
find ./ -type f -name '*_en-gb.json' -exec sh -c 'mv "$0" "${0%_en-gb.json}_en-uk.json"' {} \; |
Posted
on September 5, 2018, 12:36 pm,
by admin,
under
git.
Use gitk to find out which commit you want to rollback and do the following:
git reset --hard 53c309929253a2a |
Posted
on August 21, 2018, 2:03 pm,
by admin,
under
linux.
Posted
on July 24, 2018, 4:14 pm,
by admin,
under
gimp.
1. click ‘Select All’ and open and edit it
2. When you are about to save, gimp can’t save multipages pdf directly. You’ll need to use an intermediate file format
3. Install ImageMagick
sudo apt-get install imagemagick |
4. Save in Gimp
File -> Export -> document.mng
5. Export to pdf in a command line
convert -reverse document.mng document.pdf |
Posted
on July 3, 2018, 10:37 am,
by admin,
under
bash.
for i in *.png; do mv "$i" "${i/.png/t.png}"; done |
Posted
on June 13, 2018, 2:01 pm,
by admin,
under
php.
$file = 'myimage.png';
$size = getimagesize($file);
$fp = fopen($file, 'rb');
if ($size and $fp)
{
header('Content-Type: '.$size['mime']);
header('Content-Length: '.filesize($file));
fpassthru($fp);
} |
Posted
on May 21, 2018, 10:52 am,
by admin,
under
git.
git checkout -b new_branch_name |
Posted
on May 21, 2018, 9:39 am,
by admin,
under
git.
git push origin --delete feature/login
git push origin :feature/login |