Skip to content

Instantly share code, notes, and snippets.

View bageljp's full-sized avatar

Keisuke Kadoyama bageljp

  • Tokyo, Japan
  • 13:46 (UTC +09:00)
  • X @bageljp
View GitHub Profile
@bageljp
bageljp / fish_prompt.fish
Created January 4, 2019 12:11
fish_prompt with k8s ctx and ns
$ diff ~/.config/fisherman/bobthefish/fish_prompt.fish ~/.config/fisherman/bobthefish/fish_prompt.fish.org Fri Jan 4 21:11:16 2019
509,516c509
< # Customize: START
< set -l ctx (string trim -c '"\' ' -- $val)
< set -l ns (kubectl config view -o "jsonpath={.contexts[?(@.name==\"$ctx\")].context.namespace}")
< [ -z $ns ]; and set -l ns 'default'
< set -l context "$ctx/$ns"
< # Customize: END
<
< #set -l context (string trim -c '"\' ' -- $val)
@bageljp
bageljp / README.md
Created May 4, 2018 14:19
nginx_maintenance_user_id
  • POSTのbodyの中にuser_idというパラメータが含まれており、そのuser_idが特定の値(この例だと1000,2000,5000)の場合のみリクエストを許可
  • それ以外はメンテナンスを返す
@bageljp
bageljp / sigV4Client.js (2016-05-30)
Created July 30, 2016 08:30
ApiGateway SDK encoding (RFC3986 Non-reserved character)
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
@bageljp
bageljp / add_permission.py
Created July 9, 2016 17:04
Add permissions AWS Lambda Function with API Gateway
# encoding=utf-8
import argparse
import boto3
import os
import sys
import json
from datetime import datetime
import re
import uuid
@bageljp
bageljp / lambda-as-slack
Last active November 8, 2015 03:50
AWS_Lambda_source_AutoScaling_SNS
console.log('Loading function.');
const https = require('https');
const url = require('url');
const slack_url = 'https://hooks.slack.com/services/XXXXX'; // slack url
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
exports.handler = function(event, context) {
@bageljp
bageljp / post-commit
Last active November 8, 2015 03:35
SVN commit mail
#!/bin/sh
export LANG=ja_JP.utf8
REPOS="$1"
REV="$2"
# コミットユーザ
COMMIT_AUTOER=`svnlook author -r ${REV} ${REPOS}`
# コミットログ
Chef::Config[:cookbook_path].each{|elem|
if File.exists?(File.join(elem, "/nginx/templates/default/", node['nginx']['template_dir']))
conf_dir = File.join(elem, "/nginx/templates/default/", node['nginx']['template_dir'])
Dir.chdir conf_dir
confs = Dir::glob("**/*")
confs.each do |t|
if File::ftype("#{conf_dir}/#{t}") == "file"
template "/etc/nginx/#{t}" do
owner "root"
#!/bin/bash
#------------------------------------------------------------------------------------------------------------------------
# cron setting:
# */3 * * * * /root/resource.bash > /dev/null 2>&1
#------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------
# ENVIRONMENT
#------------------------------------------------------------------------------------------------------------------------
DIR_LOG="/tmp/`basename $0 .bash`"
@bageljp
bageljp / mysql_table_engine.bash
Created February 19, 2014 00:44
mysql utility.
#!/bin/bash
MYSQL_DB="$1”
MYSQL_HOST=“${2:-localhost}”
MYSQL_PASS="${3:-password}"
mysql -u root -p${MYSQL_PASS} -h ${MYSQL_HOST} -s ${MYSQL_DB} -e "show tables;" | grep -v Tables_in_ | while read line; do
echo "== ${MYSQL_DB}.${line} ============================================================================="
mysql -u root -p${MYSQL_PASS} -h ${MYSQL_HOST} -s ${MYSQL_DB} -e "show create table ${MYSQL_DB}.${line};" | grep ENGINE | grep -v 'ENGINE=InnoDB'
done
@bageljp
bageljp / chk_mount.bash
Created February 13, 2014 07:13
mount check
#!/bin/bash
FL_CHECK=".health_check.html.`hostname`"
MESSAGE=""
LIST_MOUNT[0]="/var/www/html/contents"
ret=0
flg_err=0
for i in ${LIST_MOUNT[@]}; do
rm -f "${i}/${FL_CHECK}"