Skip to content

Instantly share code, notes, and snippets.

View chernomyrdin's full-sized avatar

Andrey Chernomyrdin chernomyrdin

  • Saint-Petersburg
View GitHub Profile
@chernomyrdin
chernomyrdin / template.php
Created November 21, 2012 10:00
Small template engine for PHP
<?php
class Template {
private $vars = array();
private $file = null;
function __construct ($file = null, $vars = null) {
$this->file = $file;
if (!is_null($vars)) {
$this->vars = $vars;
@chernomyrdin
chernomyrdin / if_grep.pl
Created July 5, 2013 08:24
Operator if
#!/usr/bin/perl -w --
use strict;
use Benchmark;
my $num = 3;
my $match = 0;
timethese( 1e8, {
just_if => sub {
if ($num == 0 or $num == 1 or $num == 2 or $num == 3 or $num == 4 or $num == 5) {
/**
* @output_file_name default.js
* @compilation_level ADVANCED_OPTIMIZATIONS
* @formatting pretty_print
*/
/**
* Sample location parameter access classs
*/
@chernomyrdin
chernomyrdin / Replacer.php
Created May 27, 2014 14:30
Replace substring, append some string demo for preg_replace_callback
<?php
class Replacer {
private static $__instance;
private $regex = '';
private $append = '';
private $replace = array(
'ул' => 'улица',
'ш' => 'шоссе',
@chernomyrdin
chernomyrdin / pg_listen.php
Created March 11, 2015 12:49
Using LISTEN/NOTIFY PostgreSQL in PHP (async/pool mode)
<?php
/**
* Class Main - Проверяем возможность работы с LISTEN/NOTIFY в PostgreSQL
* Вывод: Подобное возможно только начиная с PHP 5.6, так как только там появилась функция pg_socket($dbh)
* Так-же демонстрируется возможность работать по опросу, что менее удобно, но это лучше чем ничего
*/
class Main {
/**
@chernomyrdin
chernomyrdin / sample-phar.php
Created March 16, 2015 13:25
Make phar from laravel app
<?php
class UserFilter extends FilterIterator {
public function accept () {
$file = $this->getInnerIterator()->current();
$path = explode("/", $file, 3);
if (count($path) < 2 or !in_array($path[1], array('app','bootstrap','vendor'))) return FALSE;
elseif ("/." == substr($file, -2)) return FALSE;
elseif ("/.." == substr($file, -3)) return FALSE;
# echo $file, PHP_EOL;

Keybase proof

I hereby claim:

  • I am chernomyrdin on github.
  • I am chernomyrdin (https://keybase.io/chernomyrdin) on keybase.
  • I have a public key ASCq-emI1BAZyD5J-aF5Mb0SlfgYDaMb3J6_aaqKqFU1AQo

To claim this, I am signing this object:

@chernomyrdin
chernomyrdin / expr.go
Last active September 27, 2019 18:26
package qb
import (
"io"
"strconv"
"strings"
)
const PlaceHolder = "?"