Skip to content

Instantly share code, notes, and snippets.

View you-think-you-are-special's full-sized avatar
:octocat:
Coding...

Aleksandr Litvinov you-think-you-are-special

:octocat:
Coding...
View GitHub Profile
<?php
trait GetterSetter
{
public function __get($name)
{
$getter = 'get' . ucfirst($name);
if ( ! method_exists($this, $getter) )
{
throw new \Exception('Not found getter for property - ' . $name);
}
<?php
class RedisSessionHandler implements \SessionHandlerInterface{
public $ttl = 1800; // 30 minutes default
protected $db;
protected $prefix;
public function __construct(Predis\Client $db, $prefix = 'PHPSESSID:') {
@you-think-you-are-special
you-think-you-are-special / DS.php
Created July 17, 2013 07:25
DIRECTORY_SEPARATOR
<?php defined('DS') or define('DS', DIRECTORY_SEPARATOR); ?>
<?php
protected function checkMethodExists($method)
{
if (!method_exists($this, $method))
throw new CException("Method CController::{$method}() not found");
}
?>
<?php
foreach(Yii::app()->user->getFlashes() as $key => $message) {
echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
}
?>
kill -9 $(lsof -t -i :9000)
/**
* Created by alexander on 24.02.14.
*/
var mongoose = require('mongoose')
, Schema = mongoose.Schema;
var User = new Schema({
name: String,
created: {type: Date, default: Date.now}
});
<?php
trait Singleton
{
protected static $instance;
protected function __construct()
{
static::setInstance($this);
}
<?php
trait Options {
public function setOptions(array $options)
{
// apply options
foreach ($options as $key => $value) {
$method = 'set' . $this->normalizeKey($key);
if (method_exists($this, $method)) {
$this->$method($value);
server{
listen 80;
server_name example.com;
access_log /home/path_to_site/access.log;
error_log /home/path_to_site/error.log;
location / {
proxy_pass http://0.0.0.0:8002;
proxy_set_header Host $host;