Skip to content

Instantly share code, notes, and snippets.

Keith Irwin zentrope

View GitHub Profile
@zentrope
zentrope / webviewInject.swift
Last active Dec 23, 2018
Set dark/light for web content
View webviewInject.swift
private func setMode(_ isDark: Bool) {
let mode = isDark ? "add" : "remove"
let script = "document.body.classList.\(mode)(\"dark\");"
webView.evaluateJavaScript(script) { result, error in
if let err = error {
os_log("%{public}s", log: logger, type: .error, "js error: \(err).")
}
}
}
@zentrope
zentrope / buildemacs.md
Last active Jun 10, 2018
Build emacs on macOS
View buildemacs.md

Build emacs on macOS

Build from scratch because most of the packages you use have updated to the nearly-completed next version, so why not pull that?

An alternative is to use home brew HEAD, but this is more fun.

Xcode

Probably should have Xcode installed, but at least try:

@zentrope
zentrope / number-format.cljs
Created Dec 22, 2016
A comma for thousands separator in Clojurescript using goog closure libs.
View number-format.cljs
(ns client.ui
(:require
[goog.i18n.NumberFormat.Format])
(:import
(goog.i18n NumberFormat)
(goog.i18n.NumberFormat Format)))
(def nff
(NumberFormat. Format/DECIMAL))
@zentrope
zentrope / utils.clj
Last active Apr 22, 2016
Find out the jar you're running in: Clojure
View utils.clj
(ns engine.lib.utils
(:require
[clojure.string :as s]
[clojure.java.io :as io]))
;;-----------------------------------------------------------------------------
(def ^:private path-sep
(System/getProperty "path.separator"))
View pingweb.go
package main
import (
"encoding/json"
"io"
"log"
"net/http"
"os"
"os/signal"
)
@zentrope
zentrope / core.clj
Created Jan 21, 2016
core.logic scratch
View core.clj
(ns ls.core
(:gen-class)
(:refer-clojure :exclude [==])
(:require [clojure.core.logic :refer :all]
[clojure.core.logic.pldb :refer :all]))
;;-----------------------------------------------------------------------------
;; Interesting Links
;;
;; http://michaelrbernste.in/2013/05/12/featurec-and-maps.html
@zentrope
zentrope / clojars.txt
Created Dec 19, 2015
Clojars access forbidden, yet jars are there?
View clojars.txt
> lein deploy clojars
Created /Users/keith/Desktop/quiescent/target/quiescent-0.2.2.jar
Wrote /Users/keith/Desktop/quiescent/pom.xml
You need a passphrase to unlock the secret key for
user: "Keith Irwin <keith@zentrope.com>"
2048-bit RSA key, ID B0FDA7A9, created 2015-12-19
You need a passphrase to unlock the secret key for
@zentrope
zentrope / get-bars.clj
Last active Dec 12, 2015
Stringing out XML blobs
View get-bars.clj
#!/usr/bin/env clj
(defn get-bars
[xml]
(loop [xml xml
bars []]
(if (clojure.string/blank? xml)
bars
(let [[_ bar xml2 :as r] (clojure.string/split xml #"<bar>|</bar>" 3)]
(if (nil? bar)
@zentrope
zentrope / Vagrantfile
Created Oct 23, 2015
Vagrant file for FreeBSD on OS X
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.guest = :freebsd
config.vm.box = "freebsd/FreeBSD-10.2-RELEASE"
@zentrope
zentrope / cipher.sh
Last active Oct 21, 2015
nginx, mont and shell for running and monitoring a java process on a unix (FreeBSD) system
View cipher.sh
#!/bin/sh
app="cipher"
version="0.9.2"
java="/usr/local/bin/java"
daemon="/usr/sbin/daemon"
app_home="/home/vagrant/apps/${app}"
jar="${app}-${version}-standalone.jar"
You can’t perform that action at this time.