Skip to content

Instantly share code, notes, and snippets.

View hkulekci's full-sized avatar
⛰️
Remote

Haydar KÜLEKCİ hkulekci

⛰️
Remote
View GitHub Profile
@hkulekci
hkulekci / PHPUnit way to mock Doctrine2 Entity Manager.php
Last active August 26, 2015 03:48 — forked from wowo/PHPUnit way to mock Doctrine2 Entity Manager.php
PHPUnit's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = $this->getMock('\Doctrine\ORM\EntityManager',
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false);
$emMock->expects($this->any())
->method('getRepository')
@hkulekci
hkulekci / ceil.py
Created May 7, 2014 13:53
Ceil Method Usage Example
>>> from math import ceil
>>> ceil(1.3)
2.0
>>>
>>>
>>> ceil(1.00002)
2.0
>>> ceil(48/45)
1.0
>>> 48/45
<?php
// http://www.elasticsearch.com/docs/elasticsearch/rest_api/
class ElasticSearch {
public $index;
function __construct($server = 'http://127.0.0.1:9200'){
$this->server = $server;
}
@hkulekci
hkulekci / gist:22b08cb21f96f935e822
Created June 5, 2014 20:47
My Sublime Settings
{
"translate_tabs_to_spaces": true,
"tab_size": 4,
"rulers": [80, 120],
"caret_style": "phase",
"match_brackets_angle": true,
"trim_trailing_white_space_on_save": true,
"fallback_encoding": "UTF-8",
"show_encoding": true,
"show_line_endings": true,
@hkulekci
hkulekci / mail_signature.html
Created June 12, 2014 07:23
Mail Signature
<p style="font-size:13px;font-family:tahoma,sans-serif;">
<font style="color:#333333;font-weight:bold;">
Haydar KÜLEKCİ
</font>
<br/>
<font color="#548DD4">
@kulekci - @somedya
</font>
</p>
import argparse
import zmq
from time import sleep
parser = argparse.ArgumentParser(description='zeromq server/client')
parser.add_argument('--bar')
args = parser.parse_args()
if args.bar:
count = 0
@hkulekci
hkulekci / test.php
Created August 18, 2014 17:24
form post
// form field separator
$delimiter = '-------------' . uniqid();
// file upload fields: name => array(type=>'mime/type',content=>'raw data')
$fileFields = array(
'file1' => array(
'type' => 'text/plain',
'content' => '...your raw file content goes here...'
), /* ... */
);
// all other fields (not file upload): name => value

CamServer

Testing on Ubuntu 12.04.4 x64.

Install to your system Pygame requirement

sudo apt-get install python-opencv python-pygame

Python Magic Methods

Construction and Inıtıalization

__new__ : First run this methos when the class object is created!

__init__ : Construtor of a class. You can send parameter to your class with __init__ method.

__del__ : Deconstructor method of the class. But this method is not secure to use a garbage collector. It is not guarantee when the object is deleted.

@hkulekci
hkulekci / subtitle.py
Last active August 29, 2015 14:06
subtitle encoding fix
#!/usr/bin/python
# coding=utf-8
import os
import sys
import codecs
args = sys.argv
file = ""
encoding = 'iso-8859-9'
if len(args) == 2: