Skip to content

Instantly share code, notes, and snippets.

View johannes-jansson's full-sized avatar

Johannes Jansson johannes-jansson

  • Sweden
View GitHub Profile
@johannes-jansson
johannes-jansson / myfunction.js
Last active January 17, 2019 16:32
JS function with optional parameter
// This is our method for doing optional parameters in javascript.
// In this example source is a mandatory parameter, opts are optional,
// and callback is an optional callback. Optional parameters are stored
// in the object opts.
const myfunction = (source, opts, callback) => {
// check if any optional parameters were provided by looking at the type of the second argument
if (typeof opts === 'function') {
// If opts is a function it's the callback
callback = opts;
// Set opts to be an empty object
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(ns main
(:require [clojure.string :as str]))
(defn load_data
"Loads data from path, split by newline"
[path]
(str/split (slurp path) #"\n"))
(defn fuel
"Calculates the fuel consumption for weight"
@johannes-jansson
johannes-jansson / My QMK flashing instructions
Last active May 13, 2020 13:41
My QMK flashing instructions
Because I always forget 😅
Proton c:
make proton_c:janzon:dfu-util
@johannes-jansson
johannes-jansson / nix_on_macos.md
Last active November 17, 2022 13:16
Installing Nix on macOS

Start by running the nix installer script:

sh <(curl -L https://nixos.org/nix/install) --daemon

In order to use flakes, you need to allow two experimental features:

mkdir ~/.config/nix
echo 'experimental-features = nix-command flakes' > ~/.config/nix/nix.conf