Skip to content

Instantly share code, notes, and snippets.

View bundai223's full-sized avatar

bundai223 bundai223

View GitHub Profile
@bundai223
bundai223 / tmux-migrate-options.py
Created May 7, 2019 04:25 — forked from tbutts/tmux-migrate-options.py
For tmux configs: Merge deprecated/removed -fg, -bg, and -attr options into the -style option
#!/usr/bin/env python
# vim: set fileencoding=utf-8
#
# USAGE:
# Back up your tmux old config, run the script and redirect stdout to your conf
# file. Example:
#
# $ cp ~/.tmux.conf ~/.tmux.conf.orig
# $ python ./tmux-migrate-options.py ~/.tmux.conf.orig > ~/.tmux.conf
#
@bundai223
bundai223 / pre-commit
Created April 19, 2019 06:38 — forked from DmZ/pre-commit
Git pre-commit hook to search for Amazon AWS API keys.
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
url - https://aws.amazon.com/blogs/security/a-safer-way-to-distribute-aws-credentials-to-ec2/
Finding hard-coded credentials in your code
Hopefully you’re excited about deploying credentials to EC2 that are automatically rotated. Now that you’re using Roles, a good security practice would be to go through your code and remove any references to AKID/Secret. We suggest running the following regular expressions against your code base:
Search for access key IDs: (?<![A-Z0-9])[A-Z0-9]{20}(?![A-Z0-9]). In English, this regular expression says: Find me 20-character, uppercase, alphanumeric strings that don’t have any uppercase, alphanumeric characters immediately before or after.
Search for secret access keys: (?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=]). In English, this regular expression says: Find me 40-character, base-64 strings that don’t have any base 64 characters immediately before or after.
If grep is your preferred tool, run a recursive, Perl-compatible search using the following commands
@bundai223
bundai223 / create_debian-sys-maint_for_mysqladmin.sh
Created May 23, 2018 05:49 — forked from waja/create_debian-sys-maint_for_mysqladmin.sh
Create 'debian-sys-maint' MariaDB user for use of mysqladmin. Just in case you can't use 'root' via 'unix_socket' plugin.
#!/bin/sh
MYSQLADMIN_CFG="/etc/mysql/mariadb.conf.d/90-mysqladmin.cnf"
# generate password
PASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
# adjust /etc/mysql/debian.cnf (used as defaults file by system scripts)
sed -i "s/^password =.*$/password = ${PASS}/" /etc/mysql/debian.cnf
sed -i "s/^user =.*$/user = debian-sys-maint/" /etc/mysql/debian.cnf
# create config file for mysqladmin itself (maybe not needed)
umask 066
cat > ${MYSQLADMIN_CFG} <<EOF
@bundai223
bundai223 / prepare-commit-msg
Last active August 29, 2015 14:28
Git hook scripts
#!/usr/bin/env ruby
#
# .git/hooks/prepare-commit-msg に配置する
# コミットメッセージのテンプレ追加
if ARGV[1] && ARGV[1].include?("message")
files = `git diff --cached --name-only`
change_files = files.split("\n")
@bundai223
bundai223 / file0.txt
Created April 7, 2015 04:46
xargsで任意の箇所に受け取った文字列を埋め込む ref: http://qiita.com/bundai223/items/bea5a950ff3839f7b921
ls | xargs -IFILES echo FILES
#! /bin/bash
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
# For nginx mainline
sudo sh -c 'echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx" >> /etc/apt/sources.list'
sudo apt-get update
sudo apt-get install nginx
@bundai223
bundai223 / material_color.xml
Created October 10, 2014 04:56
Android Material Design Resource
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
<color name="red_600">#dd191d</color>
<color name="red_700">#d01716</color>
@bundai223
bundai223 / ProgrammingNoKiso_C9
Last active August 29, 2015 14:06
プログラミングの基礎読書会 9章
Chapter 9