Skip to content

Instantly share code, notes, and snippets.

AsciiDoc User Guide

AsciiDoc is a text document format for writing notes, documentation, articles, books, ebooks, slideshows, web pages, blogs and UNIX man

@lambrospetrou
lambrospetrou / asciidoc-guide-top-partial.adoc
Last active March 17, 2021 22:17
3000 lines of sample Asciidoc. Full version (6K lines) is at https://asciidoc.org/asciidoc.txt

AsciiDoc User Guide

AsciiDoc is a text document format for writing notes, documentation, articles, books, ebooks, slideshows, web pages, blogs and UNIX man

// Option 1
async function streamToString(stream: NodeJS.ReadableStream): Promise<string> {
const chunks: Array<any> = [];
for await (let chunk of stream) {
chunks.push(chunk)
}
const buffer = Buffer.concat(chunks);
return buffer.toString("utf-8")
}
@lambrospetrou
lambrospetrou / README.md
Created May 21, 2019 09:58
Kotlin server script
  1. Install tools
curl -s “https://get.sdkman.io" | bash

sdk install kotlin
sdk install kscript
  1. Run the script
@lambrospetrou
lambrospetrou / test-script.go
Last active March 11, 2018 15:08
Shebang for Go scripts
// 2>/dev/null;/usr/bin/env go run $0 $@; exit $?
// Found at https://gist.github.com/posener/73ffd326d88483df6b1cb66e8ed1e0bd
package main
import "fmt"
// You can run the script with one of two ways
// 1. chmod +x test-script.go && ./test-script.go
// 2. go run test-script.go

Change all commits

https://stackoverflow.com/a/750191/1066790

git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='new@email'; GIT_COMMITTER_NAME='Newname'; GIT_COMMITTER_EMAIL='new@email';" HEAD

Change some commits

#!/bin/bash
set -e
SOURCE_DIR="the-dir-to-save"
S3_BUCKET="s3://your-s3-bucket/with/path"
TIMENOW="$(date --rfc-3339=seconds | tr ' ' '_' | tr ':' '-' | tr '+' '.')"
FILENAME="$SOURCE_DIR.$TIMENOW.tgz"
#!/bin/bash
set -e
INSTALL_DIR="$HOME/local"
# erlang FROM SOURCE - http://erlang.org/doc/installation_guide/INSTALL.html
# You need to have OpenSSL for :crypto, wxWidgets for :wx, etc.
#ERL_VERSION="20.2"
#wget "http://www.erlang.org/download/otp_src_$ERL_VERSION.tar.gz"
@lambrospetrou
lambrospetrou / csv-to-markdown-table.rkt
Last active November 9, 2017 00:01
CSV to Markdown converter written in Racket
; The first line of the input is considered to be the heading!
; It accepts either one command line argument with the CSV file path
; or it reads the input from `stdin`.
#lang racket
(require csv-reading)
(define (getInputPort)
(cond
[(> (vector-length (current-command-line-arguments)) 0)
@lambrospetrou
lambrospetrou / quick-sort.rkt
Created November 5, 2017 01:48
Quick-sort implementation in Racket
#lang racket
(define (qsrt iarr lt)
(cond
[(< 1 (length iarr))
(let (
[pivot (first iarr)]
[gt (lambda (l r) (not (or (lt l r) (equal? l r))))])
(append
(qsrt (filter (lambda (x) (lt x pivot)) iarr) lt)