Skip to content

Instantly share code, notes, and snippets.

View mryoshio's full-sized avatar

YOSHIOKA A mryoshio

View GitHub Profile
@mryoshio
mryoshio / CmisSampleClient.java
Created December 12, 2011 07:01
CMIS sample client code using Apache Chemistry
/**
* This code uses Apache Chemistry (http://chemistry.apache.org/).
* License accords to Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
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)
# 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
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

Gemfile

gem 'jquery-rails'

app/assets/javascripts/application.js

"""
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 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)
@mryoshio
mryoshio / batcth_write_dynamodb.rb
Created September 28, 2013 16:56
sample ruby script to batch write onto DynamoDB
require 'aws'
require 'aws-sdk'
ACCESS_KEY_ID='access key'
SECRET_ACCESS_KEY='secret access key'
TABLE='table name'
MAX_ITEMS=100
AWS.config({
access_key_id: ACCESS_KEY_ID,
@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 / enum_test.cpp
Created December 23, 2013 14:41
enum in C++
using namespace std;
enum Color {
red, green, blue,
white = 10, black = white,
silver, gold = 99
};
int main()
{