Posted
on January 15, 2020, 5:02 pm,
by admin,
under
linux.
Mounting
mkdir ~/remoteDir
ssh-keygen -t rsa
ssh-copy-id -i .ssh/id_rsa.pub user@hostname
sudo apt install sshfs
sshfs user@hostname:/ ~/remoteDir |
Unmounting
fusermount -u ~/remoteDir |
Posted
on January 15, 2020, 11:04 am,
by admin,
under
linux.
Posted
on November 27, 2019, 11:27 pm,
by admin,
under
mysql,
php.
<?php
$dbname = 'dbname';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'hostname';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
mysql_select_db($dbname) or die("Could not open the db '$dbname'");
$test_query = "SELECT 1,2,3,4 FROM yourtable";
$result = mysql_query($test_query);
$tblCnt = 0;
while($tbl = mysql_fetch_array($result)) {
$tblCnt++;
echo $tbl[0]."<br />\n";
echo $tbl[1]."<br />\n";
echo $tbl[2]."<br />\n";
echo $tbl[3]."<br />\n";
}
if (!$tblCnt) {
echo "There are no tables<br />\n";
} else {
echo "There are $tblCnt tables<br />\n";
} |
Posted
on November 22, 2019, 12:41 pm,
by admin,
under
bash.
If your job is running in terminal do
bg -- Move running process to background -- |
jobs -- list the jobs in background and get id of the job you want to detach -- |
disown %1 -- use job id from previous query for detaching from the terminal -- |
Posted
on November 22, 2019, 12:00 pm,
by admin,
under
mysql.
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 |