Skip to content

Instantly share code, notes, and snippets.

View kix's full-sized avatar

Stepan Anchugov kix

View GitHub Profile
@kix
kix / FixtureTestCase.php
Created July 7, 2011 09:33
Тест-кейс с полуавтоматической подгрузкой фикстур
<?php
/**
* @author kix <kix@kixlive.ru>
*/
use Doctrine\Common\DataFixtures\Loader;
/**
*
* Тест-кейс с полуавтоматической подгрузкой фикстур
@kix
kix / mysql2
Created July 12, 2011 06:26
MySQL in RamFS second instance init script
#!/bin/sh -e
# RamFS stuff ===========================================================
#sudo su
if [ ! -d "/mnt/ram/mysql" ]; then
mkdir /mnt/ram/mysql
mkdir /etc/mysql2/
ln -s /mnt/ram/mysql/ /etc/mysql2/
cp -R /etc/mysql/* /etc/mysql2/
@kix
kix / pre-commit.sh
Created November 28, 2011 05:46
PHP CodeSniffer pre-commit hook for git
#!/bin/bash
# PHP CodeSniffer pre-commit hook for git
#
# @author Soenke Ruempler <soenke@ruempler.eu>
# @author Sebastian Kaspari <s.kaspari@googlemail.com>
#
# see the README
PHPCS_BIN=/usr/bin/phpcs
PHPCS_CODING_STANDARD=PEAR
@kix
kix / gist:1399880
Created November 28, 2011 10:19
Get all files modified by you
# will fail if you have commit comments containing '.php'
git log --author="<Your Name>" --stat=1000,1000 | grep '\S*\/.*\.php' | sed 's/|.*//' | sed 's/\s*//'
@kix
kix / twig-ref.textile
Created January 31, 2012 10:39
Twig reference

Twig is the Chyrp templating engine. It is authored by Armin Ronacher, who was generous enough to jump on the chance to build us a templating engine. The syntax in general is “similar to the Genshi text templates which in turn were inspired by Django which also inspired Jinja (all three of them python template engines) which inspired the Twig runtime environment.”

Twig’s Purpose

A language independent and simple template engine is useful for applications that use code which is written in more than one programming language. Good Examples are portal systems which use a blog written in Ruby, a forum software written in PHP and a planet system written in Python.

While it was written for Chyrp exclusively, you should fairly easily be able to use it in any other system you want to use it in. Currently there is only one implementation, and that is in PHP. If you want to port it to another language, a spec sheet can be found in /includes/class/Twig/spec.html.

Terminology

@kix
kix / PSR-Cache.md
Created May 3, 2012 07:06
Proposed PSR cache

Introduction

Caching is a common way to improve the performance of any project, making caching libraries one of the most common features of many frameworks and libraries. This has lead to a situation where many libraries roll their own caching libraries, with various levels of functionality. These differences are causing developers to have to learn multiple systems which may or may not provide the functionality they need. In addition, the developers of caching libraries themselves face a choice between only supporting a limited number of frameworks or creating a large number of adapter classes.

@kix
kix / deploy.rb
Created May 28, 2012 14:21
Capifony deploy with Composer (c) @iDotsent
set :application, "Partner cabinet"
set :domain, "domain"
set :deploy_to, "/app/name"
set :app_path, "app"
set :repository, "ssh://git@somewhere.com/project.git"
set :scm, :git
set :model_manager, "doctrine"
@kix
kix / multistage.md
Created May 29, 2012 07:18
Capistrano multistage

Capistrano's multistage extension provides an easy way to use a different deployment strategy for different scenarios. For instance, for your application, you might have two servers: one for production, where the "live" code is, and one for staging, where you can test features out without risk of affecting anything critical. Certain deployment values, such as the application name, UNIX user and group, and application environment might be the same, but other values might be different, such as the location of the server itself or the SCM repository branch. Instead of repeating code in your Capfile, you can use multistage to set the values which are different in separate files, and only load those files at runtime.

This article will walk you through installing and using the multistage extension. We're going to use the example we mentioned earlier, where we have a production server and a staging server. So naturally, we would like two deployment stages, production and staging. We also assume you're creating an a

@kix
kix / chart.html
Created July 3, 2012 11:27
Highcharts with custom HTML/CSS buttons
<div class="zoom_controls">
<span><?php echo $this->tr('Zoom:')?></span>
<a href="#" data-chart="line" data-range="1m">1m</a>
<a href="#" data-chart="line" data-range="3m">3m</a>
<a href="#" data-chart="line" data-range="6m">6m</a>
<a href="#" data-chart="line" data-range="1y">1y</a>
<a href="#" data-chart="line" data-range="Ytd">YTD</a>
<a href="#" data-chart="line" data-range="All">All</a>
</div>
@kix
kix / Autoload.php
Created September 5, 2012 07:50
Yii WTFs
/**
* Registers a new class autoloader.
* The new autoloader will be placed before {@link autoload} and after
* any other existing autoloaders.
* @param callback $callback a valid PHP callback (function name or array($className,$methodName)).
* @param boolean $append whether to append the new autoloader after the default Yii autoloader.
*/
public static function registerAutoloader($callback, $append=false)
{
if($append)