Skip to content

Instantly share code, notes, and snippets.

View unique1984's full-sized avatar
💭
I may be slow to respond.

Yasin KARABULAK unique1984

💭
I may be slow to respond.
View GitHub Profile
@unique1984
unique1984 / ajax_window_operations.js
Last active September 30, 2019 11:08
Ajax Window operations
// sayfayı açtığında veya yenilediğinde
$(document).ready(function () {
$.ajax({
type: 'POST',
url: "./open.php",
data: {
adminId: "123456_Yasin",
message: "open"
},
async: false
@unique1984
unique1984 / speedtest.py
Created September 26, 2019 23:48
speedtest
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2012-2018 Matt Martz
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@unique1984
unique1984 / kombinasyon.php
Created September 24, 2019 04:57
Verilen dizi elemanlarının kombinasyonları.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$start = microtime(true);
$start_memory = memory_get_usage();
$range = range(0, 100);
//~ $range = array(10, 20, 30, 40, 50);
shuffle($range);
$copy = $range;
@unique1984
unique1984 / average-geolocation.js
Created September 20, 2019 08:26 — forked from tlhunter/average-geolocation.js
Calculate the center/average of multiple GeoLocation coordinates
/**
* Calculate the center/average of multiple GeoLocation coordinates
* Expects an array of objects with .latitude and .longitude properties
*
* @url http://stackoverflow.com/a/14231286/538646
*/
function averageGeolocation(coords) {
if (coords.length === 1) {
return coords[0];
}
@unique1984
unique1984 / composer-completion
Last active January 4, 2021 19:00
Composer bash_completion
_composer()
{
local cur=${COMP_WORDS[COMP_CWORD]}
local cmd=${COMP_WORDS[0]}
if ($cmd > /dev/null 2>&1)
then
COMPREPLY=( $(compgen -W "$($cmd list | awk '$0 ~ /^ .*/' | awk {'print $1'} | grep -io '[^/_,]*' | grep -v 'command')" -- $cur) )
fi
}
complete -F _composer composer
# wget -O "/etc/X11/xorg.conf" https://gist.githubusercontent.com/unique1984/1d29e8caaf649546ff0bc07769b834af/raw/8140fc06dd02daae33ec7cae6aabcf6225c6dcd3/X11%2520Dummy%2520configuration.txt
# This xorg configuration file will start a dummy X11 server.
# move it to /etc/X11/xorg.conf
# don't forget apt install xserver-xorg-video-dummy;
# based on https://xpra.org/Xdummy.html
Section "ServerFlags"
Option "DontVTSwitch" "true"
Option "AllowMouseOpenFail" "true"
Option "PciForceNone" "true"
@unique1984
unique1984 / createFiles.sh
Created September 3, 2019 21:39
Create 500 folder and each one nested 1000 files and destroy them with php
#!/usr/bin/env bash
mkdir hugeNumberOfFiles
for i in `seq 500`; do mkdir hugeNumberOfFiles/$i; for j in `seq 1000`; do touch hugeNumberOfFiles/$i/$j.txt; done; done
for i in `seq 4`; do cp -r hugeNumberOfFiles hugeNumberOfFiles$i; done
# hugeNumberOfFiles -> 500 folders and nested total 500000 files
<?php
require_once __DIR__.'/V8JsNodeModuleLoader_FileAccessInterface.php';
require_once __DIR__.'/V8JsNodeModuleLoader_NormalisePath.php';
/**
* Simple Node.js module loader for use with V8Js PHP extension
*
* This class understands Node.js' node_modules/ directory structure
* and can require modules/files from there.
*
@unique1984
unique1984 / fibonacci_generator.php
Created August 31, 2019 17:36
Fibonacci Generator PHP
<?php
function FibonacciGenerator()
{
$i = 0;
$j = 1;
for(;;) {
yield $j;
list($i, $j) = array($j, $i + $j);
}
}
@unique1984
unique1984 / create_zip.php
Last active August 23, 2019 20:19
PHP zip files and extract selected ones.
<?php
$zip_it = "dummy_data"; // folder name
$zip_name = "./test.zip";
$dir = realpath(__DIR__ . "/" . $zip_it);
$listing = scandir($dir);
//~ print_r($listing);
// die;