Skip to content

Instantly share code, notes, and snippets.

View emresaracoglu's full-sized avatar
:atom:
"Every software system is flawed... Every coder is corrupt"

Emre Saraçoğlu emresaracoglu

:atom:
"Every software system is flawed... Every coder is corrupt"
View GitHub Profile
{"stocksChange":{"server":"SarexWay","service":"stocks","date_format":"ISO 8601","time_format":"UTC","requests":{"market":"nasdaq100","real_time":false,"delay":"5min"},"cache":{"timezone":"America\/New_York","last_cache":"2023-11-10 10:57:53"}},"data":{"categories":[{"category_id":138,"category_name":"Information Technology","weight":49.67100025713444},{"category_id":146,"category_name":"Communication Services","weight":15.847999960184097},{"category_id":149,"category_name":"Semiconductors","weight":15.213999941945076},{"category_id":142,"category_name":"Consumer Discretionary","weight":14.063999943435192},{"category_id":173,"category_name":"Systems Software","weight":11.357000350952148},{"category_id":153,"category_name":"Technology Hardware, Storage & Peripherals","weight":11.053999900817871},{"category_id":147,"category_name":"Interactive Media & Services","weight":9.871000051498413},{"category_id":148,"category_name":"Broadline Retail","weight":7.1799998208880424},{"category_id":139,"category_name":"Appli
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
@emresaracoglu
emresaracoglu / Encryption.js
Created June 28, 2020 18:13 — forked from ve3/Encryption.js
Encrypt and decrypt between programming languages (PHP & JavaScript).
/**
* Encryption class for encrypt/decrypt that works between programming languages.
*
* @author Vee Winch.
* @link https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs Reference.
* @link https://github.com/brix/crypto-js/releases crypto-js.js can be download from here.
*/
class Encryption {
@emresaracoglu
emresaracoglu / gist:46271cfd25a64930db06ffb4aaa3526d
Last active September 8, 2022 15:00 — forked from icanhazstring/gist:71d974a58d2f35e8abc8
Install zmq centos 7 and PHP Extension
## install
yum install zeromq-devel
## install zmq.so
cd ~
git clone https://github.com/zeromq/php-zmq.git
cd php-zmq
phpize && ./configure
make && make install
@emresaracoglu
emresaracoglu / nginx-tuning.md
Created June 10, 2018 11:26 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@emresaracoglu
emresaracoglu / curl-post.php
Created May 12, 2018 18:50 — forked from lesstif/curl-get.php
PHP CURL POST example
<?php
class Log {
public static function debug($str) {
print "DEBUG: " . $str . "\n";
}
public static function info($str) {
print "INFO: " . $str . "\n";
}
public static function error($str) {
@emresaracoglu
emresaracoglu / db-connect-test.php
Created December 2, 2017 08:08 — forked from M165437/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@emresaracoglu
emresaracoglu / gist:35e0181b42aadd118862ee253fa69343
Created May 9, 2017 10:44 — forked from erikjung/gist:3079806
PHP 5.4 Namespace-based Autoloader
<?php
// Probably unnecessary, but wanted to test the waters of 5.4
trait NamespaceConverter
{
function nsToPath($class) {
return str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
}
}
@emresaracoglu
emresaracoglu / Autoloader.php
Created May 8, 2017 23:17 — forked from Nilpo/Autoloader.php
A simple recursive PHP autoloader using the RecursiveDirectoryIterator.
<?php
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Rob Dunham
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@emresaracoglu
emresaracoglu / download.php
Created May 4, 2017 09:21 — forked from brasofilo/download.php
Force File Download with PHP
<?php
/*
* Foce File Download
* Usage: http://example.com/download.php?file=./uploads/image.jpg
*
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary
*
*/
// grab the requested file's name