Skip to content

Instantly share code, notes, and snippets.

View resize.scpt
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"
View spf check
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 Feb 21, 2011
指定秒間だけtcpdumpしてmk-query-digestするshell
View gist:836630
#!/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 Jan 18, 2012
nginxでURIの先頭使ってbackend serverのportを決める
View nginx.conf
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 {
View gist:2212589
> 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 Apr 10, 2012
Apache::BumpyLife
View gist:2349121
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 Dec 19, 2015
ExtUtils::Installedで現在インストールされているモジュールからcpanfileを作る
View installed2cpanfile
$ perl installed2cpanfile > cpanfile
$ cpanm --installdeps .
@kazuho
kazuho / setusergroups
Last active Nov 26, 2018
setuidgid w. support for supplementary groups
View setusergroups
#! /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 Dec 29, 2015
out_forward って詰まると性能劣化する?
View gist:7670731
View format-number-with-si-prefix.js
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;