Quick guide to deploy a Clojure web app to Azure
Prerequisites
- JDK 8 or newer (I use OpenJDK 11 in this example)
- Leiningen
- Maven
- Azure CLI
- A valid Azure subscription (you can try it for free)
import org.apache.commons.math3.analysis.interpolation.NevilleInterpolator; | |
public class WtfCreator { | |
public static void main(String[] args) { | |
var text = "Hello, world!\n"; | |
double[] x = new double[text.length() + 1]; | |
double[] y = new double[text.length() + 1]; | |
for(var i = 0; i < text.length(); i++) { | |
x[i] = i; |
(defn digits-in-str [s] | |
(->> (re-seq #"\d+" s) first)) | |
(def items ["item_20" "item_11" "item_1" "item_120"]) | |
(comment | |
(sort-by (comp clojure.edn/read-string digits-in-str) items) | |
;; => ("item_1" "item_11" "item_20" "item_120") |
Software versions:
$ clj
Clojure 1.10.1
$ java -version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
#!/usr/bin/perl -w # camel code | |
use strict; | |
$_='ev | |
al("seek\040D | |
ATA,0, 0;");foreach(1..3) | |
{<DATA>;}my @camel1hump;my$camel; | |
my$Camel ;while( <DATA>){$_=sprintf("%-6 | |
9s",$_);my@dromedary 1=split(//);if(defined($ | |
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda |
(defrecord Attr [has-default default]) | |
cljs.user/Attr | |
cljs.user=> (def attr (->Attr true 1)) | |
#'cljs.user/attr | |
cljs.user=> attr | |
#cljs.user.Attr{:has-default true, :default 1} | |
cljs.user=> (map? attr) | |
true | |
cljs.user=> (keys attr) | |
(:has-default :default) |
Link to the code: https://github.com/dfuenzalida/adventofcode/blob/master/advent2017/clojure/src/advent/day03.clj
The problem statement is the following:
You come across an experimental new kind of memory stored on an infinite two-dimensional grid.
(ns datomic-shortcut.core | |
(:require [datomic.api :as d])) | |
(def db-uri "datomic:mem://foo") | |
(comment | |
(d/create-database db-uri) | |
(def conn (d/connect db-uri)) | |
) |
(ns appcompany.funapp | |
(:require [libpython-clj.python :as py :refer [py. py.- py.. py* py**]] | |
appcompany.python | |
[libpython-clj.require :refer [require-python import-python]])) | |
(import-python) | |
(require-python '[builtins :as python]) | |
(require-python '[base64 :as pybase64]) | |
(require-python '[funniest :as pyfunniest]) |
;; An example InputStream made of 128 bytes: | |
(defn bytes-is [] | |
(java.io.ByteArrayInputStream. (into-array Byte/TYPE (range 128)))) | |
(defn b64encode [s] | |
(String. (.encode (java.util.Base64/getEncoder) (.getBytes s)))) | |
;; Now we read the input stream *in memory* (with slurp) and encode as base64: | |
(-> (bytes-is) slurp b64encode) | |
;; => "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJC...n8=" |