Skip to content

Instantly share code, notes, and snippets.

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

Vadim Filin filinvadim

🏠
Working from home
  • zodia-markets
  • Dubai
View GitHub Profile
@zmts
zmts / tokens.md
Last active November 16, 2024 12:50
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@teknoraver
teknoraver / unixhttpc.go
Last active November 7, 2024 14:29
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@gambol99
gambol99 / gist:d55afd69217b8e2dd727be99f0a20e7d
Created June 24, 2016 14:44
golang - create ca and build csr for signing
//
// createCertificateAuthority generates a certificate authority request ready to be signed
//
func (r *secretStore) createCertificateAuthority(names pkix.Name, expiration time.Duration, size int) (*caCertificate, error) {
// step: generate a keypair
keys, err := rsa.GenerateKey(rand.Reader, size)
if err != nil {
return nil, fmt.Errorf("unable to genarate private keys, error: %s", err)
}
# Make sure you grab the latest version
curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
# Unzip
unzip protoc-3.2.0-linux-x86_64.zip -d protoc3
# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/
# Move protoc3/include to /usr/local/include/
@valyala
valyala / README.md
Last active September 1, 2024 20:40
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@obihann
obihann / main,go
Created February 19, 2015 18:04
Go Composition
package main
import (
"encoding/json"
"fmt"
"log"
)
type (
AStruct struct {
@didasy
didasy / shuffle.go
Created February 12, 2015 16:46
Golang Array Shuffler
/*
An array shuffler with good randomness
*/
package main
import (
"fmt"
"math/big"
"crypto/rand"
)
@ulfurinn
ulfurinn / gist:45d94d8bcc99e0a10025
Created July 1, 2014 14:24
http over unix socket
// A quick and dirty demo of talking HTTP over Unix domain sockets
package main
import (
"fmt"
"io"
"net"
"net/http"
"os"
@congjf
congjf / .Title
Last active April 2, 2023 00:57 — forked from border/mgoExample.go
Using MongoDB in golang with mgo
Using MongoDB in golang with mgo
# -*- coding: utf-8 -*-
def transliterate(string):
capital_letters = {u'А': u'A',
u'Б': u'B',
u'В': u'V',
u'Г': u'G',
u'Д': u'D',
u'Е': u'E',