This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun some-dodgey-function (value) | |
(let* ((result (/ 10 value))) | |
(message "Rwesult is %d" result))) | |
(defun some-recovery-or-cleanup-code-to-always-run () | |
(message "I ALWAwYS RUN!!!")) | |
(unwind-protect | |
(some-dodgey-function 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# aproducer.py | |
# | |
# Async Producer-consumer problem. | |
# Challenge: How to implement the same functionality, but no threads. | |
import time | |
from collections import deque | |
import heapq | |
class Scheduler: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export DOCKER_HOST=ssh://[email protected] | |
export DOCKER_HOST=tcp://docker.local | |
multipass set client.primary-name=docker | |
function start-docker() { | |
local SSH_KEY="id_$RANDOM" | |
local PUBLIC_SSH_KEY="${SSH_KEY}.pub" | |
ssh-keygen -b 2048 -t rsa -f "$SSH_KEY" -P "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install multipass | |
multipass launch lts -c 6 -d 20G -m 8G -n docker | |
multipass set client.primary-name=docker | |
multipass mount /Volumes/path/to/repo docker | |
multipass shell | |
curl -sSL https://get.docker.com/ | sh | |
echo '{"features": {"buildkit": true}}' > /etc/docker/daemon.json | |
# or if you have a local k8s cluster (ala microk8s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// https://play.golang.com/p/PNax2a1rL3q | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
"golang.org/x/exp/constraints" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.ReceiveChannel | |
import kotlin.random.Random | |
import kotlin.random.nextUInt | |
import kotlin.time.ExperimentalTime | |
import kotlin.time.measureTime | |
data class TestMessage(val id: Int, val startTime: Long, val data: UInt, val streamName: String, val newData: UInt = 0u) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.client.* | |
import io.ktor.client.call.* | |
import io.ktor.client.engine.cio.* | |
import io.ktor.client.request.* | |
import io.ktor.client.statement.* | |
import io.ktor.network.tls.* | |
import io.ktor.utils.io.* | |
import io.ktor.utils.io.core.* | |
import kotlinx.coroutines.CoroutineScope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.svanellewee.hackdbagain | |
import android.content.Context | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import androidx.activity.viewModels | |
import androidx.lifecycle.* | |
import androidx.room.* | |
import com.svanellewee.hackdbagain.databinding.ActivityMainBinding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pop this in your bashrc | |
if [[ -z "$TMUX" ]] # hey bash, are you inside a tmux already? Then ignore! | |
then | |
# if bash is not currently in a tmux session, look for the first.. | |
first_session=$(tmux ls 2>/dev/null|grep -Po '\K[0-9]+?(?=\: )') | |
if [[ ! -z "${first_session}" ]] | |
then | |
# oh you found a session! Attach to that badboy | |
tmux attach-session -t "${first_session}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function split-bundle() { | |
local input_file="${1}" | |
local prefix="${2:-cert-}" | |
csplit -z -f "${prefix}" "${input_file}" '/-----BEGIN CERTIFICATE-----/' '{*}' | |
} | |
function new-truststore() { | |
local output_jks="${1:-output.jks}" |
NewerOlder