Archive for October 2019

Yahoo finance rates convert (for educational purposes only)

<?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’);

Apply and revert patch

# 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

Creating patch

git format-patch -1 SHA5