Skip to content

Instantly share code, notes, and snippets.

View clvrobj's full-sized avatar

Chi Zhang clvrobj

  • Singapore, Singapore
View GitHub Profile
@clvrobj
clvrobj / suds.js
Created July 31, 2011 04:03
Added header related properties to suds.js in Titanium KitchenSink
/**
* Suds: A Lightweight JavaScript SOAP Client
* Copyright: 2009 Kevin Whinnery (http://www.kevinwhinnery.com)
* License: http://www.apache.org/licenses/LICENSE-2.0.html
* Source: http://github.com/kwhinnery/Suds
*/
function SudsClient(_options) {
function isBrowserEnvironment() {
try {
if (window && window.navigator) {
@clvrobj
clvrobj / douban.com.js
Created October 28, 2011 08:05
douban.com dotjs plugin
// 2012 new version
// 点击logo到广播
$('.site-nav-logo a').attr('href', 'http://www.douban.com/update/');
// 按"."刷新广播,与twitter快捷键一致
$('body').keypress(
function (e) {
var code = e.charCode ? e.charCode : e.keyCode;
if (code === 46 && !$(':focus').is(':input')) {
// '.' to reload
@clvrobj
clvrobj / l2tp.sh
Created January 21, 2012 12:58
l2tp.sh
#!/bin/bash
VPN_SERVICENAME="l2tpd"
VPN_PSK="fuckgfw"
VPN_IPRANGE="10.1.100"
VPN_USERNAME="fill in your username"
VPN_PASSWORD="your password"
#L2TPD/IPSEC
@clvrobj
clvrobj / contentscript.js
Created February 8, 2012 03:21
Shame on this script, from a chrome extension (nnancliccjabjjmipbpjkfbijifaainp)
if (!pluginnetwork) var pluginnetwork = {};
var failcount = 0;
pluginnetwork.contentscript = function () {
return {
isMarketingEnabled: function () {
if (pluginnetwork.pluginStorage.getItem(pluginnetwork.GLOBALS.PLUGIN_NAMESPACE + '.marketing') == "false") {
return false;
} else {
return true;
}
r1 = {'a': {'q': 1, 'w': 2}, 'b': {'q': 3, 'w': 4}}
r2 = {'a': {'q': 5, 'w': 7}, 'b': {'q': 8, 'w': 2}}
# ret = {'a': {'q': 6, 'w': 9}, 'b': {'q': 11, 'w': 6}}
def iter_dict(x, y):
if not isinstance(x, dict):
return map(lambda x: sum(x), zip(x, y))
if isinstance(x.values()[0], dict):
return dict(zip(x.keys(), map(lambda x:iter_dict(x[0], x[1]), zip(x.values(), y.values()))))
return dict(zip(x.keys(), iter_dict(x.values(), y.values())))
@clvrobj
clvrobj / douban oauth, post miniblog.
Created March 8, 2012 01:45
post miniblog, douban oauth with ruby sinatra
require 'sinatra'
require 'oauth'
API_KEY = ''
API_SECRET = ''
token = ''
secret = ''
post '/miniblog' do
content = params[:content]
@clvrobj
clvrobj / yyets.com.js
Created April 3, 2012 09:19
人人影视yyets.com下载页面添加一个显示选中的下载链接的窗口,方便非ie使用 (dotjs required)
var exposeEd2kCon = $('<input class="button" type="button" value="显示选中链接" style="background-color:#C30604; color:#FFFFFF"/>').click(
function () {
var output = '';
for(var i = 0,array = document.querySelectorAll('.hover.filebox')[0].querySelectorAll('li'); i<array.length-1; i++){
if(array[i].querySelector('input').checked && array[i].querySelector('a').href.length > 0 && array[i].querySelector('a').href.match('-----') === null){
output += array[i].querySelector('a').href + '\n';
}
}
if (!$('#ed2kexpwin').length) {
$('body').append('<div id="ed2kexpwin" style="width:656px;height:168px;left:30px;bottom:0;position:fixed;overflow:scroll;visibility:visible;background-color:#fff;text-align:left;"><textarea rows="8" cols="90"></textarea></div>');
@clvrobj
clvrobj / gist:2290640
Created April 3, 2012 09:26 — forked from disinfeqt/gist:2286703
YYETS Copy
(function(){
var output = '';
for(var i = 0,array = document.querySelectorAll('.hover.filebox')[0].querySelectorAll('li'); i<array.length-1; i++){
if(array[i].querySelector('input').checked && array[i].querySelector('a').href.length > 0 && array[i].querySelector('a').href.match('-----') === null){
output += array[i].querySelector('a').href + '\n';
}
}
copy(output);
})();
#ab -r -n 10000 http://127.0.0.1:8880/hello/world
#You have to run Sentry at 127.0.0.1:8000 and replace the following DSN.
from bottle import route, run
@route('/hello/:name')
def index(name='World'):
from raven import Client
client = Client('http://5a77e2293b2e441188dcd03180e47e6d:4294d8e71d044c87b49a6d3f4abf113d@127.0.0.1:8000/2')
client.captureMessage('hello world!')
#-*- coding:utf-8 -*-
from optparse import OptionParser
from pyapns import configure, provision, notify, feedback
def send_notify(host, app, cert, token, string, is_feedback):
print 'Sending...\nhost: %s\napp: %s\ndevice: %s\nstring: %s' % (host, app, token, string)
configure({'HOST': host})
if cert:
provision(app, open(cert).read(), 'sandbox')
notify(app, token, {'aps':{'alert': string}})