This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns djtango.write-date | |
"Serialising/deserialsing mixed Clojure/JodaTime data.") | |
;; I made use of the advice at http://proofbyexample.com/print-and-read-in-clojure.html | |
;; in writing this file. | |
;; Make it possible to print joda DateTime instances in re-readable form, for persistence. | |
(defmethod print-dup org.joda.time.DateTime | |
[dt out] | |
(.write out (str "#=" `(org.joda.time.DateTime. ~(.getMillis dt) ~org.joda.time.DateTimeZone/UTC)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table saved_dependencies_ddl | |
( | |
deps_id serial primary key, | |
deps_view_schema varchar(255), | |
deps_view_name varchar(255), | |
dependency_name varchar(255), | |
deps_ddl_to_run text | |
); | |
create or replace function save_and_drop_dependencies(p_view_schema varchar, p_view_name varchar) returns void as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const genLongString = (url) => { | |
// doesn't actually use the url | |
let chars = []; | |
const bigNum = Math.floor(Math.random() * 1000000 + 1000000); | |
for (let i = 0; i <= bigNum; i += 1) { chars.push('x'); } | |
const longString = chars.join(''); | |
return longString; | |
}; | |
const getLargeExternalData = (url, retn) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns prime | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::prime-number | |
(fn [x] | |
(cond (<= x 1) false | |
(= 2 x) true | |
:else | |
(let [naturals (drop 2 (map inc (range))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns chess-gm.pgn | |
"See https://opensource.apple.com/source/Chess/Chess-110.0.6/Documentation/PGN-Standard.txt | |
and https://en.wikipedia.org/wiki/Portable_Game_Notation for more details on specification" | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::column-index (set "abcdefgh")) | |
(s/def ::row-index (set "12345678")) | |
(s/def ::piece-name (set "QKWBNRP")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns chess-gm.pgn-test | |
(:require [clojure.test :refer :all] | |
[orchestra.spec.test :as stest] | |
[clojure.spec.alpha :as s] | |
[chess-gm.pgn :as sut])) | |
(deftest basic-SAN | |
(testing "a simple vertical move should be valid" | |
(let [white-king-pawn-two-steps (seq "e4")] | |
(is (s/valid? ::sut/basic-move white-king-pawn-two-steps)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ARBITRARY COLUMN SELECTION | |
create table a (x int, y int, z int); | |
create table b (x int, y int, z int); | |
create table c (x int, y int, z int); | |
insert into a values (1, 2, 3); | |
insert into b values (1, null, 30); | |
insert into c values (1, 200, null); | |
select * from a; | |
/* | |
x | y | z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SOURCE: https://www.citusdata.com/blog/2017/10/20/monitoring-your-bloat-in-postgres/ | |
I take no credit this was a straight copy paste | |
*/ | |
WITH constants AS ( | |
-- define some constants for sizes of things | |
-- for reference down the query and easy maintenance | |
SELECT current_setting('block_size')::numeric AS bs, 23 AS hdr, 8 AS ma | |
), | |
no_stats AS ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns fn-name | |
(:require [clojure.main])) | |
;; https://stackoverflow.com/questions/22116257/how-to-get-functions-name-as-string-in-clojure | |
(defn fn-name | |
[f] | |
(as-> (str f) $ | |
(clojure.main/demunge $) | |
(or (re-find #"(.+)--\d+@" $) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user.repl) | |
(defn all-ns-fns | |
"Returns a map of the public intern mappings for the namespace." | |
[ns] | |
(let [ns (the-ns ns)] | |
(->> (ns-map ns) | |
(filter (comp (fn [^clojure.lang.Var v] (and (instance? clojure.lang.Var v) | |
(= ns (.ns v)))) | |
val)) |
OlderNewer