Skip to content

Instantly share code, notes, and snippets.

View ahmethakanbesel's full-sized avatar

Ahmet Hakan Beşel ahmethakanbesel

View GitHub Profile
@ahmethakanbesel
ahmethakanbesel / paylas.php
Created February 12, 2017 13:32
PHP ile Facebook'ta Resim Paylaşma
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://graph.facebook.com/v2.8/me/photos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
@ahmethakanbesel
ahmethakanbesel / speedtest.php
Created February 25, 2017 17:38
PHP İnternet Hız Testi
<?php
for($sayi = 0; $sayi &lt; 5; $sayi++) {
$kb=1024;
echo "aktarılıyor $kb Kb...&lt;!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x&lt;$kb;$x++){
echo str_pad('', 1024, '.');
@ahmethakanbesel
ahmethakanbesel / dosya-sil.php
Created July 3, 2017 11:47
PHP ile eski dosyaları silme (Delete files older than X in PHP)
<?php
/*
* Silinecek dosyaların bulunduğu dizin
*/
$dir = "klasor/dosyalar";
/*
* Dizindeki tüm dosyalara işlem uygulanır
*/
foreach (glob($dir."*") as $file) {
/*
@ahmethakanbesel
ahmethakanbesel / disable-kbd.js
Created August 3, 2017 09:49
Pure Javascript Disable Key Binds and Keyboard Shortcuts
document.onkeydown = function (e) {
return false;
}
@ahmethakanbesel
ahmethakanbesel / multi-submit-form.html
Created August 17, 2017 13:01
Separate Form Submit Buttons That Go To Different URLs
<form action="dosya.php">
<input type="submit" value="Gönder">
<input type="submit" value="Gönder 2" formaction="dosya-2.php">
</form>
@ahmethakanbesel
ahmethakanbesel / titresim.html
Last active September 8, 2017 07:18
Javascript navigator.vibration API Example
<button onclick="titret(1000)">Titret</button>
<button onclick="titret([1000, 200, 1000, 2000, 400]);">Titret (3 defa aralıklı)</button>
<script>
function titret(sure) {
navigator.vibrate(sure);
console.log(sure + "ms");
}
</script>
@ahmethakanbesel
ahmethakanbesel / wordpress-javascript-defer.php
Created September 29, 2017 16:04
Wordpress Defer Javascript
/*
* Defer Javascript
*/
add_filter( 'clean_url', function( $url )
{
if ( FALSE === strpos( $url, '.js' ) )
{
return $url;
}
return "$url' defer='defer";
@ahmethakanbesel
ahmethakanbesel / css-render.html
Created September 29, 2017 16:13
Oluşturmayı önleyen JavaScript ve CSS kodlarını ekranın üst kısmındaki içerikten kaldırın
<noscript id="deferred-styles">
<link rel="stylesheet" type="text/css" href="stil.css"/>
</noscript>
<script>
var loadDeferredStyles = function() {
var addStylesNode = document.getElementById("deferred-styles");
var replacement = document.createElement("div");
replacement.innerHTML = addStylesNode.textContent;
document.body.appendChild(replacement)
addStylesNode.parentElement.removeChild(addStylesNode);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
@ahmethakanbesel
ahmethakanbesel / battery.js
Created February 10, 2018 20:26
Javascript Battery Level GUI
var pil = navigator.battery || navigator.webkitBattery || navigator.mozBattery;
function pilDurumu(pil) {
document.getElementById('seviye').innerHTML += ' %' + pil.level * 100;
document.getElementById('yuzde').value = pil.level * 100;
if (pil.charging === true) {
var durum = "Şarj oluyor";
} else {
var durum = "Şarjda değil";
}