Skip to content

Instantly share code, notes, and snippets.

@toritori0318
toritori0318 / Vagrantfile
Last active December 22, 2015 15:49
vagrant provision test
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'pp'
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos"
config.vm.network :forwarded_port, guest: 80, host: 8888
config.vm.network :private_network, ip: "192.168.33.10"
@toritori0318
toritori0318 / pb_redis_ver2.pl
Created September 5, 2013 17:32
Parallel::Benchmark + RedisDB
use strict;
use warnings;
use Data::Dumper;
use Parallel::Benchmark;
use RedisDB;
use String::Random;
my $host = shift || 'localhost';
my $port = shift || '6379';
@toritori0318
toritori0318 / autoscale_template.json
Last active July 5, 2016 14:36
AutoScaleのCloudFormationのサンプル
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template AutoScalingKeepAtNSample: Create a load balanced, Auto Scaled sample website. This example creates an Auto Scaling group behind a load balancer with a simple health check using a basic getting start AMI that has a simple Apache Web Server-based PHP page. The web site is available on port 80, however, the instances can be configured to listen on any port (8888 by default). **WARNING** This template creates one or more Amazon EC2 instances and an Elastic Load Balancer. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"InstanceType" : {
"Description" : "WebServer EC2 instance type",
"Type" : "String",
"Default" : "m1.small",
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use RedisDB;
use Config::General;
use Array::Diff;
use Text::Diff;
my $redis_conf = shift or die 'usage:redis-conf-diff.pl <redis_config_path>';
@toritori0318
toritori0318 / bench_dynode.js
Created June 25, 2013 08:36
dynode vs node-aws-sdk-dynamodb
var access_key = '';
var secret_key = '';
var region = 'ap-northeast-1';
var dynode = require('dynode');
dynode.auth({
accessKeyId: access_key
,secretAccessKey: secret_key
,region: region
});
yoga render --template='[% i.dnsName %] ' --tagsname='web*' | xargs csshX --ssh_args '-i /path/to/key -l username'
@toritori0318
toritori0318 / sqs_recv.pl
Last active December 16, 2015 13:38
効率よくSQSを処理する単純なスクリプト
use strict;
use warnings;
use Amazon::SQS::Simple;
use Time::Piece;
my $access_key = ''; # Your AWS Access Key ID
my $secret_key = ''; # Your AWS Secret Key
my $queue_name = 'perl_test_queue';
# Create an SQS object
@toritori0318
toritori0318 / benchmark.py
Created April 16, 2013 04:56
httplib2/urllib2/requestsのベンチマーク
from benchmarker import Benchmarker
import urllib2
import httplib2
import requests
h = httplib2.Http()
with Benchmarker(loop=3000) as bm:
for _ in bm.empty(): ## empty loop
pass
@toritori0318
toritori0318 / hello_world.psgi
Created April 15, 2013 16:51
plack/gunicornとfurl/urlopen比較
my $app = sub {
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ];
};
# starman --workers 1 hello_world.psgi -p 5001
####################################################
# ab -c 30 -n 5000 http://127.0.0.1:5001/
Server Software:
@toritori0318
toritori0318 / sqlalchemy.py
Created April 4, 2013 06:57
SQLログ出ない(´・ω・`)
# encoding:utf-8
# via http://docs.sqlalchemy.org/en/rel_0_8/core/engines.html#dbengine-logging
import pdb
import logging
logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)
logging.getLogger('sqlalchemy.dialects').setLevel(logging.DEBUG)
logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG)