Skip to content

Instantly share code, notes, and snippets.

@frah
frah / patch-ngx_http_auth_digest_module.diff
Created October 20, 2012 02:24
Patch file for nginx 1.2.4 on FreeBSD ports
--- ../samizdatco-nginx-http-auth-digest-bd1c86a/ngx_http_auth_digest_module.c.orig 2011-12-29 09:00:32.000000000 +0900
+++ ../samizdatco-nginx-http-auth-digest-bd1c86a/ngx_http_auth_digest_module.c 2012-10-17 16:47:17.000000000 +0900
@@ -401,13 +401,13 @@
http_method.len = r->method_name.len+1;
http_method.data = ngx_pcalloc(r->pool, http_method.len);
if (http_method.data==NULL) return NGX_HTTP_INTERNAL_SERVER_ERROR;
- p = ngx_cpymem(http_method.data, r->method_name.data, r->method_end - r->method_name.data+1);
+ p = ngx_cpymem(http_method.data, r->method_name.data, r->method_name.len);
- ha2_key.len = http_method.len + r->uri.len + 1;
#!/bin/bash
set -e
echo "## Unrar archive ##"
for f in $(find . -maxdepth 1 -type f -name "*.rar"); do
echo " - $f"
unrar x -o- -p- -xshareraws.blogspot.com.url -y -inul $f
done
@frah
frah / gist:3889213
Created October 14, 2012 17:12
Route search function with more than 8 waypoints using Google Maps API v3
function searchLongRoute(waypoints) {
var route;
var unit = 10;
var unit_num = Math.ceil((waypoints.length+Math.ceil(waypoints.length/unit)-1)/unit);
for (var start_num = 0; start_num < waypoints.length-1;) {
var s = waypoints[start_num];
var next_start = ((waypoints.length>=start_num+unit)?(start_num+unit):(waypoints.length))-1;
var e = waypoints[next_start];
var w = waypoints.slice(start_num+1, next_start);
@frah
frah / com_lighten.sh
Created October 11, 2012 17:46
Composite photo developer (require dcraw & ImageMagick)
#!/bin/bash
set -e
shopt -s nocasematch
function print_usage {
echo "[Usage] $0 input-files dark-frame output-filename [dcraw_option]"
}
function print_header {
echo -e "\033[0;34m==> \033[0;35m$1\033[0m"
@frah
frah / dev_composite.sh
Created October 10, 2012 19:19
Composite photo developer (require dcraw & ImageMagick)
#!/bin/bash
set -e
function genfn {
printf "s%02d-%04d.ppm" $1 $2;
}
function print_usage {
echo "[Usage] $0 dark-frame [dcraw_option]"
}
@frah
frah / stat.lua
Created October 9, 2012 01:28
Lua script of server status monitoring for nginx
string.split_it = function(str, sep)
if str == nil then return nil end
assert(type(str) == "string", "str must be a string")
assert(type(sep) == "string", "sep must be a string")
return string.gmatch(str, "[^\\" .. sep .. "\n]+")
end
string.split = function(str, sep)
local ret = {}
for seg in string.split_it(str, sep) do
ret[#ret+1] = seg