Skip to content

Instantly share code, notes, and snippets.

View Matrixbirds's full-sized avatar

matrixbirds Matrixbirds

View GitHub Profile
require 'active_model_serializers'
module ActiveModelSerializers
module Adapter
class Toastio < Base
def serializable_hash(options = nil)
@__options = options = serialization_options(options)
json = Attributes.new(serializer, instance_options).serializable_hash(options)
serialized_hash = { :data => json }
serialized_hash[:success] = success
@Matrixbirds
Matrixbirds / docker-install.sh
Created January 24, 2018 02:49
daocloud payload
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.daocloud.io/docker/linux/centos/docker-ce.repo
sudo yum install -y -q --setopt=obsoletes=0 docker-ce-17.03.2.ce* docker-ce-selinux-17.03.2.ce*
sudo systemctl enable docker
sudo systemctl start docker
sudo service docker status
@Matrixbirds
Matrixbirds / payload.js
Created January 3, 2018 09:46
run nodejs on 80 port
sudo apt-get install libcap2-bin
sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which node))
node ./app
@Matrixbirds
Matrixbirds / bash_profile
Last active October 12, 2017 01:59
ssh tunnel proxy rds连接方法
ssh -f -L <local-port>:<rds-address>:<rds-port> <jump_server> -N # run in background
mysql -u<rds-username> -P <local-port> --host='127.0.0.1' -p
psql -h 127.0.0.1 -p <local-port> -U <username> <db_name> # after entered input your password
## lsof 列出建立TCP链接到 xx port的 相关进程
lsof -n -i4TCP:<portno> | grep <process-id>
@Matrixbirds
Matrixbirds / .zshrc
Last active September 29, 2017 09:34
pbcopy on ubunut
alias pbcopy="xclip -selection clipboard"
## dependencies resolver only for ubuntu LTS
```bash
sudo apt-get install xclip
```
```bash
alias pbcopy="xclip -selection clipboard"
alias say="echo $1 | espeak"
@Matrixbirds
Matrixbirds / .vimrc
Last active September 19, 2017 06:39
my-spf13-vimconfig
" Modeline and Notes {
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
"
" __ _ _____ _
" ___ _ __ / _/ |___ / __ __(_)_ __ ___
" / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
" \__ \ |_) | _| |___) |_____|\ V / | | | | | | |
" |___/ .__/|_| |_|____/ \_/ |_|_| |_| |_|
" |_|
"
@Matrixbirds
Matrixbirds / artifact.sh
Created September 11, 2017 01:59
ubuntu 16.04 global command not found
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.zshrc
source ~/.zshrc
@Matrixbirds
Matrixbirds / basic-recipes.osx.sh
Last active August 12, 2017 17:42
network-dump-recipes
# tcpdump usage recipes:
# tcpdump -i <interface> <BPF: Berkeley Packet Filter> [options]
sudo tcpdump -i lo0 '(host localhost) and (port 4399)' -vvv -tt 4
# watch with pipe chain command
watch -cd 'netstat -tan | head -n2; netstat -tan | sort | egrep 4399'
# netstat usage recipes:
# netstat [options]
cat file.log | grep 'matcher'
export line_number=12333
sed -n '${line_number},$p' file.log | less
@Matrixbirds
Matrixbirds / step.sh
Last active January 18, 2017 04:42
os x setup postgresql
initdb -D /usr/local/var/postgres # create database cluster directory for postgresql
createuser -s postgres # create postgre role