Skip to content

Instantly share code, notes, and snippets.

View xingxing's full-sized avatar
🎧
Focusing

Wade Ying Xing xingxing

🎧
Focusing
View GitHub Profile
@xingxing
xingxing / wait-for-vm-up.bash
Last active May 20, 2021 04:42
Wait for GCE instance is ready by try ssh in
function wait_vm_up {
local counter=0
local readonly project=${1:?"project required"}
local readonly instance=${2:?"instance required"}
local readonly zone=${3:?"zone required"}
local readonly user=${4:?"user required"}
local readonly maxRetry=${5:-100}
echo "Project: $project"
@xingxing
xingxing / rm_mysql.md
Created February 26, 2019 06:14 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

#!/bin/bash
mkdir -p cloudbuild
projectName=$(pwd | awk -F / '{print $NF}')
echo $projectName
touch cloudbuild/production.yaml cloudbuild/scambio.yaml
@xingxing
xingxing / codeship-elixir.sh
Created December 3, 2016 11:41 — forked from paulgoetze/codeship-elixir.sh
Codeship Elixir/Phoenix test setup
#!/bin/bash
# Erlang
ERLANG_VERSION=${ERLANG_VERSION:-19.0}
ERLANG_CACHED_DOWNLOAD="${HOME}/cache/OTP-${ERLANG_VERSION}.tar.gz"
ERLANG_DIR=${ERLANG_DIR:="$HOME/erlang"}
# Elixir
ELIXIR_VERSION=${ELIXIR_VERSION:-1.3.1}
ELIXIR_CACHED_DOWNLOAD="${HOME}/cache/elixir-v${ELIXIR_VERSION}.zip"
@xingxing
xingxing / drain_stop.ex
Created September 15, 2016 23:59 — forked from aaronjensen/drain_stop.ex
Phoenix Drain Stop
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.
DrainStop should be installed in your supervision tree *after* the
EndPoint it is going to drain stop.
defmodule Poker do
@ws ?\s
# 9 codepoint is 57
# T -> : codepoint is 58
# J -> ; codepoint is 59
# Q -> < codepoint is 60
# K -> = codepoint is 61
# A -> > codepoint is 62
def convert_to_sortable(cards) do
(defn insert [l k]
"将数插入序列"
(concat (filter #(<= % k) l) (list k) (filter #(> % k) l)))
(defn isort
"插入排序"
[s]
(loop [sorted (list (first s))
unsorted (rest s)]
(if (empty? unsorted)