Skip to content

Instantly share code, notes, and snippets.

View rkaneko's full-sized avatar
🎯
Focusing

Ryota Kaneko rkaneko

🎯
Focusing
View GitHub Profile
@rkaneko
rkaneko / .bashrc.local
Last active September 12, 2018 04:53
Selecting command history extension using peco on bash
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'

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 February 4, 2024 07:18
Docker compose file for terraform CLI.
@rkaneko
rkaneko / is_divisible.py
Created June 26, 2018 11:39
Check the number is divisible by divisor number considering decimal numbers.
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 June 9, 2018 09:11
Get CSS custom property value by name via JavaScript.
function getCustomProperty(name: string): string {
const style = window.getComputedStyle(document.documentElement);
return style.getPropertyValue(name).trim();
}
@rkaneko
rkaneko / default.conf
Created October 3, 2017 10:08
Dockerized nginx's proxy config example using variables for proxy_pass
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;
@rkaneko
rkaneko / print_utils.sh
Last active September 21, 2017 03:04
Print with colors utilities on bash.
#!/bin/bash -eu
exist_arg1() {
local EXIST_ARG1=false
if [ "$1" ]; then
local EXIST_ARG1=true
fi
echo ${EXIST_ARG1}
}
@rkaneko
rkaneko / findFilesRecursively.js
Created September 6, 2017 02:43
Node.js find files recursively
const assert = require("assert");
const fs = require("fs");
const path = require("path");
function findFilesRecursively(pathToDir) {
assert(typeof pathToDir === "string");
return fs.readdirSync(pathToDir).map(filename => {
const fullpath = path.join(pathToDir, filename);
if (isFile(fullpath)) {
# -*- coding: utf-8 -*-
def main():
print("Hello Python3")
if __name__ == '__main__':
main()
hoge

foo