Skip to content

Instantly share code, notes, and snippets.

#include<iostream>
#include<algorithm>
#include<vector>
#include<boost/lexical_cast.hpp>
#include<boost/iterator/counting_iterator.hpp>
int main(void) {
std::vector<std::string> fizzbuzz;
@a-hisame
a-hisame / create_spots.py
Created July 30, 2014 12:39
Create AWS Spot Instance Automation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
スポットインスタンスを自動的に指定個数リクエストをかけてインスタンスを作る。
作成したインスタンスIDを標準出力する。
Python2.7 + boto で動作確認。
キーを残したくない場合はコネクションの作成を工夫すること。
@a-hisame
a-hisame / non-implements-eq.hs
Created September 3, 2014 08:31
当たり前だけれど、Eqのデフォルト実装を上書きしない場合、無限ループに陥る。
-- test on ghci console
data Present a = Redbox a | Bluebox a deriving Show
instance Eq (Present a)
let a = Redbox 10
let b = Redbox 30
-- never stop
a == b
@a-hisame
a-hisame / dump.py
Created December 4, 2014 10:07
DynamoDBのダンプを取るプログラム。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Get Dump from DynamoDB (All Tables).
This program does not cover all DynamoDB format,
but It's good enough for me.
restore.py can restore Tables from this outputs JSON files.
@a-hisame
a-hisame / restore.py
Created December 4, 2014 10:13
dump.py で取得したdumpファイルからDynamoDBを復元するプログラム
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Restore DynamoDB Tables from Dump File.
This program does not cover all DynamoDB format,
but It's good enough for me.
dump.py can dump Tables to JSON file.
@a-hisame
a-hisame / sender.py
Created December 16, 2014 07:23
SNSへの通知を行うプログラム
#!/usr/bin/env python
# coding: utf-8
import uuid
import datetime
import boto.sns
# -----------------------
# 設定によって変更するところ
@a-hisame
a-hisame / receiver.py
Created December 16, 2014 07:25
QueueからデータをPollingして、処理をし、処理結果をDynamoDBに保存するサンプル
#!/usr/bin/env python
# coding: utf-8
import time
import datetime
import json
import logging
import boto.sqs
@a-hisame
a-hisame / finish_notify.py
Created December 16, 2014 07:26
DynamoDBのテーブルに処理結果が格納されたかをチェックするプログラム
#!/usr/bin/env python
# coding: utf-8
# -----------------------
# 設定によって変更するところ
# -----------------------
REGION = 'ap-northeast-1'
AWS_ACCESS_KEY = ''
AWS_SECRET_ACCESS_KEY = ''
@a-hisame
a-hisame / DispatchTest.scala
Created January 8, 2015 13:40
実行するとMainスレッドが落ちても裏でスレッドが動作しててアプリケーションが終了しない。
import dispatch.url
import dispatch.Http
import dispatch.as
import dispatch.Defaults._
object Main {
def main(args: Array[String]): Unit = {
import dispatch._, Defaults._
val svc = url("http://www.google.co.jp/")
@a-hisame
a-hisame / gzip_s3_and_json.py
Created May 17, 2016 07:27
Amazon S3と永続化ファイルを経由せずにjson.gzを取り扱う (boto3を利用)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import gzip
import StringIO
import boto3
def upload(bucket, key, obj):
s3 = boto3.client('s3')