Skip to content

Instantly share code, notes, and snippets.

@Stanback
Stanback / nginx.conf
Last active June 14, 2024 10:21 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@denji
denji / nginx-tuning.md
Last active July 20, 2024 17:33
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.

@xeoncross
xeoncross / http_accept_language.php
Last active May 31, 2024 18:43
Parse the HTTP except language header
<?php
function prefered_language($available_languages, $http_accept_language) {
$available_languages = array_flip($available_languages);
$langs = array();
preg_match_all('~([\w-]+)(?:[^,\d]+([\d.]+))?~', strtolower($http_accept_language), $matches, PREG_SET_ORDER);
foreach($matches as $match) {
@StephanHoyer
StephanHoyer / gist:bddccd9e159828867d2a
Last active March 29, 2022 11:46
Isomorphic applications with mithril

Attention

This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.

The example is updated with the current version of mithril, though.

Isomorphic applications with mithril

Instructions for installing rEFInd to dual boot a computer with FreeBSD and windows (and possibly other OSes as well).
Note! I use $esp-dev for all commands. Substitude this for the device with your ESP (for example ada0p1)
Download rEFInd from here: http://sourceforge.net/projects/refind/files/0.11.4/refind-bin-0.11.4.zip/download
This gives you a zip-file with everything you need for rEFInd.
Find out which partition is the ESP. This is easiest done by running `gpart list` and look for partitions with `type: efi`.
In a multi-disk setup there might be more than one of those.
I have always installed rEFInd to the one with the Windows bootloader.
@DarthSim
DarthSim / 00.imgproxy_vs_alternatives.md
Last active June 26, 2024 11:05
imgproxy vs alternatives benchmark

imgproxy vs alternatives benchmark

Setup

  • c5.xlarge AWS instance: 4 CPUs, 8 GB RAM
  • Ubuntu 18.04
  • Go 1.12
  • Python 2.7
  • Vips 8.7.4
@p7cq
p7cq / Arch_Linux_Root_On_ZFS.md
Last active June 21, 2024 08:37
Install Arch Linux with Root on ZFS

Arch Linux Root on ZFS

Installation steps for running Arch Linux with root on ZFS using UEFI and systemd-boot. All steps are run as root.

Requires an Arch Linux image with ZFS built-in (see References).

In live environment

If using KVM, add a Serial number for each virtual disk and reboot the VM. The disks should now be available in /dev/disk/by-id as virtio-<Serial>.

@nilsleh
nilsleh / retrieve_large_area.py
Created March 28, 2022 19:19
Split large area into smaller manageable polygons to download via Planetary Computer
import json
import os
import matplotlib.pyplot as plt
import numpy as np
import planetary_computer as pc
import rasterio
import stackstac
from pystac_client import Client
from shapely.geometry import mapping, shape