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 python | |
| target_dir = "FULL_PATH_TO_YOUR_TARGET_DIRECTORY_WITH_GIT_REPO" # example: /Users/you/github/backup/ | |
| source_dir = "FULL_PATH_TO_YOUR_TARGET_DIRECTORY_WITH_NO_GIT" # example: /Users/you/Dropbox/ImportantDocuments/ | |
| extensions = ["txt", "md"] # example list of extensions to copy, change to suit you. | |
| import glob, shutil, subprocess, os | |
| source_wildcards = [source_dir + "*." + x for x in extensions] | |
| source_filenames = [] |
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
| ;; thanks Mike Fikes for helping me figure out how to do this! | |
| #!/usr/bin/env planck | |
| (ns panpdf.core | |
| (:require [planck.shell :refer [sh]])) | |
| (def s "\"#foo\nbar\"") | |
| (sh "bash" "-c" (str "echo " s " | pandoc -o fbb.html")) |
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
| (ns upload-file.core | |
| (:require [reagent.core :refer [render atom]] | |
| [cljs.core.async :refer [put! chan <! >!]]) | |
| (:require-macros [cljs.core.async.macros :refer [go go-loop]])) | |
| ;; derived from https://mrmcc3.github.io/post/csv-with-clojurescript/ | |
| ;; and based on reagent-frontend template. | |
| ;; dependencies from project.clj in addition to clojure, clojurescript, and reagent: | |
| ;; [org.clojure/core.async "0.2.395"] |
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
| ;; note: the extra case is to fit weird euler def. of fib seq that goes 1, 2, 3, 5, 8, 13, ... rather than 1, 1, 2, 3, 5, 8, 13 | |
| ;; not nearly as cool as the fibs here: https://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci | |
| (def fib | |
| (memoize | |
| (fn [n] | |
| (case n | |
| 0 0 | |
| 1 1 | |
| 2 2 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| # you can extract the text from NYT article in javascript console with document.documentElement.outerText | |
| # nyt article is here: http://www.nytimes.com/interactive/2016/01/28/upshot/donald-trump-twitter-insults.html | |
| # first open the file. I saved it as trumpinsults2.txt on my hard drive | |
| # I also changed non-ascii quotes to quotes and got rid of other non-ascii stuff using sublime text, and some code I | |
| # wrote for the purpose from here: https://github.com/paultopia/ascii_punctuation | |
| with open("trumpinsults2.txt") as t: | |
| insults = t.readlines() |
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 python3 | |
| import sys | |
| import os | |
| mode = sys.argv[1] | |
| command = sys.argv[2] | |
| def markdown_to_pdf(root_filename): | |
| md_filename = root_filename+".md" | |
| pdf_filename = root_filename+".pdf" | |
| print("converting {0} to {1}".format(md_filename, pdf_filename)) | |
| return "pandoc -o {0} {1}".format(pdf_filename, md_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
| ;; attempted translation of the basic parts of the clojure documentation page on transducers http://clojure.org/reference/transducers | |
| ;; into more comprehensible terms that don't require you to be as smart as Rich Hickey to understand. | |
| ;; transducers are a way to compose sequence functions with less than their normal arity into a combined transformation | |
| ;; which then gets applied more efficiently than just nesting calls to the transformation, using ->, etc. | |
| ;; In the below, xf is a transducer. The composition goes left to right, hence tests for oddness before testing for less-than-5ness | |
| (def xf | |
| (comp | |
| (filter odd?) |
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
| # python3 for pythonista compatible version | |
| from bs4 import BeautifulSoup as BS | |
| import sys | |
| from urllib.request import urlopen | |
| def clearJunk(BSobj): | |
| [s.extract() for s in BSobj(['style', 'script'])] | |
| def makeSoup(url): | |
| soup = BS(urlopen(url)) |
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.core.match :refer [match]]) | |
| (defn discard-nils [a b] | |
| (match [a b] | |
| [_ nil] a | |
| :else b)) | |
| (def safe-merge (partial merge-with discard-nils)) | |
| ;; examples |