<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<rss version="2.0"><channel><title>An explorer&apos;s log</title><link>http://nakkaya.com</link><description>Random bits and pieces on stuff that I find interesting.</description><item><title>Ferret Lisp FFI Notes</title><link>http://nakkaya.com/2017/06/24/ferret-lisp-ffi-notes/</link><pubDate>Sat, 24 Jun 2017 00:00:00 +0300</pubDate><description>&lt;div id=&quot;table-of-contents&quot;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;div id=&quot;text-table-of-contents&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1&quot;&gt;Value&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-2&quot;&gt;Extending Ferret Objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-3&quot;&gt;Pointer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-4&quot;&gt;Macros for C++ Code Generation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This posts serves as documentation on how to interact with third
party C,C++ libraries when using Ferret Lisp, a free software Clojure
implementation, it compiles a restricted subset of the Clojure
language to self contained ISO C++11 which allows for the use of
Clojure in real time embedded control systems. It has been verified to
run on architectures ranging from microcontrollers with as little as
2KB of RAM to general purpose computers running Linux/Mac OS
X/Windows.
&lt;/p&gt;

&lt;p&gt;
Following Clojure&apos;s design philosophy of embracing the host. Ferret
provides multiple ways of interacting with the host
language. Currently there are 4 methods that can be used to pass data
back and forth between Ferret and C,C++,
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1&quot;&gt;Value&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-2&quot;&gt;Extending Ferret Objects&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-3&quot;&gt;Pointer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-4&quot;&gt;Macros for C++ Code Generation&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div id=&quot;outline-container-sec-1&quot; class=&quot;outline-2&quot;&gt;
&lt;h2 id=&quot;sec-1&quot;&gt;Value&lt;/h2&gt;
&lt;div class=&quot;outline-text-2&quot; id=&quot;text-1&quot;&gt;
&lt;p&gt;
A &lt;code&gt;value&lt;/code&gt; Ferret object can used to capture any C++ type &lt;code&gt;T&lt;/code&gt;. This is
useful when interacting with modern C++ libraries where instead of
using pointers they use smart pointers. One example for these types of
libraries is the OpenCV computer vision library. Following is the
Hello World of OpenCV, a simple app to open the first attach camera,
grab a frame from it and show that frame on a GUI element.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-c++&quot;&gt;&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;#include&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;opencv2/opencv.hpp&quot;&lt;/span&gt;

&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;cv&lt;/span&gt;;

&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;main&lt;/span&gt;(&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;argc&lt;/span&gt;, &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;char&lt;/span&gt;** &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;argv&lt;/span&gt;){

  &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;VideoCapture&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;cap&lt;/span&gt;;

  &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt;(!cap.open(0))
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;return&lt;/span&gt; 0;

  &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;for&lt;/span&gt;(;;){
    &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;Mat&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;frame&lt;/span&gt;;
    cap &amp;gt;&amp;gt; frame;

    imshow(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Cam 0&quot;&lt;/span&gt;, frame);
    waitKey(1);
  }

  &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;return&lt;/span&gt; 0;
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
For converting the above program we need to create 4 functions,
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;A function to return a handle to a &lt;code&gt;VideoCapture&lt;/code&gt; object.
&lt;/li&gt;
&lt;li&gt;A function to grab a frame from the capture.
&lt;/li&gt;
&lt;li&gt;A function to show the grabbed frame on a OpenCV window.
&lt;/li&gt;
&lt;li&gt;A function to tell OpenCV to update GUI.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defnative&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;video-capture&lt;/span&gt; [n]
  (on &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;defined FERRET_STD_LIB&quot;&lt;/span&gt;
      (&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;opencv2/opencv.hpp&quot;&lt;/span&gt;)
      &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;using namespace cv;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;       VideoCapture cap;&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;       cap.open(number::to&amp;lt;number_t&amp;gt;(n));&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;       if (!cap.isOpened())&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;         return nil();&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;       __result = obj&amp;lt;value&amp;lt;VideoCapture&amp;gt;&amp;gt;(cap);&quot;&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Converting Ferret types to C++ types are handled by &lt;code&gt;::to=&lt;/code&gt;
functions. Every built in type has a static &lt;code&gt;::to=&lt;/code&gt; function to
convert the type to its native counter part. Above function takes the
camera id as a parameter and can be used in the following way,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;capture&lt;/span&gt; (video-capture 0))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
In order to convert camera id to a native number one can use the
&lt;code&gt;number&lt;/code&gt; objects &lt;code&gt;::to=&lt;/code&gt; method.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-c++&quot;&gt;&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;cam_id&lt;/span&gt; = &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;number&lt;/span&gt;::to&amp;lt;&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;int&lt;/span&gt;&amp;gt;(n);
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Once we have the camera id we can open the attached camera, check if it
is correctly initialized using &lt;code&gt;isOpened()&lt;/code&gt; method, if not return &lt;code&gt;nil&lt;/code&gt;
otherwise we use a &lt;code&gt;value&lt;/code&gt; Ferret object to return the OpenCV
&lt;code&gt;VideoCapture&lt;/code&gt; object back to Ferret side. A &lt;code&gt;value&lt;/code&gt; Ferret object can
hold any type &lt;code&gt;T&lt;/code&gt;.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-c++&quot;&gt;&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;dev&lt;/span&gt; = obj&amp;lt;&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;value&lt;/span&gt;&amp;lt;VideoCapture&amp;gt;&amp;gt;(0);
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Any arguments passed to &lt;code&gt;value&lt;/code&gt; constructor will be forwarded to the
type &lt;code&gt;T&lt;/code&gt;&apos;s constructor. A &lt;code&gt;value&lt;/code&gt; object acts just like any other
Ferret object type, and its lifetime is handled by the active
GC. (Ferret supports various schemes for garbage collection.)
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;query-capture&lt;/span&gt; [c]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;using namespace cv;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;   Mat frame;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;   value&amp;lt;VideoCapture&amp;gt;::to_value(c) &amp;gt;&amp;gt; frame;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;   __result = obj&amp;lt;value&amp;lt;Mat&amp;gt;&amp;gt;(frame);&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Type &lt;code&gt;T&lt;/code&gt; contined within a &lt;code&gt;value&lt;/code&gt; type can be accessed using the
&lt;code&gt;::to_value&lt;/code&gt; static function of the &lt;code&gt;value&lt;/code&gt; class.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;VideoCapture dev = value&amp;lt;VideoCapture&amp;gt;&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;::to_value&lt;/span&gt;(c)&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
A &lt;code&gt;value&lt;/code&gt; object is used to return the latest frame from the camera
back to Ferret.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;frame&lt;/span&gt; (query-capture capture))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Two other function needs to be wrapped to convert the above C++
program in to a Ferret program.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defnative&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;imshow&lt;/span&gt; [n f]
  (on &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;defined FERRET_STD_LIB&quot;&lt;/span&gt;
      (&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;opencv2/highgui/highgui.hpp&quot;&lt;/span&gt;)
      &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;using namespace cv;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;       imshow(string::to&amp;lt;std::string&amp;gt;(n), value&amp;lt;Mat&amp;gt;::to_value(f));&quot;&lt;/span&gt;))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;wait-key&lt;/span&gt; [n]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;number&amp;gt;(cv::waitKey(number::to&amp;lt;number_t&amp;gt;(n)));&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Once all the required API functions are wrapped above C++ program can
be represented using the following Ferret program.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;capture&lt;/span&gt; (video-capture 0))

(forever
 (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;-&amp;gt;&amp;gt;&lt;/span&gt; capture
      query-capture
      (imshow &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Cam 0&quot;&lt;/span&gt;))
 (wait-key 1))
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-2&quot; class=&quot;outline-2&quot;&gt;
&lt;h2 id=&quot;sec-2&quot;&gt;Extending Ferret Objects&lt;/h2&gt;
&lt;div class=&quot;outline-text-2&quot; id=&quot;text-2&quot;&gt;
&lt;p&gt;
For tighter integration with Ferret, users can define their own
types. While a &lt;code&gt;value&lt;/code&gt; object is just a container holding a type &lt;code&gt;T&lt;/code&gt;
user defined objects can implement built in interfaces making them
seekable and/or callable. i.e, instead of using the built in D-List
based maps, one can use any map implementation from any C,C++ library
and it will behave just like the built in type. In order to create a
user defined object you have to define a class that extends &lt;code&gt;object&lt;/code&gt;
and implement some methods required by Ferret.(&lt;code&gt;stream_console&lt;/code&gt;,
&lt;code&gt;equals&lt;/code&gt;, &lt;code&gt;type&lt;/code&gt;). When using this method garbage collection is also
automatically handled by the active GC scheme. No manual allocation
deallocation is necessary other than what is required by the native
library.
&lt;/p&gt;

&lt;p&gt;
Lets assume you are doing embedded work using an Arduino, want to
interface with a humidity and temperature sensor (HIH6130) and you
want your sensor object to be callable. Giving you a Ferret API that
can be used like the following,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;sensor&lt;/span&gt; (new-hih 0x27))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [[temprature humidity] (sensor)]
  (println temprature humidity))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
First we need to define a class that contains the implementation for
the object. You can make any user defined object callable by
implementing the &lt;code&gt;lambda_i&lt;/code&gt; and overriding &lt;code&gt;invoke&lt;/code&gt; method.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-c++&quot;&gt;&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;#include&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&amp;lt;HIH61XX.h&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;hih&lt;/span&gt; : &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;lambda_i&lt;/span&gt; {
  &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;HIH61XX&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;hih&lt;/span&gt;;

&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;public&lt;/span&gt;:

  &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;type_t&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;type&lt;/span&gt;() &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;final&lt;/span&gt; { &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;type_id&lt;/span&gt;&amp;lt;&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;hih&lt;/span&gt;&amp;gt;; }

  &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;equals&lt;/span&gt;(&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;const&lt;/span&gt; &amp;amp; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;o&lt;/span&gt;) &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;const&lt;/span&gt; { &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;this&lt;/span&gt; == o.get()); }

