Skip to content

Instantly share code, notes, and snippets.

View amirkhiz's full-sized avatar

Siavash Habil amirkhiz

  • Sony
  • Turkey
View GitHub Profile
@amirkhiz
amirkhiz / less
Last active March 11, 2017 13:49
Arrays with LESS
@material-colors: red #f44336,
pink #e91e63,
purple #9c27b0,
deep-purple #673ab7,
indigo #3f51b5,
blue #2196f3,
light-blue #03a9f4,
cyan #00bcd4,
teal #009688,
green #4caf50,
@amirkhiz
amirkhiz / javascript
Last active March 14, 2017 15:51
Get input keypress and filter content before adding to input
init();
var pattern = /[A-Za-z0-9-\.]/i;
function inputDigitsOnly(e) {
var chrTyped, chrCode = 0, evt = e ? e : event;
if (evt.charCode != null) chrCode = evt.charCode;
else if (evt.which != null) chrCode = evt.which;
else if (evt.keyCode != null) chrCode = evt.keyCode;
if (chrCode == 0) chrTyped = 'SPECIAL KEY';
@amirkhiz
amirkhiz / index.html
Created April 8, 2017 16:44
Drag drop Image upload
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dropdrop Image Upload</title>
<link rel="stylesheet" href="assets/main.css">
<script src="https://code.jquery.com/jquery-2.2.4.js" crossorigin="anonymous"
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="></script>
<script src="assets/main.js"></script>
@amirkhiz
amirkhiz / titleCaseTurkish
Last active June 30, 2017 10:41
Turkish Capitalize (Title case) for string
function titleCaseTurkish($string)
{
$temp = preg_split("/\s/u", $string, -1, PREG_SPLIT_NO_EMPTY);
foreach ($temp as &$item) {
$item = str_replace("i", "İ", $item);
}
$temp = join(' ', $temp);
return mb_convert_case($temp, MB_CASE_TITLE, "UTF-8");
}
@amirkhiz
amirkhiz / CreditCardCheck.php
Created December 4, 2018 23:01
Credit Card Check Class
<?php
class CreditCardCheck
{
public function validateCreditcard_number($cc_num)
{
$credit_card_number = $this->sanitize($cc_num);
// Get the first digit
$data = array();
@amirkhiz
amirkhiz / circle-progress.js
Last active December 24, 2018 13:25
Calculate circle progress for css gradient values in javascript
let step = 1;
let loop = Math.round(100 / step);
let increment = 360 / loop;
let half = Math.round(loop / 2);
let nextDeg = 0;
for (let i = 0; i <= loop; i += step) {
if (i < half) {
nextDeg = 90 + increment * i;
// background-image linear-gradient(90deg, $back-color 50%, transparent 50%, transparent), linear-gradient(nextDeg, $theme-color 50%, $back-color 50%, $back-color)
@amirkhiz
amirkhiz / IyzicoPayment.php
Last active January 5, 2019 17:18
Iyzico wrapper class with example payment and callback page. Iyzico library used v2.0.43 version from this repository https://github.com/iyzico/iyzipay-php
<?php
namespace App\Classes\Iyzico;
use Iyzipay;
use Iyzipay\Model;
use Iyzipay\Options;
use Iyzipay\Request;
/**
@amirkhiz
amirkhiz / sorting.sql
Created January 6, 2019 14:43
Sort Queries
#Forwarding
#ex. : from = 1, to = 5
UPDATE table_name SET order_field = order_field - 1
WHERE order_field > {from}
AND order_field <= {to}
#Backward
#ex. from = 5, to = 1
UPDATE table_name SET order_field = order_field + 1
WHERE order_field >= {to}
@amirkhiz
amirkhiz / generate_unique_id.php
Created January 6, 2019 14:45
Generate Unique ID
function generateUniqueId()
{
mt_srand();
$order_no = substr(md5(uniqid(mt_rand())), 0, 8);
return $order_no;
}
@amirkhiz
amirkhiz / send-request.js
Created January 6, 2019 14:46
Send file with ajax request in form data
$('#frm-human-res').submit(function (e) {
e.preventDefault();
var form_data = new FormData(),
cv_file = document.getElementById("upload-btn").files[0];
var other_data = $(this).serializeArray();
$.each(other_data, function (key, input) {
form_data.append(input.name, input.value);
});