Skip to content

Instantly share code, notes, and snippets.

View takakd's full-sized avatar
🧑‍💻
coding, coding, and coding

Takahiro Kudo takakd

🧑‍💻
coding, coding, and coding
  • VIdeo Market Corp.
  • Japan
View GitHub Profile
@takakd
takakd / mockgen.pl
Last active March 2, 2021 12:52
The helper script of mockgen in golang/mock.
#!/usr/bin/perl
use strict;
use warnings;
# Usage
sub usage() {
my $usage = <<"EOS";
$0 creates go mock file in the same directory where the go file is located.
@takakd
takakd / go-routine-select-nil-pattern.go
Created January 21, 2021 23:53
Golang channel sample code.
package main
import (
"fmt"
)
func main() {
ch1 := make(chan int)
ch2 := make(chan int)
@takakd
takakd / note.go
Created January 17, 2021 00:56
My Golang note.
# Returning value
# github.com/aws/aws-sdk-go/service/translate/api.go
# line. 4560
func newErrorUnsupportedLanguagePairException(v protocol.ResponseMetadata) error {
return &UnsupportedLanguagePairException{
RespMetadata: v,
}
}
# Redundancy
@takakd
takakd / set.go
Created December 12, 2020 19:38
Golang, Set structure.
// Package collection provides collection data structure.
package collection
const (
// Use as the stuffing data.
// Use "map" for implementing this struct but it does not use the value of map,
// so set dummy value to the map value.
_stuffing = 0
)
#!/usr/bin/env bash
# golang-migrate helper script
# https://github.com/golang-migrate/migrate
usage() {
echo "Usage: migrate.sh COMMAND
COMMAND:
Input golang-migrate command and options.
@takakd
takakd / pyhton_code.sh
Last active September 20, 2020 13:43
Python codes.
# Create virtual env in {directory}
pyton3 -v venv {directory}
# - Activate
source {directory}/bin/activate
# - Deactivate
deactivate
@takakd
takakd / sampleREADME.md
Last active August 8, 2020 14:38 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.
@takakd
takakd / docker.sh
Last active January 18, 2021 09:15
Docker snnipets.
# Stop all containers
docker stop $(docker ps -q)
# Remove all containers
docker rm $(docker ps -q -a)
# Remove all images
$ docker rmi $(docker images -q)
@takakd
takakd / my_shell_script_template.sh
Last active August 9, 2020 19:39
my_shell_script_template.sh
#!/usr/bin/env bash
# Ref: https://qiita.com/koara-local/items/2d67c0964188bba39e29
# Ref: https://qiita.com/mashumashu/items/f5b5ff62fef8af0859c5
SCRIPT_DIR=$(cd $(dirname $0); pwd)
function usage() {
cat <<_EOT_
Usage:
@takakd
takakd / utils_panic_test.go
Created May 27, 2020 14:53
Testing panic function.
// Testing if testFunc calls panic.
// e.g.
// IsTestCallPanic(func(){
// <place test target here.>
// })
func IsTestCallPanic(testFunc func()) (ok bool){
defer func() {
if err := recover(); err == nil {
ok = false
}