Skip to content

Instantly share code, notes, and snippets.

View aspyatkin's full-sized avatar

Aleksandr Piatkin aspyatkin

View GitHub Profile
import os
import pytest
from alembic.command import upgrade
from alembic.config import Config
from project.factory import create_app
from project.database import db as _db
@vongosling
vongosling / gist:9929680
Last active January 31, 2024 04:49
Performance Tuning

Three system configuration parameters must be set to support a large number of open files and TCP connections with large bursts of messages. Changes can be made using the /etc/rc.d/rc.local or /etc/sysctl.conf script to preserve changes after reboot.

1. /proc/sys/fs/file-max: The maximum number of concurrently open files.

fs.file-max = 1000000

2. /proc/sys/net/ipv4/tcp_max_syn_backlog: Maximum number of remembered connection requests, which are still did not receive an acknowledgment from connecting client. The default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines.

net.ipv4.tcp_max_syn_backlog = 3240000

3. /proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128.

net.core.somaxconn = 3240000

@benmccormick
benmccormick / minimal.vim
Last active February 26, 2022 17:09
A minimal vimrc for new vim users
" A minimal vimrc for new vim users to start with.
"
" Referenced here: http://vimuniversity.com/samples/your-first-vimrc-should-be-nearly-empty
"
" Original Author: Bram Moolenaar <Bram@vim.org>
" Made more minimal by: Ben Orenstein
" Modified by : Ben McCormick
" Last change: 2014 June 8
"
" To use it, copy it to
@ianmariano
ianmariano / nokogiri cygwin
Created October 9, 2014 15:27
nokogiri cygwin
Make sure libxml2-devel, libxslt-devel and libiconv-devel are installed:
$ gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib --with-xslt-dir=/usr/include/libxslt --with-iconv-include=/usr/include --with-iconv-lib=/usr/lib
@DQNEO
DQNEO / InstallBerkshelfOnCygwin.md
Last active January 12, 2016 04:32
How to Install Berkshelf version3 on Cygwin 64bit

How to Install Berkshelf version3 on Cygwin 64bit

Installation of Berkshelf v3 on Cygwin is known to be very diffcult, but I have finally found the way. 😄

You can successfully install it by following the procedure below.

(As at 2014/6/8, v3.1.3 is available)

Why is it so difficult ?

@arusso
arusso / make-san-cert.rb
Last active June 1, 2021 21:20
Generating a SAN Certificate in Ruby
require 'openssl'
require 'openssl-extensions/all'
keyfile = '/tmp/mycert.key'
csrfile = '/tmp/mycert.csr'
file = File.new(keyfile,'w',0400)
key = OpenSSL::PKey::RSA.new 2048
file.write(key)
@mariocesar
mariocesar / access.lua
Last active November 5, 2023 07:16
Nginx Lua script redis based for Basic user authentication
function password_encode(password)
local bcrypt = require 'bcrypt'
return bcrypt.digest(password, 12)
end
function check_password(password, encoded_password)
local bcrypt = require 'bcrypt'
return bcrypt.verify(password, encoded_password)
end
@ourmaninamsterdam
ourmaninamsterdam / LICENSE
Last active April 24, 2024 18:56
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@aspyatkin
aspyatkin / generate_csr.rb
Last active October 7, 2023 18:20
Generate X509 CSR with SAN extension in Ruby
require 'openssl'
# Generate X509 CSR (certificate signing request) with SAN (Subject Alternative Name) extension and sign it with the RSA key
def generate_csr(common_name, organization, country, state_name, locality, domain_list)
# create signing key
signing_key = OpenSSL::PKey::RSA.new 2048
# create certificate subject
subject = OpenSSL::X509::Name.new [
['CN', common_name],
@friskfly
friskfly / multiple-url-paths.lua
Created February 18, 2016 05:31 — forked from anonymous/multiple-url-paths.lua
Benchmark multiple url paths with wrk
-- Resource: https://github.com/timotta/wrk-scripts/blob/master/multiplepaths.lua
-- Initialize the pseudo random number generator
-- Resource: http://lua-users.org/wiki/MathLibraryTutorial
math.randomseed(os.time())
math.random(); math.random(); math.random()
-- Shuffle array
-- Returns a randomly shuffled array
function shuffle(paths)