screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
screen -AmdS docker ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
screen -r docker
# enter, then disconnect with Ctrl-a d
screen -S docker -p 0 -X stuff $(printf root\\r\\n)
screen -r docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nocache = "&nocache=" + Math.random() * 1000000 | |
request = new ajaxRequest() | |
request.open("GET", "urlget.php?url=oreilly.com" + nocache, true) | |
// 与post相比, get 请求不需要设置header | |
request.onreadystatechange = function() | |
{ | |
if (this.readyState == 4) | |
{ | |
if (this.status == 200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// javascrpt布尔值的类型转换 | |
console.log(Boolean(NaN)); // flase | |
console.log(Boolean(null)); // false | |
console.log(Boolean(undefined)); // false | |
console.log(Boolean(0)); // false | |
console.log(Boolean([])); // true 注意这里与python不同 | |
console.log(Boolean({})); // true 注意这里与python不同 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# chkconfig: 2345 55 25 | |
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx | |
# For Debian, run: update-rc.d -f nginx defaults | |
# For CentOS, run: chkconfig --add nginx | |
# | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#################################################################### | |
# Usage: | |
# Save all docker images to tar files for copy to another machine | |
#################################################################### | |
images=$(docker images | awk 'NR>1 && $1 != "<none>" {printf("%s:%s\n", $1, $2)}') | |
for image in $images | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 免翻墙安装Go tools | |
branch="release-branch.go1.4" | |
mkdir -p $GOPATH/src/golang.org/x | |
git clone -b $branch [email protected]:golang/tools.git $GOPATH/src/golang.org/x/tools | |
git clone [email protected]:golang/net.git $GOPATH/src/golang.org/x/net | |
cd $GOPATH | |
go install golang.org/x/tools/cmd/goimports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get current ec2 AutoScaling group name | |
# note: change region option as yours | |
aws autoscaling describe-auto-scaling-instances --region us-east-1 --output text --query=AutoScalingInstances[].AutoScalingGroupName --instance-ids=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scrapy.loader.processors import Compose, MapCompose | |
proc = Compose(lambda v: v[0], str.upper) | |
proc(['hello', 'world']) # HELLO | |
mproc = MapCompose(lambda v: v[0], str.upper) | |
mproc(['hello', 'world']) # ['H', 'W'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Refer: https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/ | |
brew install coreutils | |
brew tap homebrew/dupes | |
brew install binutils | |
brew install diffutils | |
brew install ed --with-default-names | |
brew install findutils --with-default-names | |
brew install gawk | |
brew install gnu-indent --with-default-names | |
brew install gnu-sed --with-default-names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
from datetime import datetime | |
# 本脚本只适用于适用特定的用户操作Firehose, 模拟角色可以参考 | |
# http://boto3.readthedocs.io/en/latest/reference/services/sts.html#STS.Client.assume_role | |
# https://gist.github.com/gene1wood/938ff578fbe57cf894a105b4107702de | |
def list_delivery_streams(client): | |
response = client.list_delivery_streams( |
OlderNewer