Skip to content

Instantly share code, notes, and snippets.

View aliuygur's full-sized avatar

Ali UYGUR aliuygur

View GitHub Profile
@aliuygur
aliuygur / countries_list.php
Last active August 27, 2021 08:08
Function: Countries (php countries list array)
<?php
/**
* Countries List
* @return array
*/
function countries()
{
$countries = Array(
'AF' => 'Afghanistan',
@aliuygur
aliuygur / .vimrc
Last active October 6, 2015 13:58
my vimrc
" File-type highlighting and configuration.
" Run :filetype (without args) to see what you may have
" to turn on yourself, or just set them all to be sure.
syntax on
filetype on
filetype plugin on
filetype indent on
" Intuitive backspacing in insert mode
set backspace=indent,eol,start
@aliuygur
aliuygur / fibonacci.php
Last active February 1, 2017 05:18
php fibonacci
<?php
/**
* Get value of index in fibonacci series
*
* @author Ali OYGUR <alioygur@gmail.com>
* @param int $n index number
* @return int value of index
*/
function fibonacci($n)
{
@aliuygur
aliuygur / denyhosts-remove-ip.sh
Last active December 31, 2015 12:29
Remove specifed IP from denyhosts Worked ubuntu 12.04
#!/bin/bash
echo Removing $1 from denyhosts tables
WORK_DIR=/var/lib/denyhosts/
IP=`echo $1 | sed 's/\./\\\\./g'`
service denyhosts stop
eval "sed -i /$IP/d /etc/hosts.deny"
eval "sed -i /$IP/d ${WORK_DIR}hosts"
eval "sed -i /$IP/d ${WORK_DIR}hosts-restricted"
eval "sed -i /$IP/d ${WORK_DIR}hosts-root"
eval "sed -i /$IP/d ${WORK_DIR}hosts-valid"
@aliuygur
aliuygur / fix-locale-issue.md
Created December 16, 2014 17:11
ubuntu makinadaki locale problemi ve çözümü. bu problem genelde digitalocean.com dan alınan makinalarda çıkıyor.

lets fix the ubuntu locale issue (digitalocea.com droplets)

1. step, browse locale settings

root@piklook-dev:~# locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
<?php
/**
* Creating date collection between two dates
*
* <code>
* <?php
* # Example 1
* date_range("2014-01-01", "2014-01-20", "+1 day", "m/d/Y");
*
@aliuygur
aliuygur / add-swap-file.sh
Created May 28, 2015 13:59
this file add 4GB swap file to ubuntu 14.04 x64
#!/bin/bash
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
echo "Added!"
free -m
@aliuygur
aliuygur / main.go
Last active August 29, 2015 14:24 — forked from nmerouze/main.go
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"
package main
import (
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
u, _ := url.Parse("https://leanfoods-9f12.restdb.io")
@aliuygur
aliuygur / desc.md
Last active July 22, 2022 09:48
removes duplicate values in given slice

this algorithm 10x faster than https://www.dotnetperls.com/duplicates-go and zero allocation

➜  api git:(master) ✗ go test -v -bench=. main_test.go
=== RUN   TestSliceUniq
--- PASS: TestSliceUniq (0.00s)
BenchmarkSliceUniq-4             3000000               439 ns/op               0 B/op          0 allocs/op
BenchmarkRemoveDuplicates-4       500000              4599 ns/op             571 B/op          8 allocs/op
PASS