Skip to content

Instantly share code, notes, and snippets.

View futoase's full-sized avatar
🐱
Focusing

Keiji Matsuzaki futoase

🐱
Focusing
  • Japan
View GitHub Profile
@futoase
futoase / put-process-status.sh
Created March 15, 2019 05:59 — forked from michimani/put-process-status.sh
Put linux process status to Amazon CloudWatch.
###################################################################################
# check process aliving (count process number)
# return integer 1 (process is running) or 0 (process is dead) or 9 (some error)
###################################################################################
function is_process_alive() {
count=`ps awux | grep -v grep | grep -v "$0" | grep -w "$1" | wc -l`
if [[ $count =~ ^[0-9]+$ ]]; then
if [ $count != 0 ]; then
echo 1
else
CREATE DATABASE IF NOT EXISTS test_db;
CREATE TABLE IF NOT EXISTS test_db.users (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
age INT NOT NULL,
sex TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
@futoase
futoase / network-address-digital-ocean-instance.rb
Created February 13, 2018 23:59
network-address-digital-ocean-instance
require 'droplet_kit'
# get access token from https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2
# export DIGITAL_OCEAN_TOKEN=XXXXXXXXXXXX
client = DropletKit::Client.new(access_token: ENV['DIGITAL_OCEAN_TOKEN'])
client.droplets.all().map do |i|
i.networks.each do |network|
if network&.first&.ip_address
puts "#{network&.first&.ip_address}"
end
@futoase
futoase / create-digital-ocean-instance.rb
Created February 13, 2018 16:35
create-digital-ocean-instance.rb
require 'openssl'
require 'droplet_kit'
PREFIX = 'prefix-'
CLIENT_COUNT = 50
digest = OpenSSL::Digest.new("sha256")
# get application token from https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2
# export DIGITAL_OCEAN_TOKEN=XXXXXXXX
client = DropletKit::Client.new(access_token: ENV['DIGITAL_OCEAN_TOKEN'])
@futoase
futoase / destroy-digital-ocean-instances.rb
Created February 13, 2018 16:10
digital ocean destroy
require 'openssl'
require 'droplet_kit'
CLIENT_COUNT = 20
digest = OpenSSL::Digest.new("sha256")
# get digital ocean token from
# https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2
# export DIGITAL_OCEAN_TOKEN=XXXXXXXXXXXXXX
client = DropletKit::Client.new(access_token: ENV['DIGITAL_OCEAN_TOKEN'])
@futoase
futoase / api_v1_01_introduction.md
Last active November 16, 2017 06:24 — forked from yokoji/api_v1_01_introduction.md
freee API v1.0

freee API v1.0

全自動クラウド会計ソフトfreeeの開発者向けAPIのドキュメントです。

概要

本APIを利用することで、あなたのアプリやサービスをfreeeと連携させることができます。

提供機能(2013/10/10現在)

set shell=/bin/sh
set guifont=Andale\ Mono:h20
set clipboard=unnamed
set number
set nocompatible
set wildmenu
set autoread
set wrapscan
set shell=/bin/sh
set guifont=Andale\ Mono:h20
set clipboard=unnamed
set number
set nocompatible
set wildmenu
set autoread
set wrapscan
@futoase
futoase / test.rb
Created April 5, 2016 15:23
test.rb
require 'benchmark'
n = 10000000
Benchmark.bm do |x|
x.report ('to_sym') { n.times do ; 'test'.to_sym end }
x.report ('to_s') { n.times do ; :test.to_s end }
end
@futoase
futoase / 0-Searchable list of companies with employees on Hacker News.md
Created March 1, 2016 05:19
Searchable list of companies with employees on Hacker News (from people saying "I work at ...")