Skip to content

Instantly share code, notes, and snippets.

@sonots
sonots / why-run.md
Last active August 29, 2015 14:06
why-run でテストできない事象はあるのか

結論:みあたらないので誰か

my $spf_server = Mail::SPF::Server->new;
my $request = Mail::SPF::Request->new(
versions => [1,2],
scope => 'mfrom',
identity => $self->from,
ip_address => $ip,
);
my $result = $spf_server->process($request);
$result->is_code('pass');
@riywo
riywo / gist:836630
Created February 21, 2011 03:41
指定秒間だけtcpdumpしてmk-query-digestするshell
#!/bin/sh
SEC=$1
tcpdump -s 65535 -nn -q -tttt -x port 3306 -l > /tmp/tcpdump.3306 2> /dev/null &
PID_3306=$!
tcpdump -s 65535 -nn -q -tttt -x port 11211 -l > /tmp/tcpdump.11211 2> /dev/null &
PID_11211=$!
@riywo
riywo / nginx.conf
Created January 18, 2012 18:29
nginxでURIの先頭使ってbackend serverのportを決める
http {
map $uri $backend_port {
include port_map;
}
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
server {
@kazeburo
kazeburo / gist:2349121
Created April 10, 2012 07:46
Apache::BumpyLife
package Apache::BumpyLife;
use strict;
use warnings;
use Config;
use Apache::Constants ();
use constant IS_WIN32 => $Config{'osname'} eq 'MSWin32' ? 1 : 0;
our $VERSION = '0.01';
@fujiwara
fujiwara / installed2cpanfile
Last active December 19, 2015 02:19
ExtUtils::Installedで現在インストールされているモジュールからcpanfileを作る
$ perl installed2cpanfile > cpanfile
$ cpanm --installdeps .
@sonots
sonots / gist:7670731
Last active December 29, 2015 12:29
out_forward って詰まると性能劣化する?
@kazuho
kazuho / setusergroups
Last active November 26, 2018 11:01
setuidgid w. support for supplementary groups
#! /usr/bin/perl
use POSIX qw(setuid setgid);
use Unix::Groups qw(setgroups);
die "usage: setusergroups username child\n"
unless @ARGV >= 2;
my $username = shift @ARGV;
# get user entry
> perl -E 'say "生" & "死"'
生 Life U+751F \xe7\x94\x9f 11100111 10010100 10011111
死 Death U+6B7B \xe6\xad\xbb 11100110 10101101 10111011
愛 Love u+611B \xe6\x84\x9b 11100110 10000100 10011011
@jidaikobo-shibata
jidaikobo-shibata / calculate-region-and-insert.el
Last active June 27, 2019 06:47
Emacs(Elisp): calculate region and insert. 選択範囲の数式を計算して、次の行にinsertします。数字が羅列されている場合は、加算します。数字や式と自然な文章が混在している場合は、数式のみを計算します。
;;; ------------------------------------------------------------
;;; 選択範囲を計算してバッファに出力
;; gist-description: Emacs(Elisp): calculate region and insert. 選択範囲の数式を計算して、次の行にinsertします。数字が羅列されている場合は、加算します。数字や式と自然な文章が混在している場合は、数式のみを計算します。
;; gist-id: b967d6a7441f85aa541d
;; gist-name: calculate-region-and-insert.el
;; gist-private: nil
(defun add-number-grouping (number &optional separator)
"Add commas to NUMBER and return it as a string.
Optional SEPARATOR is the string to use to separate groups.