Skip to content

Instantly share code, notes, and snippets.

@frah
frah / patch-ngx_http_auth_digest_module.diff
Created Oct 20, 2012
Patch file for nginx 1.2.4 on FreeBSD ports
View patch-ngx_http_auth_digest_module.diff
--- ../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;
View gist:3892253
#!/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 Oct 14, 2012
Route search function with more than 8 waypoints using Google Maps API v3
View gist:3889213
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 Oct 11, 2012
Composite photo developer (require dcraw & ImageMagick)
View com_lighten.sh
#!/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 Oct 10, 2012
Composite photo developer (require dcraw & ImageMagick)
View dev_composite.sh
#!/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 Oct 9, 2012
Lua script of server status monitoring for nginx
View stat.lua
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