First, a few dependencies:
- Leiningen: https://leiningen.org/
- Node.js & NPM: https://nodejs.org/
- Serverless: https://serverless.com/
- An active AWS account: https://aws.amazon.com/
First, a few dependencies:
(set! *warn-on-infer* true) | |
(def ^js wifi (js/require "Wifi")) | |
(def ^js http (js/require "http")) | |
(def n (atom 0)) | |
(defn build-response [] | |
(str | |
"<html>" |
%%% This macro will create a function that converts a record to | |
%%% a {key, value} list (a proplist) | |
-define(record_to_list(Record), | |
fun(Val) -> | |
Fields = record_info(fields, Record), | |
[_Tag| Values] = tuple_to_list(Val), | |
lists:zip(Fields, Values) | |
end | |
). |
# .ebextensions/01-ebs.config | |
commands: | |
01clear-if-unmounted: | |
command: if ! mount | grep /media/ebs_volume > /dev/nul; then rm -rf /media/ebs_volume; fi | |
02attach-volume: | |
command: aws ec2 attach-volume --region eu-central-1 --volume-id vol-ddb08e34 --instance-id $(curl -s http://169.254.169.254/latest/meta-data/instance-id) --device /dev/sdh | |
ignoreErrors: true | |
03wait: | |
command: sleep 10 | |
04trymount: |
import org.apache.commons.codec.binary.Base64; | |
private String encodeFileToBase64Binary(String fileName) | |
throws IOException { | |
File file = new File(fileName); | |
byte[] bytes = loadFile(file); | |
byte[] encoded = Base64.encodeBase64(bytes); | |
String encodedString = new String(encoded); |
(ns dynamic.test | |
(:require [clojure.test :refer :all])) | |
;; This example shows how tests can be generated dynamically, by | |
;; creating new vars with the correct metadata. | |
(defn add-test | |
"Add a test to the given namespace. The body of the test is given as | |
the thunk test-fn. Useful for adding dynamically generated deftests." | |
[name ns test-fn & [metadata]] |
[Unit] | |
Description = Foo HTTP server | |
Requires = foo.socket | |
After = multi-user.target | |
[Service] | |
User = www-data | |
Group = www-data | |
WorkingDirectory = /var/foo | |
ExecStart = /var/foo/bin/foo-server |
I've experimented with Kotlin and coroutines in programming Akka. And I must say, I really like the combination so far.
But before I go into it some brief preliminaries for those who don't know Akka and actors.
Actors are a programming model that fits cloud native architectures particularly well. Being highly available and scaling horizontally. All while embracing the realities of multiple servers collaborating, server instances coming and going and the network having hickups.
On the JVM Akka is the prominent actor framework. It's been around for a while now and as a result it's highly reliable, well thought out and offers a wide programming eco system. My own interest in Akka is because of its suitability for software systems that can only be built with business events as a key construct and thinking model. And then of course materialized views, CQRS and near real-time data streams play a big role in constructing those systems.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
FROM golang:1.21.0-bullseye as builder | |
COPY . /workdir | |
WORKDIR /workdir | |
ENV CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" | |
ENV GOFLAGS="-buildmode=pie" | |
RUN go build -ldflags "-s -w" -trimpath ./cmd/app |