Skip to content

Instantly share code, notes, and snippets.

@JohnnyNiu
JohnnyNiu / .vimrc
Last active February 29, 2016 05:49
My Vim Setting
" set tab to 2 spaces for my vim
:set expandtab
:set tabstop=2
:set shiftwidth=2
" show line number
:set number
@JohnnyNiu
JohnnyNiu / .my_nix_alias.sh
Last active March 18, 2016 02:10
.my nix alias
#===============General=============
#docker
alias d="docker"
alias drm='docker rm $(docker ps -aq)'
alias drmi='docker rmi $(docker images -aq)'
alias drmin='docker rmi $(docker images -f "dangling=true" -aq)'
#Git related alias
alias gco="git checkout"
@JohnnyNiu
JohnnyNiu / .vimrc
Created March 18, 2016 13:33
.vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@JohnnyNiu
JohnnyNiu / find ip of machine.md
Last active June 28, 2016 06:32
Problem that can't find IP of the machine by command in Groupmanagment/MailRouting run script

The script in the run script is using below command to calculate the ip of the localhost:

export HOST_IP=$(ifconfig $(ifconfig | grep ^eth | cut -d' ' -f1 | tail -1) | grep 'inet addr' | cut -d':' -f2 | cut -d' ' -f1)

or

export HOST_IP=$(ifconfig $(ifconfig | grep ^eth | cut -d' ' -f1) | grep 'inet addr' | cut -d':' -f2 | cut -d' ' -f1)
@JohnnyNiu
JohnnyNiu / terraform_iam_users_and_policys_notes.md
Last active September 12, 2016 01:36
terraform user and policy notes
  1. user creation: aws_iam_user and aws_iam_access_key comparing with manually creation from console, terraform created user :
    • can be destroyed(revoked) by terraform
    • can be used as variables in other resources
    • will store all key and secret in tfstate file, not secure?
  2. ways to apply policy to resource and user:
    • create aws_iam_policy_document, assign to policy arg of aws_iam_user_policy
      • using user arg to attach policy
      • or using principle in policy's statement to attach to different IAM users
  • create aws_iam_policy_document, attached to aws_iam_user_policy_attachment
@JohnnyNiu
JohnnyNiu / loop terraform.tf
Created September 9, 2016 04:07
terraform iterate a list to create resource
variable "foo" {
default = ["1", "2", "3"]
}
resource "aws_sns_topic" "test" {
name = "${element(var.foo, count.index)}"
count = "${length(var.foo) }"
}
@JohnnyNiu
JohnnyNiu / instance_profile_example.tf
Created September 16, 2016 07:17
instance_profile_example.tf
provider "aws" {
access_key = ""
secret_key = ""
region = "ap-southeast-2"
}
resource "aws_s3_bucket" "test-ec2-iam-role-bucket" {
bucket = "test-ec2-iam-role-bucket"
acl = "private"
@JohnnyNiu
JohnnyNiu / gist:5e49272a84bf93315a2c202357fd977b
Created October 21, 2016 00:30
How to solve vagrant put tempororay file under coder structure
https://github.com/mitchellh/vagrant/issues/3493
Vagrant tried to put temp files to your temp dir which is `/tmp`, it failed becuase of the permission.
So "/tmp" directory is by default with "sticky" flag, I run chmod 777 and break that and having the same problem. To make your "/tmp" sticky you need to run:
chmod 1777 /tmp
or
chmod +t /tmp
@JohnnyNiu
JohnnyNiu / omprehensive list of all liquibase datatypes
Created October 26, 2016 01:27
omprehensive list of all liquibase datatypes
boolean
MySQLDatabase: BIT(1)
SQLiteDatabase: BOOLEAN
H2Database: BOOLEAN
PostgresDatabase: BOOLEAN
UnsupportedDatabase: BOOLEAN
DB2Database: SMALLINT
MSSQLDatabase: [bit]
OracleDatabase: NUMBER(1)
HsqlDatabase: BOOLEAN
@JohnnyNiu
JohnnyNiu / gist:e27ec654a867ed4656efa9961c41063f
Created November 18, 2016 05:59
ssh force using password
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com