First of all I want to thank borkdude and all the other people around Babashka for building SCI, Scittle and many other things that so many people can use and learn from! You guys rock!
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
#!/bin/env bb | |
(require '[babashka.fs :as fs]) | |
(require '[babashka.curl :as curl]) | |
(defn get-day-component [] | |
(let [components (fs/components (fs/cwd))] | |
(-> (filter #(str/starts-with? % "day") components) | |
first))) | |
(defn get-day-number [day-name] |
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 friends | |
(:require [cheshire.core :as json] | |
[clojure.set :as set])) | |
;; The way this works is you download your own Facebook data as JSON | |
;; (Settings -> Privacy -> Your Facebook information -> Download Your Information) | |
;; All that you need is Connections -> Friends and followers selected. | |
;; It will be ready in a few minutes and will be less than 1MB. | |
;; Place 2 files spanning a certain period of time in this folder, | |
;; and pass the 2 filenames to `friends/unfriended`. |
Create an account at https://openweathermap.org and get an API key.
Note that it can take up to a couple of hours for the key to become active.
Add an environment variable OPEN_WEATHER_API_KEY
with the value of the key.
run the script:
./weather.clj Toronto,CA
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
#!/usr/bin/env bb | |
(ns bookstats | |
(:require [babashka.pods :as pods] | |
[clojure.pprint :as pprint])) | |
(pods/load-pod 'org.babashka/go-sqlite3 "0.1.0") | |
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9") | |
(require '[pod.babashka.go-sqlite3 :as sqlite] | |
'[pod.retrogradeorbit.hickory.select :as s] | |
'[pod.retrogradeorbit.bootleg.utils :as utils]) | |
(import [java.net URLEncoder] |
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
#!/usr/bin/env bb | |
(require '[clojure.repl]) | |
(def namespaces ; well, readily available ones | |
['clojure.core | |
'clojure.edn | |
'clojure.instant | |
'clojure.java.browse | |
'clojure.java.io |
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
#!/usr/local/bin/bb | |
(import '[java.io ByteArrayOutputStream]) | |
(import '[java.util Base64]) ; | |
(import '[java.util.zip Inflater]) ; | |
(defn uncompress [source-bytes] | |
(let [inflater (doto (Inflater.) | |
(.setInput source-bytes)) | |
outputStream (new ByteArrayOutputStream (count source-bytes)) |
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
#!/usr/bin/env bb | |
;;; | |
; A babashka script to update all clojure -Ttools to the latest versions | |
; author: Tyler Wardhaugh | |
;;; | |
(ns update-clj-tools | |
(:require [babashka.fs :as fs] | |
[babashka.process :refer [process]])) |
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
# command line to deploy the project | |
gcloud functions deploy hello --runtime nodejs14 --trigger-http |
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
#!/bin/env bb | |
(let [cgb #(->> % (cons "http://169.254.169.254/latest") (str/join "/") curl/get :body) | |
try-json #(try (json/parse-string %) (catch Exception _ %)) | |
dir? #(str/ends-with? (last %) "/") | |
paths (fn [p] (->> (cgb p) | |
str/split-lines | |
(map #(->> (str/split % #"=") first (conj p))))) | |
trimlslash #(str/replace % #"/$" "")] | |
(json/generate-stream |
NewerOlder