Skip to content

Instantly share code, notes, and snippets.

View noahlz's full-sized avatar
🕵️‍♂️
Secret Stuff for SEI Novus. I might take 1 - 3 days to respond.

Noah Zucker noahlz

🕵️‍♂️
Secret Stuff for SEI Novus. I might take 1 - 3 days to respond.
View GitHub Profile
@noahlz
noahlz / scala_impatient_gotchas.md
Last active January 13, 2018 12:22
Notes while working through "Scala for the Impatient"

Free excerpt from TypeSafe (pdf): Scala for the Impatient

Class Setters

I discovered the special syntax for a field setter:

class Person {
  private var privateAge = 0 // Make private and rename
  def age = privateAge
 def age_ = (newValue: Int) {
@mgodave
mgodave / javadoc.py
Last active December 16, 2015 08:39
Serve javadocs from maven cache
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from zipfile import ZipFile
from string import join
import os
import re
def getMavenCoordinates(elements):
return dict(zip(('group', 'artifact', 'version'), elements))
def getMavenArtifactName(coordinates):
@avescodes
avescodes / Editing Clojure with Emacs
Last active July 5, 2022 13:32
Get started editing Clojure in Emacs with this basic config.
Check out README.md to get started editing Clojure with Emacs.
@wjlroe
wjlroe / gist:3839414
Created October 5, 2012 11:56
Utility function for getting types of Java methods from Clojure (for debugging)
(defn method-spy
"Print out reflection info about a method."
[classname methodname]
(let [c (Class/forName classname)
all-methods (.getDeclaredMethods c)
matching-methods (filter #(= methodname (.getName %)) all-methods)
pr-col (fn [name info] (println (format "%24s: %s" name info)))]
(doseq [m matching-methods]
(println (.toGenericString m))
(pr-col "ReturnType" (.getReturnType m))
@stuarthalloway
stuarthalloway / gist:2645453
Created May 9, 2012 15:22
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@noahlz
noahlz / map-invert-preserve-dups.clj
Created December 10, 2011 02:11
Implementation of map-invert that preserves duplicates by cons entries into a sequence.
;; See: http://codereview.stackexchange.com/q/6682/9032
(defn map-invert-preserve-dups [m]
(apply merge-with into
(for [[k v] m]
{v [k]})))
(->> "http://www.weeklyscript.com/Pulp%20Fiction.txt"
(slurp)
(re-seq #"\w{5,}")
(frequencies)
@noahlz
noahlz / any-pair-make-sum.clj
Created December 4, 2011 04:47
(Clojure version) Given an array of integers, determine if any two given elements sum to a given target.
(defn any-pair-make-sum? [arr target]
(let [m (frequencies arr)]
(loop [f (first arr)
x (- target f)
r (rest arr)]
(let [entry (find m x)
only-needs-one-count (not (= x f))]
(if (and entry (or only-needs-one-count (> 1 (val entry))))
true
(if (empty? r)
@noahlz
noahlz / fix-clj-dev-unit-tests.clj
Created November 14, 2011 00:21
Running fix-clj unit tests in the repl without using lein test - see http://nakkaya.com/2009/11/18/unit-testing-in-clojure/
; SLIME
user>
user> (load-file "c:/projects/github/fix-clj/src/fix_clj/core.clj")
#'fix-clj.core/next-value-and-rest
user> (load-file "c:/projects/github/fix-clj/test/fix_clj/test_core.clj")
nil
user> (use ['fix-clj.core 'fix-clj.test_core] :reload-all :verbose)
; Evaluation aborted.
user> (use '[fix-clj.core fix-clj.test_core] :reload-all :verbose)
; Evaluation aborted.
@jasonrudolph
jasonrudolph / about.md
Last active January 6, 2024 07:40
Programming Achievements: How to Level Up as a Developer