a9e85b8e5f66

More
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 19 Dec 2018 13:55:03 -0500
parents deda525820e3
children 384770359545
branches/tags (none)
files bin/addcontact bin/frameworkpython bin/lec bin/lecdown bin/pass-work lisp/Makefile lisp/_skeleton.lisp lisp/clhs.lisp lisp/compile lisp/compile-parenscript.ros lisp/lispindent.lisp

Changes

--- a/bin/addcontact	Wed Dec 19 10:18:23 2018 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#!/bin/bash
-osascript -e "tell application \"Address Book\"" \
--e "  set firstParam to \"$1\"" \
--e "  set secondParam to \"$2\"" \
--e "  set thirdParam to \"$3\"" \
--e "  set fourthParam to \"$4\"" \
--e "  set contactEmailLabel to \"\"" \
--e "  set spaceOffset to (offset of \" \" in firstParam)" \
--e "  if (spaceOffset is not equal to 0) then" \
--e "    set AppleScript's text item delimiters to \" \"" \
--e "    set firstName to (text item 1 of firstParam)" \
--e "    set lastName to (text item 2 of firstParam)" \
--e "    set firstEmailParam to secondParam" \
--e "    set secondEmailParam to thirdParam" \
--e "  else" \
--e "    set firstName to firstParam" \
--e "    set lastName to secondParam" \
--e "    set firstEmailParam to thirdParam" \
--e "    set secondEmailParam to fourthParam" \
--e "  end if" \
--e "  set atOffset to (offset of \"@\" in firstEmailParam)" \
--e "  if (atOffset is not equal to 0) then" \
--e "    set contactEmail to firstEmailParam" \
--e "  else" \
--e "    set contactEmailLabel to firstEmailParam" \
--e "    set contactEmail to secondEmailParam" \
--e "  end if" \
--e "  set bracketOffset to (offset of \"<\" in contactEmail)" \
--e "  if (bracketOffset is not equal to 0) then" \
--e "    set contactEmail to text 2 thru -2 of contactEmail" \
--e "  end if" \
--e "  if (contactEmailLabel is equal to \"\") then" \
--e "    set contactEmailLabel to \"Home\"" \
--e "  end if" \
--e "  set newPerson to (make new person with properties {first name:firstName, last name:lastName})" \
--e "  make new email at end of emails of newPerson with properties {label:contactEmailLabel, value:contactEmail}" \
--e "  save" \
--e "  if (newPerson exists) then" \
--e "    if (firstName exists) then" \
--e "      set returnString to (\"First name: \" & firstName)" \
--e "    end if" \
--e "    if (lastName exists) then" \
--e "      set returnString to (returnString & \"; Last name: \" & lastName)" \
--e "    end if" \
--e "    if (contactEmailLabel exists) then" \
--e "      set returnString to (returnString & \"; Email label: \" & contactEmailLabel)" \
--e "    end if" \
--e "    if (contactEmail exists) then" \
--e "      set returnString to (returnString & \"; Email address: \" & contactEmail)" \
--e "    end if" \
--e "    return returnString" \
--e "  end if" \
--e "end tell"
-
--- a/bin/frameworkpython	Wed Dec 19 10:18:23 2018 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-# what real Python executable to use
-PYVER=3.4
-PATHTOPYTHON=/usr/local/bin/
-PYTHON=${PATHTOPYTHON}python${PYVER}
-
-# find the root of the virtualenv, it should be the parent of the dir this script is in
-# ENV=`$PYTHON -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`
-
-# now run Python with the virtualenv set as Python's HOME
-export PYTHONHOME=$VIRTUAL_ENV
-exec env PYTHONPATH= $PYTHON -m IPython "$@"
--- a/bin/lec	Wed Dec 19 10:18:23 2018 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-
-echo $* | peat "lecdown $* > index.html"
-
--- a/bin/lecdown	Wed Dec 19 10:18:23 2018 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-echo "<!DOCTYPE html><html><head>"
-
-cat <<EOF
-<meta charset="utf-8" />
-<style media="screen" type="text/css">
-
-body {
-    margin: 50px auto 300px;
-    width: 600px;
-    font: 24px/1.4 "Palatino Linotype";
-    color: #222;
-}
-
-h1, h2, h3, h4, h5, h6 {
-    font-family: "Gill Sans";
-}
-
-code {
-    font: 20px Menlo;
-}
-
-p code {
-    border: 1px solid #ccc;
-    background: #fdfdfd;
-    padding: 1px 5px;
-}
-
-pre {
-    border: 1px solid #ddd;
-    background: #fdfdfd;
-    padding: 10px 10px;
-}
-
-a, a:visited {
-    color: #6A1D18;
-    text-decoration: none;
-}
-
-</style>
-EOF
-
-
-cat <<EOF
-    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-EOF
-
-cat <<EOF
-<script>
-MathJax.Hub.Config({
-  tex2jax: {
-    inlineMath: [[',,',',,']],
-    displayMath: [['!!!','!!!']],
-    processEscapes: true
-  },
-  TeX: {
-    equationNumbers: {autoNumber: "AMS"}
-  }
-});
-
-</script>
-EOF
-
-cat <<EOF
-</head><body>
-<div style="height: 0px !important; display: none !important; margin: 0px !important;">
-
-!!!
-\\newcommand{\\qed}{\\square}
-!!!
-
-!!!
-\\newcommand{\\abs}[1]{\\left|#1\\right|}
-!!!
-
-!!!
-\\newcommand{\\R}{\\mathbb{R}}
-!!!
-
-!!!
-\\newcommand{\\limas}[3]{\\lim\\limits_{#1 \\to #2}{#3}}}
-!!!
-
-!!!
-\\newcommand{\\limx}[2]{\\lim\\limits_{x \\to #1}{#2}}
-!!!
-
-!!!
-\\newcommand{\\deriv}[2]{\\frac{d}{d#1}\\left(#2\\right)}
-!!!
-
-</div>
-EOF
-
-
-cat $* | sed -Ee 's_\\_\\\\_g' | pandoc --from markdown --to html
-
-echo "</body></html>"
-
--- a/bin/pass-work	Wed Dec 19 10:18:23 2018 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -eo pipefail
-
-PASSWORD_STORE_DIR=$HOME/.password-store-work pass "$@"
--- a/lisp/Makefile	Wed Dec 19 10:18:23 2018 -0500
+++ b/lisp/Makefile	Wed Dec 19 13:55:03 2018 -0500
@@ -2,10 +2,10 @@
 
 all: binaries/clhs binaries/lispindent
 
-binaries/clhs: clhs.lisp
-	sbcl --eval '(load "clhs.lisp")' --eval "(build)" --eval "(exit)"
+binaries/clhs: clhs.lisp compile
+	./compile clhs.lisp
 	mv clhs binaries/clhs
 
-binaries/lispindent: lispindent.lisp
-	sbcl --no-userinit --eval '(load "lispindent.lisp")' --eval "(build)" --eval "(exit)"
+binaries/lispindent: lispindent.lisp compile
+	./compile lispindent.lisp --no-userinit
 	mv lispindent binaries/lispindent
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/_skeleton.lisp	Wed Dec 19 13:55:03 2018 -0500
@@ -0,0 +1,33 @@
+(ql:quickload '(:adopt))
+
+;;;; Config -------------------------------------------------------------------
+(defparameter *default-name* "World")
+
+
+;;;; Functionality ------------------------------------------------------------
+(defun run (name)
+  (format t "Hello, ~A~%" name))
+
+
+;;;; CLI ----------------------------------------------------------------------
+(adopt:define-interface *ui* "NAME"
+  "Say Hello."
+  ((help) "display help and exit"
+   :long "help"
+   :short #\h
+   :reduce (constantly t))
+  ((name) (format nil "say hello to NAME (default ~A)" *default-name*)
+   :long "name"
+   :short #\n
+   :parameter "NAME"
+   :initial-value *default-name*
+   :reduce #'adopt:newest))
+
+(defun toplevel ()
+  (multiple-value-bind (arguments options) (adopt:parse-options *ui*)
+    (when (gethash 'help options)
+      (adopt:print-usage *ui*)
+      (adopt:exit 0))
+    (unless (null arguments)
+      (cerror "Ignore them" "Unrecognized command-line arguments: ~S" arguments))
+    (run (gethash 'name options))))
--- a/lisp/clhs.lisp	Wed Dec 19 10:18:23 2018 -0500
+++ b/lisp/clhs.lisp	Wed Dec 19 13:55:03 2018 -0500
@@ -137,10 +137,3 @@
             (format *error-output* "Symbol not found: ~A~%" target)
             (adopt:exit 1)))))))
 
-
-;;;; Build --------------------------------------------------------------------
-(defun build ()
-  (sb-ext:save-lisp-and-die "clhs"
-                            :executable t
-                            :toplevel 'toplevel
-                            :save-runtime-options t))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/compile	Wed Dec 19 13:55:03 2018 -0500
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+LISP=$1
+BINARY=$(basename "$1" .lisp)
+shift
+
+sbcl --load "$LISP" --eval "(sb-ext:save-lisp-and-die \"$BINARY\" :executable t :save-runtime-options t :toplevel 'toplevel)" "$@"
--- a/lisp/lispindent.lisp	Wed Dec 19 10:18:23 2018 -0500
+++ b/lisp/lispindent.lisp	Wed Dec 19 13:55:03 2018 -0500
@@ -253,12 +253,7 @@
               (incf i))))))))
 
 
-(defun main ()
+(defun toplevel ()
   (source-config-files)
   (indent-lines)
   t)
-
-(defun build ()
-  (sb-ext:save-lisp-and-die "lispindent"
-                            :toplevel 'main
-                            :executable t))