Skip to content

Instantly share code, notes, and snippets.

View mkorkmaz's full-sized avatar

Mehmet Korkmaz mkorkmaz

View GitHub Profile
@mkorkmaz
mkorkmaz / DetermineDSNForPDO.php
Last active December 12, 2015 06:28
Determine dsn string for PDO to connect multiple nodes. If one node is down, removes it ASAP ( in this script it takes max 15 secs )
<?php
class DetermineDSNForPDO{
public $dsn = '';
public $system_failover = FALSE;
@mkorkmaz
mkorkmaz / model_utils.py
Last active March 15, 2016 06:09
A simple python class for validating, variable type fixing and setting defaults for a model definition encoded as a dict. It may be useful when you use schemaless databases.
#!/usr/bin/env python3.5
# -*- coding: utf-8 -*-
# author: [email protected]
# created: 2016-03-11
# A simple class for validating, variable type fixing and setting defaults
# for a model definition encoded as a dict
class ModelUtils:
@mkorkmaz
mkorkmaz / model_utils.php
Last active March 15, 2016 06:48
A simple PHP class for validating, variable type fixing and setting defaults for a model definition encoded as a array. It may be useful when you use schemaless databases.
/*
* ModelUtils: A simple PHP class for validating, variable type fixing and setting defaults for a model definition encoded as a array
*
* @ver: 0.0.2
* @author: [email protected]
* created at: 2016-03-13
* updated at: 2016-03-15
*/
class ModelUtils {
@mkorkmaz
mkorkmaz / _design_doc.txt
Created April 27, 2016 06:34
CouchDB readonly database design document.
# set validate_doc_update value as:
function(newDoc, oldDoc, userCtx, secObj) {
var ddoc = this;
secObj.admins = secObj.admins || {};
secObj.admins.names = secObj.admins.names || [];
secObj.admins.roles = secObj.admins.roles || [];
var IS_DB_ADMIN = false;
if(~ userCtx.roles.indexOf('_admin')){
IS_DB_ADMIN = true;
@mkorkmaz
mkorkmaz / .travis.yml
Created June 28, 2016 14:16
Testing your code with Elasticseach 2 on TravisCI
language: php
sudo: false
jdk:
- oraclejdk8
addons:
apt:
packages:
- oracle-java8-installer
php:
- 7.0
@mkorkmaz
mkorkmaz / check_ssl_enabled_url.php
Last active October 11, 2016 19:29
Redirect non-secure requests to ssl enabled url for Cloudflare Flexible SSL enabled domains using PHP.
<?php
if (empty($_SERVER["HTTP_CF_VISITOR"]) || $_SERVER["HTTP_CF_VISITOR"] != '{"scheme":"https"}') {
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}

Keybase proof

I hereby claim:

  • I am mkorkmaz on github.
  • I am mkorkmaz (https://keybase.io/mkorkmaz) on keybase.
  • I have a public key whose fingerprint is ACD4 DCE4 7A8C FFD6 E711 FFAD 24D6 90DF 8DB2 C093

To claim this, I am signing this object:

@mkorkmaz
mkorkmaz / pypi.sh
Last active February 21, 2017 13:56
Submit your package to PyPI
# create ~/.pypirc if does not exist
touch ~/.pypirc
echo "[distutils]" >> ~/.pypirc
echo "index-servers=pypi" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[pypi]" >> ~/.pypirc
echo "repository: https://pypi.python.org/pypi" >> ~/.pypirc
echo "username = pypi_username" >> ~/.pypirc
echo "password = pypi_password" >> ~/.pypirc
@mkorkmaz
mkorkmaz / .htaccess
Created May 23, 2017 09:45
Apache redirect according to date.
RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} > 20170523
RewriteRule ^$ /destination/url.html [R=301,L]
@mkorkmaz
mkorkmaz / bitbucket-pipelines.yml
Last active June 18, 2018 01:24
Bitbucket pipeline example for PHP 7.1 + MongoDB + Memcached + Codeception
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.1
pipelines:
default:
- step:
caches:
- composer
script: