Skip to content

Instantly share code, notes, and snippets.

@plepe
plepe / gist:52ecc9f18efb32c68d18
Last active April 3, 2025 19:15
MDADM and LVM cheat sheet

mdadm

Glossary:

  • md: multiple devices
command description
cat /proc/mdstat show status of all raids
mdadm --detail /dev/md0 detailed status of raid md0
@fqrouter
fqrouter / worker nginx conf
Last active August 13, 2024 07:41
Youtube Reverse Proxy
resolver 8.8.8.8;
location /video/ {
if ($request_uri ~ "^/video/(.+?)/.+") {
set $upstream_host $1.googlevideo.com;
add_header Content-Disposition "attachment; filename=video.mp4;";
}
rewrite /video/.+?/(.+)$ /$1 break;
proxy_buffering off;
proxy_pass https://$upstream_host;
proxy_set_header Host $upstream_host;
@fsodogandji
fsodogandji / socat-tips.sh
Last active April 5, 2025 14:56
socat tips & tricks
#To create a classic TCP listening daemon, similar to netcat -l, use a variation of the following command.
socat TCP-LISTEN:8080 stdout
#use remotly a command shell
socat TCP4-LISTEN:1234,reuseaddr,fork 'SYSTEM:/bin/cat /home/infos.txt'
#sslify a server
socat OPENSSL-LISTEN:443,reuse‐addr,pf=ip4,fork,cert=server.pem,cafile=client.crt TCP4-CONNECT:localhost:80
@denji
denji / nginx-tuning.md
Last active April 17, 2025 07:26
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.

@adamchal
adamchal / ngx_http_upload_module.c
Created September 5, 2013 22:16
ngx_http_upload_module.c with patch applied so that Nginx Upload Module works with Nginx 1.4.2+. To use, replace the ngx_http_upload_module.c file in https://github.com/vkholodkov/nginx-upload-module with this Gist.
/*
* Copyright (C) 2006, 2008 Valery Kholodkov
* Client body reception code Copyright (c) 2002-2007 Igor Sysoev
* Temporary file name generation code Copyright (c) 2002-2007 Igor Sysoev
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include <nginx.h>
@shiedman
shiedman / ffmpeg_script
Last active March 2, 2021 06:16
ffmpeg convert script
ffmpeg -y -i v1.wmv -r 30000/1001 -aspect 16:9 -b:v 1150k -bt 2300k -vcodec libx264 -pass 2 -threads 2 -ss 00:02:18 -t 30 -acodec libfaac -ac 2 -ar 44100 -ab 128k -profile:v main -tune fastdecode v.mp4
-vcodec libx264 -crf 20 -threads 2 -r 24000/1001 -acodec libmp3lame -ac 2 -ar 44100 -ab 128k -y -s 800:450 -aspect 16:9 kyou01.avi
-vcodec libx264 -crf 20 -threads 2 -r 24000/1001 -y -aspect 16:9 -s 800:450 -profile:v high -tune psnr -acodec libfaac -ac 2 -ar 48000 -ab 128k
-vcodec libx264 -crf 20 -threads 2 -r 24000/1001 -y -aspect 16:9 -s 960:540 -profile:v high -tune fastdecode -acodec libfaac -ac 2 -ar 48000 -ab 128k
-c:v libx264 -crf 21 -profile:v main -threads 2 -r 24000/1001 -c:a libmp3lame -ac 2 -ar 44100 -ab 128k -y -s 720:540 -aspect 4:3
@ck-on
ck-on / ocp.php
Last active March 14, 2025 08:34
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
@codler
codler / gist:3906826
Created October 17, 2012 17:18
Support HTTP Header Range, mp4, php.php/mp4.mp4
<?php
# Nginx don't have PATH_INFO
if (!isset($_SERVER['PATH_INFO'])) {
$_SERVER['PATH_INFO'] = substr($_SERVER["ORIG_SCRIPT_FILENAME"], strlen($_SERVER["SCRIPT_FILENAME"]));
}
$request = substr($_SERVER['PATH_INFO'], 1);
$file = $request;
$fp = @fopen($file, 'rb');
@nrk
nrk / command.txt
Created April 2, 2012 19:19
Using ffprobe to get info from a file in a nice JSON format
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
@wontoncc
wontoncc / balloontip.py
Last active November 18, 2024 01:04
Balloon tip module, Python, using win32gui.
# -- coding: utf-8 --
from win32api import *
from win32gui import *
import win32con
import sys, os
import struct
import time
class WindowsBalloonTip: