Skip to content

Instantly share code, notes, and snippets.

View mryoshio's full-sized avatar

YOSHIOKA A mryoshio

View GitHub Profile
@mryoshio
mryoshio / sample.tf
Created April 27, 2016 12:16
Terraform Sample Configuration
#
# aws
#
# declare variables
variable "aws_access_key" {}
variable "aws_secret_access_key" {}
# connection
@mryoshio
mryoshio / rsa_enc_dec.rb
Last active October 24, 2018 01:59
RSA encryption/decryption
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)
"""
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

Gemfile

gem 'jquery-rails'

app/assets/javascripts/application.js

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
# 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
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)