Skip to content

Instantly share code, notes, and snippets.

@powerman
powerman / OAuth 2.0.adoc
Created June 25, 2022 18:34
Recommendations on secure implementation of OAuth 2.0 (server and client)

OAuth 2.0

Table of Contents

Abstract

@powerman
powerman / chan_queue.go
Created June 20, 2021 16:35
Helper for buffering data from non-blocking channel for sending into blocking channel
// Usage example:
func process(in <-chan Msg, outBlocking chan<- Msg) {
out := newQueueMsg(QueueSize, outBlocking)
for {
select {
case msg := <-in:
out.append(msg)
case out.C <- out.Elem:
out.del()
}
--- /tmp/westmore.flags 2020-05-30 12:25:20.909340358 +0300
+++ /tmp/haswell.flags 2020-05-30 12:25:34.182340758 +0300
+abm
-aes
+cpuid_fault
-dca
+ept_ad
+erms
+fsgsbase
-ida
@powerman
powerman / create-local-CA.md
Last active May 7, 2024 01:23
Create local CA to issue localhost HTTPS certificates

Create local CA to issue localhost HTTPS certificates

You can check How to securely test local/staging HTTPS project for more details about required setup or just follow instructions below.

WARNING: You'll need to run these commands just once, don't run them again if you already did this before for some other project.

MacOS users should first prepare OpenSSL package:

func BenchmarkJSON(b *testing.B) {
for i := 0; i < b.N; i++ {
obj := Object{}
if err := json.Unmarshal(testCase, &obj); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkFastJSON(b *testing.B) {
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.
//
/*** MY OVERRIDES ***/
user_pref("_user.js.parrot", "overrides section syntax error");
/* [UX,-HIST] Restore previous session after Firefox restart. */
user_pref("browser.startup.page", 3); // 0102
/* [UX,-GEO] Allow websites to detect my locale. */
user_pref("intl.accept_languages", "ru,en-us,en"); // 0210
user_pref("javascript.use_us_english_locale", false); // 0211
@powerman
powerman / tail.go
Created November 22, 2018 16:46
Template for tail.go
// Package tail implements behaviour of `tail -n 0 -F path`.
package tail
import (
"time"
)
var (
pollDelay = 200 * time.Millisecond // delay between polling to save CPU
pollTimeout = time.Second // how long to wait before returning os.ErrNotExist
@powerman
powerman / Testing_local_HTTPS_project.md
Last active December 20, 2023 19:22
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
powerman / graphviz_v1.md
Last active October 2, 2020 13:36
Gist+Graphviz example

Alt text

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