Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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);
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 / 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:6016248
javascript:(function(){var o=function(w,v){var i=new Blob([v]);var u=window.URL||window.webkitURL;var t=u.createObjectURL(i);var e=document.createElement("a");e.download=w;e.href=t;return e};var c=function(a){return unescape(escape(a).replace(/(%u3000|%20|%09)/g,""))};var r=document.getElementsByTagName("table")[10].innerText.trim();var d=document.getElementsByTagName("table")[11];var j=d.getElementsByTagName("tr");var s="";var n="";var h="";for(var g=0;g<j.length;g++){var l=j[g];if(l.attributes.length==0){var q=o("address.csv",n);q.innerText="[CSV Download]";l.children[0].insertBefore(q,l.children[0].firstChild);s=s+n;n="";continue}if(l.attributes[0].value=="#B0C4DE"){h=l.children[0].innerText}else{var p=l.children[1].innerText;var m=c(p.substring(0,3));p=c(p.substring(3));var f=m+","+p+","+m+" "+p;f+=","+r+","+h+",";f+=l.children[0].innerText.replace(/[A-Za-z0-9]/g,function(a){return String.fromCharCode(a.charCodeAt(0)-65248)});f+=","+l.children[2].innerText.replace(/\n/g,"");f+=","+c(l.children[3].innerTex
View tree.sh
#!/bin/bash
########################## ツリー表示スクリプト ###########################
# 第一引数に与えられたディレクトリがルートのディレクトリツリーを表示する。#
# また、ディレクトリの所有ユーザ名、グループ名、パーミッションを表示する。#
# シンボリックリンク先も辿る。 #
# #
# 引数1: ツリー表示したいディレクトリパス #
# 引数2: 走査する深度(オプション) #
# #
@frah
frah / led.html
Created Oct 11, 2013
LimitlessLED control test with Lua on Nginx
View led.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>LimitlessLED control</title>
<style type="text/css">
html {
-webkit-user-select: none;
-webkit-background-size: 10px 10px;
@frah
frah / SendMes.vbs
Last active Dec 27, 2015
プロキシの設定を有効化するVBScript
View SendMes.vbs
Option Explicit
Dim Excel, Com
Set Excel = WScript.CreateObject("Excel.Application")
Excel.Visible = False
rem HWND_BROADCAST = 0xffff
rem WM_SETTINGCHANGE = 0x001a
rem SMTO_NOMAL = 0x0