Skip to content

Instantly share code, notes, and snippets.

@toritori0318
toritori0318 / hello.py
Last active August 29, 2015 13:55
boto 2.24.0 (gevent?) problem...
# -*- coding: utf-8 -*-
from flask import Flask
app = Flask(__name__)
app.config['DEBUG'] = True
import boto.sqs
AWS_ACCESS_KEY = 'xxxxxxxxxxxxxx'
AWS_SECRET_KEY = 'xxxxxxxxxxxxxx'
class SqsClient(object):
####
T 172.31.22.82:46389 -> 172.31.17.27:3000 [AP]
GET /engine.io/?EIO=2&transport=polling HTTP/1.1.
User-Agent: node-XMLHttpRequest.
Accept: */*.
Host: 172.31.17.27:3000.
Connection: close.
.
##
@toritori0318
toritori0318 / userdata
Created February 7, 2014 07:39
userdataでmount
#!/bin/bash -ex
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
while [ ! -e /dev/sdb ]; do echo Waiting for Ephemeral Disk to attach; sleep 5; done
if ! `df | grep -q /media/ephemeral0` ; then
mkfs.ext3 /dev/sdb
mount -t ext3 /dev/sdb /media/ephemeral0
fi
# snip...
@toritori0318
toritori0318 / lgtm.pl
Created February 19, 2014 09:45
ircbot用lgtm
use strict;
use Web::Scraper;
use URI;
my $uri = URI->new('http://www.lgtm.in/g');
my $scraper = scraper {
process '//input[@id="imageUrl"]', 'image_url' => '@value';
process '//input[@id="dataUrl"]', 'data_url' => '@value';
};
my $result = $scraper->scrape($uri);
@toritori0318
toritori0318 / ikachan_color_notice.pl
Last active August 29, 2015 13:57
ikachanでメッセージをカラフルにするラッパー
# example:
# perl ikachan_color_notice.pl ikachan-server.com \#main '%{red:hoge}%fuga%{yellow:piyo}%e'
# screenshot:
# http://gyazo.com/b7cb0bc5013b724d6ddbb9bf983a8ffa
use strict;
use warnings;
use LWP::UserAgent;
my $usage = 'usage: ikachan_color_notice.pl <host> <channel> <message>';
use strict;
use warnings;
use WebService::Dropbox;
my $app = '/';
my $dropbox = WebService::Dropbox->new({
key => 'xxxxxx', # App Key
secret => 'xxxxxx' # App Secret
});
module Hoge
class Fuga
end
end
module Hoge
module Fuga
class Piyo
end
end
@toritori0318
toritori0318 / aws_rikanjo_cli.rb
Last active August 29, 2015 14:02
rikanjoのやつ
require 'optparse'
require 'aws/rikanjo/base'
module Aws
module RiKanjoo
class CLI
def initialize
@options = {}
@optparse = nil
@toritori0318
toritori0318 / sysctl.conf
Created October 16, 2014 17:43
sysctlメモ
# カーネルパニックで再起動する
kernel.panic = 10
# tcp
# net.ipv4.tcp_tw_recycle = 1 # LB以下で使うと副作用あり?/でもtimestamp=0で指定すれば問題なさそう?
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 5
# ソケットあたりのメモリチューニング
# データ受信バッファ サイズ
@toritori0318
toritori0318 / install.sh
Last active August 29, 2015 14:10
openresty install
PCRE_VERSION=8.36
OPENRESTY_VERSION=1.7.7.1
LUAROCKS_VERSION=2.2.0
# depends
sudo yum install -y openssl-devel
# pcre
cd /tmp
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCRE_VERSION}.tar.gz