Skip to content

Instantly share code, notes, and snippets.

Avatar

Kerem Güneş k-gun

  • Istanbul, Turkey
View GitHub Profile
@k-gun
k-gun / Preferences.sublime-settings
Last active Nov 2, 2019
Preferences.sublime-settings
View Preferences.sublime-settings
{
"added_words":
[
"uber",
"versioning"
],
"always_show_minimap_viewport": true,
"color_scheme": "Packages/Inspired GitHub Color Scheme/InspiredGitHub_2.tmTheme",
"default_line_ending": "unix",
"detect_indentation": false,
View salt.js
const crypto = require('crypto');
const Salt = {
/**
* Length.
* @const int
*/
LENGTH: 128,
/**
View nope.sql
-- 2. Soru
SELECT "class", count(*) AS "count"
FROM "Student"
WHERE "grade" >= 70
GROUP BY "class"
HAVING count(*) > 1 -- 10
ORDER BY "count" DESC
-------
@k-gun
k-gun / Element.prototype.classList.js
Last active Apr 12, 2019
Polyfill: Element.prototype.classList for IE8/9, Safari.
View Element.prototype.classList.js
/**
* Element.prototype.classList for IE8/9, Safari.
* @author Kerem Güneş <k-gun@mail.com>
* @copyright Released under the MIT License <https://opensource.org/licenses/MIT>
* @version 1.2
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
*/
;(function() {
// Helpers.
var trim = function(s) {
View fn_vector.py
def fn_vector(words):
import re, locale
#global words
def slug(words):
return fn_slug(words)
i = 0
dic = {}
words = slug(words)
View fn_slug.py
def fn_slug(words):
import re
#global words
chrs = {'ı':'i', 'ö':'o', 'ü':'u', 'ç':'c', 'ğ':'g', 'ş':'s',
'İ':'I', 'Ö':'O', 'Ü':'U', 'Ç':'C', 'Ğ':'G', 'Ş':'S'}
def lower(word):
return word.replace('İ', 'i').replace('I', 'ı').lower()
View InspiredGitHub_2.tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
Inspired GitHub Color Scheme for Sublime Text 3
Copyright 2015 Seth Lopez
Released under the MIT License <http://opensource.org/licenses/MIT>
https://github.com/sethlopezme/InspiredGitHub.tmtheme
-->
<!--
ed6a43 > this
@k-gun
k-gun / copy_function.php
Last active Jan 20, 2019
PHP: copy_function()
View copy_function.php
<?php
function copy_function($name) {
$reflection = new ReflectionFunction($name);
return function(...$arguments) use($reflection) {
return call_user_func_array([$reflection, 'invoke'], $arguments);
};
}
$fn = copy_function('is_int');
@k-gun
k-gun / Number.prototype.toNumberFormat.js
Created Oct 8, 2017
PHP's number_format() implementation with JavaScript.
View Number.prototype.toNumberFormat.js
/**
* To number format.
* @param {Integer} decimals?
* @param {String} decimalsSeparator?
* @param {String} thousandsSeparator?
* @return {String}
* @links http://php.net/number_format, https://stackoverflow.com/q/2901102
*/
Number.prototype.toNumberFormat = function(decimals, decimalsSeparator, thousandsSeparator) {
decimalsSeparator = decimalsSeparator || '.';
@k-gun
k-gun / date_time_stuff.php
Last active Mar 7, 2016
Date time stuff.
View date_time_stuff.php
<?php
function time_zone_offset_to_identifier(string $offset, int $offsetIndex = 0) {
static $timeZoneOffsets = [];
if (empty($timeZoneOffsets)) {
foreach(timezone_identifiers_list() as $timeZoneIdentifier) {
$dateTimeZone = new DateTimeZone($timeZoneIdentifier);
$dateTime = new DateTime('NOW', $dateTimeZone);
$timeZoneOffsets[$dateTimeZone->getOffset($dateTime)][] = $timeZoneIdentifier;
}
}
You can’t perform that action at this time.