Skip to content

Instantly share code, notes, and snippets.

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

genzj genzj

👽
你现在最大的问题是做了人类
View GitHub Profile
@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 / ffmpeg_backend.py
Last active May 8, 2020 23:25
Get the process bar of ffmpeg
#!/usr/bin/env python3
from io import BytesIO
def ffmpeg_it(clip, input, output, overwriteopt='-y'):
cmd = [ffmpeg, '-ss', clip['start'], '-i', input, '-c', 'copy',
'-t', clip['end'], overwriteopt, output ]
ffmpegp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
buf = BytesIO()
while True:
# put the single char to IO buffer in case it's a multi-byte
###############################################################################
# The MIT License
#
# Copyright 2012-2015 Jie ZHU <zj0512@gmail.com>.
#
# 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
@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 / 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 / .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=