Skip to content

Instantly share code, notes, and snippets.

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

Savaş Can ALTUN saltun

🏠
Working from home
View GitHub Profile
@saltun
saltun / validation.php
Created December 9, 2015 16:10
Laravel 5 Validation Türkçe
<?php
/* Translate Savaş Can ALTUN < savascanaltun@gmail.com > */
return [
/*
|--------------------------------------------------------------------------
| Validation Language Lines
|--------------------------------------------------------------------------
|
| The following language lines contain the default error messages used by
1c349abe3d2ee7889fc44dff28dfbb2bff25376910f75615cff9d180f2014f6cf46fa21a79a2
@saltun
saltun / cutnumber.js
Created December 19, 2017 23:33
JavaScript cut number
// Turkish
function cutNumber(value) {
var newValue = value;
if (value >= 1000) {
var suffixes = ["", "Bin", "Milyon", "Milyar"," Trilyon"];
var suffixNum = Math.floor( (""+value).length/3 );
var shortValue = '';
for (var precision = 2; precision >= 1; precision--) {
shortValue = parseFloat( (suffixNum != 0 ? (value / Math.pow(1000,suffixNum) ) : value).toPrecision(precision));
var dotLessShortValue = (shortValue + '').replace(/[^a-zA-Z 0-9]+/g,'');
@saltun
saltun / phpdoc.php
Last active July 14, 2016 17:28
PHPDOC Example Class
<?php
/**
* İnsan sınıfı x)
* @author Savaş Can ALTUN <savascanaltun@gmail.com>
* @link http://savascanaltun.com.tr
* @version 1.0
*/
class Human {
@saltun
saltun / php-create-random-date.php
Created June 12, 2016 22:56
PHP Create Random Date
<?php
/**
* @author Savaş Can ALTUn <savascanaltun@gmail.com>
* www.savascanaltun.com.tr
*/
$tarihBas = strtotime('1.1.2016'); // date Start
$tarihSon = strtotime('24.06.2016'); // date End
$rastgeleTarih = rand($tarihBas, $tarihSon); // create random
echo(date('d.m.Y H:i', $rastgeleTarih)); // convert time
@saltun
saltun / LoginController.php
Created December 3, 2015 22:29
Laravel Manuel Auth Login
<?php
class LoginController extends BaseController {
//
public function getLogin($id){
$user=Auth::loginUsingId($id);
if (!$user){
throw new Exception('Giriş Hatası');
}else{
@saltun
saltun / strposa.php
Created May 16, 2015 18:30
PHP strpos in array function
<?php
/**
* @author Savaş Can ALTUN <savascanaltun@gmail.com>
* @link http://savascanaltun.com.tr
* PHP strpos function in array
*/
function strposa($text, $finds, $offset=0) {
if(!is_array($finds)) $finds = array($finds);
foreach($finds as $query) {
if(strpos($text, $query, $offset) !== false) return true;
@saltun
saltun / gist:12d687383f656e344dd4
Created May 12, 2015 11:49
PHP URL Facebook Share Count
<?php
$source = file_get_contents("https://graph.facebook.com/?id=http://www.savascanaltun.com.tr");
$json = json_decode($source, true);
echo "Total : ".$json['shares']; // return number format
?>
@saltun
saltun / randomtime.php
Created April 22, 2015 15:03
PHP Rastgele Saat oluşturma
<?php
/**
* Create random time [ PHP ]
* @author Savaş Can ALTUN <savascanaltun@gmail.com>
*/
function randomTime($first,$last){
$number = rand($first,$last);
if($number<10){
$result='0'.$number;
return $result;
@saltun
saltun / .htaccess
Last active August 29, 2015 14:17
Tüm Sub Domainleri yönlendirme
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^siteadi.com$ [NC]
RewriteRule ^(.*)$ http://siteadi.com/$1 [L,R=301]