&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;#if&lt;/span&gt; !&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;defined&lt;/span&gt;(FERRET_DISABLE_STD_OUT)
  &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;stream_console&lt;/span&gt;() &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;const&lt;/span&gt; {
    &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;runtime&lt;/span&gt;::print(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;HIH Temrature Sensor&quot;&lt;/span&gt;);
  }
&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;#endif&lt;/span&gt;

  &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;explicit&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;hih&lt;/span&gt;() : hih(0x27) { }

  ~&lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;hih&lt;/span&gt;(){ }

  &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;invoke&lt;/span&gt;(&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;const&lt;/span&gt; &amp;amp; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;args&lt;/span&gt;) &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;const&lt;/span&gt; {
    &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;status&lt;/span&gt;;
    &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;double&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;T&lt;/span&gt;,&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;P&lt;/span&gt;,&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;p0&lt;/span&gt;,&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;a&lt;/span&gt;;

    status = pressure.startTemperature();
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (status != 0){
      delay(status);
      status = pressure.getTemperature(T);
      &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (status != 0){
        status = pressure.startPressure(3);
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (status != 0){
          delay(status);
          status = pressure.getPressure(P,T);
          &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (status != 0){
            p0 = pressure.sealevel(P, default_altitude);
            __result = &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;runtime&lt;/span&gt;::&lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;list&lt;/span&gt;(obj&amp;lt;number&amp;gt;(&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;T&lt;/span&gt;), obj&amp;lt;number&amp;gt;(&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;P&lt;/span&gt;));
          }
        }
      }
    }

    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;return&lt;/span&gt; nil();
  }
};
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
And somewhere in your program tell Ferret where the implementation for
the object is,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defobject&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;hih&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/path/to/hih_implementation.h&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;new-hih&lt;/span&gt; [id]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;hih&amp;gt;(number::to&amp;lt;int&amp;gt;(id));&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-3&quot; class=&quot;outline-2&quot;&gt;
&lt;h2 id=&quot;sec-3&quot;&gt;Pointer&lt;/h2&gt;
&lt;div class=&quot;outline-text-2&quot; id=&quot;text-3&quot;&gt;
&lt;p&gt;
For interacting with legacy C++ libraries or C libraries Ferret
provides a &lt;code&gt;pointer&lt;/code&gt; type. It holds a pointer to a type &lt;code&gt;T&lt;/code&gt;. Unlike a
&lt;code&gt;value&lt;/code&gt; type or user defined object, user is responsible for garbage
collection.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;new-int&lt;/span&gt; [i]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;pointer&amp;gt;(new int(number::to&amp;lt;int&amp;gt;(i)));&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;print-int&lt;/span&gt; [i]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;std::cout &amp;lt;&amp;lt; pointer::to_pointer&amp;lt;int&amp;gt;(i) &amp;lt;&amp;lt; std::endl;&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-4&quot; class=&quot;outline-2&quot;&gt;
&lt;h2 id=&quot;sec-4&quot;&gt;Macros for C++ Code Generation&lt;/h2&gt;
&lt;div class=&quot;outline-text-2&quot; id=&quot;text-4&quot;&gt;
&lt;p&gt;
Once in a while you may come across a library that does not play well
with any of the above methods and custom C++ code should be generated
for each invocation. i.e You want to register a Ferret function as a
interrupt service routine on a Raspberry PI via WiringPi
library. &lt;code&gt;wiringPiISR&lt;/code&gt; function expects a C style callback
function, a Ferret function can not be passed as is. What we can do is
for every Ferret function we want to register as callback, define a
native function that in turn invokes the Ferret function.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defmacro&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;attach-isr&lt;/span&gt; [pin callback]
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [fn (gensym)]
    `(~&apos;do
      (~&apos;def ~fn ~callback)
      (~&apos;cxx ~(str &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;wiringPiISR (&quot;&lt;/span&gt; pin &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;, INT_EDGE_FALLING, [](){ run(&quot;&lt;/span&gt; fn &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;);})&quot;&lt;/span&gt;)))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
&lt;code&gt;wiringPiISR&lt;/code&gt; expects a function with the signature &lt;code&gt;void
(*function)(void))&lt;/code&gt; so C++ lambdas can not capture the Ferret function
variable passed. What the above macro does is define a unique variable
for the function passed and using a non capturing lambda execute the
function pointed by the unique variable.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(attach-isr 0 #(println &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Interrupted!&quot;&lt;/span&gt;)) &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;attach interrupt in WiringPI pin 0&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description></item><item><title>Bare Metal Lisp - RC Control using Ferret</title><link>http://nakkaya.com/2017/02/15/bare-metal-lisp-rc-control-using-ferret/</link><pubDate>Wed, 15 Feb 2017 00:00:00 +0200</pubDate><description>&lt;p&gt;
Some sample code to demonstrate FFI capabilities of Ferret on embedded
systems. Ferret is a free software Clojure implementation, it compiles
a restricted subset of the Clojure language to self contained ISO
C++11 which allows for the use of Clojure in real time embedded
control systems. See &lt;a href=&quot;http://ferret-lang.org&quot;&gt;Project Home Page&lt;/a&gt;. Mobile platform used in this
post is a &lt;a href=&quot;https://www.pololu.com/product/2506&quot;&gt;Zumo Robot&lt;/a&gt; (required &lt;a href=&quot;https://github.com/pololu/zumo-shield&quot;&gt;third party libraries&lt;/a&gt;) and the
microcontroller is a Arduino Uno / Atmega328.
&lt;/p&gt;

&lt;p&gt; &lt;img width=&quot;60%&quot; src=&quot;/images/post/bare-metal-lisp-rc-control-using-ferret.jpg&quot; /&gt; &lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot; id=&quot;header&quot;&gt;(configure-ferret! &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:command&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;mv ferret-rc-control.cpp ferret-rc-control.ino&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Ferret outputs a &lt;i&gt;cpp&lt;/i&gt; file however Arduino IDE expects a &lt;i&gt;ino&lt;/i&gt;
file. We override build command to rename the &lt;i&gt;cpp&lt;/i&gt; file to a &lt;i&gt;ino&lt;/i&gt;
file.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot; id=&quot;header&quot;&gt;(configure-runtime! FERRET_MEMORY_POOL_SIZE 1024)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
On embedded systems Ferret can be configured to avoid calling
malloc/free. Enabling memory pooling will allocate (1 kb in this case)
memory to be used as heap. 
&lt;/p&gt;

&lt;p&gt;
Ferret&apos;s FFI is modeled after Gambit scheme. Whereas Gambit scheme
lets you embed C into Scheme, Ferret lets you embed C or C++ into
Clojure.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot; id=&quot;ffi&quot;&gt;(native-header &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;ZumoMotors.h&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;new-motor&lt;/span&gt; []
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;value&amp;lt;ZumoMotors&amp;gt;&amp;gt;();&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
A &lt;i&gt;value&lt;/i&gt; object is useful when dealing with C++ objects. It acts as
a container for native object. It can wrap any type &lt;i&gt;T&lt;/i&gt;, once wrapped
it can be used just like any other Ferret variable. (Any arguments
passed to &lt;i&gt;obj&lt;/i&gt; will be forwarded to &lt;i&gt;T&lt;/i&gt; constructor.)
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot; id=&quot;ffi&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;speeds&lt;/span&gt; [m s1 s2]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;ZumoMotors motor = value&amp;lt;ZumoMotors&amp;gt;::to_value(m);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;   motor.setSpeeds(number::to&amp;lt;int&amp;gt;(s1), number::to&amp;lt;int&amp;gt;(s2));&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;pulse-in&lt;/span&gt; [pin]
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;number&amp;gt;(pulseIn(number::to&amp;lt;int&amp;gt;(pin), HIGH,25000));&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Calling C++ functions with Ferret variables is just as easy, every
Ferret object type has a corresponding &lt;i&gt;to&lt;/i&gt; / &lt;i&gt;from&lt;/i&gt; function/s. These
can be used to convert native types to ferret types and vice
versa. (Ferret is a strongly, dynamically typed language. If you try
to convert a ferret number to a value you will get a segmentation
fault.)
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot; id=&quot;control&quot;&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;throttle - ch 1&lt;/span&gt;
&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;steering - ch 2&lt;/span&gt;
(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;read-control&lt;/span&gt; []
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [throttle (scale (pulse-in 4) 981 1998  0   254)
        steering (scale (pulse-in 5) 981 1998 -254 254)]
    (list (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (&amp;lt; throttle 5) &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;setup dead zone&lt;/span&gt;
            0
            throttle)
          (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (&amp;lt; -5 steering 5) &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;setup dead zone&lt;/span&gt;
            0
            steering))))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [motor (new-motor)]
  (forever
   (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [[throttle steering] (read-control)]
     (speeds motor (+ throttle steering) (- throttle steering)))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Radio-control transmitters and receivers are used to drive model cars
or planes. They typically have a bunch of control surfaces like
joysticks. Each degree of freedom that the controller gives is
assigned a channel. They are typically used to control servos so each
channel outputs a signal called PWM (Pulse Width Modulation). i.e
Width of the signal changes as control input changes. Arduino
platform has a function called &lt;i&gt;pulseIn&lt;/i&gt; which we wrapped in a Ferret
function that returns the length of the pulse, this pulse is then
converted to a PWM value which is used to drive the motors on the 
robot. 
&lt;/p&gt;

&lt;p&gt;
Forward motion is controlled by mapping the current pulse width on
channel 1 to a value between 0 and 254. No throttle 0 PWM full
throttle 254 PWM. Steering is controlled in a similar manner but
instead of mapping from 0 to 254 it is mapped to -254 to 254. Final
motor speed is calculated by adding throttle and steering controls
together and apply the resulting PWM to motors.
&lt;/p&gt;
</description></item><item><title>Ferret - A Hard Real-Time Clojure for Lisp Machines</title><link>http://nakkaya.com/2016/06/10/ferret-a-hard-real-time-clojure-for-lisp-machines/</link><pubDate>Fri, 10 Jun 2016 00:00:00 +0300</pubDate><description>&lt;p&gt;
Ferret is a free software Clojure implementation, it compiles a
restricted subset of the Clojure language to self contained ISO C++11
which allows for the use of Clojure in real time embedded control
systems. It has been verified to run on architectures ranging from
embedded systems with as little as 2KB of RAM to general purpose
computers running Linux/Mac OS X/Windows.
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://ferret-lang.org&quot;&gt;Project Home Page&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ferret-lang.org/builds/ferret&quot;&gt;Executable&lt;/a&gt; (Requires Bash and JVM)
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ferret-lang.org/builds/ferret.jar&quot;&gt;Standalone Jar&lt;/a&gt; (Requires JVM)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Unlike other Lisp implementations Ferret is specifically tailored for
real time control applications, provides deterministic execution and
gives you total control on memory management. (Achilles heel of high
level languages for hard real time control). Ferret programs when
running on embedded systems or in single threaded mode 
can be configured to run using a memory pool. This avoids
calling malloc/heap at runtime, improves performance and determinism,
you can also tell how much memory will be used at compile
time.
&lt;/p&gt;

&lt;p&gt;
Starting with a simple example, following shows a simple Arduino Due
example to generate a Sawtooth wave,
&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src=&quot;/images/post/ferret-saw-tooth.jpg&quot; alt=&quot;Ferret Real Time Lisp Saw Tooth Wave&quot; width=&quot;500&quot; /&gt;&lt;/center&gt;&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;saw.clj&lt;/span&gt;
(configure-runtime! FERRET_DISABLE_STD_OUT &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Disable Serial&lt;/span&gt;
                    FERRET_PROGRAM_MAIN &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;signal()&quot;&lt;/span&gt; &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Main Entry for the application&lt;/span&gt;
                                                   &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Ferret functions are C++ functors&lt;/span&gt;
                    FERRET_MEMORY_POOL_SIZE 512) &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Allocate 512 Bytes of static memory&lt;/span&gt;

(require &apos;[ferret.arduino &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:as&lt;/span&gt; gpio])

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;dac-1&lt;/span&gt; []
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;number&amp;gt;(DAC1);&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;signal&lt;/span&gt; []
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;doseq&lt;/span&gt; [sample (range 255)]
    (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;gpio&lt;/span&gt;/analog-write (dac-1) sample)
    (sleep 10)))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
All functions mimic their Clojure counterparts the only thing that&apos;s
different from Clojure is the &lt;b&gt;dac-1&lt;/b&gt; function. A function with just a
string in its body is assumed to be a FFI call and the string is assumed to
be native statement/s. In this case &lt;b&gt;dac-1&lt;/b&gt; function when called returns
the value of &lt;b&gt;DAC1&lt;/b&gt;. (Pin number of digital analog converter on Due.)
In order to run the example on hardware just compile it using Ferret,
&lt;/p&gt;

&lt;pre class=&quot;example&quot;&gt;
$ mkdir saw
$ ./ferret -i saw.clj
$ mv saw.cpp saw.ino
&lt;/pre&gt;

&lt;p&gt;
then upload as usual. Best way to experiment with Arduino and Ferret
is to set the Arduino IDE to use an external editor in preferences and
add the following to you Ferret program, (Overrides the compile command
with &lt;b&gt;mv&lt;/b&gt; by default Ferret uses &lt;b&gt;g++&lt;/b&gt; or the value of &lt;b&gt;CXX&lt;/b&gt;
environment variable to compile the generated code into binary.)
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(configure-ferret! &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:command&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;mv saw.cpp saw.ino&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
then you can just run,
&lt;/p&gt;

&lt;pre class=&quot;example&quot;&gt;
$ ./ferret -i saw.clj -c
&lt;/pre&gt;

&lt;p&gt;
Arduino IDE will pick up changes automatically when you hit
upload. Moving on to a more complicated example, a line following
robot, following shows the built in primitives of Ferret for control
(State Machines, PID Controller) and interfacing with third party C++
libraries using an Arduino Due and a &lt;a href=&quot;https://www.pololu.com/product/2510&quot;&gt;Zumo&lt;/a&gt; robot platform.
&lt;/p&gt;


&lt;p&gt;&lt;center&gt;&lt;img src=&quot;/images/post/ferret-line-follower.gif&quot; alt=&quot;Ferret Real Time Lisp Line Follower&quot; width=&quot;750&quot; /&gt;&lt;/center&gt;&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(configure-runtime! FERRET_DISABLE_STD_OUT &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;save memory&lt;/span&gt;
                    FERRET_PROGRAM_MAIN program &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Default function to run.&lt;/span&gt;
                    FERRET_MEMORY_POOL_SIZE 1024) &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Allocate 1kb Heap&lt;/span&gt;

(require &apos;[ferret.arduino &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:as&lt;/span&gt; gpio])

&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Inlucde Third Party Headers&lt;/span&gt;
&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;https://github.com/pololu/zumo-shield&lt;/span&gt;
(native-header &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;QTRSensors.h&quot;&lt;/span&gt;
               &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;ZumoReflectanceSensorArray.h&quot;&lt;/span&gt;
               &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;ZumoMotors.h&quot;&lt;/span&gt;
               &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Pushbutton.h&quot;&lt;/span&gt;)

&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;Initialize Hardware&lt;/span&gt;
(native-declare &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;unsigned int line_buffer[6];&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 ZumoReflectanceSensorArray line_sensors;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 ZumoMotors zumo_motors;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 Pushbutton button(ZUMO_BUTTON);&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;wait-button&lt;/span&gt; []
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;button.waitForButton();&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;   button.waitForRelease();&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;   __result = obj&amp;lt;boolean&amp;gt;(true)&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;button-pressed?&lt;/span&gt; []
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;boolean&amp;gt;(button.isPressed())&quot;&lt;/span&gt;)

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;motors&lt;/span&gt;
  ([]
   &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;zumo_motors.setSpeeds(0,0);&quot;&lt;/span&gt;)
  ([c]
   &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;int corr = number::to&amp;lt;int&amp;gt;(c);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;    zumo_motors.setSpeeds(400 + (-1 * corr), 400 + corr);&quot;&lt;/span&gt;)
  ([m1 m2]
   &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;zumo_motors.setSpeeds(number::to&amp;lt;int&amp;gt;(m1), number::to&amp;lt;int&amp;gt;(m2));&quot;&lt;/span&gt;))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;read-line&lt;/span&gt; []
  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;__result = obj&amp;lt;number&amp;gt;(line_sensors.readLine(line_buffer,QTR_EMITTERS_ON,1));&quot;&lt;/span&gt;)
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Wrappers for Zumo Libraries needed to interface with the shield. All
follow the same FFI convention explained in the first example.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;calibrate&lt;/span&gt; []
  (cxx &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;line_sensors.init();&quot;&lt;/span&gt;)
  (sleep 1000)
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;dotimes&lt;/span&gt; [i 80]
    (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;or&lt;/span&gt; (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;and&lt;/span&gt; (&amp;gt; i 10) (&amp;lt;= i 30))
            (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;and&lt;/span&gt; (&amp;gt; i 50) (&amp;lt;= i 70)))
      (motors -200  200)
      (motors  200 -200))
    (cxx &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;line_sensors.calibrate();&quot;&lt;/span&gt;)
    (sleep 20))
  (motors))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
&lt;b&gt;calibrate&lt;/b&gt; function is run when the robots boots up and used to
calibrate the Pololu QTR Reflectance Sensors on the shield. &lt;b&gt;cxx&lt;/b&gt;
macro is a convenience macro for calling native code in place. It will
define a &lt;b&gt;fn&lt;/b&gt; and call it in place so,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
is equivalent to,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;((&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fn&lt;/span&gt; [] &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;line_sensors.init();&quot;&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Next we define a PID controller. It takes the result of &lt;b&gt;read-line&lt;/b&gt;, a
number between 0 to 5000 depending on the position of the line under
the sensor and returns correction that we are going to feed in to
&lt;b&gt;motors&lt;/b&gt; function that will keep the sensor at position 2500 which
means the line is in the middle of the robot.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;motor-controller&lt;/span&gt; (pid-controller &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:kp&lt;/span&gt; 0.75
                                      &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:ki&lt;/span&gt; 0
                                      &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:kd&lt;/span&gt; 1
                                      &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:set-point&lt;/span&gt; 2500
                                      &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:bounds&lt;/span&gt; [0 5000 -400 400]
                                      &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:continuous&lt;/span&gt; &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;false&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
A state machine glues all of the above together. &lt;b&gt;fsm&lt;/b&gt; macro
compiles a function, which when called will iterate through its
transition states.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;program&lt;/span&gt;
  (fsm
   (states
    (boot (motors)
          (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;gpio&lt;/span&gt;/pin-mode 53 &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:output&lt;/span&gt;)
          (wait-button)
          (calibrate))

    (follow-line (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;gpio&lt;/span&gt;/digital-write 53 1)
                 (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;-&amp;gt;&amp;gt;&lt;/span&gt; (read-line)
                      (motor-controller)
                      (motors))
                 (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;gpio&lt;/span&gt;/digital-write 53 0))

    (stop (motors)
          (cxx &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;button.waitForRelease();&quot;&lt;/span&gt;)))

   (transitions
    (boot         wait-button      follow-line)
    (follow-line  button-pressed?  stop)
    (stop         wait-button      follow-line))))
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Robot starts at &lt;b&gt;boot&lt;/b&gt; state, where we wait for the user to press a
button to start calibrating the sensors, when done we wait for another
button press to transition into &lt;b&gt;follow-line&lt;/b&gt; state where we read the
current position of the line and feed it to the PID controller and
feed the controllers result to &lt;b&gt;motors&lt;/b&gt; function. After each iteration
of &lt;b&gt;follow-line&lt;/b&gt; we check if the button is pressed when pressed we
transition into &lt;b&gt;stop&lt;/b&gt; state otherwise we keep executing &lt;b&gt;follow-line&lt;/b&gt;
state. In &lt;b&gt;stop&lt;/b&gt; state we stop and wait for the user to press the
button again to continue following the line.
&lt;/p&gt;

&lt;p&gt;
Pin 53 is used to produce to following oscilloscope output to show the
jitter in the system.
&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src=&quot;/images/post/ferret-line-follower.jpg&quot; alt=&quot;Ferret Real Time Lisp Line Follower&quot; width=&quot;750&quot; /&gt;&lt;/center&gt;&lt;/p&gt;
</description></item><item><title>Static Galleria Script</title><link>http://nakkaya.com/2014/10/7/static-galleria-script/</link><pubDate>Tue, 7 Oct 2014 00:00:00 +0300</pubDate><description>&lt;p&gt;
Following is a Clojure shell script that piggy backs on the
&lt;a href=&quot;http://nakkaya.com/static.html&quot;&gt;static.jar&lt;/a&gt; to create static image galleries using galleria and upload
them to S3.
&lt;/p&gt;

&lt;p&gt;
Either tangle this file (it will tangle to ~/.bin/static-galleria) or
copy/paste the snippets into a file on your path and make it
executable, and update path to static.jar. This script depends on
ImageMagick command line tools.
&lt;/p&gt;

&lt;pre class=&quot;example&quot;&gt;
bash ~/.bin/static-galleria &quot;Photo Folder&quot;
&lt;/pre&gt;

&lt;p&gt;
See &lt;a href=&quot;http://nakkaya.com/photos.html&quot;&gt;Photos&lt;/a&gt; page for example static galleries hosted on S3.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot; id=&quot;header&quot;&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;^:shebang &apos;[&lt;/span&gt;
             &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;exec&lt;/span&gt; java -cp &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;static-app.jar&quot;&lt;/span&gt; clojure.main &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$0&quot;&lt;/span&gt; -- &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$@&quot;&lt;/span&gt;
               ]
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-clojure&quot; id=&quot;script&quot;&gt;(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;ns&lt;/span&gt; &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;album-builder&lt;/span&gt;
  (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:use&lt;/span&gt; clojure.java.shell)
  (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:use&lt;/span&gt; [static io core config]))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;images&lt;/span&gt; [in-dir]
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;-&amp;gt;&amp;gt;&lt;/span&gt; (map #(java.io.File. in-dir &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;%&lt;/span&gt;) (.list in-dir))
       (filter #(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [ext (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;org.apache.commons.io.FilenameUtils&lt;/span&gt;/getExtension (.toString &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;%&lt;/span&gt;))]
                  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;and&lt;/span&gt; (.isFile &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;%&lt;/span&gt;)
                       (contains? #{&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;JPG&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;jpg&quot;&lt;/span&gt; 
                                    &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;JPEG&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;jpeg&quot;&lt;/span&gt; 
                                    &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;png&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;gif&quot;&lt;/span&gt;} ext))))))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;prep-images&lt;/span&gt; [in-dir out-dir]
  (println &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Prepping Images&quot;&lt;/span&gt;)
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;doall&lt;/span&gt;
   (pmap (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fn&lt;/span&gt; [f]
           (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;org.apache.commons.io.FileUtils&lt;/span&gt;/copyFileToDirectory f out-dir)

           &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;fix orientation&lt;/span&gt;
           (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [file (str out-dir &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt;
                           (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;-&amp;gt;&amp;gt;&lt;/span&gt; (.toString f)
                                (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;org.apache.commons.io.FilenameUtils&lt;/span&gt;/getName)))] 
             (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;clojure.java.shell&lt;/span&gt;/sh 
              &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;convert&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;-auto-orient&quot;&lt;/span&gt; file file))) 
         (images in-dir)))

  &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;scale originals&lt;/span&gt;
  (sh &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;mogrify&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;-geometry&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;1024x&quot;&lt;/span&gt; (str out-dir &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/*&quot;&lt;/span&gt;))
  &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;; &lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;generate thumbs&lt;/span&gt;
  (sh &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;mkdir&quot;&lt;/span&gt; (str out-dir &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/thumbs&quot;&lt;/span&gt;))
  (sh &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;mogrify&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;-thumbnail&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;256x&quot;&lt;/span&gt;
      &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;-path&quot;&lt;/span&gt; (str (str out-dir &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt;) &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;thumbs&quot;&lt;/span&gt;)  (str out-dir &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/*&quot;&lt;/span&gt;)))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;galleria-img-json&lt;/span&gt; [idx files]
  (str
   &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;    var data&quot;&lt;/span&gt; idx &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; = [&quot;&lt;/span&gt;
   (reduce (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fn&lt;/span&gt;[h v] 
             (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [name (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;-&amp;gt;&amp;gt;&lt;/span&gt; (.toString v)
                             (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;org.apache.commons.io.FilenameUtils&lt;/span&gt;/getName)
                             (str &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;./&quot;&lt;/span&gt;))
                   thumb (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;-&amp;gt;&amp;gt;&lt;/span&gt; (.toString v)
                              (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;org.apache.commons.io.FilenameUtils&lt;/span&gt;/getName)
                              (str &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;./thumbs/&quot;&lt;/span&gt;))]
               (str h 
                    &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;{thumb: &apos;&quot;&lt;/span&gt; thumb &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&apos;,&quot;&lt;/span&gt;
                    &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;image: &apos;&quot;&lt;/span&gt; name &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&apos;,},&quot;&lt;/span&gt;)))
           &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&quot;&lt;/span&gt; files)
   &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;];&quot;&lt;/span&gt;))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;album-html&lt;/span&gt; [name in-dir]
  (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;let&lt;/span&gt; [images (partition 20 20 &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;nil&lt;/span&gt; (images in-dir))]
    (list
     [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:script&lt;/span&gt;
      (map-indexed (&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fn&lt;/span&gt; [idx val] (galleria-img-json idx val)) images)]

     [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:div&lt;/span&gt; {&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:id&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;pagination&quot;&lt;/span&gt;}]
     [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:div&lt;/span&gt; {&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:id&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;galleria&quot;&lt;/span&gt;}]

     [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:script&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;document.body.style.backgroundColor = &lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;#333&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             var gallery;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             var currentPage = 0;&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             jQuery(window).load(function () {&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                var anchor = window.location.hash.substring(6);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                if(anchor){&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   $(&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;#pagination&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;).pagination(&apos;selectPage&apos;, parseInt(anchor));&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                }&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             });&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             $( document ).ready(function() {&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               $(function() {&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             if (&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;onhashchange&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt; in window)&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 window.onhashchange = function () {&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   var anchor = window.location.hash.substring(6);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   if(anchor)&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                      $(&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;#pagination&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;).pagination(&apos;selectPage&apos;, parseInt(anchor));&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   else&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                      $(&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;#pagination&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;).pagination(&apos;selectPage&apos;, 1);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             }&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             $(&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;#pagination&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;).pagination({&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 items: &quot;&lt;/span&gt; (count images) &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 itemsOnPage: 1,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 cssStyle: &apos;dark-theme&apos;,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 onPageClick:function(pageNumber, event){&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   pageNumber = pageNumber - 1;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   if(gallery &amp;amp;&amp;amp; (currentPage != pageNumber)){&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                     gallery.load(eval(&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt; + pageNumber));&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                     currentPage = pageNumber;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                   }&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 }&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             });&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;         });&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;       });&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             Galleria.loadTheme(&apos;http://photos.nakkaya.com/galleria/themes/folio/galleria.folio.min.js&apos;);&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             var dataSource = data0;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             var anchor = window.location.hash.substring(6);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             if(anchor){&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               currentPage = (parseInt(anchor) - 1);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               dataSource = eval(&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;data&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-weight: bold; font-style: italic;&quot;&gt;\&quot;&lt;/span&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt; + currentPage);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             }&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             Galleria.configure({&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 variation: &apos;dark&apos;,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 dataSource:dataSource&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             });&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             Galleria.ready(function(){&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 gallery = this;&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;                 this.lazyLoadChunks(3);&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             });&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             Galleria.run(&apos;#galleria&apos;,{&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               responsive:true,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               height:1,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               debug:true,&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;               preload:2&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;             });&quot;&lt;/span&gt;])))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;defn&lt;/span&gt; &lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;dump-album&lt;/span&gt; [album-name in-dir out-dir]
  (prep-images in-dir out-dir)
  (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;static.io&lt;/span&gt;/write-out-dir 
   (str album-name &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/index.html&quot;&lt;/span&gt;)
   (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;hiccup.core&lt;/span&gt;/html
    [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:html&lt;/span&gt;
     [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:head&lt;/span&gt;
      [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:title&lt;/span&gt; (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;org.apache.commons.io.FilenameUtils&lt;/span&gt;/getName (str in-dir))]
      &lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;(org.apache.commons.io.FilenameUtils/getFullPathNoEndSeparator in-dir)&lt;/span&gt;
      [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:script&lt;/span&gt; {&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:src&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js&quot;&lt;/span&gt;}]
      [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:script&lt;/span&gt; {&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:src&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;http://photos.nakkaya.com/galleria/galleria-1.3.5.min.js&quot;&lt;/span&gt;}]
      [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:script&lt;/span&gt; {&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:src&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;http://photos.nakkaya.com/simplepagination/js/jquery.simplePagination.js&quot;&lt;/span&gt;}]
      [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:link&lt;/span&gt; {&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:href&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;http://photos.nakkaya.com/simplepagination/css/simplePagination.css&quot;&lt;/span&gt;
              &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:type&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;text/css&quot;&lt;/span&gt;
              &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:rel&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;}]]
     [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:body&lt;/span&gt;
      [&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:div&lt;/span&gt;
       (album-html album-name in-dir)]]])))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;in-dir&lt;/span&gt; (second &lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;*command-line-args*&lt;/span&gt;))
(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;album-name&lt;/span&gt; (.toString (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;java.util.UUID&lt;/span&gt;/randomUUID)))

(set!-config &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;:out-dir&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;./&quot;&lt;/span&gt;)
(println &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Building &quot;&lt;/span&gt; album-name)
(println &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;In Dir:&quot;&lt;/span&gt; in-dir)
(dump-album album-name (java.io.File. in-dir) (java.io.File. album-name))

(&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;when&lt;/span&gt; (&amp;gt; (count &lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;*command-line-args*&lt;/span&gt;) 2)
  (println &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Uploading...&quot;&lt;/span&gt;)
  (&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;clojure.java.shell&lt;/span&gt;/sh 
   &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;s3cmd&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;sync&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;--delete&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;--acl-public&quot;&lt;/span&gt; 
   (str album-name &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt;) (str (nth &lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;*command-line-args*&lt;/span&gt; 2) &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt; album-name &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt;)))

(shutdown-agents)

&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;$(&apos;.galleria-container&apos;).height($(&apos;#galleria&apos;).height());&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
</description></item><item><title>Pentadactyl Configuration</title><link>http://nakkaya.com/2014/01/26/pentadactyl-configuration/</link><pubDate>Sun, 26 Jan 2014 00:00:00 +0200</pubDate><description>&lt;p&gt;
This is a dump of all &lt;a href=&quot;http://5digits.org/pentadactyl/&quot;&gt;Pentadactyl&lt;/a&gt; related configuration and scripts so
I can edit them in one place and tangle from a single
file. Pentadactyl is a Firefox extension that provides a more
efficient user interface for keyboard-fluent users, allowing you to
browse without using a mouse.
&lt;/p&gt;

&lt;p&gt;
Disable smooth scroll,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set scrollsteps=1
set scrolltime=0
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Editor, C-e invokes it in text fields,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set editor=&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;emacsclient&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Show pattern matches as you type,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set incfind
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Highlight previous search pattern matches,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set hlfind
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Ignore case in search unless pattern has uppercase chars,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set findcase=smart
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Color Scheme,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;colorscheme solarized-dark
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Faster Scrolling,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;map -b j 8j
map -b k 8k
map -b h 8h
map -b l 8l
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Use Full Zoom,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;map -b zi ZI
map -b zo ZO
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Use characters for hints,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set hintkeys=asdflkj
hi -a Hint font-size: 9pt !important;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Focus settings, (Let gmail mess with DOM)
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set strictfocus=google.com:laissez-faire,&apos;chrome:*&apos;:laissez-faire,*:despotic
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Load custom css modifications,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;so ~/.pentadactyl/user.css
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Shortcuts to frequently used bookmarks,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; Email current url&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;command email-url :open gmail-this&lt;/span&gt;

&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&lt;/span&gt; Save to org-mode Read Later Tree
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; command read-later :open org-capture-read-later&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Open link in a private tab,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;command private-tab -nargs=+ -description &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Open Private Tab&quot;&lt;/span&gt; -javascript &amp;lt;&amp;lt;EOF
        privateTab.readyToOpenTab(true);
        gBrowser.addTab(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;about:blank&quot;&lt;/span&gt;);
        dactyl.execute(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;:tablast&quot;&lt;/span&gt;);
        dactyl.execute(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;:open &quot;&lt;/span&gt; + args);
        privateTab.stopToOpenTabs();
EOF
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Toggle plugins.click&lt;sub&gt;to&lt;/sub&gt;&lt;sub&gt;play&lt;/sub&gt;,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;command toggle-click-to-play -js &amp;lt;&amp;lt;EOF
        if(Services.prefs.getBoolPref(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;plugins.click_to_play&quot;&lt;/span&gt;))
            Services.prefs.setBoolPref(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;plugins.click_to_play&quot;&lt;/span&gt;, false);
        else
            Services.prefs.setBoolPref(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;plugins.click_to_play&quot;&lt;/span&gt;, true);
        dactyl.execute(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;:reload&quot;&lt;/span&gt;);
EOF
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Convert given time to local time using wolfram alpha,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;command local-time -nargs=+ -description &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Convert Date to Local Time&quot;&lt;/span&gt; -javascript &amp;lt;&amp;lt;EOF
        dactyl.execute(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;:tabopen&quot;&lt;/span&gt;);
        dactyl.open(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;http://www.wolframalpha.com/input/?i=&quot;&lt;/span&gt; + args + &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; in local time&quot;&lt;/span&gt;);
EOF
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Custom search commands,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;command search-nakkaya -nargs=+ -description &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Search nakkaya.com&quot;&lt;/span&gt; -javascript &amp;lt;&amp;lt;EOF
        dactyl.execute(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;:tabopen&quot;&lt;/span&gt;);
        dactyl.open(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;site:nakkaya.com &quot;&lt;/span&gt; + args);
EOF

command search-hackernews -nargs=+ -description &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Search news.ycombinator.com&quot;&lt;/span&gt; -javascript &amp;lt;&amp;lt;EOF
        dactyl.execute(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;:tabopen&quot;&lt;/span&gt;);
        dactyl.open(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;site:news.ycombinator.com &quot;&lt;/span&gt; + args);
EOF
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Save to org-mode Read Later Tree,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;command read-later -description &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Execute emacsclient&quot;&lt;/span&gt; -javascript &amp;lt;&amp;lt;EOF
        var emacsClient = &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/Applications/Emacs.app/Contents/MacOS/bin/emacsclient&quot;&lt;/span&gt;;
        var osString = Components.classes[&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;@mozilla.org/xre/app-info;1&quot;&lt;/span&gt;]  
                       .getService(Components.interfaces.nsIXULRuntime).OS;

        if(osString == &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;Linux&quot;&lt;/span&gt;)
          emacsClient = &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/home/nakkaya/apps/emacs/bin/emacsclient&quot;&lt;/span&gt;

        var url = &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;\&quot;org-protocol://capture://l/&quot;&lt;/span&gt;+ encodeURIComponent(content.location) + &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt;+ encodeURIComponent(content.document.title) +&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/&quot;&lt;/span&gt; + encodeURIComponent(content.window.getSelection()) + &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;\&quot;&quot;&lt;/span&gt;;
        var command = emacsClient + &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; &quot;&lt;/span&gt; + url;
        CommandExMode().open(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;!&quot;&lt;/span&gt; + command);
EOF
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Rename tab,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;:com tabrename -nargs=1 -literal=0 -js content.document.title = args[0];
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
GMail settings,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; Allow GMail shortcuts&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;set passkeys+=mail.google.com:jksacrqG#&amp;lt;CR&amp;gt;,gi,gl,gp&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&lt;/span&gt; Let Hint Message from X Links 
autocmd LocationChange mail.google.com set ht+=span.ata-asJ
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; Let Hint Expand Collapsed Conversations&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;autocmd LocationChange mail.google.com set ht+=span.adx&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;&lt;/span&gt; Let Hint Expand Message
autocmd LocationChange mail.google.com set ht+=td.gF
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; Let Hint Expand Delete All Spam Messages&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;autocmd LocationChange mail.google.com set ht+=span.x2&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Auto pin mail.google.com,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;autocmd PageLoad mail.google.com js if(!getBrowser().mCurrentTab.pinned) getBrowser().pinTab(getBrowser().mCurrentTab);
autocmd PageLoad gmail.com js if(!getBrowser().mCurrentTab.pinned) getBrowser().pinTab(getBrowser().mCurrentTab);
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Auto pin git-annex tab,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;autocmd PageLoad &apos;127\.0\.0\.1:\d+/\?auth=&apos; js if(!getBrowser().mCurrentTab.pinned) getBrowser().pinTab(getBrowser().mCurrentTab);
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Additional hints,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot; Hint Instagram Load More&lt;/span&gt;
&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;autocmd LocationChange instagram.com set ht+=a.button.button-grey.button-large&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
~/.pentadactyl/user.css,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;/* @-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;www.reddit.com&quot;&lt;/span&gt;) { */
/*     .side{ display: none !important; } */
/*     .md { max-width: 100% ! important;} */
/* } */

@-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;10.1.2.50&quot;&lt;/span&gt;), domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;) {
    #jwplayer_wrapper,#media_control{width:100% !important;}
    #jwplayer_wrapper{height:75% !important;}
    #progress_slider{width:99% !important;
                     height: 10px !important;}
    .ui-slider .ui-slider-handle {height: 15px !important;}
}

@-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;youtube.com&quot;&lt;/span&gt;) {
    #confirmBox.yt-alert-default.yt-alert-warn{ display: none !important; }
}

@-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;google.com.tr&quot;&lt;/span&gt;), domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;google.com&quot;&lt;/span&gt;), domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;google.de&quot;&lt;/span&gt;){
    #gbzw,       /* links */
    #gbx3, #gbx4, /* background */
    #fll, #bfl
    {
        display: none !important;
    }

    #gbq, #gbu,  /* controls */
    #gbx1, #gbx2 /* background */
    {
        top: 0 !important;
    }

    /* remove google plus  */
    ol.gbtc { display: none ! important;}
    /* remove safe search button */
    a#abar_button_ss.ab_button { display: none ! important;}
}

@-moz-document url-prefix(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;https://mail.google.com/&quot;&lt;/span&gt;){
    #gbzw,       /* links */
    #gbx3, #gbx4 /* background */
    {
        display: none;
    }

    #gbq, #gbu,  /* controls */
    #gbx1, #gbx2 /* background */
    {
        top: 0 !important;
    }

    /* Bar container */
    #gb {
        height: 72px !important;
    }

    /* Share pop-up content */
    #gbwc.gbmwca {
        top: -29px;
    }

    /* remove google plus shit  */
    ol.gbtc { display: none ! important;}

    /* get rid of copy right */
    div.wIFnie { display: none !important; }

    /* Remove people widget completely */
    .nH.adC {
        display: none ! important;
    }

    .yPPMxf, .nH.adC, .qHcrae, .y3, .y4 {
        width: 0 ! important;
    }

    /* Plain-text Message Body */
    /* Compose Interfaces */
    .editable.LW-avf, .editable, .ii, .Ak{
        font-size: 14px ! important;
        font-family: monospace ! important;
    }

    td.Bu.y3
    {
        display: none !important;
    }
}

@-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;www.facebook.com&quot;&lt;/span&gt;) {
    #rightCol{ display: none !important; }
    #appsNav{ display: none !important; }
    #pagesNav{ display: none !important; }
    .fbChatSidebar,#fbDockChatBuddylistNub{ display: none !important; }
}

@-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;twitter.com&quot;&lt;/span&gt;) {
    div.module.trends{ display: none !important; }
    div.module.site-footer{ display: none !important; }
    div.module.wtf-module.js-wtf-module.has-content{ display: none !important; }
    div.global-nav{ display: none !important; }
    .wrapper.white { background: none !important;}
}

@-moz-document domain(&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;facebook.com&quot;&lt;/span&gt;) {
    /** Set Background color for page **/
    .fbIndex { background-color: #3B5998 !important }

    /** Hide Crap **/
    .fbIndex #globalContainer #dropmenu_container,
    .fbIndex #globalContainer #content,
    .fbIndex #globalContainer #pageFooter { display: none !important }

    /** Center Login Bar **/
    .fbIndex .loggedout_menubar_container {
        position: fixed !important;
        width: 420px !important;
        height: 82px !important;
        min-width: 0 !important;
        top: 50% !important;
        left: 50% !important;
        margin-top: -17px !important;
        margin-left: -210px !important;
        z-index: -1 !important;
    }

    /** Center Login form **/
    .fbIndex .loggedout_menubar { width: auto !important }
    .fbIndex .loggedout_menubar_container .lfloat,
    .fbIndex .loggedout_menubar_container .rfloat { float: none !important }
    .fbIndex .loggedout_menubar_container .lfloat img,
    .fbIndex .loggedout_menubar_container .rfloat #login_form table { display: block !important; margin: 0 auto !important }
    .fbIndex .loggedout_menubar_container .lfloat i { display: block !important; margin: -70px auto 20px !important; }
    .fbIndex .loggedout_menubar_container .sp_69c1xs { display: block !important; }

    /** Hide Homepage Box **/
    #SetAsHomepage_Callout {
        display: none;
    }

    /** Reset bluBar z-index **/
    .fbIndex div#blueBar {
        z-index: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
}

@-moz-document domain(news.ycombinator.com) {
  p { word-break: break-all; }

  #non-existent-id {}

  #csres { display: none; }

  .title {
    font-size: 120% !important;
  }

  .subtext {
    font-size: 90% !important;
  }

  * {
    font-family: Helvetica !important;
    line-height: 1.4 !important;
  }

  body {
    padding: 10px !important;
    background: #F6F6EF;
  }

  body &amp;gt; center &amp;gt; table {
    width: 100% !important;
  }

  body &amp;gt; center &amp;gt; table &amp;gt; tbody &amp;gt; tr:first-child &amp;gt; td {
    font-size: 120%;
    -moz-border-radius: 5px;
    -moz-box-shadow: 0 0 10px rgba(0,0,0,0.5);
  }

  .title a {
    font-family: Museo !important;
  }

  .title a:visited {
    color: #666 !important;
  }

  .comment,
  .comhead {
    font-size: 120% !important;
  }

  .title .comhead {
    font-size: 85% !important;
  }

  .pagetop {
    display: block;
    padding: 6px 0 4px;
    font-size: 110% !important;
  }

  .pagetop a {
    font-family: Helvetica !important;
    color: rgba(0,0,0,0.6) !important;
    font-size: 110% !important;
  }

  img[src=http\:\/\/ycombinator\.com\/images\/y18\.gif] {
    margin: 0 2px 0 5px;
  }
}
&lt;/pre&gt;
&lt;/div&gt;
</description></item><item><title>tmux Configuration</title><link>http://nakkaya.com/2014/01/05/tmux-configuration/</link><pubDate>Sun, 5 Jan 2014 00:00:00 +0200</pubDate><description>&lt;p&gt;
This is a dump of all tmux related configuration and
scripts so I can edit them in one place and tangle from a single
file.
&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/post/tmux.png&quot; alt=&quot;tmux configuration&quot; width=&quot;780&quot;/&gt;&lt;/p&gt;

&lt;p&gt;
Start windows and panes at 1, not 0,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set -g base-index 1
set -g pane-base-index 1
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Replace C-b with \,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;unbind C-b 
set -g prefix &apos;\&apos;
bind-key &apos;\&apos; send-prefix
set-window-option -g xterm-keys on
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Setup key bindings,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;bind-key r command-prompt -p &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;rename window to:&quot;&lt;/span&gt;  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;rename-window &apos;%%&apos;&quot;&lt;/span&gt;
bind t source-file ~/.tmux-over-ssh.conf
bind k confirm kill-window
bind K confirm kill-server

bind tab last-window

# window movement / renumbering like in screen&apos;s :number
bind-key m command-prompt -p &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;move window to:&quot;&lt;/span&gt;  &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;swap-window -t &apos;%%&apos;&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Enable UTF-8,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;setw -g utf8 on
set -g status-utf8 on
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;setw -g window-status-current-format &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;|#I:#W|&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Makes using the scroll wheel automatically switch to copy mode and
scroll back the tmux scrollback buffer.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set -g mouse on
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Status bar,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;set-option -g status-interval 60
set-option -g status-right-length 120
set -g status-right &apos;#(date +&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;%a %b %_d %H:%M&quot;&lt;/span&gt;) | #(hostname)&apos;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Create a new window, swtich to home directory and type tmux-ssh,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;neww -n tmux-ssh
send-keys -t tmux-ssh &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;cd ~/&quot;&lt;/span&gt; C-m
send-keys -t tmux-ssh &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;tmux-ssh &quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Create/attach a dev session. Start tmux create two windows for two
emacs instances for for editing one for dired.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;TERM&lt;/span&gt;=xterm-256color
tmux has-session -t dev 
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; [ $&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;?&lt;/span&gt; != 0 ]
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;
    tmux new-session -s dev -n emacs -d
    tmux send-keys -t dev &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;cd ~/&apos;&lt;/span&gt; C-m 
    tmux send-keys -t dev &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;emacs -main-instance&apos;&lt;/span&gt; C-m
    tmux new-window -n dired -t dev
    tmux send-keys -t dev &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;cd ~/&apos;&lt;/span&gt; C-m 
    tmux send-keys -t dev &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;emacs&apos;&lt;/span&gt; C-m
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
tmux attach -t dev
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Solarized theme,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-fundamental&quot;&gt;# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default

# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright

# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01

# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange

# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange

# clock
set-window-option -g clock-mode-colour colour64 #green
&lt;/pre&gt;
&lt;/div&gt;
</description></item><item><title>SSH as a Hidden Service with Tor</title><link>http://nakkaya.com/2014/01/05/ssh-as-a-hidden-service-with-tor/</link><pubDate>Sun, 5 Jan 2014 00:00:00 +0200</pubDate><description>&lt;p&gt;
Note to self, setup .torrc,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;RunAsDaemon 1

HiddenServiceDir /home/tor/.hidden-ssh/
HiddenServicePort 22 127.0.0.1:22
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Locate tor address,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;cat ~/.hidden-ssh/hostname
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Edit rc.local so tor starts during boot,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;su - tor -c &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/home/tor/Apps/tor/App/tor -f /home/tor/.torrc&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Edit SSH conf so it uses the SOCKS proxy for .onion addresses,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;Host *.onion
   ProxyCommand nc -xlocalhost:9050 -X5 %h %p
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
and add hosts,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;Host machine.onion
   HostName dkflcfnvfkddjfkd.onion
   Port 22
&lt;/pre&gt;
&lt;/div&gt;
</description></item><item><title>Parse S3 Logs with Goaccess</title><link>http://nakkaya.com/2013/11/20/parse-s3-logs-with-goaccess/</link><pubDate>Wed, 20 Nov 2013 00:00:00 +0200</pubDate><description>&lt;p&gt;
Note to self, create ~/.goaccessrc add S3 log format,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;date_format %d/%b/%Y
log_format %^ %^ [%d:%^] %h %^ %^ %^ %^ &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;%^ %r %^&quot;&lt;/span&gt; %s %^ %b %^ %^ %^ &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;%^&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;%u&quot;&lt;/span&gt; %^
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Sync log bucket to local folder,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;s3cmd sync  s3://logs.nakkaya.com/ ./
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Parse yesterdays logs,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;find . -name &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;`date +%Y-%m-%d -d &quot;yesterday&quot;`*&quot;&lt;/span&gt; -exec cat {} &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;\;&lt;/span&gt; | goaccess -a
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Parse all logs,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;find . -exec cat {} &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;\;&lt;/span&gt; | goaccess -a
&lt;/pre&gt;
&lt;/div&gt;
</description></item><item><title>Notes on Synchronization and Backup of $HOME using git, git-annex and mr</title><link>http://nakkaya.com/2013/10/23/notes-on-synchronization-and-backup-of-home-using-git-git-annex-and-mr/</link><pubDate>Wed, 23 Oct 2013 00:00:00 +0300</pubDate><description>&lt;div id=&quot;table-of-contents&quot;&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;
&lt;div id=&quot;text-table-of-contents&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1&quot;&gt;~/annex/&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-1&quot;&gt;~/.mrconfig&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-2&quot;&gt;~/annex/.mrconfig&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-3&quot;&gt;~/.bin/git-anx-drop-unused&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-4&quot;&gt;~/.bin/git-fast-push&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-5&quot;&gt;Mount / Unmount EncFS Volumes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-6&quot;&gt;Webapp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-1-0-7&quot;&gt;Misc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#sec-2&quot;&gt;~/source/&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#sec-2-0-1&quot;&gt;~/source/.mrconfig&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
This is a dump of all git, git-annex and mr related configuration and
scripts so I can edit them in one place. When &lt;a href=&quot;http://orgmode.org/manual/Working-With-Source-Code.html&quot;&gt;tangled&lt;/a&gt;,
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;All mr configs will go into their respective folders.
&lt;/li&gt;
&lt;li&gt;All Bash scripts will go into ~/.bin/ folder.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Repository structure,
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;~/annex/ - git-annex repositories that are synced between
computers.
&lt;/li&gt;
&lt;li&gt;~/source/ - Git repos.
&lt;/li&gt;
&lt;li&gt;/external - Single git-annex repo spread over multiple USB
drives. Working as a Poor Mans Raid.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div id=&quot;outline-container-sec-1&quot; class=&quot;outline-2&quot;&gt;
&lt;h2 id=&quot;sec-1&quot;&gt;~/annex/&lt;/h2&gt;
&lt;div class=&quot;outline-text-2&quot; id=&quot;text-1&quot;&gt;
&lt;p&gt;
Instead of having a single large annex folder synced across
machines, I have split all files into 6 annexes,
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;documents
&lt;/li&gt;
&lt;li&gt;music
&lt;/li&gt;
&lt;li&gt;notes
&lt;/li&gt;
&lt;li&gt;old-code
&lt;/li&gt;
&lt;li&gt;photos
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
This scheme makes git-annex much faster. At first I was reluctant
to go with this, instead of pushing pulling single annex, now I
have to deal with 6. Then I found about &lt;a href=&quot;http://myrepos.branchable.com/&quot;&gt;mr&lt;/a&gt; which lets you run
commands on a collection of repositories, even though there are 6
repos with mr a single command will push pull all of them.
&lt;/p&gt;

&lt;p&gt;
These annexes are shared between 3 computers (one with two full
copy of all repos and two with partial copies.), all behind NAT so
all clients dump data to rsync.net (GPG encrypted with separate keys.)
and sync changes with a repo inside rsync.net.
&lt;/p&gt;

&lt;p&gt;
When ever I make changes to any of the repos, I just run &lt;i&gt;mr push&lt;/i&gt;.
It will iterate repositories with changes (new files/deletes/renames)
and upload changes to and sync with rsync.net. Then when I
switch machines I just do a &lt;i&gt;mr pull&lt;/i&gt; which downloads all changes.
&lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-1&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-1&quot;&gt;~/.mrconfig&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-1&quot;&gt;
&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;include&lt;/span&gt; = cat ~/annex/.mrconfig-annex ~/source/.mrconfig-source
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-2&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-2&quot;&gt;~/annex/.mrconfig&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-2&quot;&gt;
&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;DEFAULT&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;git_sync&lt;/span&gt; = git annex add .;git annex sync --content
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;git_status&lt;/span&gt; = git annex status
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;git_gc&lt;/span&gt; = git repack -ad; git gc

&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;lib&lt;/span&gt; = 
    &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;initAnnex()&lt;/span&gt; {
       git config remote.origin.annex-ignore true
       git annex init &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;`hostname`&quot;&lt;/span&gt;
       git annex untrust here
       git annex enableremote cloud
    }
    &lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;fastFsChck()&lt;/span&gt; {
      git annex fsck --fast --from &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$1&quot;&lt;/span&gt;
    }

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;annex/documents&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/annex-documents.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;documents&apos;&lt;/span&gt;
           cd documents/
           initAnnex
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt; = lazy
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;fsck&lt;/span&gt; = fastFsChck cloud
       fastFsChck storage-box
       fastFsChck rclone_drive

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;annex/notes&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/annex-notes.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;notes&apos;&lt;/span&gt;
           cd notes/
           initAnnex
           git annex direct
           git annex get .
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;fsck&lt;/span&gt; = fastFsChck cloud
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-3&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-3&quot;&gt;~/.bin/git-anx-drop-unused&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-3&quot;&gt;
&lt;p&gt;
Drop all unused files by date,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-hy&quot;&gt;#!/usr/bin/env hy

(import  [sh [grep git perl awk ErrorReturnCode]]
	 [re [split]]
	 [datetime [datetime date]]
	 [sys])

(def remote (if (&amp;gt;= (len sys.argv) 2)
	      (second sys.argv)
	      &quot;here&quot;))

(def drop-age (if (= (len sys.argv) 3)
		(int (nth sys.argv 2))
		180))

(defn unused-files []
  (let [[files (try 
		(-&amp;gt; (.annex git &quot;unused&quot; &quot;--from&quot; remote)
		    (perl &quot;-ne&quot; &quot;print if /^    [0-9]+.*/&quot;)
		    str)
		(catch [e ErrorReturnCode] &quot;&quot;))]
	[unused-files (-&amp;gt;&amp;gt; files 
			   (split &quot;\n&quot;)
			   (map (fn [x] 
				  (-&amp;gt;&amp;gt; (.strip x)
				       (split &quot; +&quot;)
				       (take 2)
				       (map (fn [x] (.strip x))))))
			   (filter (fn [x] 
				     (= (len x) 2)))
			   list)]]
    (print &quot;Unused files: &quot; (len unused-files))
    unused-files))

(defn last-seen [file]
  (let [[key (second file)]]
    (-&amp;gt;&amp;gt; (git &quot;--no-pager&quot; &quot;log&quot; &quot;-1&quot; &quot;-S&quot; key &quot;--pretty=format:%at&quot;)
	 str
	 (split &quot;\n&quot;)
	 (map (fn [x] (.fromtimestamp datetime (float x))))
	 first)))

(defn age [file]
  (let [[delta (- (.today datetime) (last-seen file))]]
    delta.days))

(print &quot;Dropping &quot; remote)

(if (= drop-age 0)
  (for [file (unused-files)]
    (let [[id (first file)]]
      (print &quot;Id &quot; id)
      (if (= remote &quot;here&quot;)
	(.annex git &quot;dropunused&quot; &quot;--force&quot; (str id))
	(.annex git &quot;dropunused&quot; &quot;--force&quot; &quot;--from&quot; remote (str id)))))
  (for [file (unused-files)]
    (let [[id (first file)]
	  [file-age (try 
		     (age file)
		     (catch [e Exception] -1))]]

      (if (&amp;gt;= file-age drop-age)
	(do 
	 (print &quot;Id &quot; id &quot; age &quot; file-age &quot; days...&quot;)
	 (if (= remote &quot;here&quot;)
	   (.annex git &quot;dropunused&quot; &quot;--force&quot; (str id))
	   (.annex git &quot;dropunused&quot; &quot;--force&quot; &quot;--from&quot; remote (str id))))))))
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-4&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-4&quot;&gt;~/.bin/git-fast-push&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-4&quot;&gt;
&lt;p&gt;
Custom push command. For repositories with no changes it simply
returns true, for repositories with changes or new files,
&lt;/p&gt;

&lt;ul class=&quot;org-ul&quot;&gt;
&lt;li&gt;If acting on a regular git repo, pushes changes to origin.
&lt;/li&gt;
&lt;li&gt;If acting on a git annex repo, uploads changes and sync with
rsync.net.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;/bin/bash&lt;/span&gt;

&lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;updateAnnexHost&lt;/span&gt;() {
    &lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;Updating Remote...&apos;&lt;/span&gt;
    &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;ORIGIN&lt;/span&gt;=&lt;span style=&quot;font-weight: bold;&quot;&gt;`git config --get remote.origin.url`&lt;/span&gt;
    &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;HOST&lt;/span&gt;=&lt;span style=&quot;font-weight: bold;&quot;&gt;`echo &quot;$ORIGIN&quot; | grep -oiP &apos;//.*?\/&apos; | cut -d/ -f3`&lt;/span&gt;
    &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;DIR&lt;/span&gt;=&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/${ORIGIN#*//*/}&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$HOST $DIR&quot;&lt;/span&gt;
    ssh $&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;HOST&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;cd $DIR;git annex sync&quot;&lt;/span&gt;
}

&lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;hasNoChanges&lt;/span&gt;(){
    git diff-index --quiet HEAD --
}

&lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;hasNewFiles&lt;/span&gt;(){
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; [ &lt;span style=&quot;font-weight: bold;&quot;&gt;`git ls-files --exclude-standard --others| wc -l`&lt;/span&gt; != 0 ]; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt; 
        true
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;else&lt;/span&gt;
        false
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
}

&lt;span style=&quot;color: #d7af00; font-weight: bold;&quot;&gt;isRepoAhead&lt;/span&gt;(){
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; [ &lt;span style=&quot;font-weight: bold;&quot;&gt;`git log origin/$(git branch | grep &apos;*&apos; | cut -d&apos; &apos; -f2)..HEAD | wc -l`&lt;/span&gt; != 0 ]; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt; 
        true
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;else&lt;/span&gt;
        false
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
}

&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;handle direct annex repo&lt;/span&gt;
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;font-weight: bold;&quot;&gt;`git config --get annex.direct`&lt;/span&gt;; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;
    &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;oldHead&lt;/span&gt;=&lt;span style=&quot;font-weight: bold;&quot;&gt;`git rev-parse HEAD`&lt;/span&gt;
    git annex add .
    git annex sync
    &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;newHead&lt;/span&gt;=&lt;span style=&quot;font-weight: bold;&quot;&gt;`git rev-parse HEAD`&lt;/span&gt;
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; [ &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$oldHead&quot;&lt;/span&gt; != &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$newHead&quot;&lt;/span&gt; ]; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; git config remote.depot.annex-uuid; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;
            git annex copy --to depot --not --in depot
            git annex sync
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;else&lt;/span&gt;
            git annex copy --to origin --not --in origin
            updateAnnexHost
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;exit&lt;/span&gt;
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;

