Skip to content

Instantly share code, notes, and snippets.

View ostretsov's full-sized avatar
🏠
Working from home

Artem Ostretsov ostretsov

🏠
Working from home
View GitHub Profile
package main
import (
"fmt"
"time"
)
func Example_cancellationByTimeout() {
heavyWork := func(d time.Duration) {
timeout := time.After(d)
package main
import (
"fmt"
"time"
)
func Example_cancellationByTimeout() {
heavyWork := func(d time.Duration) {
timeout := time.After(d)
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"time"
)
@ostretsov
ostretsov / token_test.go
Created February 1, 2020 13:46
Compare perfect hash function performance with `IsKeyword()` method
package main
import (
"go/token"
"testing"
)
func BenchmarkIsKeyword(b *testing.B) {
for n := 0; n < b.N; n++ {
for i := token.BREAK; i < token.VAR; i++ {
@ostretsov
ostretsov / Dockerfile
Last active February 28, 2018 06:04
TeX to PDF async server (aerys, amphp)
FROM php:7.2.2-cli-stretch
# tex
RUN apt-get update && apt-get install -y texlive-full\
biber\
tar\
libarchive-tools
# composer
RUN curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/bin
class ImageUtil
{
/**
* @see https://github.com/recurser/exif-orientation-examples for test samples
*
* @param string $absoluteFilePath
* @return bool
*/
public static function fixOrientation(string $absoluteFilePath): bool
{
#!/bin/sh
##############################################################################
# If a PUID/PGID enviroment variable exists, use those values for the `uid`
# and `gid` when executing scripts, otherwise change the dev user's uid and
# gid to match the user that owns the project directory and run a command as
# that user. If a ~/.ssh directory exists and it's not owned by root then
# switch and run as that user instead in order to take advantage of public key
# authentication.
##############################################################################
<?php
/**
* (c) Artem Ostretsov <artem@ostretsov.ru>
* Created at 25.01.2016 11:22
*/
namespace SP\MainBundle\Util;
class StringUtil
@ostretsov
ostretsov / go_otp_1453874557.md
Created January 27, 2016 06:02
Repositories comparison: golang/go, erlang/otp.

Repositories comparison: golang/go, erlang/otp.

Generated by githubcmp-cli

Generation time: 01-27-2016 11:02

1. golang/go with 74%

+--------------------------+--------+--------+----------+
@ostretsov
ostretsov / Ratchet_Wrench_1453284932.md
Created January 20, 2016 10:15
Repositories comparison: ratchetphp/Ratchet, varspool/Wrench.

Repositories comparison: ratchetphp/Ratchet, varspool/Wrench.

Generated by githubcmp-cli

Generation time: 01-20-2016 15:15

1. ratchetphp/Ratchet with 82%

+--------------------------+-------+--------+---------+