Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Ryota rkaneko

🎯
Focusing
Block or report user

Report or block rkaneko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rkaneko
rkaneko / psql-grant.md
Last active Jan 10, 2019
psql grant, logs configurations
View psql-grant.md
# display privileges
SELECT grantee, privilege_type FROM information_schema.role_table_grants WHERE table_name='some_table_name';

  grantee  | privilege_type
-----------+----------------
 root      | INSERT
 root      | SELECT
 root      | UPDATE
 root      | DELETE
@rkaneko
rkaneko / docker-disk-troubles.md
Last active Dec 20, 2018
Docker disk trouble shooting
View docker-disk-troubles.md

Case: No space left on device error

# remove unnecessary images
docker rm $(docker ps -q -f 'status=exited')
docker rmi $(docker images -q -f "dangling=true")

Case: Volumes are full

@rkaneko
rkaneko / README.md
Last active Dec 19, 2018
awk sample for mapping some column values in some .csv file
View README.md

awk command sample for mapping some column values in some .csv file

$ cat origin.csv
id,created,notes
1,1518393600000,blahblah
2,1518393600000,foobar

# Case1: We want to all column2 values (e.g. unix timestamp-ish value) to formatted datetime
$ head -1 origin.csv > /dev/stdout && tail origin.csv -n+2 | awk -F "," '{gsub($2, strftime("%Y-%m-%d %H:%M:%S", substr($2, 0, 10))); print}' >> /dev/stdout
@rkaneko
rkaneko / test_connection.py
Created Nov 25, 2018
Verify to get Postgresql connection
View test_connection.py
import logging
import psycopg2
import sys
import traceback
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__file__)
log.setLevel(logging.INFO)
@rkaneko
rkaneko / .bashrc.local
Last active Sep 12, 2018
Selecting command history extension using peco on bash
View .bashrc.local
export HISTCONTROL="ignoredups"
_peco_select_history() {
local l=$(HISTTIMEFORMAT= history | tac | sed -e 's/^\s*[0-9]*\+\s\+//' | peco --query "$READLINE_LINE")
READLINE_LINE="$l"
READLINE_POINT=${#l}
}
bind -x '"\C-r":_peco_select_history'
View README.md

Usage

Boot tmp Kafka

$ docker run --rm -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=localhost --env ADVERTISED_PORT=9092 spotify/kafka

Create topic

@rkaneko
rkaneko / README.md
Last active Jul 9, 2018
Docker compose file for terraform CLI.
View README.md
@rkaneko
rkaneko / is_divisible.py
Created Jun 26, 2018
Check the number is divisible by divisor number considering decimal numbers.
View is_divisible.py
from decimal import Decimal
import numbers
import unittest
def is_divisible(num, divisor):
assert isinstance(num, numbers.Number)
assert isinstance(divisor, numbers.Number)
quotient = Decimal(str(num)) / Decimal(str(divisor))
@rkaneko
rkaneko / getCustomProperty.ts
Last active Jun 9, 2018
Get CSS custom property value by name via JavaScript.
View getCustomProperty.ts
function getCustomProperty(name: string): string {
const style = window.getComputedStyle(document.documentElement);
return style.getPropertyValue(name).trim();
}
@rkaneko
rkaneko / default.conf
Created Oct 3, 2017
Dockerized nginx's proxy config example using variables for proxy_pass
View default.conf
server {
listen 80 default_server;
# real_ip_header X-Forwarded-For
# server_name localhost;
location ~ ^/graphql(.*) {
# see https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver
resolver 127.0.0.11 ipv6=off;
set $target http://${SOME_HOST}:${SOME_PORT}/graphql;
You can’t perform that action at this time.