Posted
on November 15, 2019, 1:09 pm,
by admin,
under
php.
function getNearestMatch($number, $candidates) {
$candidates = is_array($candidates) ? $candidates : array($candidates);
$size = count($candidates);
if ($size > 0) {
//absolute difference between 0th element and input value
$diff = abs($candidates[0] - $number);
//element closest to input value
$ret = $candidates[0];
//loop through the rest of the array
for ($i = 1; $i < $size; $i++) {
$temp = abs($candidates[$i] - $number);
if ($temp < $diff) {
//set new difference and closest element
$diff = $temp;
$ret = $candidates[$i];
}
}
return $ret;
} else {
return NULL;
}
} |
Posted
on October 22, 2019, 10:30 am,
by admin,
under
php.
<?php
class Rates {
function Convert($amount,$from,$to){
$url="http://adsynth-ofx-quotewidget-prod.herokuapp.com/api/1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"method":"spotRateHistory","data":{"base":"'.$from.'","term":"'.$to.'","period":"week"}}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_REFERER, "https://widget-yahoo.ofx.com/");
$html = curl_exec ($ch);
curl_close ($ch);
$veri=json_decode($html,true);
return $veri["data"]["CurrentInterbankRate"]*$amount;
}
}
$kur = new Rates();
echo $kur->Convert(1, 'USD', 'GBP'); |
Posted
on October 17, 2019, 1:15 pm,
by admin,
under
bash.
# Test before apply
patch -p1 --dry-run > /path/to/some.patch
# Apply patch
patch -p1 > /path/to/some.patch
# Revert
patch -p1 -R > /path/to/some.patch |
Posted
on October 2, 2019, 1:38 pm,
by admin,
under
git.
Posted
on September 15, 2019, 7:30 pm,
by admin,
under
linux.
ffmpeg -i wombsounds.mp4 -f mp3 -ab 192000 -vn wombsounds.mp3 |
Posted
on September 1, 2019, 12:09 pm,
by admin,
under
apache,
html.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_self">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="imran.aghayev@yahoo.co.uk"/>
<input type="hidden" name="item_name" value="Itemname"/>
<input type="hidden" name="item_number" value="1"/>
<input type="hidden" name="amount" value="150"/>
<input type="hidden" name="currency_code" value="GBP"/>
<input type="hidden" name="lc" value="UK"/>
<input type="hidden" name="bn" value="btn_buynow_SM.gif"/>
<input type="hidden" name="weight_unit" value="kgs"/>
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif" name="submit" alt="Make payments with PayPal"/>
</form> |
Posted
on August 28, 2019, 1:59 pm,
by admin,
under
dictionary.
1. Sprint Refinement – when a team goes through the backlog, score points, etc. It focuses on a long term goals
2. Scrum Planning – when a team go through the backlog and discuss tickets to be added to oncoming Sprint, assign to developer. It focuses on a short term, goals within next Sprint.
3. Scrum Retro(spective) – when a team discuss finished Sprint, how did it go, what could have been done better.
4. Scrum Review – when a project manager demonstrates achievements of last Sprint/s to the management.
Posted
on August 20, 2019, 2:49 pm,
by admin,
under
mysql.
SELECT DATE_FORMAT(FROM_UNIXTIME(yourfield), '%e %b %Y') FROM yourtable; |
Associative arrays in PHP = Javascript Objects written as name value pairs = Hash maps in Java
Posted
on July 31, 2019, 9:41 am,
by admin,
under
bash.
<?php
$x = 5;
for($i=0; $i<10; $i++)
{
if($i % $x == 0)
{
echo 'yes';
}
} |
Result: yes yes
Explanation: 5 % 5 has remainder 0 (fully divided), 10 % 5 has remainder 0 (fully divided)