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
double comp4(vector<double>& v) // vが十分大きい場合に多くのタスクを開始 | |
{ | |
if (v.size() < 10000) // concurrencyにする価値があるか? | |
return; | |
accum(v.begin(), v.end(), 0.0); | |
auto v0 = &v[0]; | |
auto sz = v.size(); | |
auto f0 = async(accum, v0, v0 + sz/4, 0.0); // 1st quarter |
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
#!/bin/sh | |
# | |
# sidekiq_tkikaku Init script for Sidekiq tkikaku | |
# | |
# chkconfig: 345 75 25 | |
# description: Starts and Stops Sidekiq message processor for Stratus application. | |
# processname: sidekiq_tkikaku | |
# user-specified exit parameters used in this script: | |
# | |
# Exit Code 5 - Incorrect User ID |
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' | |
AWS.config( | |
:access_key_id => 'xxx', | |
:secret_access_key => 'xxx', | |
:region => 'ap-northeast-1' | |
) | |
elb = AWS::ELB.new |
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> | |
#include <vector> | |
using namespace std; | |
int main() { | |
long n; | |
cout << "n: "; cin >> n; | |
if (n == 0 || n == 1) { | |
cout << "fibo(" << n << ") is " << n << 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> | |
#include <algorithm> | |
using namespace std; | |
int prices[] = { 0, 1, 5, 8, 9, 10, 17, 17, 20, 24, 30 }; | |
int N; | |
void solve() { | |
for (int i = 1; i <= N; i++) { | |
int v = 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
require 'aws-sdk' | |
def main | |
ec2 = AWS::EC2.new | |
ec2.regions.each do |r| | |
puts "# region: #{r.name}" | |
r.instances.each do |i| | |
puts "## instance: #{i.id} #{i.tags[:Name]}" | |
if i.status != :running | |
puts "- [skipped] name: #{i.tags[:Name]} because it's not running." |
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-sdk' | |
NEW_CERT_NAME = 'xxx' | |
REGIONS = AWS::EC2.new.regions.map(&:name) | |
NEW_CERT = AWS::IAM.new.server_certificates[NEW_CERT_NAME] | |
REGIONS.each do |r| | |
puts "# region: #{r}" | |
elb = AWS::ELB.new(region: r) |
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-sdk' | |
TO=false | |
def main | |
client = AWS::OpsWorks::Client.new(region: 'us-east-1') | |
client.describe_stacks[:stacks].each do |s| | |
puts "## #{s[:stack_id]}: #{s[:name]}" | |
puts "##### [begin] at #{Time.now}" | |
client.describe_layers(stack_id: s[:stack_id])[:layers].each do |l| |
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-sdk' | |
REGION = 'ap-northeast-1' | |
WAIT_INTERVAL = 1 | |
def put_alarms(instance_id) | |
cloudwatch = Aws::CloudWatch::Client.new(region: REGION) | |
cloudwatch.put_metric_alarm( | |
alarm_name: "cpu-mon-#{instance_id}", |
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-sdk' | |
REGION = 'ap-northeast-1' | |
cloudwatch = Aws::CloudWatch::Client.new(region: REGION) | |
res = cloudwatch.describe_alarms | |
while true | |
res.metric_alarms.each do |al| | |
# some logic for each alarm |