Skip to content

Instantly share code, notes, and snippets.

@simeji
simeji / nc-http-server
Last active May 13, 2018 11:18
OneLiners
bash -c 'trap exit INT; while true; do ( echo "HTTP/1.0 200 Ok"; echo; echo "Hello World" ) | nc -l 8080; done'
# http://blog.livedoor.jp/sonots/archives/34703829.html
@simeji
simeji / build.sh
Created January 4, 2017 12:52
jid build with docker
#!/bin/bash
bdir=`pwd`
find $bdir/cmd/jid/jid_* | grep -v .go | xargs -I{} -L1 -P4 rm -f {}
docker run --rm -v $bdir:/go -w /go tcnksm/gox:latest sh -c "go get -d ./... && cd cmd/jid && gox -ldflags '-w -s'"
cd $bdir/cmd/jid
find jid_* | grep -v .go |xargs -I@ -L1 -P4 zip @{.zip,}
package main
import (
"log"
"os"
)
const (
LogFileName string = "/tmp/go-debug.log"
)
@simeji
simeji / get_repo_stars.sh
Last active August 29, 2022 07:38
Get count of Github repository stars
#!/bin/bash
USER=$1
REPO=$2
if [ -z "$USER" -o -z "$REPO" ]; then
echo '$1 : Github username, $2: Github repository name (only public repo)'
exit 1
fi
FILENAME=star_${USER}_${REPO}
@simeji
simeji / file0.txt
Last active September 16, 2015 17:50
AWS CLI で現在停止中で30日以上前に起動されたインスタンスを取得するワンライナー ref: http://qiita.com/simeji/items/3d680c3a59897700f43c
$ ago=30;date -v-${ago}d > /dev/null 2>&1 && DATE=`date -v-${ago}d +%Y-%m-%d` || DATE=`date --date="-${ago} days" +%Y-%m-%d`; aws ec2 describe-instances --filter Name=instance-state-name,Values=stopped --query "Reservations[].Instances[?LaunchTime<='$DATE'][].{InstanceId: InstanceId,PrivateIpAddress: PrivateIpAddress,LaunchTime: LaunchTime}"
@simeji
simeji / descrive_ec2_instances.go
Last active May 29, 2023 20:09
Get EC2 instance list filtered by NameTag
package main
import (
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/credentials"
"github.com/awslabs/aws-sdk-go/service/ec2"
)
func main() {
@simeji
simeji / file0.txt
Created February 27, 2015 02:20
特定のタグのついたセキュリティグループ内容を編集だけできるIAMポリシー ref: http://qiita.com/simeji/items/dc32b2dec0362376258f
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:RevokeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress"
@simeji
simeji / function.vim
Created September 29, 2014 09:46
vim-sample
" function sample
function TestFunction(a,b,c)
echo a:a
echo a:b
echo a:c
endfunction
" 引数の設定
com -nargs=+ TestFunc call TestFunction(<f-args>)
" insert map
imap <C-t> Helloworld!!<CR>
" normal map
nmap <C-f> :echo expand('%:p')<CR>
" visual map
vmap <C-e> :s/xxxx/homes/g<CR>
" commandline map
cmap <C-a> <Home>
cmap <C-e> <End>
cmap <C-f> <Right>
@simeji
simeji / vim-practice-3
Last active August 29, 2015 14:02
vim-practice-3
hoge
moge
fuga
bar
test
this is a pen
hoge = [Hoge]
moge = [Moge]