Skip to content

Instantly share code, notes, and snippets.

View andrerocker's full-sized avatar
🤓
Clojure / SRE

Andre Souza andrerocker

🤓
Clojure / SRE
View GitHub Profile
@andrerocker
andrerocker / clojure-check-jpg-using-cats.clj
Last active January 13, 2022 20:36
clojure: check if a file is a valid jpg file
;; Using javax.imageio and funcool/cats
;; it's leaking fds, take care!
(defn valid-jpg-image? [image-url]
(let [image-input (-> image-url io/input-stream ImageIO/createImageInputStream)
encoders (-> (ImageIO/getImageReadersByFormatName "jpg") iterator-seq)
image-result (map #(either/try-either (doto % (.setInput image-input) (.read 0))) encoders)]
(->> image-result either/rights not-empty boolean)))
@andrerocker
andrerocker / 1.js
Last active January 27, 2023 19:34
react + google-maps: @googlemaps/react-wrapper (Yes It's really need at least two components)
import { Wrapper } from "@googlemaps/react-wrapper";
const ParentComponentThatWillReceiveGoogleMap = () => {
return <Wrapper apiKey={"42-l337-lol-bbq"}>
<MyGoogleMapComponent/>
</Wrapper>
}