Skip to content

Instantly share code, notes, and snippets.

View crazygit's full-sized avatar

Crazygit crazygit

View GitHub Profile
@crazygit
crazygit / run_ss_server.sh
Last active December 14, 2018 16:35
run shadowsocks-libev server with docker
#!/usr/bin/env bash
# 配置参考:
# https://github.com/shadowsocks/shadowsocks-libev/blob/master/docker/alpine/README.md
# 密码
PASSWORD="your_password"
# 绑定到主机的端口号
SERVER_PORT=8388
# 加密方式
@crazygit
crazygit / debian_mirror.sh
Created December 28, 2017 09:50
Create Debian apt-get mirror
#!/bin/bash
# install tools
# sudo apt-get install debmirror
LOG_DIR="/disk_3T/debian_mirrors/log"
LOG="$LOG_DIR/$(date '+%F.%T').txt"
test -d $LOG_DIR || mkdir -p $LOG_DIR
# save mirror log
@crazygit
crazygit / ubuntu_mirror.sh
Last active December 28, 2017 09:50
Create ubuntu apt-get mirror
#!/bin/bash
#============================================================================
# Run below command for the first time
#============================================================================
cat<< EOF
# install tools
sudo apt-get install debmirror
# Set up keyring to correctly verify Release signatures
@crazygit
crazygit / init_ubuntu.sh
Created December 28, 2017 09:48
Install common package for ubuntu
#!/bin/bash -oe
# FIXME:
#==================================================
# NOTE:
# 运行脚本之前,先给当前用户不要输入密码的权限
# 运行如下命令:
# $ sudo sed -i 's/%sudo ALL=(ALL) ALL/%sudo ALL=(ALL) NOPASSWD:ALL/' /etc/sudoers
#==================================================
@crazygit
crazygit / change.sh
Created December 28, 2017 09:46
Change the commiter name and email in git repo for all branches
#!/bin/bash
# 改变当前git库所有分支git 历史提交人的信息
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
@crazygit
crazygit / screen-stuff.md
Created August 12, 2017 06:00 — forked from gesellix/screen-stuff.md
screen and Docker for Mac
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
@crazygit
crazygit / test_put_data_to_aws_firehose.py
Last active May 17, 2017 09:24
Test put data to AWS firehose
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(
@crazygit
crazygit / install_gnu_utilities.sh
Last active September 14, 2021 13:43
Use GNU Command Line Tools on macOS/OS X
# 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
@crazygit
crazygit / diff_of_scrapy_Compose_and_MapCompse.py
Last active March 13, 2023 15:33
The difference of scrapy built in loader processor Compose and MapComose
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']
@crazygit
crazygit / get_autosaling_name.sh
Created April 14, 2017 06:54
get aws ec2 autoscaling group name
# 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)