A rather dirty way to patch module code at runtime.
This file contains 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
#!python | |
# Note that this whole effort is fundamentally flawed. The Harvest API does not | |
# provide the ability to submit the timesheet for approval. So, even though this | |
# code can fill in your timesheet, you still have to go to the web page to submit | |
# it. Which makes this a waste of time. | |
# See the feature request thread here: | |
# http://forum.getharvest.com/forums/api-and-developer-chat/topics/is-there-a-timesheet-api | |
# HARVEST_URL, PROJECT_NAME, and TASK_NAME need to be set to the desired values. |
This file contains 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
import win32clipboard as cb | |
builtin_type = { | |
2: "CF_BITMAP", | |
8: "CF_DIB", | |
17: "CF_DIBV5", | |
5: "CF_DIF", | |
130: "CF_DSPBITMAP", | |
142: "CF_DSPENHMETAFILE", |
This file contains 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
import sys | |
import subprocess | |
def copy(s): | |
if sys.platform == 'win32' or sys.platform == 'cygwin': | |
subprocess.Popen(['clip'], stdin=subprocess.PIPE).communicate(s) | |
else: | |
raise Exception('Platform not supported') | |
''' |
This file contains 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
// This function is from https://github.com/adam-p/markdown-here/blob/3fca89d704d431dc55e78c68b1afae762794c7e7/src/firefox/chrome/content/ff-overlay.js#L382 | |
/* | |
* doFunction will be passed a [browser](https://developer.mozilla.org/en-US/docs/XUL/browser) | |
* (which is approximately analogous to a tab) | |
* and a [tabbrowser](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser) | |
* (which is approximately analogous to the window containing the tab) | |
* for each open tab. browser.contentDocument can be used to access the page's | |
* document object. | |
*/ | |
function forAllTabsDo(doFunction) { |
This file contains 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
Test extension to demonstrate possible memory leak in Chrome extension API. | |
Install it, open a bunch of tabs, open Chrome's task manager, let it run, watch memory usage increase. |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
pip install --upgrade PyGithub | |
TODO: | |
- Configurable output directory | |
- Output more issue info | |
- Better rendering |
It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream
.)
Getting the PR code
-
Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37
-
Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it
pr37
:
$ git fetch upstream pull/37/head:pr37
OlderNewer