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 / 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 / expr.go
Last active September 27, 2019 18:26
package qb
import (
"io"
"strconv"
"strings"
)
const PlaceHolder = "?"

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 / 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) {
@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 / autoload.pl
Created November 19, 2012 07:30
Simple auloload
#!/usr/bin/perl -w --
use strict;
use warnings;
use diagnostics;
sub new {
my $class = shift;
my $obj;
@chernomyrdin
chernomyrdin / one_item.pl
Created November 15, 2012 08:36
Get one item from hash
#!/usr/bin/perl -w --
use strict;
use Benchmark;
my %hash;
for (1..1e4) {
my $key = join($_, "*" x (10*rand), (10*rand));
$hash{$key} = "*" x (100*rand);
@chernomyrdin
chernomyrdin / test_hash.pl
Created November 14, 2012 11:17
test for non empty hash
#!/usr/bin/perl -w --
use strict;
use Benchmark;
my %hash;
for (1..1e6) {
my $key = join($_, "*" x (10*rand), "*" x (10*rand));
@chernomyrdin
chernomyrdin / Dummy.hx
Created January 20, 2012 10:44
Simple Haxe file
package ;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
import flash.Lib;
class Dummy extends MovieClip {
private static var _ready:Bool = false;
@chernomyrdin
chernomyrdin / bloger-float.js
Created December 16, 2011 00:53
Bloger Float button
function share42 (f,u,t,m1,m2) {
if (!u) {
u = location.href;
}
u = encodeURIComponent(u);
if (!t) {
t = document.title;
}
t = encodeURIComponent(t);