Skip to content

Instantly share code, notes, and snippets.

@denji
denji / nginx-tuning.md
Last active March 28, 2024 09:45
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@miguelgrinberg
miguelgrinberg / rest-server.py
Last active March 28, 2024 08:13
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@marshyski
marshyski / Windows 10 Gaming Performance.md
Last active March 25, 2024 08:42
Windows 10 Gaming Optimizations

Windows 10 Gaming Performance

Tested On: MSI GS66 Stealth 10SFS-037 Laptop | Intel i7-10750H | Nvidia RTX 2070 Super

Date Updated: 28JUN2020

Est. Time to Completion: 1 hour

Expected improvement from stock Windows 10 install for gaming is 1-3x network improvement and reduction in OS overhead.

@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active March 22, 2024 23:37
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@marshyski
marshyski / download-go-linux-amd64.sh
Created January 17, 2024 23:16
Download latest golang version for linux amd64
#!/bin/sh
GO_VERSION=$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -n1)
GO_FILE="$GO_VERSION.linux-amd64.tar.gz"
GO_URL="https://go.dev/dl/$GO_FILE"
cd /usr/local || exit 1
curl -fsSLO "$GO_URL"
tar -zxvf "$GO_FILE"
rm -f "$GO_FILE"
@iamralch
iamralch / compress.go
Last active April 16, 2023 03:04
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@vgoklani
vgoklani / app.py
Last active December 19, 2022 09:13
Using Flask to output Python data to High Charts
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index(chartID = 'chart_ID', chart_type = 'bar', chart_height = 350):
chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,}
series = [{"name": 'Label1', "data": [1,2,3]}, {"name": 'Label2', "data": [4, 5, 6]}]
title = {"text": 'My Title'}
# Windows AMIs don't have WinRM enabled by default -- this script will enable WinRM
# AND install 7-zip, curl and .NET 4 if its missing.
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2008 SP2 64bits AMIs provided by Amazon
#
# Inject this as user-data of a Windows 2008 AMI, like this (edit the adminPassword to your needs):
#
# <powershell>
# Set-ExecutionPolicy Unrestricted
@edhemphill
edhemphill / fifo.go
Last active April 30, 2020 13:06
Thread / goroutine safe, batching and blocking FIFO queue in golang
import (
"net/http"
"sync"
"fmt"
)
type logBuffer struct {
stuff string
}
@iamralch
iamralch / custom_flag.go
Created July 6, 2015 20:40
Custom flag arguments with flag package in Go
package main
import (
"flag"
"fmt"
"net/url"
"strings"
)
type UrlFlag struct {