Skip to content

Instantly share code, notes, and snippets.

View masayang's full-sized avatar

Masa Nakamura masayang

View GitHub Profile
@masayang
masayang / mapper_with_LongValueSum.py
Created March 9, 2013 01:19
LongValueSumを指定したMapper
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# 標準入力から読み込む
for line in sys.stdin:
# strip()を呼び出して余分な空白や改行コードを取り除く
line = line.strip()
# split()を呼び出して、単語ごとに分ける
@masayang
masayang / creativecommons.txt
Created March 8, 2013 20:15
MapReduce原理説明用
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modif
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Create a Server in specified VPC subnet",
"Parameters": {
"InstanceType": {
"Description": "EC2 instance type",
"Type": "String",
"Default": "t1.micro",
"AllowedValues": [
"m1.small",
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation Sample Template vpc_multiple_subnets.template: Sample template showing how to create a VPC with multiple subnets. The first subnet is public and contains the load balancer, the second subnet is private and contains an EC2 instance behind the load balancer. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters": {
"NetCIDR": {
"Description": "VPC Subnet, like 10.0.0.0/16",
"Type": "String",
"Default": "10.0.0.0/16"
},
"PublicSubnetCIDR": {
@masayang
masayang / virtualenv.sh
Created December 8, 2012 23:21
Preparing Virtualenv for Bootcamp
#! /bin/sh
source virtualenvwrapper.sh
mkvirtualenv bootcamp
cat << EOF > requirements.txt
Baker==1.3
Fabric==1.5.1
boto==2.6.0
paramiko==1.9.0
pycrypto==2.6
EOF
@masayang
masayang / setup.sh
Created December 8, 2012 22:34
Preparing python boto/fabric environment for Bootcamp
#! /bin/sh
sudo yum -y install emacs git gcc make python-devel
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
sudo pip install virtualenvwrapper
. virtualenvwrapper.sh
mkvirtualenv bootcamp
@masayang
masayang / fabfile.py
Created December 8, 2012 22:24
Fabric script for Wordpress on Amazon Linux
from fabric.api import run, env, sudo
from fabric.context_managers import cd
def check():
for k in env:
print k, env[k]
def install_httpd():
sudo("yum -y install httpd")
@masayang
masayang / vpc.py
Created December 7, 2012 01:28
VPC w/ 2 subnets
#! /usr/bin/env python
from boto.vpc import VPCConnection
from boto.ec2 import get_region, connect_to_region
import baker
import time
def create_vpc(region, vpc_cidr):
ec2region = get_region(region)
conn = VPCConnection(region=ec2region)
return conn.create_vpc(vpc_cidr)
@masayang
masayang / vpc.py
Created December 7, 2012 00:27
VPC w/ public subnet
#! /usr/bin/env python
from boto.vpc import VPCConnection
from boto.ec2 import get_region
EC2_REGION='ap-northeast-1'
VPC_CIDR='10.99.0.0/16'
PUBLIC_CIDR='10.99.0.0/24'
@masayang
masayang / dyndns.sh
Created November 18, 2012 01:12
Dynamic DNS script for Route53
#! /bin/bash
export AWS_ACCESS_KEY_ID=YOURAWSKEYHERE
export AWS_SECRET_ACCESS_KEY=YOURAWSSECRETACCESSKEYHERE
HOSTNAME=`curl http://169.254.169.254/latest/meta-data/public-hostname`
TTL=60
R53CMD=/usr/bin/route53
ZONEID=Z1SP2Z8BRPBI0E
CNAME=host.domain.com.