Skip to content

Instantly share code, notes, and snippets.

View yyoshiki41's full-sized avatar
📻

Yoshiki Nakagawa yyoshiki41

📻
View GitHub Profile
curl -fsSL https://mackerel.io/file/script/amznlinux/setup-yum.sh | sh
sudo cp /etc/mackerel-agent/mackerel-agent.conf.rpmsave /etc/mackerel-agent/mackerel-agent.conf
sudo yum clean all
sudo yum install -y mackerel-agent mackerel-agent-plugins mackerel-check-plugins mkr
sudo /sbin/service mackerel-agent start
$ vim cat .ssh/config
Host github.com
HostName github.com
IdentityFile ~/.ssh/github_id_rsa
User username

$ sudo -u jenkins ssh -T [email protected]
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
grep -rl "before" ./ | xargs perl -i -pe "s/before/after/g"

複数の返り値

関数は一つ以上の結果を返すことが出来る。

これまでに、2つ以上の値を結果として返す標準pkg内の関数の例をみることが出来る、計算された結果とそのエラーの値もしくは、計算が機能したかどうかを示すブール値など。

https://github.com/adonovan/gopl.io/blob/master/ch5/findlinks2/main.go

4つのreturn があり、それらは結果のペアを返す。

# suspend
aws autoscaling suspend-processes --auto-scaling-group-name hoge 
# resume
aws autoscaling resume-processes --auto-scaling-group-name hoge
@yyoshiki41
yyoshiki41 / tw-search.js
Last active December 30, 2020 04:42
twitter の検索結果をspreadsheetに書き出す。
var TWITTER_CONSUMER_KEY = '';
var TWITTER_CONSUMER_SECRET = '';
var SHEET_NAME = '';
function trigger() {
search('#検索単語', 0);
}
function reset() {
var service = getService();
require 'net/http'
require 'uri'
require 'json'
resp = JSON.parse($stdin.gets)
if resp["exitCode"] != 0 then
uri = URI.parse("https://hooks.slack.com/services/***")
payload = {
text: "```#{JSON.pretty_generate(resp)}```",
@yyoshiki41
yyoshiki41 / monthly-forecast.sql
Last active January 11, 2017 05:57
当月の獲得数から、着地予想を出す。(線形近似)
SELECT
count(*) AS count,
floor(
COUNT(*) * date_part('day', DATE_TRUNC('month', now() + '1 months') + '-1 days') / date_part('day', now())
) AS forecast
FROM user
WHERE registered_at >= CAST(DATE_TRUNC('month', now()) AS TIMESTAMP)
@yyoshiki41
yyoshiki41 / 2weeks-forecast.sql
Last active January 23, 2017 00:50
過去2週間分の登録者数から、着地予想を出す。(線形近似)
SELECT
SUM(
CASE WHEN registered_at >= DATE_TRUNC('month', now()) THEN 1 ELSE 0 END
) AS COUNT,
SUM(
CASE WHEN registered_at >= DATE_TRUNC('month', now()) THEN 1 ELSE 0 END
) + SUM(
CASE WHEN registered_at BETWEEN DATE_TRUNC('day', now() + '-14 days') AND DATE_TRUNC('day', now()) THEN 1 ELSE 0 END
) / 14 * (
date_part('day', DATE_TRUNC('month', now() + '1 months') + '-1 days') - date_part('day', DATE_TRUNC('day', now()))