Skip to content

Instantly share code, notes, and snippets.

Verifying myself: My Bitcoin username is +aan. https://onename.io/aan

Keybase proof

I hereby claim:

  • I am adamneilson on github.
  • I am aan (https://keybase.io/aan) on keybase.
  • I have a public key whose fingerprint is CB72 5E77 83B4 D681 6B27 C536 04F9 51C5 E8B4 CF95

To claim this, I am signing this object:

@adamneilson
adamneilson / non-componentized-schema-alter.clj
Created May 16, 2015 16:32
De-componentizes the attributes that are not refs but are components.
;; assume conn to be your database connection
(let [dbval (d/db conn)
;; dump the whole schema
schema (->> (d/q '[:find ?ident
:in $ ?p
:where
[:db.part/db :db.install/attribute ?attr]
[?attr :db/ident ?ident]]
λ: (time (+ 2 2))
"Elapsed time: 0.02675 msecs"
4
@adamneilson
adamneilson / schema-dump.clj
Last active November 4, 2015 18:00
This dumps the Datomic schema from the user partition
;; This dumps the Datomic schema from the user partition
(let [dbval (d/db conn)]
(->> (d/q '[:find ?ident
:in $ ?p
:where
[:db.part/db :db.install/attribute ?attr]
[?attr :db/ident ?ident]]
dbval :db.part/user)
(map (fn [attr] [(d/entity dbval (first attr))]))
(map (fn [attr]
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″ />
<style>
/* ———–Smartphone View———– */
@media only screen and (max-width : 800px) {
/* All smartphone rules go inside here */
}
/* ———–Tablet View———– */
@media only screen and (max-width : 1180px) and (min-width : 801px) {
@adamneilson
adamneilson / gist:5029974
Created February 25, 2013 14:04
Swap variables values without the use of a third trivial interview question.
// set the initial values
$a = 100;
$b = 200;
// swap them!
$a = $a + $b; // $a == 300
$b = $a - $b; // $b == 100
$a = $a - $b; // $a == 200
// done!
@adamneilson
adamneilson / mentions_and_tags.clj
Last active December 17, 2015 22:39
Sample code to scan a body of text for @mentions and #tags
;=============================
; a sample body of text
;=============================
(def sample "A mention: @bob and another: \uFF20charlie but not me@home.com and #my_tag should be caught as should #another. Tests passed? #blimey!")
;=============================
; valid at chars are @ and \uFF20
;=============================
(def mention-pattern #"(^|\s)[@\uFF20](\w+)")
(def tag-pattern #"(^|\s)#(\w+)")
@adamneilson
adamneilson / tumblr_gist_iphone_fix.css
Last active December 18, 2015 00:09
Gists don't seem to display correctly on an iPhone when embedded in a Tumblr post. After a bit of digging I've cobbled together the following CSS which seems to fix the issue.
/** corrections for displaying gists in iOS **/
.gist {
font-family: Consolas,"Liberation Mono",Courier,monospace;
font-size: 12px !important;
line-height:20px !important;
}
.gist .line,
.gist .line-number {
font-family: Consolas,"Liberation Mono",Courier,monospace;
font-size: 12px !important;
(let [conn (langohr.core/connect)]
(comment do-stuff))