Skip to content

Instantly share code, notes, and snippets.

View tyru's full-sized avatar
🏠
Working from home

Fujiwara Takuya tyru

🏠
Working from home
View GitHub Profile
@thinca
thinca / _nya.lua
Created September 20, 2010 13:07
function keys(t)
local keylist = {}
for k in pairs(t) do
table.insert(keylist, k)
end
local i = 0
return function()
i = i + 1
return keylist[i]
end
#!/bin/sh
IPTABLES=/sbin/iptables
# 初期化
$IPTABLES -F
# デフォルトルール(以降のルールにマッチしなかった場合に適用するルール)設定
$IPTABLES -P INPUT DROP # 受信はすべて破棄
$IPTABLES -P OUTPUT ACCEPT # 送信はすべて許可
@migrs
migrs / dropbox
Created September 23, 2010 00:19
/etc/init.d/dropbox
# /etc/init.d/dropbox
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $network $syslog $remote_fs
# Required-Stop: $network $syslog $remote_fs
# Should-Start: $named $time
# Should-Stop: $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the dropbox daemon for debian/ubuntu
" Conque
" http://www.vim.org/scripts/script.php?script_id=2771
" ~/.vim/after/ftplugin/conque_term.vim
augroup MyConqueTerm
autocmd!
" start Insert mode on BufEnter
autocmd BufEnter *
\ if &l:filetype ==# 'conque_term' |
--- Configure 2010-09-30 14:41:41.000000000 +0900
+++ /tmp/configure.perl 2010-09-30 14:40:55.000000000 +0900
@@ -23388,6 +23388,14 @@
EOM
rp="Press return or use a shell escape to edit config.sh:"
+ . UU/myread
+ nostick=''
+ case "$ans" in
+ '') ;;
@mattn
mattn / gtk0x.cxx
Created September 30, 2010 09:42
#include <gtk/gtk.h>
int
main(int argc, char* argv[]) {
gtk_init(&argc, &argv);
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete-event", [] () {
gtk_main_quit();
}, window);
GtkWidget* button = gtk_button_new_with_label("click me");
function cdup() {
echo
cd ..
echo "=> $PWD"
zle reset-prompt
}
function cdprev() {
echo
popd
@sunaot
sunaot / gist:613106
Last active April 28, 2020 00:30
バグを生まないプログラミングのために

話しをしたいポイントは3つ。

  • 条件分岐を避けましょう
  • 一時変数の使い方に注意しましょう
  • 状態の使い方に気を使いましょう

これを徹底することで、バグの入り込む余地を最小限に保つプログラミングをしましょう。

条件分岐を避けましょう

@sunaot
sunaot / gist:613111
Created October 6, 2010 10:00
凝集性

凝集性 (cohesion)

課題

  • ルーチンの作り方に指針がない。
  • どんな風にルーチンを構成するとよいルーチンになるのかがわからない。
  • 抽象化という単語は知っているが、抽象化された状態がどんな状態なのかわからない。
@sunaot
sunaot / gist:613113
Created October 6, 2010 10:01
結合性

結合性 (coupling)

課題

凝集性を誤解し、とにかくひとつのルーチンになんでも多くのことを詰めこもうとする。さらに詰めこんだため、ルーチンとルーチンの間で膨大で複雑な引数を介してデータ構造を共有しようとする。

解決策