Skip to content

Instantly share code, notes, and snippets.

View inokappa's full-sized avatar
😴
zzzzz

Yohei Kawahara inokappa

😴
zzzzz
View GitHub Profile
@inokappa
inokappa / deploy.rb
Last active December 18, 2016 09:46
シンプルなテーブルを作ったり、削除したり、キャパシティを変更するタスク
require "capistrano_colors"
require "aws-sdk"
set :aws_region, "ap-northeast-1"
set :aws_profile, "oreno-profile"
#####################################################
def dynamo
Aws::DynamoDB::Client.new(region: aws_region, profile: aws_profile)
@inokappa
inokappa / my_issues.gs
Last active October 14, 2020 13:44
Backlog で完了となっていない課題を Google SpreadSheet に取得するスクリプトサンプル
// Backlog API
var backlog_team = "hage"
var backlog_api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var backlog_assigneeid = "12345";
// SpreadSheet
var sheet_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var sheet_name = "my_issues";
function change_issue_status(issue_key, status_code, update_comment) {
  //Logger.log("issue_key: " + issue_key);
@inokappa
inokappa / ftp-check.rb
Last active December 3, 2016 06:29
作成した FTP ユーザーが正しく FTP 操作を行えるかを確認するスクリプト的な何か
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
require "net/ftp"
require "yaml"
class FtpCheck
def initialize(host, mode)
@ftp = Net::FTP.new
@ftp.passive = mode
@inokappa
inokappa / app.py
Last active October 30, 2016 15:09
fitbit で収集した心拍数を flask で Mackerel に飛ばすサンプル
import time, json
from datetime import datetime as dt
from flask import Flask, request, session, redirect
from fitbit.api import FitbitOauth2Client
import fitbit
import requests
app = Flask(__name__)
app.secret_key = 'super secret key'
@inokappa
inokappa / aws-cli.md
Created May 14, 2016 15:42
AWS CLI memo

aws ec2 describe-instances

インスタンスの状態が Running の Public DNS を取得

  • run
aws ec2 describe-instances \
  --filters 'Name=instance-state-name,Values=running' \
 --query 'Reservations[].Instances[].PublicDnsName[]' \
@inokappa
inokappa / in_rds_mysqlslowlog_stream.rb
Last active May 7, 2016 05:28
ファイルに記録された RDS(MySQL) のスロークエリログを読み込む fluentd インプットプラグイン
module Fluent
class InRdsMysqlSlowLogStream < Fluent::Input
Fluent::Plugin.register_input('rds_mysqlslowlog_stream', self)
unless method_defined?(:log)
define_method("log") { $log }
end
unless method_defined?(:router)
define_method("router") { Fluent::Engine }
require 'aws-sdk'
ec2 = Aws::EC2::Client.new(
region: "ap-northeast-1"
)
namespace :ecs do
namespace :instance do
desc "Launch ECS Container Instances"
task :launch do
@inokappa
inokappa / logger.py
Last active February 20, 2016 23:21
Python logger のハンドラに slack Incoming Webhook を使う例
# -*- coding:utf-8 -*-
import sys
import time
import logging
from slack_log_handler import SlackLogHandler
#
# logger の基本設定
#
logger = logging.getLogger()
@inokappa
inokappa / windows-event-log-sample.rb
Last active February 12, 2016 15:07
Ruby スクリプトから Windows Server のイベントログにログを送るメモ
require 'win32/eventlog'
class EventLog
def initialize()
@logger = Win32::EventLog.new
@app_source = "oreno-app"
end
def info(event_id, message)
puts message
@inokappa
inokappa / windows-event-log-sample.py
Last active August 29, 2017 13:34
Python スクリプトから Windows Server のイベントログにログを送るメモ
# -*- coding:utf-8 -*-
import win32api
import win32con
import win32evtlog
import win32security
import win32evtlogutil
import time
class EventLog: