Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
bundle check || bundle install --jobs 4 --retry 5
pids=( server.pid realtime_updater.pid )
for file in "${pids[@]}"
do
path="tmp/pids/$file"
if [ -f $path ]; then
rm $path
fi
@zealinux
zealinux / linux-http-tcp.md
Created March 2, 2018 02:43 — forked from v5tech/linux-http-tcp.md
linux下查看http 并发和 tcp连接数

linux查看httpd进程数

ps -ef | grep httpd | wc -l

查看Apache的并发请求数及其TCP连接状态

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
@zealinux
zealinux / db.rake
Created April 21, 2018 03:57 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@zealinux
zealinux / README.md
Created May 11, 2018 07:42 — forked from magnetikonline/README.md
Bash getopts usage template.

Bash getopts usage template

#!/bin/bash -e

function usage {

	cat <<EOM
Usage: $(basename "$0") [OPTION]...
@zealinux
zealinux / homebrew_opencv_245.sh
Created May 29, 2018 04:25 — forked from tstellanova/homebrew_opencv_245.sh
Install a specific version of OpenCV on OSX with homebrew
# 20131214
# switch to the relevant keg directory
cd /usr/local/Library/Taps/homebrew-science
brew versions opencv
# look for the version you want, eg:
# 2.4.5 git checkout ae74fe9 opencv.rb
# checkout the version you want
git checkout ae74fe9 opencv.rb
@zealinux
zealinux / checkUrlExists.m1.py
Created December 18, 2018 06:51 — forked from fedir/checkUrlExists.m1.py
Check if URL exists via Python
from urllib2 import urlopen
code = urlopen("http://example.com/").code
if (code / 100 >= 4):
print "Nothing there."
# via http://stackoverflow.com/questions/1966086/how-can-i-determine-if-anything-at-the-given-url-does-exist
@zealinux
zealinux / install-docker.sh
Created January 4, 2019 10:09 — forked from brianz/install-docker.sh
Install docker on Amazon Linux
#!/bin/bash
#
# steps taken verbatim from:
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html#install_docker
#
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# log out and log in to pickup the added group
@zealinux
zealinux / tmux-cheatsheet.markdown
Created February 28, 2019 10:16 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@zealinux
zealinux / org-mode-reference-in.org
Created March 22, 2019 03:42 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!
@zealinux
zealinux / gist:5c69e978b316473a9abe2d4ef7630b5a
Created March 26, 2019 08:55 — forked from newhouseb/gist:1620133
MySQL vs PostgreSQL Schema changes benchmarks
The basic idea here is to substantiate the claims made by this square post:
http://corner.squareup.com/2011/06/postgresql-data-is-important.html
In PostgreSQL, and MySQL (MyISAM and InnoDB) I create millions of rows and then add
and remove columns and add and remove indexes. For columns without defaults this is
basically free in PostgreSQL and O(n) in MySQL. For adding indexes its at best O(n)
everywhere, but with PostgreSQL it claims not to do any locking that would otherwise
prevent table interaction.
Also, PostgreSQL has _awsome_ documentation (it has real examples!). I always get