Skip to content

Instantly share code, notes, and snippets.

@mizzy
mizzy / antipop-as-shikakun.rb
Created November 23, 2012 14:23
www.shikakun.com で あんちぽさんの過去tweetをランダムな相手にランダムにつぶやく
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'mechanize'
require 'twitter'
Twitter.configure do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.oauth_token = ENV['TWITTER_OAUTH_TOKEN']
hmac = require "hmac";
local args = ngx.req.get_uri_args()
ngx.var.filename = args["filename"];
if ngx.now() > ngx.parse_http_time(args["expire"]) then
ngx.exit(403);
end
if args["sign"] ~= hmac.hmac_sha1("secret", args["filename"] .. args["expire"]) then
ngx.exit(403);
end
#!/usr/bin/env ruby
require 'octokit'
username = 'mizzy'
password = 'xxxxxxxx'
octokit = Octokit::Client.new(:login => username, :password => password)
octokit.orgs.each do |org|
@mizzy
mizzy / ghe-proxy.js
Last active December 12, 2015 07:38
var url = require('url');
var http = require('http');
var port = 80;
var cookie = 'xxxxx';
http.createServer(function(serverRequest, serverResponse) {
var requestUrl = url.parse(serverRequest.url);
var body = [];
@mizzy
mizzy / gist:5002809
Created February 21, 2013 06:56 — forked from mala/gist:5002784
このLEMONってのがrapgeniusの人ね。
http://cache.gyazo.com/91f2e906a220fbeef2e9283b0aee597a.png
Unicorn使っても2workerで動いているところに遅いリクエストが3件来たら詰まるよ!!
根本的な解決にならない!!
とか言ってるんですよ。
じゃあ例えば、並列数1x10と並列数2x5で遅いリクエスト5件投げてキューに詰まる確率を考えてみよう。
絵で表すとこう。絵じゃなくて文字だけど。

ヒューマンエラーを許容する

  • 「きをつけよう」は意味ない
  • 実装、プラクティス、プロセスに落とし込む

バグ、ミスオペの混入を防ぐ

  • コードレビュー
  • 二人で作業
  • テストケース
#!/bin/sh
set -e
image=/tmp/sl63.img
root_dir=/tmp/root
truncate -s 5368709120 $image
#!/bin/sh
set -e
image=/tmp/lvm.img
root_dir=/tmp/root
truncate -s 5368709120 $image
require 'container_spec_helper'
describe 'nrpe' do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
describe 'nagios-plugins-all' do
it { should be_installed }
#!/usr/bin/env perl
use strict;
use warnings;
use LWP::UserAgent;
use String::IRC;
use JSON;
my $ukigumo_base_url = 'http://ukigumo.example.jp:5000';
my $repo_url = '[email protected]:foo/puppet.git';