Calculate Passed Time

function calculate_passed_time($date){ $today = date(‘Y-m-d H:i:s’); // Bugünün tarihi $today_seconds = strtotime($today); // Bugünün tarihi – saniye cinsinden $date_seconds = strtotime($date); // Verilen parametre – saniye cinsinden $diff = $today_seconds – $date_seconds; // Aradaki fark – saniye cinsinden if($diff > 0 && $diff < 60){ $passed_time = $diff.” saniye”; }else if($diff >= 60 && $diff […]

Read More

HTML5 Desktop Notification

<input type=”button” id=”push_notification_button” value=”Push Notification”> <script> $(document).ready(function(){ // push_notification fonksiyonu function push_notification(baslik,icerik,resim,url) { // bildirim opsiyonları var options = { body: icerik, icon: resim, dir : “ltr” }; // bildirim opsiyonları if (!(“Notification” in window)) { // Tarayıcı bildirim özelliğini destekliyor mu? alert(“Tarayıcınız bildirim özelliğini desteklememektedir!”); }else if (Notification.permission === “granted”) { // Daha önce […]

Read More

SEF Link Fonksiyonu

<?php function generate_sef_link_text($string){ $convert_from = array(“Ç”, “ç”, “Ğ”, “ğ”, “ı”, “İ”, “Ö”, “ö”, “Ş”, “ş”, “Ü”, “ü”); // türkçe karakterler $convert_to = array(“C”, “c”, “G”, “g”, “i”, “I”, “O”, “o”, “S”, “s”, “U”, “u”); // ingilizce karakterler $string = trim($string); // stringin başındaki ve sonundaki boşlukları sil $string = str_replace($convert_from,$convert_to,$string); // türkçe karakterleri ingilizce karakterlere […]

Read More

Apache Server Enable Deflate

# BEGIN Enable Compression <IfModule mod_deflate.c> # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType […]

Read More

Apache Server Enable Browser Caching

# BEGIN Browser Caching <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css “access plus 1 month” ExpiresByType text/javascript “access plus 1 month” ExpiresByType text/html “access plus 1 month” ExpiresByType application/javascript “access plus 1 month” ExpiresByType application/x-javascript “access plus 1 month” ExpiresByType application/xhtml-xml “access plus 1 month” ExpiresByType image/gif “access plus 1 month” ExpiresByType image/jpeg “access plus 1 […]

Read More

Apache Server Enable GZIP

# BEGIN Enable GZIP <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> # END Enable GZIP

Read More

Currency Switcher

jQuery.ajax( { url: ‘//freegeoip.net/json/’, type: ‘GET’, dataType: ‘jsonp’, success: function(location) { if (location.country_code === ‘GB’) { $(“#currencies”).val(“GBP”); $(“#currencies”).change(); } else if (location.country_code === ‘US’) { $(“#currencies”).val(“USD”); $(“#currencies”).change(); } else { $(“#currencies”).val(“EUR”); $(“#currencies”).change(); } } });

Read More

Check Internet Connection

function doesConnectionExist() { var xhr = new XMLHttpRequest(); var file = “https://www.emretalu.net”; var randomNum = Math.round(Math.random() * 10000); xhr.open(‘HEAD’, file + “?rand=” + randomNum, true); xhr.send(); xhr.addEventListener(“readystatechange”, processRequest, false); function processRequest(e) { if (xhr.readyState == 4) { if (xhr.status >= 200 && xhr.status < 304) { alert(“connection exists!”); } else { alert(“connection doesn’t exist!”); } […]

Read More

jQuery Select Option Sorting Function With LocaleCompare

var sortSelectOptions = function(select, order){ if(order === ‘asc’){ var elements = $(select).children(‘option’).not(‘:first’).get(); elements.sort(function(elm1, elm2){ return $(elm1).text().trim().localeCompare($(elm2).text().trim()); }); $(select).append(elements); }else if(order === ‘desc’){ var elements = $(select).children(‘option’).not(‘:first’).get(); elements.sort(function(elm1, elm2){ return $(elm2).text().trim().localeCompare($(elm1).text().trim()); }); $(select).append(elements); } };

Read More

İki Tarih Arasındaki Farkı Almak

function getNumberOFDays($from,$to){ $from_date = new DateTime($from); $to_date = new DateTime($to); return $from_date->diff($to_date)->days; //return $from_date->diff($to_date)->h; //return $from_date->diff($to_date)->i; //return $from_date->diff($to_date)->s; //return $from_date->diff($to_date)->invert; //return $from_date->diff($to_date)->d; //return $from_date->diff($to_date)->m; //return $from_date->diff($to_date)->y; //DateInterval Object ( [y] => 0 [m] => 0 [d] => 26 [h] => 0 [i] => 0 [s] => 0 [invert] => 0 [days] => 26 ) } […]

Read More