This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cond | |
((= 23 emacs-major-version) | |
(if (file-exists-p "~/.emacs.d/emacs23.el") | |
(load-file "~/.emacs.d/emacs23.el"))) | |
((= 24 emacs-major-version) | |
(if (file-exists-p "~/.emacs.d/emacs24.el") | |
(load-file "~/.emacs.d/emacs24.el"))) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun add-py-header () | |
"check and add # -*- coding: utf-8 -*-" | |
(interactive) | |
(let ((pyheader "# -*- coding: utf-8 -*-")) | |
(if (not (equal pyheader (buffer-substring-no-properties 1 (1+ (length pyheader))))) | |
(progn (goto-char 1) | |
(insert (concat pyheader "\n\n")))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
import fnmatch | |
def Walk(root='.', recurse=True, pattern='*'): | |
""" | |
Generator for walking a directory tree. | |
Starts at specified root folder, returning files | |
that match our pattern. Optionally will also |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- 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}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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:[email protected]:8000/2') | |
client.captureMessage('hello world!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'oauth' | |
API_KEY = '' | |
API_SECRET = '' | |
token = '' | |
secret = '' | |
post '/miniblog' do | |
content = params[:content] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |