Skip to content

Instantly share code, notes, and snippets.

View telless's full-sized avatar

Viktor telless

  • Russia, Moscow
View GitHub Profile
@telless
telless / BooleanHelper.php
Last active November 28, 2018 11:07
Yii2-style bool-checker
<?php
abstract class BooleanHelper
{
public static function equalTrue($value): bool
{
return self::process($value) === self::getTrueValue();
}
public static function notEqualTrue($value): bool
<?php
abstract class Calculatable
{
const SUBTRACT_ACTION = 'subtract';
const SUBTRACT_SYMBOL = '-';
const ADD_ACTION = 'add';
const ADD_SYMBOL = '+';
public function add(Calculatable $child): Calculatable
@telless
telless / OtpState.php
Created March 23, 2018 09:51
Example symfony entity without typical getter\setter boilerplate
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
/**
* Class OtpState
* @package AppBundle\Entity
<?php
$a = [1, 1, 1, 2, 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6];
$count = [];
foreach ($a as $v) {
if (isset($count[$v])) {
unset($count[$v]);
} else {
$count[$v] = true;
}
<?php
class ODList
{
/** string $name */
public $name;
/** ODList|null $next */
public $next;
<?php
class FooParent
{
}
class Foo extends FooParent
{
}
<?php
class A
{
public $prop;
public function __construct()
{
$this->prop = 'prop';
}
function isBalanced(str) {
const strArr = str.split('');
let balanced = true;
let stack = [];
const len = strArr.length;
for (i = 0; i < len; i++) {
switch (strArr[i]) {
case '{':
package main
import (
"bytes"
"fmt"
"strconv"
"time"
)
func lPrint(ch chan string, delay time.Duration) {
@telless
telless / xdebug.ini
Last active April 12, 2017 07:19
Typical xdebug config
zend_extension=xdebug.so
; Enable remote mode
xdebug.remote_enable=1
; Autostart on every request
xdebug.remote_autostart=1
; Autodetect requester IP
xdebug.remote_connect_back=1
; Set remote port
xdebug.remote_port=9000
; Usually work even without it