Skip to content

Instantly share code, notes, and snippets.

View genzj's full-sized avatar
👽
你现在最大的问题是做了人类

genzj genzj

👽
你现在最大的问题是做了人类
View GitHub Profile
@genzj
genzj / clean_file_name.py
Created August 28, 2015 05:31
Clean / unquote url encode sequences in downloaded files.
#!/usr/bin/env python
from __future__ import generators
from functools import partial
import os, os.path
try:
from urllib import unquote
except ImportError:
from urllib.parse import unquote
@genzj
genzj / .bashrc
Created September 10, 2014 16:38
persistent ssh keys
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent > "$SSH_ENV"
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
}
# check for running ssh-agent with proper $SSH_AGENT_PID
@genzj
genzj / .bashrc
Created September 11, 2014 11:55
attach daily tmux session
function attach-daily {
tmux -u new-session -s daily -AD
}
@genzj
genzj / Makefile
Created April 9, 2015 07:17
A makefile to generate a gfw-free Firefox portable release
# The MIT License (MIT)
#
# Copyright (c) 2015 genzj
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@genzj
genzj / child.py
Created August 20, 2015 08:25
Output and merge subprocess outputs
#!/usr/bin/env python
from time import sleep
for i in range(1, 3):
print "line %d" %(i, )
print "xxxxxxxxxx" * 20
sleep(5)
print "exit"
@genzj
genzj / .screenrc
Created June 14, 2016 03:31
A good screen config
# GNU Screen - main configuration file
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
@genzj
genzj / issue_token_v3.sh
Created October 24, 2016 06:40
Retrieve an unscoped token from Keystone.
#!/bin/bash
default_domain_name='default'
if [[ $# -lt 2 ]] ; then
echo "Usage: $0 USERNAME PASSWORD"
exit 1
fi
curl -i \
-H "Content-Type: application/json" \
-d '
@genzj
genzj / env.sh
Created September 2, 2017 06:03
Jupyterhub use OAuth with local user
# env
#
# add your github oauth config to this file
# and launch the server with `sh run.sh`
#
# Note: Be careful to keep the client secret private. Use caution
# with version control to prevent publicly exposing the secret.
export GITHUB_CLIENT_ID=
export GITHUB_CLIENT_SECRET=
export OAUTH_CALLBACK_URL=
@genzj
genzj / rot-dict.py
Created December 22, 2017 15:37
Rotting substitution cipher examples
# -*- encoding: utf-8 -*-
def circle_alphabet(offset='a', start='a'):
start_code = ord(start)
offset_code = ord(offset)
for i in range(offset_code, start_code + 26):
yield chr(i)
for i in range(start_code, offset_code):
yield chr(i)
@genzj
genzj / README.md
Created August 26, 2018 13:05 — forked from DocX/README.md
Connect to bash inside running ECS container by cluster and service name