Skip to content

Instantly share code, notes, and snippets.

View codenoid's full-sized avatar

codenoid

  • Wonogiri, Jawa Tengah, Indonesia
  • 23:52 (UTC +07:00)
View GitHub Profile
@mashingan
mashingan / monitorfs.nim
Last active January 14, 2021 17:59
Monitor folder and files using in Windows
import winim
proc quit(value: DWORD) =
quit value.int
proc refreshDirectory(handle: var HANDLE) =
handle = FindFirstChangeNotification(".", false,
FILE_NOTIFY_CHANGE_FILE_NAME)
if handle == INVALID_HANDLE_VALUE:
quit GetLastError()
package main
import (
"fmt"
"log"
"net/http"
)
func init() {
log.SetFlags(log.Lshortfile)
require "kemal"
require "jwt"
require "json"
require "yaml"
require "arangocr"
require "redis"
# Load .env file
env_data = YAML.parse File.read(".env.yml") rescue Hash(String, String).new
env_data.each { |k, v| ENV[k.to_s] = v.to_s }
# Install https://www.vaultproject.io/
brew install vault
# Start dev vault server in a separate terminal
vault server -dev
# ==> Vault server configuration:
# ...
# Unseal Key: 7ACQHhLZY5ivzNzhMruX9kSa+VXCah3y87hl3dPSWFk=
# Root Token: 858a6658-682e-345a-e4c4-a6e14e6f7853
@valyala
valyala / README.md
Last active June 3, 2024 17:00
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:
@JayGoldberg
JayGoldberg / is_ipv4.go
Last active May 12, 2019 12:50
determines if a string is a valid IPv4 address in golang, but the correct way to do this is to use net.ParseIP() and check for err
package main
import (
"fmt"
"strconv"
)
import "strings"
func is_ipv4(host string) bool {
parts := strings.Split(host, ".")
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 4000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
@bcardiff
bcardiff / README.md
Last active November 21, 2017 16:39
wkhtmltopdf binding for crystal

Experiment for wkhtmltopdf

brew install wkhtmltopdf
crystal wkhtmltopdf.cr

known issue: althout conversion succeeds the wkhtmltopdf process seems to hanging in the very end :-(

@magnetikonline
magnetikonline / README.md
Last active June 5, 2024 01:05
NSSM - the Non-Sucking Service Manager cheatsheet.