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
| (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
| 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
| 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 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
| #!/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 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
| from requests import get | |
| from shutil import copyfileobj | |
| from hashlib import sha256 | |
| import gzip | |
| testhtml = "http://paul-gowder.com/curve/index.html" | |
| testbinary = "http://paul-gowder.com/penguin-square.jpg" | |
| # fetch and save to file | |
| def fetch_and_save(url, name): |
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
| # Ubuntu 16.10 32bit on smallest digitalocean droplet | |
| # Operating as root | |
| # point of this is to have something I can ssh into from iPad to compile and run stuff | |
| # I've run all this stuff interactively, but I think it should work as a shell script... tried to put force confirmation in everything. | |
| # apologies if something blows up, or hangs waiting for confirmation; work in progress | |
| # make sure all is good in the world | |
| apt-get update |
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
| ;; -*- mode: emacs-lisp -*- | |
| ;; This file is loaded by Spacemacs at startup. | |
| ;; It must be stored in your home directory. | |
| (defun dotspacemacs/layers () | |
| "Configuration Layers declaration. | |
| You should not put any user code in this function besides modifying the variable | |
| values." | |
| (setq-default | |
| ;; Base distribution to use. This is a layer contained in the directory |