Skip to content

Instantly share code, notes, and snippets.

View stathissideris's full-sized avatar

Stathis Sideris stathissideris

  • London
View GitHub Profile

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.

select * from saved_searches where user_id = 16556 AND created_on > now()::date + interval '1h' order by created_on desc;
@stathissideris
stathissideris / cthulu.clj
Created January 23, 2015 11:33
minimized lovecraft cultist text generator by TEttinger
(let[a #(apply str(flatten %))r repeatedly p partition N rand-nth n #(a(N(concat(repeat %"")(mapcat p[1 2 3]%&))))v #(n 0"aioeu""iaai")w(fn[](let[b(n 6"!.""""...")s[(n0"STKNYPKLG""GlThShNyFt""ZvrCth")(r(N[1 2])#(do[(v)(n 9(map str"'-"(r 2 v)))(n 0(concat"lpstnkgx"[(N["h""gl""gr""nd"])(v)])"rlthggghtsltrkkhshng")]))]][b(if(seq b)[" "s][(n 3",")" "(.(as)toLowerCase)])]))](re-find #"[A-Z].+"(a[(r 500 w)"."])))
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
(defn mapify
"Return a seq of maps like {:name \"Edward Cullen\" :glitter-index 10}"
[rows]
(let [headers (map (comp conversions headers->keywords) (first rows))]
(for [row (rest rows)] (zipmap headers row))))
--select get the total count along with the results in one query using window functions
--see: http://www.postgresql.org/docs/9.1/static/tutorial-window.html
select email, count(*) over () as total_count from users limit 10;
COPY postcode_master_lookup
FROM '/tmp/MasterLookup.txt'
CSV
DELIMITER E'\t'
QUOTE '"'
ENCODING 'WIN1252'
HEADER;
@stathissideris
stathissideris / tree-seq-extra.clj
Last active July 2, 2023 11:33
Like Clojure's tree-seq, but with depth info for each node or the full path (recursive - blow up the stack for deep trees)
(defn tree-seq-depth
"Returns a lazy sequence of vectors of the nodes in a tree and their
depth as [node depth], via a depth-first walk. branch? must be a fn
of one arg that returns true if passed a node that can have
children (but may not). children must be a fn of one arg that
returns a sequence of the children. Will only be called on nodes for
which branch? returns true. Root is the root node of the tree."
[branch? children root]
(let [walk (fn walk [depth node]
(lazy-seq
To access a private var (e.g. for testing), use the @#'some.ns/var form
@stathissideris
stathissideris / pos-info.clj
Created July 25, 2014 14:50
Get file, column and row info at compile time in Clojure files
(defmacro pos-info []
(let [m (meta &form)]
`{:file ~*file*
:column ~(:column m)
:line ~(:line m )}))