Skip to content

Instantly share code, notes, and snippets.

@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=$!
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@takus
takus / .perltidyrc
Created April 10, 2012 11:15
.perltidyrc described in "Perl Best Practice"
# Max line width is 78 cols
-l=78
# Indent level is 4 cols
-i=4
# Continuation indent is 4 cols
-ci=4
# Output to STDOUT
@Cside
Cside / colorize.pl
Created June 14, 2012 09:54
colorize keywords of logs.
#!/usr/bin/env perl
=head1 Examples
$ tail -f access_log | perl colorize.pl
$ plackup app.psgi 2>&1 | perl colorize.pl
=cut
use strict;
@netologist
netologist / MountainLion-Python-Fix
Created July 27, 2012 05:44 — forked from sonicradish/MountainLion-Python-Fix
Fix Mountain Lion 10.8 Python IOError pyconfig.h Error
After upgrading to Mountain Lion : 10.8 I noticed that I was getting Python errors which prevented me from starting vim:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 565, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 547, in main
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 278, in addusersitepackages
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 253, in getusersitepackages
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 243, in getuserbase
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 523, in get_config_var
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py", line 419, in get_config_vars
@silenvx
silenvx / borders.patch
Created October 15, 2012 21:04
tmuxのペインの境目に使われる罫線を書き換えただけのpatch
diff -Narup tmux-1.6.orig/tty-acs.c tmux-1.6/tty-acs.c
--- tmux-1.6.orig/tty-acs.c 2012-10-15 00:13:51.729160450 +0900
+++ tmux-1.6/tty-acs.c 2012-10-15 00:35:51.770801087 +0900
@@ -41,21 +41,21 @@ const struct tty_acs_entry tty_acs_table
{ 'g', "\302\261" },
{ 'h', "\342\226\222" },
{ 'i', "\342\230\203" },
- { 'j', "\342\224\230" },
- { 'k', "\342\224\220" },
- { 'l', "\342\224\214" },
@kazuho
kazuho / gist:4122754
Created November 21, 2012 03:00
The "queue_stats()" function, introduced in Q4M 0.9.7
How it looks like
==================================
mysql> select queue_stats('t');
+------------------------------------------------------------------------------------------------------------------------------+
| queue_stats('t') |
+------------------------------------------------------------------------------------------------------------------------------+
| rows_written: 0
rows_removed: 0
wait_immediate: 0
@limitusus
limitusus / paraserv.pl
Created February 7, 2013 18:02
TCP server that listens on multiple processes: accept succeeds only on one process for a connection.
#!/usr/bin/env perl
use strict;
use warnings;
use Socket;
use IO::Socket;
use IO::Socket::INET;
use IO::Select;
use IO::Handle;
@sunaot
sunaot / if.md
Last active October 2, 2019 15:15
条件分岐とのつきあい方

条件分岐とのつきあい方

プログラムが複雑になる一番の理由は条件分岐 (if 文など) です。

条件分岐がなければ、一本道で読み下していけばいいのでバグが入り込む余地は大変少なくなります。

ということで、

  • 条件分岐を書かなくていいように書く
  • 条件分岐を書くなら、わかりやすく局所化して書く

子育て5ヶ月やって、先に知っておきたかったこと

現時点で子どもがちょうど5ヶ月になる。
子育ては、やりながらノウハウが溜まっていくと実感している。
その中で、「これはもっと早く知っておけば良かった」と思ったものを記録しておく。

夜長く眠れるようにする

生後すぐは生活サイクルが変わって体力的なしんどさがある。