Skip to content

Instantly share code, notes, and snippets.

View schaternik's full-sized avatar

Anastasia schaternik

  • Berlin, Germany
  • 05:39 (UTC +02:00)
View GitHub Profile
@schaternik
schaternik / main.go
Created May 19, 2025 12:43
Main function handling graceful shutdown
const (
_shutdownPeriod = 15 * time.Second
_shutdownHardPeriod = 3 * time.Second
_readinessDrainDelay = 5 * time.Second
)
var isShuttingDown atomic.Bool
func main() {
// Setup signal context
@schaternik
schaternik / server.go
Last active May 19, 2025 12:44
Golang HTTP handler
package main
import (
"log"
"net/http"
"time"
)
func timeHandler(w http.ResponseWriter, r *http.Request) {
tm := time.Now().Format(time.RFC1123)
@schaternik
schaternik / main.go
Created November 19, 2019 10:42
Graphql server in go with Graphiql handling one query
package main
import (
"net/http"
"github.com/friendsofgo/graphiql"
graphql "github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/relay"
)
package main
import (
"fmt"
"io"
"os"
"path"
)
func dirTree(out io.Writer, root string, printFiles bool) error {
@schaternik
schaternik / .editorconfig
Created February 28, 2019 23:57
Sample editor config file
# https://editorconfig.org/#example-file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
@schaternik
schaternik / secret-key-base.rb
Last active February 6, 2019 13:48
Generate secreta key base like rails does it in IRB
require 'securerandom'
puts SecureRandom.hex(64)
comment = "# frozen_string_literal: true\n"
filemode = "r+"
dirs = Dir[Rails.root.join('spec/**/*.rb').to_s] + Dir[Rails.root.join('lib/**/*.rake').to_s] + Dir[Rails.root.join('lib/**/*.rb').to_s]
dirs.each do |filename|
contents = File.open(filename, "r") do |f|
f.read
end
contents = comment + contents
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: alabama_song
password: 1
development:
<<: *default
database: alabama_song_development
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
@schaternik
schaternik / regional-setting.md
Last active August 29, 2015 14:22
Set up Regional Settings with command line in Linux