Skip to content

Instantly share code, notes, and snippets.

@JohnnyNiu
JohnnyNiu / go intall vs go build.md
Last active February 16, 2021 09:34
Difference between `go build` and 'go install`

go build compile and build executable and move it to the destination where you run the command

go install compile and move executable to $GOBIN directory, and cache all non-main packages which imported for the package you installed, it will be used in your next compile if not changed yet.

@JohnnyNiu
JohnnyNiu / whenAccessedMssql.sql
Created March 2, 2017 23:21
check when db accessed
SELECT TOP 5 accessdate
FROM accessLog
ORDER BY 1 DESC;
@JohnnyNiu
JohnnyNiu / Check sqlserver 2008 connections and filter.sql
Created December 20, 2016 22:52
Check sqlserver 2008 connections and filter
SELECT spid,
sp.[status],
loginame [Login],
hostname,
blocked BlkBy,
sd.name DBName,
cmd Command,
cpu CPUTime,
physical_io DiskIO,
last_batch LastBatch,
@JohnnyNiu
JohnnyNiu / gist:e27ec654a867ed4656efa9961c41063f
Created November 18, 2016 05:59
ssh force using password
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com
@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: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 / 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 / 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 / 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 / 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)