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
| import tweepy, json | |
| def twitter_poster(json_creds): | |
| """Pass me a json file with twitter creds. | |
| Fields: | |
| 'consumer_key', | |
| 'consumer_secret | |
| 'access_token', | |
| 'access_secret', | |
| which are all in the order given in the twitter dev page |
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
| #!/usr/bin/env planck | |
| ;; note: I haven't included any lein or boot tooling since there are no | |
| ;; dependencies. the easiest way to run is to use planck on osx, as a script. | |
| ;; can also be easily adapted to normal clojure or have some tooling added if you want to | |
| ;; run it and don't have a mac | |
| (ns dfs.core | |
| "depth-first search of tree. Makes a few assumptions for simplification purposes: | |
| 1. tree is directed graph |
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
| import re | |
| def tab_paras_to_double_lines(s): | |
| return re.sub("\n\t", "\n\n", s) | |
| def de_leading_trailing(s): | |
| s1 = re.sub(" \n", "\n", s) | |
| return re.sub("\n ", "\n", s1) | |
| def fix_unspaced(mobj): | |
| m = mobj.group(0) |
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
| import requests | |
| import appex | |
| url = "http://c.docverter.com/convert" | |
| filename = appex.get_file_path() | |
| with open(filename, 'rb') as f: | |
| r = requests.post(url, data={'to':'docx','from':'markdown'},files={'input_files[]':f}) | |
| if r.ok: | |
| outfile = filename.rpartition('/')[-1].rpartition('.')[0] + '.docx' | |
| with open(outfile, 'wb') as o: | |
| o.write(r.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
| import requests, appex | |
| from urllib.parse import urlparse | |
| url = appex.get_url().replace("dl=0", "dl=1") | |
| r = requests.get(url) | |
| filename = urlparse(url).path.rpartition("/")[-1].replace(".py", "-downloaded.py") | |
| with open(filename, "wb") as outfile: | |
| outfile.write(r.content) | |
| print("script downloaded as " + filename) |
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 '[clojure.math.combinatorics :as c]) | |
| (defn breaks->partition | |
| ([v brks] | |
| (breaks->partition 0 [] v brks)) | |
| ([start pars v brks] | |
| (if (empty? brks) | |
| (conj pars (subvec v start (count v))) | |
| (let [this-part (subvec v start (first brks))] | |
| (recur (first brks) (conj pars this-part) v (rest brks)))))) |
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
| # written for pythonista ios app, takes advantage of its library and access to ios twitter login. generates a list of followers who don't follow you back and lets you look at each individually to decide whethee to dispose of them or not. Only works for followers < 5000 amd following < 5000, else rate limits and cursors get imvolved and are icky. could use a real UI. | |
| import twitter, json, webbrowser, random | |
| account = twitter.get_all_accounts()[0] | |
| followers = frozenset(json.loads(twitter.request(account, "https://api.twitter.com/1.1/followers/ids.json", "GET")[1].decode("utf-8"))["ids"]) | |
| ifollow = frozenset(json.loads(twitter.request(account, "https://api.twitter.com/1.1/friends/ids.json", "GET")[1].decode("utf-8"))["ids"]) | |
| not_following_back = list(ifollow.difference(followers)) | |
| def make_url(id): | |
| return 'https://twitter.com/intent/user?user_id=' + str(id) | |
| turls = [make_url(id) for id in not_following_back] |
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 partial(func, arg){ | |
| return function(){ | |
| var args = arguments ? [].slice.call(arguments) : [] | |
| args.unshift(arg); | |
| return func.apply(null, args); | |
| }; | |
| } | |
| // comp applies functions right to left, like Clojure. | |
| function comp(func1, func2){ |
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
| from requests import post | |
| from xml.etree.ElementTree import fromstring | |
| from copy import deepcopy | |
| endpoint = "http://freecite.library.brown.edu/citations/create" | |
| # the example citations on their webpage | |
| cite1 = "Udvarhelyi, I.S., Gatsonis, C.A., Epstein, A.M., Pashos, C.L., Newhouse, J.P. and McNeil, B.J. Acute Myocardial Infarction in the Medicare population: process of care and clinical outcomes. Journal of the American Medical Association, 1992; 18:2530-2536." | |
| cite2 = "Fielderman, A., Silvester, G., Gatsonis, C.A., Hoenig, J., Flynn, S. Prognostic significance of flow cytometric DNA analysis and proliferative index in stage I non-small cell lung cancer. American Review of Respiratory Disease, 1992; 146:707-710" |
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
| from dialogs import text_dialog | |
| import twitter | |
| from time import sleep | |
| acct = twitter.get_all_accounts()[0] | |
| # if there are multiple accounts this will need to be changed to get different account. I only have one account so don't care. | |
| # right now I also don't care to have authentication error handling, will need to experiment with unauthenticated devices to figure out what it throws. | |
| def numerate_tweets(tweetlist): | |
| numtweets = len(tweetlist) | |
| newoutlist = [] |