Brad Lucas

Programming, Clojure and other interests

Update Last Git Commit Comment

July 10, 2017

You just committed to your Git repo and realized you have a typo in your commit message. Here is how you can edit the last commit's comment.

$ git commit --amend

Continue reading →

Git Reset Hard

July 9, 2017

Here is how you can backup one commit in Git. The situation is where you've just committed to a branch and want to backup and throw this recent commit away.

Get the SHA of the previous commit then git reset hard to it.

For example,

$ git reset --hard 2acdd9bcdbd71a4ee919c90c0e964778346c54d1

Continue reading →

4clojure

July 8, 2017

4Clojure is a site which offers 156 exercises to learn Clojure by solving some sort of programming challenge. The exercises are grouped from Elementary, Easy, Medium to Hard. For each you are presented with an explanation and a set of test cases which when run with your entered function must pass.

I decided to mention 4Clojure today because I've gotten back to it and am trying to finish the last few problems. I can say at this point the Hard problems are in fact Hard.

I highly recommend trying to get through as many of the 4Clojure exercises as you can if you are an aspiring Clojurist.


Continue reading →

Insert Org Mode Line

July 7, 2017

If you use org-mode a lot you'll eventually look to a way to quickly setup a new file with your favorite settings. Here I use the following to quickly add the org mode line and a few favored settings.

(defconst *org-modeline*  "# -*- mode:org; -*-")
(defconst *org-mode-settings* "
#+STARTUP: showall
#+STARTUP: hidestars
#+OPTIONS: toc:nil
#+OPTIONS: skip:t
#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"./org.css\" />
#+OPTIONS: ^:nil

* HEADING
")

(defun insert-org-modeline ()
  (interactive)
  (save-excursion
    (beginning-of-buffer)
    (insert *org-modeline*)
    (insert *org-mode-settings*)
    (newline)
    (newline)
    )
  (end-of-buffer)
  (save-buffer))

Feel free to add or modify to make the above your own.


Continue reading →

Function update-work

July 6, 2017

I've had a long time practice of putting all my projects in their own repositories and keeping them in a work directory under my home directory. I even start repos for personal projects as well as various of interest items. Smaller lists and plans go into more general repos and everything is organized and backed up in a source control system.

With this I've ended up creating various functions to help manage things. For example, the following update-work bash function goes through my work directory and runs the git status command in each directory which is a git repo.

function update-work {
    pushd "$HOME/work"
    for f in `find . -maxdepth 2 -name .git`
    do
        echo "--------------------------------------------------"
        echo "REPO: $f"
        pushd "${f%/.git}"
        git status
        popd
        echo "--------------------------------------------------"
    done
    popd
}

Continue reading →