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
sudo docker run -it clojure:latest bash |
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
export default class KVStore { | |
#data; | |
constructor() { | |
this.#data = new Map(); | |
} | |
/** | |
* Given a key, returns its value | |
* @param {any} key | |
* @returns {any} |
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
//====================================================================================== | |
// List of each condition | |
//====================================================================================== | |
/** | |
* Given a list of digits, returns true | |
* if the first and second digits equal to 24 | |
* @param {Array} digits | |
* @returns Boolean | |
*/ |
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
@startuml | |
title New Twirl Architecture | |
top to bottom direction | |
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml | |
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml | |
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml | |
Person(User, "User", "Someone who wants to shorten links") |
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 * as nodeWorker from "worker_threads"; | |
import * as db from "../src/db_connection.js"; | |
import * as model from "../src/model.js"; | |
db.poolStart(); | |
let entityX = "X"; | |
await model.insertEntity(entityX, "user"); | |
const timeSlotX = {}; | |
timeSlotX.from = Math.floor( |
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
//[...] =>[[], []] | |
// [] => [[]] | |
// [1] => [[], [1]] | |
// [1, 2] => [[], [1]] + [2] + [1, 2] | |
// [1, 2, 3] => [[], [1], [2], [1, 2]] + [3] + [1, 3] + [ 1, 2] + [1, 2, 3] | |
function powerSet(arr) { | |
if (arr.length === 0) { |
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 scratch.read-csv | |
(:require [clojure.string :as string])) | |
(defn find-val [s key] | |
(let [s-coll (string/split s key) | |
val-str (first (string/split (last s-coll) #"[,}]")) | |
val-cleaned (string/replace val-str #"[\"\\\:]" "")] | |
val-cleaned)) | |
(defn extract-all-vals [s] |
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
(defn middleware-fn | |
[handler-fn] | |
(fn [request] | |
;; operations on the request: | |
;; to create a `new-request` | |
;; or to simply log etc | |
(let [new-response (handler-fn new-request)] | |
;; operations on the `new-response`: | |
;; to create a `new-and-modified-response` | |
;; or to simply log etc |
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
;; curl -d 'id="1234"' -X POST 'http://localhost:65535/?name=otee' | |
(defn handler-that-needs-keyword-params | |
[{params :params}] | |
;; the following will return this response map: | |
;; {:body "Hello otee your ID is: 1234" ...} | |
(ring.util.response/response "Hello" (:name params) " your ID is: " (:id params))) |
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
(defn handler-that-supports-multiple-routes | |
[{:keys [uri request-method] :as request}] | |
request | |
(cond | |
(and (= uri "/contact") | |
(= request-method :get)) | |
{:status 200 | |
:headers {} | |
:body "Contact us at [email protected]"} |
OlderNewer