Skip to content

Instantly share code, notes, and snippets.

View pataprogramming's full-sized avatar

Paul L. Snyder pataprogramming

  • Philadelphia, PA
View GitHub Profile
@pataprogramming
pataprogramming / symmetrical.clj
Last active September 27, 2017 12:15
PhillyDev Slack #daily_programmer 2017-09-26 - Symmetrical Strings
(let [symmetrical-chars "!\"'+*-.:=AHIMOTUVWXY^_ovwx| "
symmetrical-pairs "()<>[]{}qpbd/\\"
lookup-table (->> symmetrical-pairs
((juxt seq reverse))
(apply concat)
(partition 2)
(map vec)
(into {})
(merge (zipmap symmetrical-chars
symmetrical-chars)))]
@pataprogramming
pataprogramming / ordering.clj
Last active September 5, 2017 19:29
PhillyDev Slack #daily_programmer 2017-09-05 - Testing word alphabetization
(ns daily.ordering
;; Include [org.clojure/core.match "0.3.0-alpha5"] in project deps
(:require [clojure.core.match :refer [match]]
[clojure.string :as string])
(:import java.text.Normalizer))
(defn ordered?
([coll]
(ordered? compare coll))
([^java.util.Comparator cmp coll]
@pataprogramming
pataprogramming / rpn.clj
Last active August 30, 2017 18:18
PhillyDev Slack #daily_programmer 2017-08-30 - Reverse Polish Notation
(ns daily.rpn
;; Needs [instaparse "1.4.7"] in project deps
(:require [instaparse.core :as insta]
[instaparse.failure :as failure]
[clojure.string :as string]
[clojure.edn :as edn]))
(def whitespace
(insta/parser
"whitespace = #'\\s*'"))
@pataprogramming
pataprogramming / alliterations.clj
Created August 25, 2017 16:30
Find alliterations - PhillyDev #daily_programmer 2017-08-25
(ns daily.alliteration
(:require [clojure.string :as string]))
(def stopwords #{"i" "a" "about" "an" "and" "are" "as"
"at" "be" "by" "com" "for" "from" "how"
"in" "is" "it" "of" "on" "or" "that"
"the" "this" "to" "was" "what" "when"
"where" "who" "will" "with"})
(defn alliterations
@pataprogramming
pataprogramming / similar_frequencies.clj
Last active August 17, 2017 19:27
Similar words by frequency - phillydev #daily_programmer
(ns daily.similar-frequencies
(:require [clojure.string :as string]
[clojure.java.io :as io]))
(def word-file "resources/google-10000-english-no-swears.txt")
;; A vector containing all words in the dataset
(def words
(with-open [rdr (io/reader word-file)]
(->> rdr
(ns luhn.core)
(defn sum-digits [n]
(->> n
str
(mapv (comp #(- % 48) int))
(reduce +)))
(defn luhn-checksum [n]
(->> n
boot.user> (start-repl)
<< started Weasel server on ws://127.0.0.1:35242 >>
<< waiting for client to connect ... java.lang.NullPointerException
at clojure.java.io$make_parents.doInvoke(io.clj:433)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at adzerk.boot_cljs_repl$make_repl_connect_file.invoke(boot_cljs_repl.clj:43)
at adzerk.boot_cljs_repl$write_repl_connect_file.invoke(boot_cljs_repl.clj:59)
at adzerk.boot_cljs_repl$repl_env$fn__505.invoke(boot_cljs_repl.clj:104)
at weasel.repl.websocket$websocket_setup_env.invoke(websocket.clj:72)
at weasel.repl.websocket.WebsocketEnv._setup(websocket.clj:27)
@pataprogramming
pataprogramming / NettySampleStartServer.java
Last active July 3, 2018 03:53
Quick-and-dirty fix to get the example zuul-netty server working
/**
* Copyright 2015 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pataprogramming
pataprogramming / gist:2ff48dac497e59c21698
Last active August 29, 2015 14:22
Eldritch Tips and Strategies
Eldritch can seem ugly and hard, but it's fun game once you push through the learning curve.
For a game with so many right angles, it feels surprisingly non-Euclidean! I was pretty
underwhelmed th first two times I tried the game out, but the third time it really clicked...
it's now a definitefavorite.
Here are a few suggestions to make it up that initial ramp. Some of these might be considered
spoilery, but if they get you to actually play the game, who's going to kick?
(1) _Don't_ loot bodies until you're better at the game. Looted enemies respawn; by clearing them
out, you buy yourself breathing space.