diff --git a/src/content/archives/what-is-docker.md b/src/content/archives/what-is-docker.md index 2c8812a..8f890b2 100644 --- a/src/content/archives/what-is-docker.md +++ b/src/content/archives/what-is-docker.md @@ -16,13 +16,13 @@ The advantage to this approach is that it's very lightweight since it doesn't re **Examples** You can get a fully functional ubuntu machine by just running -``` +```sh docker run -it ubuntu bash ``` Running an nginx web server can be done easily using docker-compose: -docker-compose.yml: +Create: `docker-compose.yml` ```yml web: @@ -37,17 +37,21 @@ web: command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" ``` -`docker-compose up -d` +And run: + +```sh +docker-compose up -d +``` You can start a Redis instance like this: -``` +```sh docker run --name my-redis -d redis ``` Then you can inspect the running containers with: -``` +```sh $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES @@ -56,7 +60,7 @@ d295137f5965 redis "docker-entrypoint.s…" 6 seconds ago and attach to the running redis container to run commands with redis-cli: -``` +```sh $ docker exec -it my-redis redis-cli 127.0.0.1:6379> set example-key 1234 OK diff --git a/src/content/archives/what-is-graphql.md b/src/content/archives/what-is-graphql.md index 7f7a1bb..3cc4049 100644 --- a/src/content/archives/what-is-graphql.md +++ b/src/content/archives/what-is-graphql.md @@ -35,7 +35,7 @@ GraphQL was created internally by Facebook in 2012, mainly to optimize the netwo Meanwhile, a GraphQL query would look like : -``` +```graphql query user(id: "5") { id name @@ -61,7 +61,7 @@ query user(id: "5") { 2. GraphQL helps building features faster. Because of the way the front-end can explicitly query the data it needs, it's not rare to not need to update the backend API. Again, using the example from earlier, if we wanted to also fetch the user friends, we could simply add it to our query: -``` +```graphql query user(id: "5") { name posts { @@ -85,7 +85,7 @@ GraphQL has three types of operations: Basic query: -``` +```graphql query User($id: ID) { user { id @@ -99,7 +99,7 @@ query User($id: ID) { Basic mutation: -``` +```graphql mutation CreatePost($title: String!, $content: String!, $draft: Boolean!) { createPost(title: $title, content: $content, draft: $draft) { title @@ -111,9 +111,9 @@ mutation CreatePost($title: String!, $content: String!, $draft: Boolean!) { Basic subscription: -``` -subscription OnMessageReceived($conversationId: ID!){ - messageReceived(conversationId: $conversationId){ +```graphql +subscription OnMessageReceived($conversationId: ID!) { + messageReceived(conversationId: $conversationId) { id content } @@ -124,7 +124,7 @@ At its core, GraphQL consists of two parts: client, and server. A server contains a single endpoint, accepting GET and POST requests, which are translated like so: -``` +```graphql { me { name diff --git a/src/content/archives/what-is-lisp.md b/src/content/archives/what-is-lisp.md index 8dae016..45e333b 100644 --- a/src/content/archives/what-is-lisp.md +++ b/src/content/archives/what-is-lisp.md @@ -123,19 +123,19 @@ If you know python, this document may be of particular interest to you: http://n Common Lisp: -``` +```clojure (print "Hello, World!") ``` Scheme: -``` +```clojure (print "Hello, World!") ``` Clojure (as a JVM program entry point): -``` +```clojure (defn -main "A documentation string for my hello world function" [& args] @@ -144,7 +144,7 @@ Clojure (as a JVM program entry point): Racket: -```lisp +```clojure #lang racket (println "Hello, World!") @@ -152,7 +152,7 @@ Racket: ALGOL60, as implemented in Racket (to demonstrate the flexibility offered by Racket): -``` +```clojure #lang algol60 begin @@ -164,7 +164,7 @@ end Common Lisp: -``` +```clojure (let ((first (block a (write-line "first number:") (read))) (second (block b (write-line "second number: ") (read)))) (format t "The sum of ~A and ~A is ~D" first second (+ first second))) @@ -172,7 +172,7 @@ Common Lisp: Scheme: -``` +```clojure (let ((first (begin (display "first number:") (read))) (second (begin (display "second number: ") (read)))) (format #t "The sum of ~s and ~s is ~s" first second (+ first second))) @@ -180,7 +180,7 @@ Scheme: Clojure: -``` +```clojure (let [first (do (println "first number: ") (Integer/parseInt (read-line))) second (do (println "second number: ") (Integer/parseInt (read-line)))] (printf "The sum of %d and %d is %d" first second (+ first second))) @@ -188,7 +188,7 @@ Clojure: Racket: -```lisp +```clojure #lang racket (let ((first (begin (print "first number:")(read))) @@ -198,7 +198,7 @@ Racket: - A very basic macro in Clojure -``` +```clojure ;; definition - we'll take an expression, evaluate it once, print the formatted string, and then return the result (defmacro log-call [form] @@ -215,7 +215,7 @@ Racket: - A really simple Clojure web site using the ring and compojure libraries -``` +```clojure ;; define a namespace for our functions, and import routing and default request handling functions (ns hello-web.handler (:require [compojure.core :refer :all] @@ -234,7 +234,7 @@ Racket: - Memoizing pure functions in Clojure -``` +```clojure (defn expensive [number] (Thread/sleep 1000) @@ -257,7 +257,7 @@ Racket: - Lazy sequences in Clojure -``` +```clojure (defn fib-seq "Returns a lazy sequence of Fibonacci numbers. Copied from http://clojure-doc.org/articles/language/laziness.html" ([] @@ -273,7 +273,7 @@ Racket: - Collatz sequence in Scheme -``` +```clojure (define (collatz n) (cond [(equal? n 1)(format #t "1")] @@ -284,7 +284,7 @@ Racket: - FizzBuzz from 1 to n using lazy evaluation in Racket -```lisp +```clojure #lang lazy (define fizzes (cycle "" "" "Fizz"))