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
function hasClass(ele,cls) {
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
if (!this.hasClass(ele,cls))
ele.className += " "+cls;
}
function removeClass(ele,cls) {
function anchorEventer(baseUrl)
{
if (baseUrl) {
anchorEventer.oldUrl = baseUrl;
}
if (!anchorEventer.oldUrl) {
anchorEventer.oldUrl = document.location.href;
}
return {

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 / 1.php
Created September 21, 2011 19:34
<?php
namespace Ololo\Bundle\UsersBundle\Service;
use Doctrine\ORM\EntityManager;
use Ololo\Bundle\UsersBundle\Entity\User;
use Ololo\Bundle\UsersBundle\Entity\Friendship;
use Ololo\Bundle\UsersBundle\Event\FriendshipSuccessEvent;
<?php
$userVariable = array(
'max_riders_on_trip' => 50,
'has_bycicle' => 1,
'has_rollers' => 0,
'has_snowboard' => 1,
'invite_users' => 27,
);
<?php
namespace Ololo\Bundle\BadgesBundle\Entity;
use Doctrine\ORM\EntityRepository;
class BadgeRepository extends EntityRepository
{
public function getInfoAboutBadge($id, $locale)
{
@Koc
Koc / gist:1501185
Created December 20, 2011 10:50
start-stop-daemon php example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
NAME="brouzie-php-53"
RUN_AS_USER=brouzie
PHP_FCGI_CHILDREN=3
PHP_FCGI_MAX_REQUESTS=200
@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:3016704
Created June 29, 2012 08:42
Doctrine2 DISTANCE function
<?php
namespace Myako\Geographical\Functions;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
/**
* "DISTANCE" "(" LatitudeFrom, LongitudetFrom, LatitudeTo, LongitudeTo ")"
*