Skip to content

Instantly share code, notes, and snippets.

View vermiculus's full-sized avatar
🙃
I may be slow to respond.

Sean Allred vermiculus

🙃
I may be slow to respond.
View GitHub Profile
@vermiculus
vermiculus / squash-no-error-handling.sh
Last active September 25, 2022 12:45
Squash a Git repository to just include specific snapshots
#!/bin/bash
# usage: ./squash-no-error-handling.sh <new-branch-name>
#
# Expects a list of refs on standard input. One commit will be made
# per ref. The last line provided will be the tip of the new branch.
#
# This version is provided to illustrate the concept without any
# error-handling. It is unforgiving against any mistakes -- I strongly
# recommend you use the 'squash.sh' script instead!
@vermiculus
vermiculus / ReversePriorityQueue.java
Created November 5, 2012 02:22
Reverse Priority Queue (Example 4 for Alan)
import java.util.Comparator;
import java.util.PriorityQueue;
// Write a program that takes in 10 integers via command-line and prints them out in reverse natural order using a PriorityQueue. (this should use a Comparator)
public class ReversePriorityQueue
{
public class Reverse implements Comparator<Integer>
{
public int compare(Integer arg0, Integer arg1)
{
;; a packagelet for figuring out where melpa is. will move point to commit in magit-log buffers.
(defun melpautil-where-is-melpa (package &optional force-refresh)
(interactive (list (intern (let-alist (magithub-repo) .name))
current-prefix-arg))
(let ((commit (melpautil-commit-for-package package force-refresh)))
(unless commit
(error "Commit not found"))
(setq commit (magit-rev-parse "--short" commit))
(when (derived-mode-p 'magit-log-mode)
(goto-char 0)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; base-uri 'self'; connect-src 'self'; form-action 'self'; img-src data:; script-src 'self'; style-src 'unsafe-inline'">
<meta content="origin" name="referrer">
<title>Server Error &middot; GitHub</title>
<style type="text/css" media="screen">
body {
background-color: #f1f1f1;
;;; Neat convenience function for working with Elisp's EIEIO objects
(defmacro oref* (object &rest slots)
"Like `oref', but each slot in SLOTS is applied in sequence.
For example,
\(oref* obj :inner :property)
is equivalent to
(defun *magit-delete-trailing-whitespace-from-file ()
"Removes whitespace from the current item."
(interactive)
(save-excursion
(magit-visit-item)
(delete-trailing-whitespace)
(save-buffer)
(kill-buffer))
(magit-refresh))
;; Show a backtrace whenever an error is encountered
(defun user-error-to-backtrace (&rest r)
(with-current-buffer-window
(get-buffer-create "*issue*")
#'display-buffer-pop-up-window nil
(insert (kill-new (with-output-to-string (backtrace))))))
(mapc (lambda (e) (advice-remove e #'user-error-to-backtrace))
'(user-error error))
(mapc (lambda (e) (advice-add e :before #'user-error-to-backtrace))
Use CIDER's nREPL handler
2 files changed, 5 insertions(+), 2 deletions(-)
project.clj | 3 ++-
src/clj/myapp/core.clj | 4 +++-
modified project.clj
@@ -55,7 +55,8 @@
[ring/ring-mock "0.3.0"]
[ring/ring-devel "1.4.0"]
pdf:
pdflatex -recorder word.tex
pdflatex word.tex
(defn get-topic-children [topics topic-id]
(map first (filter #(= topic-id (:parent (second %))) topics)))
(defn get-routes [topics topic-id & [slug-so-far]]
(let [children (get-topic-children topics topic-id)
newslug (if (= topic-id :root) ""
(str slug-so-far "/" (:slug (get topics topic-id))))]
(if children
(into (if (= topic-id :root) {} {topic-id newslug})
(map #(get-routes topics % newslug) children))