Skip to content

Instantly share code, notes, and snippets.

View fukata's full-sized avatar

fukata fukata

View GitHub Profile
@fukata
fukata / backup.sh
Created August 3, 2012 14:20
backup script example.
#!/bin/bash
BASEDIR=$(dirname $0); if [ $(expr match "$BASEDIR" ^\/) -eq 0 ]; then BASEDIR=$(pwd)/$BASEDIR; fi
TMPDIR=$BASEDIR
BKNAME=$(date +%Y%m%d-%H%M)
BKDIR=/var/backups/erogeeks.com/$(date +%Y%m)
TMPFILE=$BKNAME.tar.bz2
# 必要なディレクトリを作成
mkdir $TMPDIR/$BKNAME
@fukata
fukata / MyApp-Model-Example.pm
Created September 23, 2012 14:45
My Mojolicious FW
use strict;
use warnings;
use utf8;
package MyApp::Model::Example;
use Mojo::Base 'MyApp::Model';
sub say {
"Hello World from MyApp::Model::Example";
}
@fukata
fukata / environment
Created October 6, 2012 17:33
Gitorious rbenv + passenger(standalone) + supervisord
PATH=/home/git/.rbenv/bin:/home/git/.rbenv/shims:/var/www/gitorious/script:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin
@fukata
fukata / nginx.lb.conf
Created October 25, 2012 05:57
nginx proxy cache gzipped contents
http {
upstream web_backend {
server web01:80;
server web02:80;
}
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache-space:100m max_size=1024m inactive=1h;
proxy_temp_path /var/cache/nginx/tmp;
server {
@fukata
fukata / git_branch_author
Last active December 12, 2015 05:08
All git branches last commit author.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
{
my @lines = `git branch -rv`;
foreach my $line ( @lines ) {
chomp $line;
[program:shimapan_web]
command=bash -lc 'cd /var/app/shimapan_web/current && bundle exec unicorn_rails -c /var/app/shimapan_web/current/config/unicorn.rb -E production'
environment=PATH=/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/deploy/bin
user=deploy
numprocs=1
autostart=true
autorestar=true
logfile_maxbytes=1MB
logfile_backups=10
redirect_stderr=false
@fukata
fukata / package.pl
Last active December 18, 2015 15:49
#!/usr/bin/env perl
package Base;
sub new {
my ($class) = @_;
bless {}, $class;
}
sub pkg {
my ($self) = @_;
@fukata
fukata / fluentd.rb
Last active December 22, 2015 17:19
fluentd DSL config. I want to extract number from hostname.
source {
type "forward"
port 24224
}
match('test.**') {
type "forward"
num = ::Kernel.open("|hostname"){|o| o.read.chop}.gsub('hoge','').to_i / 20 + 1 # host01 => 1
(num..num+1).each do |n|
server {
@fukata
fukata / Makefile
Last active December 24, 2015 06:59
ALL go tests.
# see http://d.hatena.ne.jp/holidays-l/20110823/p1
define MAKETEST
for pkg in $$(for f in $$(find ./adstir -name *_test.go); do echo $${f%/*}; done |sort -u)
do
gom test $$pkg
done
endef
export MAKETEST
test:
@echo "$${MAKETEST}" > /tmp/$$$$ ; $(SHELL) /tmp/$$$$ ; rm -f /tmp/$$$$
@fukata
fukata / Guardfile
Created October 2, 2013 12:10
Guardfile for golang
guard 'shell' do
watch(/.+\.go$/) do |m|
`gom test .`
end
watch(/(.+)\/.+\.go$/) do |m|
`gom test ./#{m[1]}`
end
# 現在編集中のファイルのみをテストしたい場合