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
0% cat bb.edn | |
{:deps {org.flatland/ordered {:mvn/version "1.15.10"} | |
org.clojure/data.json {:mvn/version "2.4.0"}}} | |
0% cat ordered.clj | |
(ns ordered | |
(:require [flatland.ordered.map :as ordered-map] | |
[clojure.data.json :as data-json]) | |
(:import (java.io PushbackReader))) | |
;; Taken from https://github.com/clojure/data.json/blob/master/src/main/clojure/clojure/data/json.clj#L295-L317 |
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
import boto3 | |
import zlib | |
def decompress_object(bucket, key, out_file): | |
s3 = boto3.client("s3") | |
body = s3.get_object(Bucket=bucket, Key=key)['Body'] | |
with open(out_file, "ab") as out: | |
decompressor = zlib.decompressobj(zlib.MAX_WBITS|32) | |
for chunk in body.iter_chunks(): | |
out.write(decompressor.decompress(chunk)) |
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
;; Task to run nrepl server and send some init code into it, when the nrepl server starts | |
{:tasks {dev {:requires ([bencode.core :as b] | |
[babashka.wait :as wait] | |
[babashka.process :as p :refer [process]]) | |
:task (do | |
(let [;; Put the command to start nrepl server here, along any other aliases | |
proc (process "clj -M:dev/nrepl:dev/hashp" {:inherit true})] | |
(wait/wait-for-path ".nrepl-port") | |
(try | |
(let [port (Integer/parseInt (slurp ".nrepl-port"))] |
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
;; dependency: [software.amazon.awssdk/s3 "2.16.7"] | |
(ns some-ns | |
(:import (software.amazon.awssdk.services.s3.presigner S3Presigner) | |
(software.amazon.awssdk.services.s3.model GetObjectRequest) | |
(software.amazon.awssdk.services.s3.presigner.model GetObjectPresignRequest) | |
(software.amazon.awssdk.auth.credentials AwsCredentialsProvider) | |
(software.amazon.awssdk.auth.credentials AwsBasicCredentials) | |
(software.amazon.awssdk.regions Region) | |
(java.net URI) |
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
locals { | |
monitoring_emails = [ | |
"user1@example.com", | |
"user2@example.com" | |
] | |
} | |
resource "aws_sns_topic" "monitoring" { | |
name = "monitoring" | |
} |
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
(re-find #"\d+"(.getName (java.lang.management.ManagementFactory/getRuntimeMXBean))) |
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
(spit "talk-samples.html" (format "<html><head><style>%s</style></head><body>%s</body></html" | |
(g/generate-css (-> glow.colorschemes/solarized-dark | |
(dissoc :background) | |
(assoc :symbol "#0b2a34") | |
(assoc :string "#1f7a73"))) | |
(g/highlight-html (slurp "talk-samples.clj")))) |
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 myapp.test | |
(:require [cljs.test :as test :refer-macros [deftest is] :refer [report]])) | |
(enable-console-print!) | |
(defmethod report [:karma :begin-test-ns] [m] | |
(println "\nTesting with Karma" (name (:ns m)))) | |
(defmethod report [:karma :summary] [m] | |
(println "All done")) |
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
;; Solves math excercise: | |
;; 9 = 5 [ ] 3 [ ] 4 [ ] 5, | |
;; , where [ ] should be one of operations: +, - | |
;; Uses just random brute force :) | |
user> (def ops #{+ -}) | |
user> (loop [cnt 0 | |
op1 (first ops) | |
op2 (first ops) | |
op3 (first ops)] |
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
def make_rules(hosts, ports, proto): | |
return [{"proto": proto, | |
"from_port": port, | |
"to_port": port, | |
"cidr_ip": host} for host in hosts for port in map(int, ports.split(","))] | |
class FilterModule(object): | |
def filters(self): | |
return {'make_rules': make_rules} |
NewerOlder