Skip to content

Instantly share code, notes, and snippets.

View Koc's full-sized avatar
🇺🇦
Donate to United24 or Come Back Alive

Konstantin Myakshin Koc

🇺🇦
Donate to United24 or Come Back Alive
  • METRO Markets GmbH
  • Ukraine, Kyiv
  • X @myakshin
View GitHub Profile

Some rules

Configs exist in three levels:

  1. local
  2. dev | stg | prod
  3. default (no environment)

There are three types of configs:

@Koc
Koc / Doctrine MongoDB ODM Tail Cursor Command Daemon
Created April 23, 2011 14:01 — forked from jwage/Doctrine MongoDB ODM Tail Cursor Command Daemon
This is a Symfony2 Doctrine MongoDB ODM Tail Cursor console command. It can be ran as a daemon and it will tail a mongodb collection with a tailable cursor and process the documents with a given service as the "processor". You must specify the document, t
<?php
namespace MyCompany\Bundle\MyBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpFoundation\Request;
@Koc
Koc / bijective.php
Created March 26, 2012 12:56 — forked from xeoncross/bijective.php
URL shortener
<?php
class Bijective
{
public $dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public function __construct()
{
$this->dictionary = str_split($this->dictionary);
}
@Koc
Koc / gist:5812828
Last active December 18, 2015 16:39 — forked from anonymous/gist:5803875
/usr/local/bin/fake-sendmail
#!/usr/bin/php
<?php
$processUser = posix_getpwuid(posix_geteuid());
$name = $processUser['dir'].'/mail/'.date('Y-m-d H:i:s').'-'.microtime(true).'.eml';
if (!is_dir($dir = dirname($name))) {
mkdir($dir, 0777, true);
}
$fh = fopen($name, "w");
if (!$fh) {
die(1);
// An example controller binded to the form
function FormCntl($scope, $compile) {
// Consider using FosJsRouting bundle, if you want to use a Symfony2 route
$scope.formUrl = "http://url-to-fetch-my-form";
// Data from the form will be binded here
$scope.data = {};
// Method called when submitting the form
$scope.submit = function() {
@Koc
Koc / Table.php
Created March 12, 2016 10:37 — forked from IvanChepurnyi/Table.php
Optimized options load
<?php
/**
* Optimized version of attribute source options model
*
* That allows to preload options once and reuse them instead of doing calls to db all the time
*
*/
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table
extends Mage_Eav_Model_Entity_Attribute_Source_Table
@Koc
Koc / run_script.bat
Created September 21, 2017 15:05 — forked from zhuzhuor/run_script.bat
Batch file to run a Python script in the same folder
@ECHO off
set "script_path=%~dp0"
set "script_path=%script_path%my_script.py"
python %script_path% %*
@Koc
Koc / bin > drun
Created March 20, 2018 15:09 — forked from jakzal/bin > drun
Docker with Symfony, RabbitMQ, Nginx
#!/bin/bash
set -e
set -u
set -o pipefail
COMMAND=${1:-"help"}
MACHINE_NAME=myapp
DENV=${DENV:-"dev"}