&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; ! hasNoChanges || hasNewFiles || isRepoAhead; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt; 
&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;handle indirect annex repo&lt;/span&gt;
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; [ -d &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;.git/annex/&apos;&lt;/span&gt; ]; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;    
        git annex add .
        git annex sync
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; git config remote.depot.annex-uuid; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;
            git annex copy --to depot --not --in depot
            git annex sync
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;else&lt;/span&gt;
            git annex copy --to origin --not --in origin
            updateAnnexHost
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
        &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;exit&lt;/span&gt;
&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;handle plain git repo        &lt;/span&gt;
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;else&lt;/span&gt;
        git push origin master
    &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;else&lt;/span&gt;
    true
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-5&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-5&quot;&gt;Mount / Unmount EncFS Volumes&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-5&quot;&gt;
&lt;p&gt;
Scripts for mounting and unmounting EncFS Volumes.
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;/bin/bash&lt;/span&gt;

&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;CUR_DIR&lt;/span&gt;=&lt;span style=&quot;font-weight: bold;&quot;&gt;`pwd`&lt;/span&gt;
&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;cd&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$1&quot;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;DIR&lt;/span&gt;=$(&lt;span style=&quot;font-weight: bold;&quot;&gt;basename&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$1&quot;&lt;/span&gt;)
mkdir &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/Volumes/$DIR&quot;&lt;/span&gt;
git annex get .
git annex unlock &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;.&quot;&lt;/span&gt;
encfs &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$CUR_DIR/${1}&quot;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/Volumes/$DIR&quot;&lt;/span&gt;
&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;cd&lt;/span&gt; $&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;CUR_DIR&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: #008787; font-weight: bold; font-style: italic;&quot;&gt;/bin/bash&lt;/span&gt;

