Skip to content

Instantly share code, notes, and snippets.

View mmasashi's full-sized avatar

Masashi mmasashi

View GitHub Profile
@mmasashi
mmasashi / README.md
Last active May 1, 2021 10:38
Install Oracle instant client (sqlplus) v12.1 on MacOSX

Install Oracle instant client (sqlplus) on MacOSX

  1. Get Oracle instant client for MacOSX
  1. Unarchive downloaded zip files into a same directory
  • ex: $HOME/Downloads/instantclient_12_1
  1. Create install.sh and copy the following code and past it on that file.
@mmasashi
mmasashi / example_query.txt
Last active July 9, 2020 22:10
Get primary key columns on PostgreSQL/Amazon Redshift
-- Get primary keys for "fsb_schema_7_7379bca4"."m_test_table_multi_pk"
SELECT
f.attnum AS number,
c.relname AS table_name,
f.attname AS column_name
FROM pg_attribute f
JOIN pg_class c ON c.oid = f.attrelid
JOIN pg_type t ON t.oid = f.atttypid
LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum
@mmasashi
mmasashi / delete_dup_records_redshift.rb
Last active August 31, 2020 22:04
Duplicate Record Delete Query Generator For Amazon Redshift
# Duplicate record delete query generator for Amazon Redshift
# By running a generated query, duplicate rows in a specified table will be removed.
#
# Usage:
# ruby delete_dup_records_redshift.rb <table-name> <priary-keys-with-comma-separator>
unless ARGV.count == 2
puts <<EOT
Usage:
ruby delete_dup_records_redshift.rb <table name> <primary keys>
@mmasashi
mmasashi / osx_el_capitan_initial_settings.md
Last active October 11, 2015 05:32
El Capitan Initial Setup

Prepare for OS update (事前準備)

  • Backup data to Time machine drive
  • Backup some important data to HDD drive manually
  • Make a list which directory should be copied into the new OS
  • Export vicosity config into a file

Clean Install El Capitan (El Capitanのクリーンインストール)

@mmasashi
mmasashi / sigdump_with_mem.sh
Last active September 17, 2015 05:43
Get sigdump with timestamp filename and extract memory section in sorted order by the variable name.
#!/bin/bash
pid=$(expr "$1" : '\([0-9][0-9]*\)')
if [ "$1" = "" ] || [ "$1" != "$pid" ]; then
echo "pid requires to be given"
exit 1
fi
kill -CONT $pid
sleep 1
@mmasashi
mmasashi / validate_number_argument.sh
Created September 17, 2015 05:38
Validate number for argument value (Bash)
#!/bin/bash
pid=$(expr "$1" : '\([0-9][0-9]*\)')
if [ "$1" = "" ] || [ "$1" != "$pid" ]; then
echo "pid requires to be given"
exit 1
fi
echo $pid
@mmasashi
mmasashi / install_mysql_server.md
Last active April 26, 2024 01:37
How to install mysql-server from source code

Install MySQL

Install dependencies

sudo yum install ncurses-devel

Download MySQL source code

@mmasashi
mmasashi / convert_s3endpoint_to_region.rb
Created July 30, 2015 19:15
convert s3 endpoint to region
# Convert s3-endpoint to region name
# http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
def self.endpoint_to_region(endpoint)
case endpoint.to_s
when ''
nil
when 's3.amazonaws.com', 's3-external-1.amazonaws.com'
'us-east-1'
when 's3-us-west-2.amazonaws.com'
'us-west-2'
@mmasashi
mmasashi / sigdump_flydata.sh
Created June 18, 2015 21:41
dump flydata-agent sigdump
flydata_pid=$(pgrep -P $(cat ~/.flydata/flydata.pid)); kill -CONT $flydata_pid && echo "/tmp/sigdump-$flydata_pid.log"
@mmasashi
mmasashi / run_command_on_instance.rb
Created May 29, 2015 01:38
Run OpsWorks Stack command on Instance
require 'aws-sdk-v1'
require 'pp'
AWS_KEY_ID = ENV['AWS_KEY_ID']
AWS_SEC_KEY = ENV['AWS_SEC_KEY']
opsw = AWS::OpsWorks.new(access_key_id: AWS_KEY_ID, secret_access_key: AWS_SEC_KEY)
@opsw_cli = opsw.client
def retrieve_stacks(region = nil, stack_prefix_hint = nil)