Skip to content

Instantly share code, notes, and snippets.

View matsubo's full-sized avatar

Yuki Matsukura matsubo

View GitHub Profile
@botimer
botimer / yesno.rb
Created June 7, 2012 19:56
Handy yes/no prompt for little ruby scripts
# This is a reasonably well-behaved helper for command-line scripts needing to ask a simple yes/no question.
# It optionally accepts a prompt and a default answer that will be returned on enter keypress.
# It keeps asking and echoes the answer on the same line until it gets y/n/Y/N or enter.
# I tried to get Highline to behave like this directly, but even though it's sophisticated, I didn't like the result.
# This isn't especially elegant, but it is straightforward and gets the job done.
require 'highline/import'
def yesno(prompt = 'Continue?', default = true)
a = ''
s = default ? '[Y/n]' : '[y/N]'
@pitch-gist
pitch-gist / gist:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@hayajo
hayajo / changelog_en.md
Last active May 3, 2024 08:29
ChangeLog を支える英語

ChangeLog を支える英語

ChangeLog を書く際によく使われる英語をまとめました。

ほとんど引用です。

基本形

@narusemotoki
narusemotoki / dirwatch.py
Created November 12, 2012 12:35
ディレクトリを監視して,ファイルに変更があった場合に任意のコマンドを実行します.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import datetime
import time
import os
from stat import *
import commands
def watch(dir, command):
@brundage
brundage / database.yml
Created November 16, 2012 22:05
Use sqlite in-memory database for rspec testing
test:
adapter: sqlite3
encoding: utf8
pool: 5
timeout: 5000
database: ":memory:"
verbosity: quiet
@yuryu
yuryu / pre-warm-elb.pl
Last active June 2, 2021 21:52
ELB Warm-up tool
#!perl
use strict;
use warnings;
use Parallel::ForkManager;
use POSIX;
use String::Random;
my $c_start = 1;
my $c_end = 64;
@mzdakr
mzdakr / ServerMonitoringWithGAS.js
Last active January 29, 2018 02:12
Google Apps Script を使って簡易的にWEBサーバの死活監視をするスクリプトです。 外部からURL叩いて 200 が返ってこなかったらメールをするだけのとてもシンプルなコードです。 Google Apps Scriptを採用した理由は 1) JSで書けてお手軽 2)Google Apps Scriptで定期実行が可能 3) Google Apps の基盤上で動かせるので可用性が高い の3つです。 毎分スクリプトを動かすことができるので便利なのと死活監視自体が死んでるということを極力回避できるというのはポイント高いと思います。死活監視の死活監視なんて新たな死活監視を産むだけです。 Google Apps Scriptはかなり便利なので使ってみてください。
var url = 'http://www.example.com/';
var to = 'foo@example.com';
var sub = 'サーバ障害報告';
var body = "監視中の サーバが停止した模様です。サーバの状態を確認してください。\n" + url ;
function myFunction()
{
if(check_server(url) != 200){
MailApp.sendEmail(to, sub, body);
@ninetails
ninetails / Dockerfile
Created March 7, 2014 02:09
docker with CentOS+LAMP (PHP 5.5 + Apache 2.4)
FROM centos
MAINTAINER Ninetails - Carlos Kazuo
RUN rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
RUN curl -s http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo > /etc/yum.repos.d/epel-httpd24.repo
RUN yum install -y xterm git mysql mysql-server httpd24-httpd php55w php55w-common php55w-cli mysql mysql-server php55w-devel php55w-mcrypt php55w-mbstring php55w-mysqlnd php55w-pdo php55w-pecl-xdebug php55w-xml php55w-xmlrpc php55w-opcache
RUN /sbin/chkconfig --add httpd
RUN /sbin/chkconfig httpd on --level 235
@koko1000ban
koko1000ban / nested_query_in_arel.rb
Last active August 29, 2015 13:58
Nested query in Arel
limit = 200
post_table = Post.arel_table
visibility_ids = PostVisibility.select(:post_id).where(user_id: 1).order(id: :desc).limit(limit).arel.as('t')
inner_query = Arel::Table.new(:tmp).project(:post_id).from(visibility_ids.to_sql)
Post.where(post_table[:is_public].eq(true).or(post_table[:id].in(inner_query))).limit(limit)
@koyopro
koyopro / amazon-calc.js
Last active April 2, 2022 08:23 — forked from polamjag/amazon-calc.js
Amazonで一年間に使った金額と、注文履歴のTSVを出力するブックマークレット【2015年版】
// Amazonの注文履歴をTSV形式で出力するスクリプト
//
// 2015-01-01 時点での DOM 構造に対応, GoogleCrome, Opera でテスト済。
// formatEntry関数を書き換えれば自由な書式で出力できます。
//
// 参考:
// - Amazonの注文履歴をCSV形式にして出力するスクリプト
// https://gist.github.com/arcatdmz/8500521
// - Amazon で使った金額の合計を出す奴 (2014 年バージョン)
// https://gist.github.com/polamjag/866a8af775c44b3c1a6d