Skip to content

Instantly share code, notes, and snippets.

View o's full-sized avatar
🔥
deleting code

Osman o

🔥
deleting code
View GitHub Profile
@o
o / PDO_Singleton.php
Created November 22, 2010 16:30
Singleton PDO Class, needs PHP 5.3
<?php
class PDO_Singleton {
private static $instance;
public static function getInstance() {
if (!(self::$instance instanceof PDO)) {
self::$instance = new PDO('mysql:dbname=test;host=127.0.0.1', 'root', 'root', array(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
}
@o
o / LimitIterator.php
Created December 22, 2010 14:08
Sample of using PHP SPL Limit Iterator, you can use for the limiting cached objects
<?php
/**
* Creating dummy data for pagination
*/
$result = array();
for ($i = 0; $i < 100; $i++) {
$result[$i]['age'] = rand(18, 50);
$result[$i]['facebook_id'] = rand(1000000, 9999999);
}
@o
o / gist:1156255
Created August 19, 2011 07:22
Homebrew mongo-php 1.2.3 verbose installation output
osman@Osman-Ungurs-MacBook-Work:~
> sudo brew install mongo-php -v
==> Downloading http://pecl.php.net/get/mongo-1.2.3.tgz
File already downloaded in /Library/Caches/Homebrew
/usr/bin/tar xf /Library/Caches/Homebrew/mongo-php-1.2.3.tgz
==> phpize
phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
@o
o / gist:1162441
Created August 22, 2011 14:00
Git push failed
> git push origin dev
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 306 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: /data/github/current/lib/github/config/failbot.rb:5: undefined method `setup' for Failbot:Module (NoMethodError)
remote: from /data/github/current/config/basic.rb:168:in `require'
remote: from /data/github/current/config/basic.rb:168
remote: from hooks/post-receive:13:in `require'
@o
o / gist:1946396
Created March 1, 2012 01:11
Doctrine 2 Query Profiler
<?php
class Profiler implements Doctrine\DBAL\Logging\SQLLogger {
private $start;
private $sql;
private $params;
private $types;
public function startQuery($sql, array $params = null, array $types = null) {
$this->sql = $sql;
@o
o / gist:2116905
Created March 19, 2012 15:49
Localized date time example
<?php
// Check your supported locales with $ locale -a
setlocale(LC_TIME, 'tr_TR.UTF-8');
echo strftime("%d %B %Y %A");
// 19 Mart 2012 Pazartesi
@o
o / User.php
Created May 3, 2012 18:51
A sample user entity with Doctrine 2
<?php
namespace Import\Bundle\TestBundle\Entity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
@o
o / phpist-ardindan.md
Created July 8, 2013 08:22
php-ist '13 ardindan

Merhabalar,

Oncelikle php-ist sunumuna katilan herkese cok tesekkurler. Oldukca kalabalik bir toplulukla beraber olmak hem dinleyiciler hemde konusmacilar icin guzel bir motivasyon oldu. Sunum aralarinda cok guzel sohbetler yapildi, harika insanlarla tanisma firsatim oldu.

Bu organizasyonda konusmaci olmamda konularin citasinin yuksek olmasinin buyuk etkisi vardi. Monolitik konulardan ote insanlari daha kaliteli isler yapmaya yonelten konulara deginildi ve dinleyiciler bundan oldukca keyif aldi. Bundan sonra yapilacak benzer bir etkinlikte de bu seviyenin korunmasini dilerim. Laravel, Jenkins, Doctrine, olceklenebilirlik gibi konular oldukca guzel olurdu. Sektorde kabul gormus bir teknolojinin daha fazla anlatilmaya, dogrularin, yanlislarin neler oldugunun daha fazla sekilde gosterilmeye ve anlatilmaya ihtiyaci var. Ben de insanlarin daha guzel seyler yapabilecegi bir teknolojiyi anlatmaktan buyuk mutluluk duydum.

Organizasyonun tek gun ve tek salonda olmasida oldukca iyi oldu, zira insanlar bolunmedi, t

@o
o / community-bundle.md
Created July 8, 2013 12:36
ImportCommunityBundle

I need your help guys. This is the short brief for the our community driven project like Google groups. My goal is the made done this with Symfony2 Standard Edition.

Features:

  • Clean, minimalistic layout.
  • Question / answer system.
  • User login / registration.
  • Filters for questions: Topics i started, Topics i answered, Topics i participated, Nobody replied, Modified within date, Started within date, marked as complete.
  • Powerful search (Will be done with ElasticSearch or something like that)
  • Email features: Instant emails for new topics, instant emails for new answers, Daily summaries, replying topic through email. (Emails will be queued to RabbitMq and processed)
@o
o / example.com.conf
Created August 4, 2013 00:48
Symfony2 Nginx Configuration (For production)
upstream php5-fpm-sock {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name domain.com;
root /path/to/domain.com/public_html/web/;
charset utf-8;