Skip to content

Instantly share code, notes, and snippets.

@bfg
bfg / apache-2.2-mod_remoteip.c
Created June 23, 2011 09:32
Working backport (doesn't crash when using Allow/Deny ACLs) of Apache 2.3 module mod_remoteip to Apache 2.2.x
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ymirpl
ymirpl / gist:1052094
Created June 28, 2011 20:21
Python unicode e-mail sending
#coding: utf-8
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import Charset
from email.generator import Generator
import smtplib
# Example address data
@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:
@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"
@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');
@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
@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
@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>
@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.

@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