Skip to content

Instantly share code, notes, and snippets.

View johanmynhardt's full-sized avatar
♻️
Upgrade to MySQL 8 would be fun they said...

Johan Mynhardt johanmynhardt

♻️
Upgrade to MySQL 8 would be fun they said...
View GitHub Profile
@borkdude
borkdude / router.clj
Last active April 9, 2024 15:03
Small ring router using core.mach in babashka
(require '[clojure.core.match :refer [match]]
'[clojure.string :as str]
'[hiccup2.core :refer [html]]
'[org.httpkit.server :as server])
(defn router [req]
(let [paths (vec (rest (str/split (:uri req) #"/")))]
(match [(:request-method req) paths]
[:get ["users" id]] {:body (str (html [:div id]))}
:else {:body (str (html [:html "Welcome!"]))})))
@pesterhazy
pesterhazy / promises-cljs.md
Last active October 10, 2023 18:09
Promises in ClojureScript

Chaining promises

Chaining promises in ClojureScript is best done using the thread-first macro, ->. Here's an example of using the fetch API:

(-> (js/fetch "/data")
    (.then (fn [r]
             (when-not (.-ok r)
               (throw (js/Error. "Could not fetch /data")))
             (.json r)))
@sogaiu
sogaiu / sha1-string-for-babashka.clj
Last active January 21, 2023 15:03
cross-platform sha1 for babashka
;; adapted borkdude's implementation
(defn sha1
[s]
(let [hashed (.digest (.getInstance java.security.MessageDigest "SHA-1")
(.getBytes s))
sw (java.io.StringWriter.)]
(binding [*out* sw]
(doseq [byte hashed]
(print (format "%02x" byte)))) ; prefer lower case :)
(str sw)))
@pierreis
pierreis / template.yaml
Last active September 9, 2023 20:37
AWS SAM Deploy Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Test API
Parameters:
Stage:
Type: String
AllowedValues:
- dev
- sat
@shortjared
shortjared / list.txt
Last active May 20, 2024 07:26
List of AWS Service Principals
a4b.amazonaws.com
access-analyzer.amazonaws.com
account.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
airflow-env.amazonaws.com
airflow.amazonaws.com
alexa-appkit.amazon.com
alexa-connectedhome.amazon.com
amazonmq.amazonaws.com
@beldaz
beldaz / PDFTableStripper.java
Created October 14, 2017 22:09
Class to extract tabular PDF text using PDFBox
/*
* Copyright 2017 Beldaz (https://github.com/beldaz)
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@xfsnowind
xfsnowind / debounce.clj
Created October 23, 2015 22:08
The clojure version with library core.async of debounce function
(defn debounce-chan
"Taken from https://github.com/swannodette/async-tests
A little different with original one, write to channel after the interval
instead of doing it in the beginning"
([source msecs]
(debounce-chan (chan) source msecs))
([c source msecs]
(go-loop [state ::init
last-one nil
cs [source]]
@tracker1
tracker1 / 01-directory-structure.md
Last active May 4, 2024 19:55
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@mowat27
mowat27 / init.el
Created December 30, 2013 20:06
Emacs config for clojure + cider + paredit + auto-complete
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(defvar my-packages '(clojure-mode
cider
paredit
auto-complete
highlight-parentheses