Skip to content

Instantly share code, notes, and snippets.

View omerucel's full-sized avatar
🎯
Focusing

Ömer ÜCEL omerucel

🎯
Focusing
View GitHub Profile
@omerucel
omerucel / bulk_insert.php
Created August 11, 2013 15:13
a function to generate bulk insert sql query for PDO.
<?php
function createBulkInsertSql($sql, $rowCount, $columnSize = 1) {
$rowCount = intval($rowCount);
$columnSize = intval($columnSize);
$columnMarker = array_fill(0, $columnSize, '?');
$rowValues = array_fill(0, $rowCount, '(' . implode(',', $columnMarker) . ')');
$sql .= ' VALUES' . implode(',', $rowValues);
return $sql;
}
@omerucel
omerucel / README.md
Last active December 25, 2015 21:39
rjsmin and rcssmin sample file for fabric

Bu örnekteki fabfile.py dosyası ile statik dosyaları (JS ve CSS) küçültebilir ve tek bir dosya halinde sunabilirsiniz. Bu kodları ben bir Django projesi için kullandım. Ancak kodlar genel kullanıma yönelik güncellenebilir ve farklı projeler için de hazır hale getirilebilir.

project_folder
  appname
    static
  fabfile.py

Aşağıdaki komut project_folder/appname dizini altında css_version.py ve js_version.py dosyalarını oluşturur (varsa üzerine yazar)

@omerucel
omerucel / fabfile.py
Last active December 25, 2015 23:09
fabfile deployment
#-*- coding: utf-8 -*-
from fabric.api import *
from fabric.contrib.files import exists
from rjsmin import jsmin
from rcssmin import cssmin
import time
timestamp = int(time.time())
@omerucel
omerucel / settings_phpcs.json
Last active December 28, 2015 12:19
Sublime text settings files.
{
"phpcs_executable_path": "/Users/omer/.composer/vendor/bin/phpcs",
"phpcs_linter_run": true,
"phpcs_php_path": "/usr/bin/php",
"phpcs_additional_args": {
"--standard": "PSR2",
"-n": ""
}
}
@omerucel
omerucel / Config.php
Created March 3, 2014 00:00
Config class with dot notation support.
<?php
/**
* $configs = array(
* 'app' => array(
* 'tmp_dir' => '/tmp',
* 'db' => array(
* 'database' => 'abc
* )
* )
<?php
$jobHandles = [];
foreach ($jobs as $job) {
$jobHandles[] = $this->getGearmanClient()->doBackground('work', json_encode($job));
}
do {
$jobHandleCount = count($jobHandles);
if ($jobHandleCount == 0) {
@omerucel
omerucel / Test.php
Created July 18, 2014 11:23
PHPUnit test case for protected methods
<?php
namespace Application\Service;
use Application\Model\Service;
use Application\Model\User;
class ServiceValidatorTest extends \PHPUnit_Framework_TestCase
{
/**
#!/usr/bin/perl -s
#
# solo v1.6
# Prevents multiple cron instances from running simultaneously.
#
# Copyright 2007-2013 Timothy Kay
# http://timkay.com/solo/
#
# It is free software; you can redistribute it and/or modify it under the terms of either:
#
@omerucel
omerucel / backup.sh
Last active August 29, 2015 14:05
backup & recovery script
#!/bin/bash
CURRENT_DIR=$(date +"%Y-%m-%d-%H-%M-%S")
ROOT=/media/omer/YEDEK/backup/$CURRENT_DIR
PATHS=()
PATHS+=(/home/omer/AndroidKeys)
PATHS+=(/home/omer/AndroidProjects)
PATHS+=(/home/omer/Apps)
PATHS+=(/home/omer/Documents)
PATHS+=(/home/omer/Music)
@omerucel
omerucel / app.php
Created March 12, 2015 14:40
PHP Expect example
<?php
ini_set("expect.timeout", -1);
ini_set("expect.loguser", "Off");
$stream = expect_popen('php cmd.php');
while (true) {
switch (expect_expectl ($stream, array (
array ('Filename : ', 'filename')
))) {