This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book < AWS::Record::HashModel | |
set_shard_name :Book | |
string_attr :title | |
string_attr :author | |
string_attr :content | |
end | |
unless Book.dynamo_db_table.exists? | |
Book.create_table 1, 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#define STATION_NUMBER (6) | |
#define START_STATION (0) | |
using namespace std; | |
string stations[] = { "Yokohama", "Musashikosugi", "Shinagawa", "Shibuya", "Shimbashi", "Tameikesannno" }; | |
int current_cost[STATION_NUMBER] = { -1, -1, -1, -1, -1, -1 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation for HTTP OPTIONS method in rails 3.2.13 | |
# inspired by https://gist.github.com/ajturner/832700 | |
# routes.rb | |
match '/*any_path', :controller => 'application', :action => 'method_for_options_method', :constraints => { :method => 'OPTIONS' } | |
# application_controller.rb | |
def method_for_options_method | |
render :nothing => true, :status => 200 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REQUEST_METHOD} ^OPTIONS | |
RewriteRule .* - [R=405,L] | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#define df(f) cout << "# " << f << endl | |
using namespace std; | |
void get_bit(int num, int i) { | |
df(__func__ << "(" << num << ", " << i << ")"); | |
cout << "Get " << i << "'th bit is : "; | |
cout << ((num & (1 << i)) != 0) << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
// see http://d.hatena.ne.jp/kobapan/20090208/1281901941 | |
int strbin2i (const std::string &s) { | |
int out = 0; | |
for (int i = 0, size = s.size() ; i < size ; ++i ) { | |
out *= 2; | |
out += ((int)s[i] == 49) ? 1 : 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/utility/binary.hpp> | |
#include <iostream> | |
using namespace std; | |
#define B(x) BOOST_BINARY(x) | |
void row1() { | |
cout << "# row1" << endl; | |
cout << (B(0110) + B(0010)) << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef BINARY_OP_H | |
#define BINARY_OP_H | |
#include <vector> | |
#include <sstream> | |
using namespace std; | |
// see http://d.hatena.ne.jp/kobapan/20090208/1281901941 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<source> | |
type tail | |
format apache2 | |
path /var/log/apache2/access_log | |
pos_file /var/log/fluent/tmp/apache2.access_log.pos | |
tag s3.apache.access | |
</source> | |
# S3 plugin test | |
<match s3.*.*> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws' | |
require 'aws-sdk' | |
ACCESS_KEY_ID='access key' | |
SECRET_ACCESS_KEY='secret access key' | |
TABLE='table name' | |
MAX_ITEMS=100 | |
AWS.config({ | |
access_key_id: ACCESS_KEY_ID, |