Skip to content

Instantly share code, notes, and snippets.

🕵
...

Christian Meter n2o

🕵
...
Block or report user

Report or block n2o

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@n2o
n2o / clojure-multistage.md
Last active Oct 21, 2019
Docker Multistage Build for a Clojure Application
View clojure-multistage.md

A Docker Multistage Build reduces the complexity of a production image to a minimum. Since it is very easy to build jars from Clojure applications, we can just use an JRE to bring it to production.

Let's create a sample project using the app template with Leiningen:

lein new app foo
cd foo
View introduction_in_clojure_210618.md

Clojure Meetup Juni 2018

Wir haben ein wenig in der REPL gespielt und dabei ist dieser Code entstanden:

(ns intro.core)

(defn spielregeln
  "I don't do a whole lot."
  [x]
@n2o
n2o / hands-on-spacemacs.md
Last active Nov 3, 2017
First steps with Spacemacs
View hands-on-spacemacs.md

Spacemacs

In Spacemacs wird die Philosophie verfolgt, dass es nicht den besten Editor gibt, sondern man bemüht sich die besten Funktionen von vim und emacs zu vereinen.

Dabei sind beide Keymappings möglich, vim oder emacs. Oder einfach beides (hybrid-mode). Wenn der emacs-mode gewählt wurde beim Keymapping, so sind die Tastaturkürzel mit M-x (also die Tasten ALT + x) oder M-m meistens zu erreichen. Unter vim-mode finden

@n2o
n2o / devcard-chart-js.md
Last active Oct 4, 2017
Creating graphs with chart.js, ClojureScript, devcards and om.next
View devcard-chart-js.md

I have a huge amount of data in an Excel-Sheet and want to get some statistics of it. Since I am only using LibreOffice, which is not very comfortable, and I am really loving web-techniques to build UIs / visualizations, I decided to use devcards and ClojureScript with React.js to build some Charts.

This is inspired by this gist, but I want to use it with om.next and devcards, which is why I am writing this gist.

@n2o
n2o / fizzbuzz-clojure.md
Last active Feb 4, 2018
FizzBuzz without conditions in Clojure
View fizzbuzz-clojure.md

Just thought about a FizzBuzz solution written in frege which I saw on a meetup. This solution does not need any conditionals and is completely lazy, which is why I like this solution so much.

The rules are as follows:

  • print all numbers from 1 to n, but...
    • replace all numbers, which are smoothly divisible by 3, with "fizz"
@n2o
n2o / clojure-korma-minimal.md
Last active Nov 3, 2019
Minimal Clojure Korma example to read data from a postgresql database
View clojure-korma-minimal.md

Let's play around with a postgres database and Clojure. To query and insert a database, we need to create one:

docker run --rm --name eventdb -e POSTGRES_PASSWORD=foo -e POSTGRES_USER=foo -e POSTGRES_DB=foo -d -p 5432:5432 postgres

This creates a postgres database named foodb, with password, user and tablename also being foo. Ports are exposed to our local machine and we can access the database at localhost:5432.

Now, we need to connect to the database and create a table, which can be queried and filled with korma. You can use a library to do this, but for a minimal example this is not necessary:

user@host ~ % docker exec -it eventdb su postgres -c psql
@n2o
n2o / clojure-meetup-july-clojure.spec.md
Created Jul 7, 2017
Clojure Meetup July: clojure.spec
View clojure-meetup-july-clojure.spec.md

We played around with clojure.spec and followed the post Interactive Development with clojure.spec.

In the beginning, we started to get to know the semantics of clojure.spec and looked at some specs. After this, we solved the codebreaker-example and successfully defined some specs for it.

REPL Session from Clojure Meetup Düsseldorf, Germany, 6th July 2017

@n2o
n2o / professional-programming-summer-2017-week-12.md
Last active Jul 6, 2017
Professional Programming: Results of practical exercises, week 12: JavaFX + SceneBuilder + AnchorPanes
View professional-programming-summer-2017-week-12.md

Today we extended the project from week 11 and created a base template. This base template contains an AnchorPane, where FX-elements from other FXML files can be appended to. Therefore, we can change on click our UI and load new elements to it.

// src/main/java/Main.java

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
@n2o
n2o / professional-programming-summer-2017-week-11.md
Last active Jun 29, 2017
Professional Programming: Results of practical exercises, week 11: JavaFX
View professional-programming-summer-2017-week-11.md

This week we started with JavaFX and created a simple HelloWorld-Application. Later, we created a more advanced UI with the Gluon SceneBuilder. But I will only upload our hello-world example, since working with the SceneBuilder is straightforward.

This is a gradle project and the source code is based on the standard JavaFX template by IntelliJ.

// build.gradle
@n2o
n2o / professional-programming-summer-2017-week-7.md
Created Jun 8, 2017
Professional Programming: Results of practical exercises, week 7
View professional-programming-summer-2017-week-7.md

Today, we played around with Unirest, gson and a sample API to address our requests to. This is just a simple and small example, because we had not much time to live-code this problem.

import com.google.gson.Gson;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
You can’t perform that action at this time.