Skip to content

Instantly share code, notes, and snippets.

@ktrysmt
ktrysmt / global-function.rs
Created March 25, 2020 12:01
implement common methods with global function or polymorphism
struct Example {
number: i32,
}
impl Example {
fn boo() {
println!("boo! Example::boo() was called!");
}
fn answer(&mut self) {
self.number += 42;
}
#!/bin/sh
curl https://sh.rustup.rs -sSf | sh -s -- -y
exec $SHELL -l
# for stable
rustup install stable
rustup default stable
rustup component add rust-analysis
rustup component add rust-src
@ktrysmt
ktrysmt / my-msys2-for-vscode.minttyrc
Last active March 3, 2019 09:29
Exstensions are markdown-all-in-one and path-autocomplete.
BackgroundColour=13,25,38
ForegroundColour=217,230,242
CursorColour=217,230,242
Black=0,0,0
BoldBlack=38,38,38
Red=184,122,122
BoldRed=219,189,189
Green=122,184,122
BoldGreen=189,219,189
Yellow=184,184,122
@ktrysmt
ktrysmt / Vagrantfile
Created September 24, 2018 13:04
My general Vagrantfile at ubuntu/trusty64
Vagrant.configure(2) do |config|
def install_plugin(plugin)
system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
end
install_plugin('vagrant-share')
install_plugin('vagrant-vbguest')
install_plugin('vagrant-omnibus')
install_plugin('vagrant-cachier')
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
@ktrysmt
ktrysmt / Makefile
Last active November 18, 2020 16:41
aws account context switcher by Makefile
.DEFAULT_GOAL:=help
THIS_FILE := $(lastword $(MAKEFILE_LIST))
CRED_TMP := /tmp/.credentials.tmp
CRED := ~/.aws/credentials
PARENT:=iamA
SERIAL:=arn:aws:iam::1234567890ab:mfa/iam-username
DURATION:=
code:=000000
@ktrysmt
ktrysmt / Makefile
Last active January 18, 2019 14:29
Plain Makefile boilerplate
.DEFAULT_GOAL := help
THIS_FILE := $(lastword $(MAKEFILE_LIST))
target: ## run the target ## make target env=development
@echo $@ # print target name
@$(MAKE) -f $(THIS_FILE) inner-target # invoke other target
inner-target:
@echo $@ # print target name
@ktrysmt
ktrysmt / .zshrc
Last active January 19, 2022 13:53
How to share clipboard between HostOS and GuestOS of Vagrant
export DISPLAY=:0
if [ -x /usr/bin/Xvfb ] && [ -x /usr/bin/VBoxClient ] && [ ! -f /tmp/.X11-unix/X0 ]; then
nohup Xvfb -screen 0 120x80x8 > /dev/null 2>&1 &
sleep 0.5
VBoxClient --clipboard
fi
if [ -x /usr/bin/xsel ]; then
alias pbcopy='xsel --display :0 --input --clipboard'
alias pbpaste='xsel --display :0 --output --clipboard'
fi
@ktrysmt
ktrysmt / .zshrc
Created December 21, 2017 03:16
minimal my zshrc
export LANG=ja_JP.UTF-8
autoload -Uz compinit
compinit -C
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:default' menu select=2
@ktrysmt
ktrysmt / ecr.tf
Last active October 26, 2017 08:26
apply ecr policies and repositories as dynamic in terraform (v0.8.7)
resource "aws_ecr_repository" "ecr_repositories" {
count = "${length(var.list_of_images)}"
name = "${var.list_of_images[ count.index ]}"
}
resource "aws_ecr_repository_policy" "ecr_policies" {
count = "${ length(var.list_of_images) * length(var.list_of_allowed_iam_users) }"
repository = "${var.list_of_images[ count.index % length(var.list_of_images) ]}"
policy = "${data.template_file.ecr_policy_allowed_iam_users.*.rendered[ count.index ]}"
}
@ktrysmt
ktrysmt / .eslintrc
Last active October 19, 2017 03:29
init files for npm module development.
{
"extends": "standard",
"rules": {
"semi": [2, "always"]
}
}