Skip to content

Instantly share code, notes, and snippets.

global screenWidth
global screenHeight
tell (do shell script "/usr/sbin/system_profiler SPDisplaysDataType | grep Resolution | tail -n 1") to set {screenWidth, screenHeight} to {word 2 as number, word 4 as number}
-- display dialog "screen: " & screenWidth & "x" & screenHeight
if screenWidth = 1200 then
-- display dialog "monitor U2410"
tell application "System Events"
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 {
> 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
@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 .
@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
@sonots
sonots / gist:7670731
Last active December 29, 2015 12:29
out_forward って詰まると性能劣化する?
function formatN (n) {
const unitList = ['y', 'z', 'a', 'f', 'p', 'n', 'u', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
const zeroIndex = 8;
const nn = n.toExponential(2).split(/e/);
let u = Math.floor(+nn[1] / 3) + zeroIndex;
if (u > unitList.length - 1) {
u = unitList.length - 1;
} else
if (u < 0) {
u = 0;