(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| ;; | |
| ;; NS CHEATSHEET | |
| ;; | |
| ;; * :require makes functions available with a namespace prefix | |
| ;; and optionally can refer functions to the current ns. | |
| ;; | |
| ;; * :import refers Java classes to the current namespace. | |
| ;; | |
| ;; * :refer-clojure affects availability of built-in (clojure.core) | |
| ;; functions. |
| require 'nokogiri' | |
| ugly = Nokogiri::HTML ARGF | |
| tidy = Nokogiri::XSLT File.open('tidy.xsl') | |
| nice = tidy.transform(ugly).to_html | |
| puts nice |
| 2 ways to extract elements from within XML namespaces using Nokogiri | |
| When trying to select elemenets in the default namespace, e.g. "xmlns= http://www.w3.org/2005/Atom", try the following two ways. Note the xmlns=" attribute on entry element: | |
| Original xml: | |
| Nokogiri::XML(@xml_string).xpath("//author/name").each do |node| | |
| puts node | |
| end | |
| 1. Define a namespace context for your XPath expression and point your XPath steps to match elements in that namespace. Define a namespace-to-prefix mapping and use this prefix (a) in the XPath expression. |
| import requests | |
| #http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file | |
| url = "http://localhost:5000/" | |
| fin = open('simple_table.pdf', 'rb') | |
| files = {'file': fin} | |
| try: | |
| r = requests.post(url, files=files) | |
| print r.text |
| call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86 | |
| call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64 |
| Sample project for the "Getting started with JavaFX in Clojure" ( https://coderwall.com/p/4yjy1a ) ProTip. |
| ;; put this into profiles.clj in ~/.lein folder | |
| {:user {:jvm-opts ^:replace ["-Xmx6G" | |
| "-XX:-OmitStackTraceInFastThrow"] | |
| :repl-options {:timeout 180000} | |
| :plugins [[cider/cider-nrepl "0.49.0"] | |
| [refactor-nrepl "3.10.0"] | |
| [jonase/eastwood "0.3.14"] | |
| [lein-ancient "1.0.0-RC3"] | |
| [lein-try "0.4.3"] | |
| [lein-cloverage "1.0.13"] |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
| ;; Gaussian sum! | |
| user=> (crit/with-progress-reporting (crit/quick-bench (/ (* (+ 1 99999) 99999) 2))) | |
| Warming up for JIT optimisations 5000000000 ... | |
| compilation occured before 333366 iterations | |
| Estimating execution count ... | |
| Sampling ... | |
| Final GC... | |
| Checking GC... | |
| WARNING: Final GC required 8.548926352381509 % of runtime | |
| Finding outliers ... |