Skip to content

Instantly share code, notes, and snippets.

View barisesen's full-sized avatar
🏠
Working from home

Barış Esen barisesen

🏠
Working from home
View GitHub Profile
@barisesen
barisesen / TaxNumber.php
Created April 12, 2018 11:45
Vergi kimlik numarası doğrulama
<?php
namespace Libraries;
class TaxNumber
{
public static function check($tax)
{
$tax = str_replace(' ', '', trim($tax));
if (strlen($tax) != 10) {
<?php
// bloomberght anlık
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($ch, CURLOPT_URL, "http://www.bloomberght.com/doviz/dolar/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$site = curl_exec($ch);
curl_close($ch);
@barisesen
barisesen / parse.php
Last active May 29, 2018 07:53
Geriye dönük olarak dolar kurunu TCMB sitesinden parse eder.
<?php
/* @barisesen
* http://www.tcmb.gov.tr/kurlar/201805/25052018.xml
*/
public function oldExchangeRate($date)
{
$dt = Carbon::parse($date);
if ($dt->isWeekend()) {
return $this->oldExchangeRate($dt->subDay());
}
package main
import (
"crypto/hmac"
"crypto/md5"
"encoding/hex"
"fmt"
"sort"
"strconv"
)
@barisesen
barisesen / verify.js
Created January 18, 2019 08:34
Tc kimlik numarası doğrulama - javascript
function verify(tcno) {
if (!tcno.match(/^[1-9]{1}[0-9]{9}[0,2,4,6,8]{1}$/)) {
return false;
}
tcno = tcno.split('').map(Number);
var odd = tcno[0] + tcno[2] + tcno[4] + tcno[6] + tcno[8];
var even = tcno[1] + tcno[3] + tcno[5] + tcno[7];
var digit10 = (odd * 7 - even) % 10;
var total = (odd + even + tcno[9]) % 10;
return !(digit10 !== tcno[9] || total !== tcno[10]);