Skip to content

Instantly share code, notes, and snippets.

View jacoyutorius's full-sized avatar
🏠
Working from home

jacoyutorius jacoyutorius

🏠
Working from home
View GitHub Profile
@jacoyutorius
jacoyutorius / lifegame.rb
Created June 27, 2018 11:11
Rubyでライフゲーム
def main
lifegame = Lifegame.new(width: 100)
generation = 0
loop do
# puts "Generation: #{generation} ---------------------------"
lifegame.draw
sleep 0.025
generation += 1
end
@jacoyutorius
jacoyutorius / s3_info.rb
Created June 27, 2018 09:56
S3のバケットサイズを取得するRubyスクリプト(AWS CLI使用)
class S3Info
require "json"
require "pstore"
attr_reader :info
def initialize
@info = JSON.parse(`aws s3api list-buckets`)
end
def buckets
@jacoyutorius
jacoyutorius / config.js
Created April 17, 2018 16:44
Vuepressで指定したディレクトリ配下に居るファイルをsidebarに定義する設定
const fs = require('fs');
const path = require('path');
// docs配下に属するディレクトリをサイドバーのグループに定義する
// dir直下のディレクトリにしか対応していない
var dirpath = "./docs"
var dirs = fs.readdirSync(dirpath).filter((f) => {
return fs.existsSync(dirpath + "/" + f) && fs.statSync(dirpath + "/" + f).isDirectory()
})
var sidebarArray = ["/"].concat(dirs.map((dir) => {
<!DOCTYPE html>
<html lang="js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>my page</title>
@jacoyutorius
jacoyutorius / aws-sdk-rekognition-client_sample.rb
Last active November 10, 2017 04:22
aws-sdk-rekognition-client_sample
require "aws-sdk"
require "pp"
cred = Aws::Credentials.new("#{aws_access_key_id}", "#{aws_secret_access_key}")
rekognition = Aws::Rekognition::Client.new(credentials: cred, region: 'us-east-1')
ret = rekognition.detect_labels({
image: {
s3_object: {
bucket: "yutoogi.images",
@jacoyutorius
jacoyutorius / ruby_dynamodb.rb
Last active September 12, 2017 16:01
Ruby on DynamoDB local
=begin
mkdir dynamodb_local
wget https://s3-ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/dynamodb_local_latest.tar.gz -P dynamodb_local
tar -xzvf dynamodb_local/dynamodb_local_latest.tar.gz -C dynamodb_local
echo '#!/bin/bash\njava -Djava.library.path=./dynamodb_local/DynamoDBLocal_lib -jar dynamodb_local/DynamoDBLocal.jar -sharedDb' >> dynamodb_local/start.sh
chmod 700 start.sh
bash dynamodb_local/start.sh
=end
# (output sample)
# {"Library Tapes"=>
# [{"A Summer Beneath The Trees"=>
# ["01 The Sound Of Emptiness Part 1.m4p",
# "02 Pieces Of Us Were Left On The Tracks....m4p",
# "03 Above The Flood.m4p",
# "04 A Summer Beneath The Trees.m4p",
# "05 The Fragile Tide.m4p",
# "06 The Modest Triumph.m4p",
# "07 The Sound Of Emptiness Part 2.m4p",
@jacoyutorius
jacoyutorius / template.rb
Created July 9, 2017 13:40
rails template
# rails template
# rails new testapp -m ./template.rb --skip-bundle --skip-test
# development, test
gem_group :development, :test do
gem "better_errors"
gem "binding_of_caller"
gem "pry-byebug"
gem "pry-doc"
gem "bullet"
@jacoyutorius
jacoyutorius / index.js
Last active June 21, 2017 00:51
AWSLambdaSlackNotification
var event = {
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:EXAMPLE",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "1970-01-01T00:00:00.000Z",
"Signature": "EXAMPLE",
@jacoyutorius
jacoyutorius / Vagrantfile
Last active June 8, 2017 22:17
Vagrantfile for AmazonLinux
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at