Skip to content

Instantly share code, notes, and snippets.

View n2o's full-sized avatar
🕵️‍♂️
...

Christian Meter n2o

🕵️‍♂️
...
View GitHub Profile
@n2o
n2o / nasm_m1.md
Last active February 17, 2025 19:26
Compiling x86_64 assembly program on M1 Mac

If you have an M1 Mac and want to compile and execute x86_64 assembly code, make sure you install Rosetta 2 and nasm (brew install nasm).

Than, take a 64 Bit assembly program, e.g. from this tutorial page (https://cs.lmu.edu/~ray/notes/nasmtutorial/) in Section "Your First Program" for macOS, save it to a file called hello.asm.

Compile, link and execute the program:

nasm -f macho64 hello.asm
ld hello.o -o hello -macosx_version_min 11.0 -L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem

./hello

@n2o
n2o / mattermost-permission-fix.md
Last active August 24, 2024 12:09
Fix mattermost permissions when deployed with helm

Fix Mattermost Permission Problem

This solution is based the code snippet provided @nsteinmetz in this issue.

If you deployed mattermost via the helm chart, you might experience the same problem as we at @schnaq did: the mounted volumes belong to root but not to the mattermost user. This is a problem if you want to install settings, or new plugins (e.g. the playbook or the focalboard).

To fix this, we checked the id of the mattermost user in our running pod:

@n2o
n2o / jwt_creation.py
Last active August 31, 2021 13:40
Erzeuge ein Schlüsselpaar, erstelle einen JWT, signiere ihn und decodiere ihn wieder
# Vorher: pip install jwt[crypto]
import jwt
# Hier ein Beispiel mit einem Testtoken, er wurde mit folgenden Befehlen erstellt:
#
# ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
testing_private_key = """
@n2o
n2o / re-frame-subscriptions.clj
Created March 29, 2021 13:23
Converted roman01la's script to babashka. But it does not find usages, where the subscription key is passed to, e.g., a function, where it is then subscribed.
#!/usr/bin/env bb
;; Code based on https://gist.github.com/roman01la/c6a2e4db8d74f89789292002794a7142
;; We converted it work with babashka. Start it with `bb re_frame_subscriptions.clj`
(ns re-frame-subscriptions
(:require [clojure.set :as set]
[babashka.pods :as pods]))
(pods/load-pod "clj-kondo")
@n2o
n2o / cache-clojure-deps.edn.md
Last active August 8, 2022 09:46
Caching Clojure tools.deps Dependencies when building Docker Images

To cache the layer containing the dependencies from your Clojure project, you can execute a command without starting a REPL. This downloads all common dependencies, which are then be cached.

For example:

FROM clojure:openjdk-14-tools-deps-alpine

# Cache and install Clojure dependencies
COPY deps.edn .
@n2o
n2o / pdf-like-fax.md
Last active October 1, 2024 09:22
Babashka Script to make a PDF file look like a fax by using ImageMagick

Inspired by this Gist and @coryodaniel's solution, I put the script inside a babashka script, called pdf-like-fax.clj:

#!/usr/bin/env bb
(defn pdf-like-fax [input output]
  (let [sign (rand-nth ["+" "-"])
        rotation (rand-int 1000)
        cmd (format "convert -density 150 %s -rotate %s0.%s -attenuate 0.4 +noise Multiplicative -attenuate 0.03 +noise Multiplicative -sharpen 0x1.0 -colorspace Gray %s" input sign rotation output)
 prepared-cmd (str/split cmd #" ")]
@n2o
n2o / clojure-multistage.md
Last active March 18, 2023 12:41
Docker Multistage Build for a Clojure Application

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

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 November 3, 2017 15:03
First steps with Spacemacs

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 January 4, 2022 13:02
Creating graphs with chart.js, ClojureScript, devcards and om.next

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.