Skip to content

Instantly share code, notes, and snippets.

View cbrunnkvist's full-sized avatar

Conny Brunnkvist cbrunnkvist

View GitHub Profile
@pstch
pstch / stream-replace.sh
Last active July 18, 2023 11:35
Pipe a file to a process "in-place"
#!/usr/bin/env bash
# stream-replace.sh -- pipe a file to a process "in-place", using fallocate
#
# Copyright (C) 2020 Hugo Geoffroy "pistache" <pistache@lebib.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

Easy Scala Publication

The following describes how you can publish artifacts for any sbt project using the GitHub Package Registry and the sbt-github-packages plugin.

Step 1: Create a GitHub Token

In your GitHub account, go to Settings > Developer settings > Personal access tokens, then click on Generate new token (or click here). Fill in some sort of meaningful name (I chose Dev) and click on the write:packages checkbox:

the new personal access token page with the above steps having been followed

@ggreen88
ggreen88 / Docker Compose Systemd Tutorial.md
Last active March 29, 2021 18:36 — forked from mosquito/README.md
Add docker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service

[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service
@midnightcodr
midnightcodr / main.js
Created December 9, 2017 18:06
node-fetch with retry
const fetch = require('node-fetch')
const delay = (ms) => {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, ms)
})
}
const retryFetch = (url, fetchOptions={}, retries=3, retryDelay=1000) => {
/*
Muji Cuckoo Clock MQTT Controller V1.0
James Sutton - 2017
jsutton.co.uk
To trigger the cuckoo animation, publish an mqtt message with the payload of '1' to the topic
described in the settings below.
Use board "WeMos D1 R2 & mini"
CPU 160MHz
@mosquito
mosquito / README.md
Last active May 22, 2024 17:17
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
#!/usr/bin/env bash
function __tc_encode {
# Only unicode characters are not supported
echo -n "$1" | sed "s/\([|']\)/\|\1/g; s/\[/\|\[/g; s/\]/\|\]/g; s/\r/\|r/g;" | sed ':a;N;$!ba;s/\n/|n/g'
}
function __tc_message {
echo "##teamcity[message text='$(__tc_encode "$2")' status='${1:-NORMAL}']"
}
function __tc_simple {
class BowlingGame {
var moves = Vector.empty[Int]
def roll(i: Int) = {
moves = moves :+ i
}
def score: Int = score()
@Salakar
Salakar / deepMerge.md
Last active November 22, 2023 09:02
ES6/ES2015 Object deep merge

Deep Merge

Quick function to deep merge using Object.assign(). Thoughts?

    /**
     * Simple is object check.
     * @param item
     * @returns {boolean}
     */
@kvz
kvz / Makefile
Last active August 28, 2021 14:35
The only Makefile for Node.js projects you'll ever need - https://twitter.com/kvz/status/685853830425231361
# Licensed under MIT.
# Copyright (2016) by Kevin van Zonneveld https://twitter.com/kvz
#
# This Makefile offers convience shortcuts into any Node.js project that utilizes npm scripts.
# It functions as a wrapper around the actual listed in `package.json`
# So instead of typing:
#
# $ npm script build:assets
#
# you could just as well type: