Skip to content

Instantly share code, notes, and snippets.

View asciidoc-guide.adoc

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 Mar 17, 2021
3000 lines of sample Asciidoc. Full version (6K lines) is at https://asciidoc.org/asciidoc.txt
View asciidoc-guide-top-partial.adoc

AsciiDoc User Guide

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

View ReadableStream-to-String.ts
// 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
Kotlin server script
View README.md
  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 Mar 11, 2018
Shebang for Go scripts
View test-script.go
// 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
View git-change-author-commits.md

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

View backup-folder-to-S3-server-side-encrypted.sh
#!/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"
View install-erlang-elixir.sh
#!/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 Nov 9, 2017
CSV to Markdown converter written in Racket
View csv-to-markdown-table.rkt
; 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 Nov 5, 2017
Quick-sort implementation in Racket
View quick-sort.rkt
#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)