Skip to content

Instantly share code, notes, and snippets.

View gotterdemarung's full-sized avatar

Антон Дорофеев gotterdemarung

View GitHub Profile
@gotterdemarung
gotterdemarung / traversable.php
Created October 11, 2013 12:04
Unexpected Traversable behavior
<?php
echo 'Declaring interface: ';
interface T extends Traversable {}
echo 'OK' . PHP_EOL;
echo 'Abstract class with right interfaces order:';
abstract class A implements Iterator, T {} // OK
echo 'OK' . PHP_EOL;

Keybase proof

I hereby claim:

  • I am gotterdemarung on github.
  • I am gotterdemarung (https://keybase.io/gotterdemarung) on keybase.
  • I have a public key whose fingerprint is 6BFC 1BAB DB74 9EB1 A8AA 1614 78C9 4F8C 737A 2ABD

To claim this, I am signing this object:

@gotterdemarung
gotterdemarung / local.md
Last active August 29, 2015 14:05
Local Context

Point

Бизнес логика компоненты должна во время работы использовать исключительно данные локального контекста:

  • Входящие аргументы
  • Внутренние свойства компоненты

Не являющимися локальными считаются данные, полученные:

  • Из глобальных переменных
  • Из суперглобальных массивов
  • Из классов (статика)
func GetParser () KeyParser {
compiledRegex := regexp.MustCompile("^([a-z0-9\\-_]*)\\+([a-z\\-]*)://(.+)")
return func(addr string) (*Key, error) {
matches := compiledRegex.FindStringSubmatch(addr)
if len(matches) != 4 {
return nil, fmt.Errorf("Wrong Eos tracking address format \"%s\"", addr)
}
<?php
namespace Maxwell\Cache;
/**
* Class PhpLruCache
*
* Inner node has following structure (it is stdClass)
* until -> expiration time or null
* key -> key
<?php
namespace Maxwell\Cache;
class PhpNativeLruCache implements CacheInterface, \Countable
{
private $capacity;
private $ttl;
private $map = [];
@gotterdemarung
gotterdemarung / gist:fe9410d83637bc4f80ea7ed1b35574c7
Last active February 16, 2017 11:48
Curl response time check
$ cat curl-format-short.txt
(dns,con,app,pre,start,total): %{time_namelookup},%{time_connect},[%{time_appconnect}],%{time_pretransfer},%{time_starttransfer},%{time_total} - %{http_code}\n
$ while true; do echo -n `date +"[%m-%d %H:%M:%S]"` && curl -w "@curl-format-short.txt" -o /dev/null -s <address>; done
@gotterdemarung
gotterdemarung / cleanmac.sh
Created April 21, 2017 10:58
Script to clean caches and trash on MacOS
#!/bin/bash
CACHES=~/Library/Caches
echo -e "🔔 \033[0;33mCurrent disk usage\033[0m"
df -h
echo -e "🔔 \033[0;33mCaches folder $CACHES\033[0m"
echo -e "🔔 \033[0;33mRemoving brew caches\033[0m"
@gotterdemarung
gotterdemarung / cas.go
Created May 3, 2017 08:00
Compare-and-swap VS mutex
package util
import (
"sync"
"sync/atomic"
"testing"
)
type cas struct {
value int64