Skip to content

Instantly share code, notes, and snippets.

View skatsuta's full-sized avatar

Soshi Katsuta skatsuta

View GitHub Profile
@skatsuta
skatsuta / install_python_36_amazon_linux2.sh
Last active November 4, 2022 09:01 — forked from PabTorre/install_python_36_amazon_linux2.sh
Install Python 3.6 in Amazon Linux 2
#!/usr/bin/env bash
# A virtualenv running Python3.6 on Amazon Linux/EC2 (approximately) simulates the Python 3.6 Docker container used by Lambda
# and can be used for developing/testing Python 3.6 Lambda functions
# This script installs Python 3.6 on an EC2 instance running Amazon Linux and creates a virtualenv running this version of Python
# This is required because Amazon Linux does not come with Python 3.6 pre-installed
# and several packages available in Amazon Linux are not available in the Lambda Python 3.6 runtime
# The script has been tested successfully on a EC2 instance
# running 4.9.75-1.56.amzn2.x86_64
@skatsuta
skatsuta / copy-new-relic-chart-link.js
Created June 1, 2018 03:54
Bookmarklet to copy a link of an embeddable chart on New Relic quickly
@skatsuta
skatsuta / ec2_enable_longer_id.sh
Last active May 5, 2016 16:39
Enable to use EC2 longer ID format for all resources in all regions by using AWS CLI.
#!/bin/bash
set -eu
# Change this as you want
PROFILE=default
# Check user ARN of the profile
USER_ARN=$(aws --profile $PROFILE sts get-caller-identity --query 'Arn' --output text)
echo "User ARN: '$USER_ARN'"
@skatsuta
skatsuta / .envrc
Last active January 9, 2016 08:15
.envrc for setting environment variables of Docker Machine
local machine=dev
local state=`docker-machine ls | grep $machine | awk '{ print $4 }'`
# Start machine if not running
if [[ "$state" != "Running" ]]; then
echo "Machine \"$machine\" is not running. Starting..."
docker-machine start $machine
docker-compose up -d
fi
@skatsuta
skatsuta / race_map.go
Last active November 12, 2015 17:14
Race condition demo of a map in Go. Try `go run race_map.go` many times.
package main
import (
"sync"
"github.com/k0kubun/pp"
)
func main() {
m := map[int]string{}
@skatsuta
skatsuta / Dockerfile-private-repo
Last active October 23, 2015 10:36
Sample Dockerfile that uses a private repository to build
FROM google/golang
RUN apt-get update -y && \
apt-get install -y ca-certificates git-core ssh
ADD id_rsa /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
RUN git config --global url.ssh://git@github.com/.insteadOf https://github.com/
@skatsuta
skatsuta / coolio_1.2.4_build_error.log
Last active September 29, 2015 18:38
cool.io v1.2.4 build error
/Users/soshi/.rbenv/versions/2.1.5/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_alone()... yes
checking for rb_str_set_len()... yes
checking for clock_gettime() in -lrt... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
@skatsuta
skatsuta / docker-machine.sh
Last active January 5, 2021 15:59
Tired of running `eval "$(docker-machine env host)"` every time? Just paste this in .bashrc / .zshrc. This script automatically sets environment variables for one of running host machines in Docker Machine.
# check if `docker-machine` command exists
if command -v docker-machine > /dev/null; then
# fetch the first running machine name
local machine=$(docker-machine ls | grep "Running" | head -n 1 | awk '{ print $1 }')
if [ "$machine" != "" ]; then
eval "$(docker-machine env $machine)"
fi
fi
@skatsuta
skatsuta / wercker_cache.sh
Last active August 29, 2015 14:22
Script for storing / restoring cache in Java / Scala project on wercker
#!/bin/bash
#=========================================
# Script for storing and restoring cache
# in Java / Scala project on werkcer
#=========================================
# cache directories
CACHES=( "ivy2" "sbt" )
CMD="$1"
@skatsuta
skatsuta / mysqldump.sh
Last active May 5, 2016 06:32
mysqldump command
#!/bin/bash
DATABASE="$1"
TABLE="$2"
mysqldump
--user=username \
--password=password \
--complete-insert \
--quick \