Skip to content

Instantly share code, notes, and snippets.

View brsnik's full-sized avatar

Boris Nikk brsnik

  • Skopje, MK
  • 05:04 (UTC +01:00)
View GitHub Profile
@dahnielson
dahnielson / UUID.php
Last active September 1, 2024 11:34
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@denji
denji / nginx-tuning.md
Last active November 5, 2024 10:10
NGINX tuning for best performance

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.

@cuibonobo
cuibonobo / Large-app-how-to.md
Last active March 6, 2024 18:40
How to structure a large application in Flask. Taken from the Flask wiki: https://github.com/mitsuhiko/flask/wiki/Large-app-how-to

Here's an example application that uses the pattern detailed below: https://github.com/tantastik/talent-curator


This document is an attempt to describe the first step of a large project structure with flask and some basic modules:

  • SQLAlchemy
  • WTForms

Please feel free to fix and add your own tips.

@gavinhungry
gavinhungry / nginx-tls.conf
Last active July 18, 2024 11:35
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Gavin Lloyd <[email protected]>
# Desc: Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Enables HTTP/2, PFS, HSTS and OCSP stapling. Configuration options not related
# to SSL/TLS are not included here.
#
# Additional tips:
#
@fsmv
fsmv / miniupnpcTest.c
Created September 12, 2014 19:47
Miniupnpc Port Forwarding Example
#include <stdio.h>
#include <arpa/inet.h> //INET6_ADDRSTRLEN
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
int main(int argc, char *argv[]) {
int error = 0;
//get a list of upnp devices (asks on the broadcast address and returns the responses)
struct UPNPDev *upnp_dev = upnpDiscover(1000, //timeout in milliseconds
NULL, //multicast address, default = "239.255.255.250"
@umrysh
umrysh / mailgun-webhook.php
Created January 29, 2015 23:11
Very simple PHP webhook for Mailgun that emails you on errors.
<?php
$key = "<API Key>";
$from = "[email protected]";
$to = "[email protected]";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['timestamp']) && isset($_POST['token']) && isset($_POST['signature']) && hash_hmac('sha256', $_POST['timestamp'] . $_POST['token'], $key) === $_POST['signature'])
{
if($_POST['event'] == 'complained') {
@drmalex07
drmalex07 / README-oneshot-systemd-service.md
Last active July 7, 2024 19:47
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@dayreiner
dayreiner / sysctl.conf
Last active July 14, 2023 06:25
A decent base to start tuning off of for centos 7 apache and mariadb systems
# MariaDB Tuning
vm.swappiness = 1
fs.file-max = 2097152
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
# Sets the time before the kernel considers migrating a proccess to another core
kernel.sched_migration_cost_ns = 5000000
# Group tasks by TTY
@meskarune
meskarune / nftables.conf
Created May 25, 2016 02:16
nftables config for ipv4
#!/usr/bin/nft -f
# ipv4/ipv6 Simple & Safe Firewall
# you can find examples in /usr/share/nftables/
flush ruleset
table firewall {
chain incoming {
type filter hook input priority 0;
@esurdam
esurdam / ecdsa_openssl.md
Last active December 21, 2023 09:12
Generate ECDSA certs

ECDSA Certs with LetsEncrypt

More on ECDSA

Info on bit length and complexity

From it you may gather that using 256 bit ECDSA key should be enough for next 10-20 years.

To view your available curves