This file contains hidden or 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
(defn sort-natural [names] | |
(sort-by | |
(fn [name] | |
(mapv (fn [s] | |
(if (every? #(Character/isDigit %) s) | |
(Long/parseLong s) | |
s)) | |
(map second (re-seq #"(\d+|[^\d]+)" name)))) | |
names)) | |
;; (sort-natural ["mun dokkari 13.doc" "mun dokkari 2.doc"]) |
This file contains hidden or 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 day20 | |
(:require [clojure.java.io :as io])) | |
(def input (-> "day20.txt" io/reader line-seq)) | |
(def enhance-alg (vec (first input))) | |
(def initial-img | |
(into #{} | |
(mapcat identity) | |
(map-indexed |
This file contains hidden or 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
testArray := #(199 200 208 210 200 207 240 269 260 263). | |
"day1 part 1" | |
part1 := [ :input | | |
| len prev incr | | |
incr := 0. | |
prev := input first. | |
len := input size. | |
2 to: len do: [ :i | | |
(prev < (input at: i)) ifTrue: [ incr := (incr + 1) ]. |
This file contains hidden or 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
% clj -Sdeps "{:deps {juxt/crux-core {:mvn/version \"21.06-1.17.1-beta\"}}}" | |
Clojure 1.10.1 | |
;; Require API and create noe | |
user=> (require '[crux.api :as crux]) | |
nil | |
user=> (def crux (crux/start-node {})) ; start in-memory node | |
#'user/crux | |
;; Insert and query some data |
This file contains hidden or 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 day2 (policy text, password text); | |
insert into day2 (policy,password) | |
values ('1-3 a','abcde'), | |
('1-3 b','cdefg'), | |
('2-9 c','ccccccccc'); | |
CREATE OR REPLACE FUNCTION count_substring_matches(string TEXT, substr TEXT) RETURNS INTEGER AS $$ | |
DECLARE | |
pos INTEGER; | |
c INTEGER; |
This file contains hidden or 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
Otetaan lista numeroita, jotka kuvaavat seinien korkeutta. | |
Jos kuva kaadetaan täyteen vettä, kuinka paljon jää seinien väliin. | |
esim. numerot: [2 5 1 2 3 4 7 3 6] | |
9 | | |
8 | | |
7 | # | |
6 | # # | |
5 | # # # |
This file contains hidden or 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
Write a short program that returns a sequence of numbers from 1 to 100. | |
- For each multiple of 3, return "Fizz" instead of the number. | |
- For each multiple of 5, return "Buzz" instead of the number. | |
- For numbers which are multiples of both 3 and 5, return "FizzBuzz" instead of the number. |
This file contains hidden or 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
#!/usr/bin/env planck | |
(require '[planck.shell :refer [sh]]) | |
(require '[clojure.string :as str]) | |
(require '[planck.core :as core]) | |
(defn json-out [shell-result] | |
(-> shell-result | |
:out js/JSON.parse (js->clj :keywordize-keys true))) |
This file contains hidden or 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
(defun deadgrep-todo-fixme-buffers () | |
(let ((buf (get-buffer-create "*deadgrep-todo-fixme-buffers*"))) | |
(switch-to-buffer buf) | |
(setq deadgrep--search-type 'regexp) | |
(list buf))) | |
(defun deadgrep-todo-fixme () | |
(interactive) | |
(advice-add 'deadgrep--buffers :override #'deadgrep-todo-fixme-buffers) | |
(deadgrep "(TODO)|(FIXME)") |
This file contains hidden or 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 aws.ec2 | |
"AUTOGENERATED clojure.spec definitions" | |
(:require [clojure.spec.alpha])) | |
(clojure.spec.alpha/def | |
:aws.ec2/launch-template | |
(clojure.spec.alpha/keys | |
:req | |
[] | |
:opt |