Skip to content

Instantly share code, notes, and snippets.

Alex Efros powerman

Block or report user

Report or block powerman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View json_test.go
func BenchmarkJSON(b *testing.B) {
for i := 0; i < b.N; i++ {
obj := Object{}
if err := json.Unmarshal(testCase, &obj); err != nil {
func BenchmarkFastJSON(b *testing.B) {
View expdelay.go
package expdelay
import "time"
// ExpDelay implements exponential delay.
type ExpDelay struct{ cur, max time.Duration }
// New returns new exponential delay which start with min delay, increase
// each next delay in 2 times up to max delay.
View user-overrides.js
/*** MY OVERRIDES ***/
user_pref("_user.js.parrot", "overrides section syntax error");
/* [UX,-HIST] Restore previous session after Firefox restart. */
user_pref("", 3); // 0102
/* [UX,-GEO] Allow websites to detect my locale. */
user_pref("intl.locale.requested", ""); // 0205
user_pref("intl.accept_languages", "ru,en-us,en"); // 0207
powerman / tail.go
Created Nov 22, 2018
Template for tail.go
View tail.go
// Package tail implements behaviour of `tail -n 0 -F path`.
package tail
import (
var (
pollDelay = 200 * time.Millisecond // delay between polling to save CPU
pollTimeout = time.Second // how long to wait before returning os.ErrNotExist
powerman /
Last active Dec 13, 2019
Cheat sheet: How to securely test local/staging HTTPS project

How to securely test local/staging HTTPS project

Modern projects often support HTTPS and HTTP/2, moreover they can use Strict-Transport-Security: and Content-Security-Policy: headers which result in different behaviour for HTTP and HTTPS versions, or even completely forbid HTTP version. To develop and test such project locally, on CI, and at staging server we either have to provide a way to access it using HTTP in non-production environments (bad idea) or somehow make it work with HTTPS everywhere.

HTTP in non-production environments is a bad idea because we'll test not the same thing which will runs on production, and because there is a chance to occasionally keep HTTP enabled on production too.

powerman /
Last active Aug 9, 2017
Gist+Graphviz example

Alt text

digraph G {
    aize ="4,4";
    main [shape=box];
    main -> parse [weight=8];
    parse -> execute;
    main -> init [style=dotted];
    main -> cleanup;

Keybase proof

I hereby claim:

  • I am powerman on github.
  • I am powerman ( on keybase.
  • I have a public key ASCSBOCcVZFOBR0em9fFkAAWPJX7QbEQq69BY9wDKS_n2Qo

To claim this, I am signing this object:

powerman / email.plain.html
Created Oct 30, 2016
clean email template for alertmanager
View email.plain.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>{{ template "__subject" . }}</title>
<body itemscope itemtype="">
powerman / AsciidocCheatsheet.adoc
Last active Feb 21, 2020
Asciidoc cheatsheet for GitHub
View AsciidocCheatsheet.adoc

Asciidoc cheatsheet for GitHub

powerman / gist:5468849
Created Apr 26, 2013
Using AnyEvent::DBI::MySQL with Mojolicious.
View gist:5468849
use AnyEvent::DBI::MySQL;
sub startup {
my $app = shift;
$app->config(db => {dsn=>…, login=>…, pass=>…});
$app->helper(dbh => sub { shift->{dbh} });
$app->helper(new_dbh => sub {
state $db = shift->app->config('db') or return;
You can’t perform that action at this time.