Skip to content

Instantly share code, notes, and snippets.

@tony612
tony612 / time_list.sh
Created April 27, 2017 09:15
k8s container create_time list
#!/bin/bash
function run {
local full_id=`sudo docker inspect --format="{{.Id}}" $1`
local system_slice
system_slice+="`ls --full-time /sys/fs/cgroup/cpu,cpuacct/system.slice/docker.service/docker/${full_id}/cgroup.clone_children 2>/dev/null | awk '{print $6, $7}'` "
system_slice+="`ls --full-time /sys/fs/cgroup/memory/system.slice/docker.service/docker/${full_id}/cgroup.clone_children 2>/dev/null | awk '{print $6, $7}'` "
system_slice+="`ls --full-time /sys/fs/cgroup/blkio/system.slice/docker.service/docker/${full_id}/cgroup.clone_children 2>/dev/null | awk '{print $6, $7}'` "
system_slice+="`ls --full-time /sys/fs/cgroup/cpuset/system.slice/docker.service/docker/${full_id}/cgroup.clone_children 2>/dev/null | awk '{print $6, $7}'` "
@tony612
tony612 / keybase.md
Created April 17, 2017 06:19
keybase.md

Keybase proof

I hereby claim:

  • I am tony612 on github.
  • I am tony612 (https://keybase.io/tony612) on keybase.
  • I have a public key ASCQeLVU2DeV5vggA89QIAQpbHKdNa3WtAks52KQPqUQMgo

To claim this, I am signing this object:

@tony612
tony612 / gen_grpc_cs.rb
Last active March 10, 2017 06:36
Generate Dash cheatset for gRPC(status code)
# https://github.com/Kapeli/cheatset#readme
# https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
body = <<-DOC
| Client Application cancelled the request | CANCELLED | Both |
| Deadline expires before server returns status | DEADLINE_EXCEEDED | Both |
| Method not found at server | UNIMPLEMENTED | Server|
| Server shutting down | UNAVAILABLE | Server|
| Server side application throws an exception (or does something other than returning a Status code to terminate an RPC) | UNKNOWN | Server|
| No response received before Deadline expires. This may occur either when the client is unable to send the request to the server or when the server fails to respond in time. | DEADLINE_EXCEEDED | Both|
@tony612
tony612 / erl
Created September 3, 2016 16:44
if [ ! -z "$USE_GDB" ]; then
gdb $BINDIR/erlexec --args $BINDIR/erlexec ${1+"$@"}
elif [ ! -z "$USE_LLDB" ]; then
lldb -- $BINDIR/erlexec ${1+"$@"}
else
exec "$BINDIR/erlexec" ${1+"$@"}
fi
USE_GDB=1 iex -S mix
gdb> r
@tony612
tony612 / source.list
Last active August 31, 2016 14:48
ubuntu 14 source.list
deb http://cn.archive.ubuntu.com/ubuntu/ trusty main universe
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-security main universe
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main universe
deb http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty main universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-security main universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-updates main universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ trusty-backports main universe
sudo sh -c "cat <<EOF >/etc/apt/sources.list
@tony612
tony612 / update_terraform.sh
Created August 16, 2016 09:26
install/update terraform on linux_amd64
#!/bin/bash
# update_terraform.sh 0.6.16
VERSION=$1
wget -nc https://releases.hashicorp.com/terraform/$VERSION/terraform_$VERSION\_linux_amd64.zip
unzip -o terraform_$VERSION\_linux_amd64.zip -d terraform_$VERSION
rm /home/deployer/terraform
ln -s /home/deployer/terraform_$VERSION /home/deployer/terraform
@tony612
tony612 / tsung.xml
Created August 3, 2016 11:41
Config for stress test
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="info" version="1.0">
<clients>
<!-- use localhost, no distribution -->
<client host="localhost" use_controller_vm="true" weight="1" maxusers="60000"/>
</clients>
<servers>
<server host="server.host" port="8080" type="tcp"/>
@tony612
tony612 / dm.xml
Created July 12, 2016 17:40
tsung config for Phoenix stress test
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="info" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true" maxusers="5000" />
</clients>
<servers>
<server host="serverhost" port="80" type="tcp" />
</servers>
@tony612
tony612 / ecto_deadlock3
Created April 21, 2016 14:15
ecto deadlock
............................
1) test messages_count_after/2 returns messages count after the time (Exchat.ChannelRepoTest)
test/models/channel_repo_test.exs:39
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 46899 waits for ShareLock on transaction 8436; blocked by process 46892.
Process 46892 waits for ShareLock on transaction 8431; blocked by process 46899.
stacktrace:
(ecto) lib/ecto/adapters/sql.ex:405: Ecto.Adapters.SQL.struct/6
@tony612
tony612 / ecto_deadlock2
Created April 21, 2016 14:13
ecto deadlock
...................
1) test the result of messages_before is ordered by desc inserted_at (Exchat.ChannelRepoTest)
test/models/channel_repo_test.exs:29
** (Postgrex.Error) ERROR (deadlock_detected): deadlock detected
Process 46231 waits for ShareLock on transaction 8105; blocked by process 46227.
Process 46227 waits for ShareLock on transaction 8107; blocked by process 46231.
stacktrace:
(ecto) lib/ecto/adapters/sql.ex:405: Ecto.Adapters.SQL.struct/6