Skip to content

Instantly share code, notes, and snippets.

View brsnik's full-sized avatar

Boris Nikk brsnik

  • Skopje, MK
  • 19:34 (UTC +02:00)
View GitHub Profile
@dahnielson
dahnielson / UUID.php
Last active May 31, 2024 23:54
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 June 21, 2024 15:08
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.

@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 March 11, 2024 14:51
Nginx SSL/TLS configuration for "A+" Qualys SSL Labs rating
#
# Name: nginx-tls.conf
# Auth: Gavin Lloyd <gavinhungry@gmail.com>
# 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 = "info@example.com";
$to = "dave@example.com";
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 May 15, 2024 10:52
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