Skip to content

Instantly share code, notes, and snippets.

@mybeky
mybeky / merge.py
Created March 21, 2023 07:55
A Python script to merge every two pages of a PDF file into one page
# pip install PyMuPDF
# usage: python merge.py input_file.pdf
import sys
import fitz
def merge_pages(input_file, output_file):
with fitz.open(input_file) as doc:
# Turn On
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 7070
networksetup -setsocksfirewallproxy Ethernet 127.0.0.1 7070
networksetup -setsocksfirewallproxystate Wi-Fi on
networksetup -setsocksfirewallproxystate Ethernet on
# Turn Off
networksetup -setsocksfirewallproxystate Wi-Fi off
networksetup -setsocksfirewallproxystate Ethernet off
@mybeky
mybeky / wwdc.list
Created June 16, 2013 09:50
aria2c -i wwdc.list
http://devstreaming.apple.com/videos/wwdc/2013/400xex2xbskwa5bkxr17zihju9uf/400/400-HD.mov?dl=1
dir=~/Downloads/WWDC 2013/Tools/
out=Session 400 - What’s New in Xcode 5.mov
http://devstreaming.apple.com/videos/wwdc/2013/400xex2xbskwa5bkxr17zihju9uf/400/400.pdf?dl=1
dir=~/Downloads/WWDC 2013/Tools/
out=Session 400 - What’s New in Xcode 5.pdf
http://devstreaming.apple.com/videos/wwdc/2013/401xbx2xq50gv7mqafyfdns2yhxl/401/401-HD.mov?dl=1
dir=~/Downloads/WWDC 2013/Tools/
out=Session 401 - Xcode Core Concepts.mov
http://devstreaming.apple.com/videos/wwdc/2013/401xbx2xq50gv7mqafyfdns2yhxl/401/401.pdf?dl=1
@mybeky
mybeky / rubocop.vim
Created April 3, 2013 12:53
rubocop checker for syntastic.vim.
"============================================================================
"File: rubocop.vim
"Description: rubocop checker for syntastic.vim
"Author: mybeky <mybeky at gmail.com>
"
"============================================================================
if exists("g:loaded_syntastic_ruby_robocop_checker")
finish
endif
let g:loaded_syntastic_ruby_robocop_checker=1
@mybeky
mybeky / autoproxy.pac
Created September 25, 2012 13:55
Bypass proxy for local networks
function FindProxyForURL(url, host)
{
var resolved_ip = dnsResolve(host);
if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") ||
isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") ||
isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") ||
isInNet(resolved_ip, "127.0.0.0", "255.255.255.0"))
return "DIRECT";
@mybeky
mybeky / download.sh
Created September 11, 2012 03:43
Download all videos from #catvidfest
# Install https://github.com/rg3/youtube-dl/ first.
youtube-dl http://www.youtube.com/playlist\?list\=PLC0B137D835A3C970 -l --max-quality mp4
@mybeky
mybeky / uncrush.sh
Created April 18, 2012 08:27
Restore iOS optimized PNG file.
# Create symbolic link first.
# ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush ~/bin/
# or
# ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush ~/bin/
# for old version Xcode.
find . -depth 1 -name '*.png' -exec pngcrush -revert-iphone-optimizations {} {}-o.png \;
@mybeky
mybeky / vim.rb
Created April 12, 2012 02:52
Vim formula for Homebrew with python, ruby and clipboard enabled
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'https://vim.googlecode.com/hg/', :revision => '2d107086903a'
version '7.3.584'
def install
system "./configure",
"--with-features=huge",
@mybeky
mybeky / open_in_iterm.scpt
Created March 30, 2012 06:50
Open MacVim's current file path in iTerm2
tell application "MacVim"
set window_title to name of window 1
set is_empty to offset of "[NO NAME]" in window_title
if is_empty is 0 then
set cwd to do shell script "echo '" & window_title & "' |sed 's/.* (\\(.*\\)).*/\\1/'"
tell application "iTerm"
make new terminal
tell the current terminal
activate current session
launch session "Default Session"
diff --git a/lixian.py b/lixian.py
index 05331e4..7139f51 100644
--- a/lixian.py
+++ b/lixian.py
@@ -37,7 +37,7 @@ class XunleiClient:
def urlopen(self, url, **args):
#print url
if 'data' in args and type(args['data']) == dict:
- args['data'] = urllib.urlencode(args['data'])
+ args['data'] = urllib.urlencode(dict([k, unicode(v).encode('utf-8')] for k, v in args['data'].items()))