Skip to content

Instantly share code, notes, and snippets.

View mryoshio's full-sized avatar

YOSHIOKA A mryoshio

View GitHub Profile
@mryoshio
mryoshio / update_elb_certificate.rb
Created January 27, 2015 07:27
Update ELB SSL Certificate
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)
@mryoshio
mryoshio / create_ec2_image.rb
Last active August 29, 2015 14:10
Create EC2 Image (AMI) of running instances
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."
@mryoshio
mryoshio / lod.cpp
Created November 12, 2014 11:48
lod with DP
#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;
@mryoshio
mryoshio / fibonacci_dp.cpp
Created November 12, 2014 11:15
Fibonacci number with DP
#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;
@mryoshio
mryoshio / check_poodle.rb
Created October 15, 2014 10:59
check your elbs if against SSLv3 (POODLE)
require 'aws'
AWS.config(
:access_key_id => 'xxx',
:secret_access_key => 'xxx',
:region => 'ap-northeast-1'
)
elb = AWS::ELB.new
@mryoshio
mryoshio / sidekiq_init_script.sh
Last active August 29, 2015 14:03
sidekiq init script sample
#!/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
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
double accum(double* beg, double* end, double init)
{
return accumulate(beg, end, init);
}
double comp2(vector<double>& v)
{
using Task_type = double(double*, double*, double);
packaged_task<Task_type> pt0 { accum }; // タスク(i.e., accum)をパッケージ化
packaged_task<Task_type> pt1 { accum };
package main
import "fmt"
const (
StationNumber = 6
StartStation = 0
)
var (
package main
import "fmt"
/*
usage: go run multi_dimension_array_play.go
*/
var multiDimensionArray = [2][5]int{ {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10} }