&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;CUR_DIR&lt;/span&gt;=&lt;span style=&quot;font-weight: bold;&quot;&gt;`pwd`&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;DIR&lt;/span&gt;=$(&lt;span style=&quot;font-weight: bold;&quot;&gt;basename&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$1&quot;&lt;/span&gt;)
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;if&lt;/span&gt; umount &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/Volumes/$DIR&quot;&lt;/span&gt;; &lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;then&lt;/span&gt;
    rm -rf &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;/Volumes/$DIR&quot;&lt;/span&gt;
&lt;span style=&quot;color: #ff5f00; font-weight: bold;&quot;&gt;fi&lt;/span&gt;
&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;cd&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;$1&quot;&lt;/span&gt;
git annex add .
git annex add .encfs6.xml
git commit -m &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;Update&apos;&lt;/span&gt;
&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;cd&lt;/span&gt; $&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;CUR_DIR&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-6&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-6&quot;&gt;Webapp&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-6&quot;&gt;
&lt;p&gt;
Create autostart file relative paths don&apos;t work so tangle one file for
each OS (Linux,OS X) then mv one to correct location,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;/home/nakkaya/annex/notes
/home/nakkaya/annex/documents
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;/Users/nakkaya/annex/notes
/Users/nakkaya/annex/documents
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Start asistant and webapp,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;git annex assistant --autostart &amp;amp;&amp;amp; nohup git annex webapp
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-1-0-7&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-1-0-7&quot;&gt;Misc&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-1-0-7&quot;&gt;
&lt;p&gt;
Setup encrypted annex directory remote,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;git annex initremote mobile &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;type&lt;/span&gt;=directory &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;directory&lt;/span&gt;=/path/to/annex/repo/ &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;encryption&lt;/span&gt;=hybrid &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;keyid&lt;/span&gt;=ID &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;embedcreds&lt;/span&gt;=yes
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Setup encrypted annex S3 remote in EU (Ireland) (eu-west-1),
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;AWS_ACCESS_KEY_ID&lt;/span&gt;=&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;KID&quot;&lt;/span&gt;
&lt;span style=&quot;color: #afd700; font-weight: bold;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;AWS_SECRET_ACCESS_KEY&lt;/span&gt;=&lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&quot;SKEY&quot;&lt;/span&gt;
git annex initremote cloud &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;type&lt;/span&gt;=S3 &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;encryption&lt;/span&gt;=hybrid &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;keyid&lt;/span&gt;=ID &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;embedcreds&lt;/span&gt;=yes &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;datacenter&lt;/span&gt;=eu-west-1 &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;chunk&lt;/span&gt;=250MiB
git setup-bitbucket
git config remote.origin.annex-ignore true
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Setup encrypted annex S3 remote in Google Cloud Storage,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;git annex initremote cloud &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;type&lt;/span&gt;=S3 &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;encryption&lt;/span&gt;=hybrid &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;keyid&lt;/span&gt;=ID &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;embedcreds&lt;/span&gt;=yes &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;host&lt;/span&gt;=storage.googleapis.com &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;port&lt;/span&gt;=80 &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;chunk&lt;/span&gt;=250MiB
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Setup encrypted annex rsync remote,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;git annex initremote depot &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;type&lt;/span&gt;=rsync &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;encryption&lt;/span&gt;=hybrid &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;rsyncurl&lt;/span&gt;=rsync:annex/repo/ &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;keyid&lt;/span&gt;=ID
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;
Setup encrypted annex rclone gdrive remote,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-sh&quot;&gt;git annex initremote rclone_drive &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;type&lt;/span&gt;=external &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;externaltype&lt;/span&gt;=rclone &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;target&lt;/span&gt;=drive_robotics &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;prefix&lt;/span&gt;=git-annex &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;chunk&lt;/span&gt;=100MiB &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;encryption&lt;/span&gt;=shared &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;mac&lt;/span&gt;=HMACSHA512 &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;rclone_layout&lt;/span&gt;=lower
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;outline-container-sec-2&quot; class=&quot;outline-2&quot;&gt;
&lt;h2 id=&quot;sec-2&quot;&gt;~/source/&lt;/h2&gt;
&lt;div class=&quot;outline-text-2&quot; id=&quot;text-2&quot;&gt;
&lt;/div&gt;&lt;div id=&quot;outline-container-sec-2-0-1&quot; class=&quot;outline-4&quot;&gt;
&lt;h4 id=&quot;sec-2-0-1&quot;&gt;~/source/.mrconfig&lt;/h4&gt;
&lt;div class=&quot;outline-text-4&quot; id=&quot;text-2-0-1&quot;&gt;
&lt;p&gt;
Git Repos,
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-conf&quot;&gt;[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;DEFAULT&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;git_pull&lt;/span&gt; = git pull origin master
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;git_push&lt;/span&gt; = git fast-push
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;git_status&lt;/span&gt; = git status --short
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;sync&lt;/span&gt; = git pull &amp;amp;&amp;amp; git push

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/latte&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/latte.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;latte&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/alter-ego&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/alter-ego.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;alter-ego&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/ardrone&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/ardrone.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;ardrone&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/clodiuno&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/clodiuno.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;clodiuno&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/easy-dns&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/easy-dns.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;easy-dns&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/emacs&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/emacs.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;emacs&apos;&lt;/span&gt;
           cd emacs
           git submodule init
           git submodule update

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/inbox-feed&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/inbox-feed.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;inbox-feed&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/nakkaya.com&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/nakkaya.com.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;nakkaya.com&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/net-eval&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/net-eval.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;net-eval&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/neu-islanders&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/neu-islanders.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;neu-islanders&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/static&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/static.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;static&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/vector-2d&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;git@github.com:nakkaya/vector-2d.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;vector-2d&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/doganilic.com&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/doganilic.com.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;doganilic.com&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/ansible-docker-build&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/ansible-docker-build.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;ansible-docker-build&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/ansible-storage&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/ansible-storage.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;ansible-storage&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/ansible-base&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/ansible-base.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;ansible-base&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/ansible-backup&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/ansible-backup.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;ansible-backup&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/control-toolbox&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/control-toolbox.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;control-toolbox&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/solarcar-tracker&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/solarcar-tracker.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;solarcar-tracker&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/solarcar-turn-indicator&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/solarcar-turn-indicator.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;solarcar-turn-indicator&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy

[&lt;span style=&quot;font-weight: bold; text-decoration: underline;&quot;&gt;source/ferret&lt;/span&gt;]
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;checkout&lt;/span&gt; = git clone &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;https://git.nakkaya.com/git/nakkaya/ferret.git&apos;&lt;/span&gt; &lt;span style=&quot;color: #afafff; font-style: italic;&quot;&gt;&apos;ferret&apos;&lt;/span&gt;
&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;skip&lt;/span&gt;=lazy
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description></item><item><title>Git SSH Verbose</title><link>http://nakkaya.com/2013/08/26/git-ssh-debugging/</link><pubDate>Mon, 26 Aug 2013 00:00:00 +0300</pubDate><description>&lt;p&gt;Note to self, debugging git ssh interaction,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;GIT_TRACE=2 git &amp;lt;command&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>