Skip to content

Instantly share code, notes, and snippets.

View gleenn's full-sized avatar
💭
Yup

Glenn Jahnke gleenn

💭
Yup
  • San Diego, California
View GitHub Profile
@gleenn
gleenn / gist:dce3d35235e7d3e589f3ba6c44c4d338
Created September 7, 2023 17:35
the complete init.lua that goes in .hammerspoon to replace shiftit which is not deprecated
mods = { 'ctrl', 'alt', 'cmd' }
units = {
bottom = { x = 0.0, y = 0.5, w = 1.0, h = 0.5 },
left = { x = 0.0, y = 0.0, w = 0.5, h = 1.0 },
right = { x = 0.5, y = 0.0, w = 0.5, h = 1.0 },
top = { x = 0.0, y = 0.0, w = 1.0, h = 0.5 },
}
animationDuration = 0
@gleenn
gleenn / README.md
Created November 2, 2022 20:34 — forked from JCGrant/README.md
Code from "Typing the technical interview" by Kyle "Aphyr" Kingsbury - https://aphyr.com/posts/342-typing-the-technical-interview

Typing the technical interview

Originally written by Kyle "Aphyr" Kingsbury

Definitely check out the awesome blog post where this code originated. It's well worth the read!

To run:

$ ghci Solution.hs

*Main> :type solution (nil :: N6)

@gleenn
gleenn / sigmoid-prime.clj
Created September 27, 2017 07:21
In Progress finding the value for sigmoid'(x) = 1
; This doesn't work yet ;)
(defn sigmoid [x] (/ 1 (- 1 (Math/exp (- x)))))
(defn sigmoid' [x] (let [sigmoidx (sigmoid x)] (* sigmoidx (- 1 sigmoidx))))
(defn bs [f ^double val ^double delta]
(loop [bottom -100.0 top 100.0 countdown 1000]
(let [middle ^double (+ bottom (/ (- top bottom) 2))
f-mid ^double (f middle)]
@gleenn
gleenn / gist:a8a604ebfa807bcd2a8c3341b3573657
Created March 24, 2017 20:31
add Git SHA to uberjar for Leiningen which can be read at runtime
; Add this to your :profile section in your project.clj:
:uberjar {:aot [spark.core]
:injections [(require '[clojure.java.shell :as shell])
(spit "resources/version.txt"
(clojure.string/trimr
(:out
(shell/sh "git" "rev-parse" "HEAD"))))]}
; You can read the file during runtime like this:

Keybase proof

I hereby claim:

  • I am gleenn on github.
  • I am gleenn (https://keybase.io/gleenn) on keybase.
  • I have a public key ASCGy4nI-MJILxWED0w9VNR_pwNyb2ZZIHhpteGZ-yAAAwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am gleenn on github.
  • I am gleenn (https://keybase.io/gleenn) on keybase.
  • I have a public key ASCGy4nI-MJILxWED0w9VNR_pwNyb2ZZIHhpteGZ-yAAAwo

To claim this, I am signing this object:

@gleenn
gleenn / Doing upsert and adding primary key and fixing sequence on Postgres table.txt
Created February 8, 2016 00:25
Doing upsert and adding primary key and fixing sequence on Postgres table
create table foo(id int, text text);
create unique index foo_id_pkey on foo(id);
create sequence foo_id_seq;
delete from foo where id is null;
alter table foo add primary key using index foo_id_pkey;
alter table foo alter id set default nextval('foo_id_seq');
;; to hack around potentially already used sequence values
select nextval('foo_id_seq');
update foo set id = id - <num skipped ids> where id >= <value of id after gap>;
@gleenn
gleenn / gist:3753975
Created September 20, 2012 04:26 — forked from swannodette/gist:3217582
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))