gem 'jquery-rails'
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
def generate_tgz(filepath, contents) | |
tar = StringIO.new | |
Gem::Package::TarWriter.new(tar) do |writer| | |
writer.add_file(filepath, 0600) do |f| | |
f.write(contents) | |
end | |
end | |
tar.seek(0) | |
gz = Zlib::GzipWriter.open("#{filepath}.tar.gz") do |gz| | |
gz.write(tar.read) |
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
# sample task model | |
# | |
# > rails c | |
# irb(main):004:0> t.finish | |
# "-------> notify_done with 0" | |
# "-------> notify_done with 1" | |
# "-------> notify_done with 2" | |
# "-------> notify_done end" | |
# => true | |
class Task < ActiveRecord::Base |
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 'csv' | |
require 'octokit' | |
require 'pry' | |
BEGIN_OF_2019 = Time.new('2019-01-01 00:00:00 UTC') | |
def client | |
@client ||= Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'], per_page: 100) | |
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
""" | |
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 |
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 '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) |
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
# | |
# aws | |
# | |
# declare variables | |
variable "aws_access_key" {} | |
variable "aws_secret_access_key" {} | |
# connection |
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 |
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' | |
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| |
NewerOlder