(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.
| Experiments in running a headless OpenOffice as a document convertor for TiddlyDocs, etc. | |
| Running OpenOffice Headless: | |
| $ cd /Applications/OpenOffice.org.app/Contents/program #Mac OSX | |
| $ cd /usr/lib/openoffice.org.app/program #CentOS | |
| $ ./soffice.bin -headless -invisible -nofirststartwizard -accept="socket,port=8100;urp;" | |
| init script: | |
| see openoffice.sh xvfb.sh for init.d scripts |
| (ns in.grok.history.html-parser | |
| (:require [clojure.contrib.logging :as log]) | |
| (:import [org.htmlcleaner HtmlCleaner] | |
| [org.apache.commons.lang StringEscapeUtils])) | |
| (defn parse-page | |
| "Given the HTML source of a web page, parses it and returns the :title | |
| and the tag-stripped :content of the page. Does not do any encoding | |
| detection, it is expected that this has already been done." | |
| [page-src] |
| require 'rubygems' | |
| require 'yaml' | |
| # A demonstration of YAML anchors, references and handling of nested values | |
| # For more info, see: | |
| # http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/ | |
| stooges = YAML::load( File.read('stooges.yml') ) | |
| # => { | |
| # "default" => { |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| (ns sample | |
| (:require [clojure-leap.core :as leap] | |
| [clojure-leap.hand :as l-hand] | |
| [clojure-leap.pointable :as l-pointable :refer [tip-position]])) | |
| (defn process-frame [frame] | |
| (let [_ (println "Frame id:" (.id frame) "timestamp:" (.timestamp frame) | |
| "hands:" (leap/hands frame) "fingers:" (leap/fingers frame) "tools:" (leap/tools frame))] | |
| (when-let [hand (and (leap/hands? frame) (leap/hand frame 0))] | |
| (let [fingers (leap/fingers hand) |
| /* | |
| TITLE: DECODER FOR HT6P20B ENCODER | |
| CREATED BY: AFONSO CELSO TURCATO | |
| DATE: 18/JUN/2014 | |
| E-MAIL: acturcato (at) gmail.com | |
| LICENSE: GPL | |
| REV.: 04 | |
| DESCRIPTION: | |
| http://acturcato.wordpress.com/2014/01/04/decoder-for-ht6p20b-encoder-on-arduino-board-english/ |
(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.
| ;; Code for blog article at | |
| ;; http://www.lexicallyscoped.com/2015/01/05/parsing-flat-files-in-clojure.html | |
| (ns flatfile.core | |
| (:use [clojure.java.io]) | |
| (:import [java.io PushbackReader])) | |
| (defn load-rulebook [file] | |
| (with-open [r (reader file)] | |
| (read (PushbackReader. r)))) |
| ## install Catalyst proprietary | |
| sudo ntfsfix /dev/sda2 | |
| sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK | |
| sudo apt-get remove --purge fglrx* | |
| sudo apt-get install linux-headers-generic | |
| sudo apt-get install fglrx xvba-va-driver libva-glx1 libva-egl1 vainfo | |
| sudo amdconfig --initial | |
| ## install build essentials | |
| sudo apt-get install cmake |