Skip to content

Instantly share code, notes, and snippets.

YOSHIOKA A mryoshio

Block or report user

Report or block mryoshio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View export-issues.py
"""
ref. https://gist.github.com/mike-ward/23dab967feaf71bde2c1
Exports Issues from a specified repository to a CSV file
- Github API v3: https://developer.github.com/v3/gists/
- ZenHub API: https://github.com/ZenHubIO/API
"""
import csv
import requests
@mryoshio
mryoshio / rsa_enc_dec.rb
Last active Oct 24, 2018
RSA encryption/decryption
View rsa_enc_dec.rb
require 'base64'
require 'openssl'
def enc(der, msg)
rsa = OpenSSL::PKey::RSA.new(der)
rsa.private_encrypt(msg)
end
def dec(der, msg)
rsa = OpenSSL::PKey::RSA.new(der)
@mryoshio
mryoshio / sample.tf
Created Apr 27, 2016
Terraform Sample Configuration
View sample.tf
#
# aws
#
# declare variables
variable "aws_access_key" {}
variable "aws_secret_access_key" {}
# connection
@mryoshio
mryoshio / how_to_use_pageble_response.rb
Created Mar 31, 2015
How to use PagebleResponse in AWS SDK for Ruby version 2
View how_to_use_pageble_response.rb
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
@mryoshio
mryoshio / add_cloudwatch_alarms.rb
Created Mar 28, 2015
Add two CloudWatch alarm
View add_cloudwatch_alarms.rb
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}",
@mryoshio
mryoshio / switch_opsworks_auto_healing.rb
Created Jan 30, 2015
update OpsWorks Layers' enable_auto_healing
View switch_opsworks_auto_healing.rb
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|
@mryoshio
mryoshio / update_elb_certificate.rb
Created Jan 27, 2015
Update ELB SSL Certificate
View update_elb_certificate.rb
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 Aug 29, 2015
Create EC2 Image (AMI) of running instances
View create_ec2_image.rb
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."
View lod.cpp
#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 Nov 12, 2014
Fibonacci number with DP
View fibonacci_dp.cpp
#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;
You can’t perform that action at this time.