Skip to content

Instantly share code, notes, and snippets.

Avatar

Roy Binux binux

View GitHub Profile
@binux
binux / aria2jsonrpc.js
Created Jul 15, 2012
aria2 jsonrpc client
View aria2jsonrpc.js
var ARIA2 = (function() {
var jsonrpc_version = '2.0';
function get_auth(url) {
return url.match(/^(?:(?![^:@]+:[^:@\/]*@)[^:\/?#.]+:)?(?:\/\/)?(?:([^:@]*(?::[^:@]*)?)?@)?/)[1];
};
function request(jsonrpc_path, method, params) {
var request_obj = {
jsonrpc: jsonrpc_version,
@binux
binux / playlist.js
Created Nov 16, 2012
playlist for moe.fm
View playlist.js
var _playlist = [];
var _next = '';
var _loading = false;
var _loaded = false;
var _current = 0;
function _load_more() {
if (_loading) return;
_loading = true;
$.get(_next, function(result){
View get_pinyin.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<roy@binux.me>
# http://binux.me
# Created on 2014-12-04 00:56:49
def get_py(word):
word = word.encode('gbk')
@binux
binux / logging_receiver
Created Apr 22, 2011
logging receiver for python logging module
View logging_receiver
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cPickle
import logging
import logging.handlers
import SocketServer
import struct
View adduser.sh
#!/bin/bash
EMAIL=$1
source vars
set -x
./pkitool $EMAIL
source sendca.sh
@binux
binux / iframe.html
Last active Jun 22, 2020
cross origin iframe
View iframe.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe src="sub_frame.html" width="640" height="480"></iframe>
<iframe src="https://httpbin.org/html" width="640" height="480"></iframe>
</body>
</html>
@binux
binux / xf_magnet.js
Last active Apr 10, 2020
QQ旋风网页版,磁力链支持 书签: javascript:void((function(){var d=document;var s=d.createElement('script');s.src='http://blog.binux.me/assets/image/xf_magnet.js';s.id='binux_script';d.body.appendChild(s)})())
View xf_magnet.js
// vim: set et sw=2 ts=2 sts=2 ff=unix fenc=utf8:
// Author: Binux<i@binux.me>
// http://binux.me
// Created on 2013-01-21 20:18:42
jQuery.ajax({
url: 'http://pyproxy.duapp.com/http://httpbin.duapp.com/cookies/set?userid=21',
cache: true,
dataType: 'script',
success: function() {
@binux
binux / auto_vpn.sh
Created Jan 16, 2014
自动添加gfwlist域名的对应ip到路由表,实现动态自动翻墙
View auto_vpn.sh
#!/bin/sh
while :
do
dev=$(ip link | grep state | awk '{ sub(":", "", $2); print $2 }' | grep vpn)
if [ $? -ne 0 ]; then
sleep 5
continue
fi
break
View electron_bug.webRequest.onBeforeSendHeaders.js
const {app, BrowserWindow} = require('electron')
app.once('ready', async () => {
win = new BrowserWindow()
win.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => callback({}));
win.webContents.once('did-finish-load', async () => {
const html = await win.webContents.executeJavaScript('document.documentElement.innerHTML');
console.log(html);
app.quit()
})
await win.webContents.loadURL('https://httpbin.org/headers', {"extraHeaders":"Addition-Header: hello world"})
@binux
binux / pool.py
Created May 26, 2011
使用threading+queue的线程池封装,使用对象在每个对象中保存独立的连接,可以安全地使用ctrl-c打断
View pool.py
# !/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import time
import Queue
import threading
import traceback
class ExitException(Exception):