Skip to content

Instantly share code, notes, and snippets.

View w33tmaricich's full-sized avatar

Alexander Maricich w33tmaricich

  • LightFeather.io
  • Bowie, MD
View GitHub Profile
@w33tmaricich
w33tmaricich / str-int.clj
Last active March 21, 2016 14:09
clj: convert a string to an int
(defn str->int
"Converts a string to an integer"
[string]
(Integer. (re-find #"\d+" string)))
@w33tmaricich
w33tmaricich / contains-keys.clj
Last active March 21, 2016 14:09
clj: checks if all keys are contained within a map
(defn contains-keys?
"True if all keys are contained within the map"
[maps keywords]
(let [map-list maps
all-keys keywords]
(if (empty? all-keys)
true
(if (contains? map-list (first all-keys))
(recur map-list (rest all-keys))
false))))
@w33tmaricich
w33tmaricich / key-with-value.clj
Last active March 21, 2016 14:08
clj: retrieves the first key that has the associated value
(defn key-with-value¬
"Retrieves the first key that has the associated value"
[list-items value]
(first (filter (comp #{value} list-items) (keys list-items))))
@w33tmaricich
w33tmaricich / arraylist-map.clj
Last active March 21, 2016 14:08
clj: converts a java arraylist to a map
(defn arraylist->map¬
"Converts an arraylist java object to a list"
[al]
(loop [finished-list {}
counter 0]
(if (>= counter (.size al))
finished-list
(recur (into finished-list (.get al counter))
(inc counter)))))
@w33tmaricich
w33tmaricich / stringmap-keymap.clj
Last active March 21, 2016 14:08
clj: converts a map with strings as keys into a map with keywords
(defn stringmap->keymap
"Converts a map with strings as keys into a map with keywords"
[m]
(into {}
(for [[k v] m]
[(keyword k) v])))
@w33tmaricich
w33tmaricich / gist:4894e786a721765ab2eb
Last active March 21, 2016 14:06 — forked from pitch-gist/gist:2999707
html: simple maintenance page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@w33tmaricich
w33tmaricich / Vim Shortcuts.md
Last active March 21, 2016 14:06
ref: vim shortcuts

#VIM Shortcuts

##How to Exit

Command Description
:q[uit] Quit Vim. This fails when changes have been made.
:q[uit]! Quit without writing.
:cq[uit] Quit always, without writing.
:wq Write the current file and exit.
@w33tmaricich
w33tmaricich / md5.clj
Last active March 21, 2016 14:00
clj: calculate md5 hash of a given string
(import 'java.security.MessageDigest
'java.math.BigInteger)
(defn md5 [s]
(let [algorithm (MessageDigest/getInstance "MD5")
size (* 2 (.getDigestLength algorithm))
raw (.digest algorithm (.getBytes s))
sig (.toString (BigInteger. 1 raw) 16)
padding (apply str (repeat (- size (count sig)) "0"))]
(str padding sig)))
@w33tmaricich
w33tmaricich / footer.css
Last active May 23, 2018 19:25
css: footer
@w33tmaricich
w33tmaricich / build-colors.css
Created May 23, 2018 19:39
css: build colors
.passing {
background-color: #6EFF75;
}
.warning {
background-color: #E8C359;
}
.failed {
background-color: #FF4D4D;
}