Skip to content

Instantly share code, notes, and snippets.

View xpe's full-sized avatar

David James xpe

View GitHub Profile
@xpe
xpe / deploy
Last active August 29, 2015 13:57
I use this script to build a WAR file (from a Clojure Pedestal app)
#!/usr/bin/env bash
set -e # exit on failure
[ -n "$DEBUG" ] && set -x # turn on command echo
# --------------
# Step 4: Deploy
# --------------
# Consult the documentation of your web container to find out how to deploy an
@xpe
xpe / project.clj
Created March 29, 2014 16:29
Example project.clj for Clojure web app using Pedestal and Datomic
(defproject myapp-service "0.0.2-SNAPSHOT"
:description "A web app"
:url "http://myapp.domain.com"
:dependencies
[[org.clojure/clojure "1.6.0"]
[org.clojure/tools.reader "0.8.3"]
[com.datomic/datomic-pro "0.9.4699"
:exclusions [org.slf4j/slf4j-api org.slf4j/slf4j-nop commons-codec]]
[io.pedestal/pedestal.service "0.2.2"
:exclusions [com.fasterxml.jackson.core/jackson-core]]
@xpe
xpe / start-riak
Created October 24, 2014 03:42
Adjusts ulimit, as needed, and starts Riak on Mac OS X. Tested on Yosemite.
#!/usr/bin/env bash
MAXFILES=$(launchctl limit maxfiles | sed -e 's/[[:space:]]+/ /g' | xargs)
if [ "$MAXFILES" != "maxfiles 65536 65536" ]; then
set -x
sudo launchctl limit maxfiles 65536 65536
fi
set -x
ulimit -n 65536
riak start
@xpe
xpe / iterate-until-stable-alternatives.clj
Last active August 29, 2015 14:13
Clojure: iterate-until-stable
;; gfredericks on IRC
(defn repeat-until-stable
[f x]
(->> (iterate f x)
(partition 2 1)
(filter (fn [[x1 x2]] (= x1 x2)))
ffirst))
;; amalloy on IRC
(defn repeat-until-stable
(ns grime-dice
(:require
[clojure.pprint :refer [print-table]]))
(def dice
{:red [4 4 4 4 4 9]
:yellow [3 3 3 3 8 8]
:blue [2 2 2 7 7 7]
:magenta [1 1 6 6 6 6]
:olive [0 5 5 5 5 5]})

Keybase proof

I hereby claim:

  • I am xpe on github.
  • I am xpe (https://keybase.io/xpe) on keybase.
  • I have a public key whose fingerprint is 20A0 61E7 8CA2 CB1C F61E 1E6D 476A 4D08 42F3 F12A

To claim this, I am signing this object:

pub struct PairSet<T> {
a: T,
b: T,
}
impl<T> PairSet<T> where T: Eq {
/// If the values are different, creates a `PairSet` with them.
pub fn new(x: T, y: T) -> Option<PairSet<T>> {
if x == y {
None
@xpe
xpe / nvidia-persistenced-service-permission-error.md
Created March 19, 2018 17:50
NVIDIA persistenced permission error

I noticed this in my syslog:

Mar 19 08:23:23 ralph systemd[1]: Configuration file /lib/systemd/system/nvidia-persistenced.service is marked executable. Please remove executable permission bits. Proceeding anyway.

I corrected the permissions with:

sudo chmod -x /lib/systemd/system/nvidia-persistenced.service
@xpe
xpe / default-terminal-in-ubuntu-gnome.md
Last active March 19, 2018 18:08
Changing the default terminal in Gnome (Ubuntu 17.10)

I'm running Ubuntu 17.10.

After I installed Terminator, it became the default terminal in Gnome.

I would like to switch back to the default terminal.

First, I checked:

gsettings get org.gnome.desktop.default-applications.terminal exec
@xpe
xpe / rust_wrapper_type_pros_and_cons.md
Last active July 11, 2018 19:11
Pros and Cons of Wrapper Types in Rust

Pros and Cons of Wrapper Types in Rust

I've written a mathematically-oriented and computatioally-intensive application in Rust. While the mathematical theory is not necessarily difficult, keeping the various quantities clear required some care.

For this reason, I'm refactoring it to clear it up. I've created some custom structs to wrap various mathematical types.

For example, I created a type to write PDFs (probability density functions)