Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct
This file contains hidden or 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
def main(args: Array[String]): Unit = { | |
import javax.script.ScriptEngineManager | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
val engine = new ScriptEngineManager().getEngineByMimeType("text/javascript") | |
// val script = "-1000 * %d" format 3 | |
val endless = "(function foo() { foo(); })()" | |
val result = Await.result(Future(engine.eval(endless)), 3.millis) | |
println(result) |
This file contains hidden or 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
// Example of how third-party imports and multiple files can be used in Go playground | |
package main | |
import ( | |
"fmt" | |
"github.com/common-nighthawk/go-figure" | |
"your.universe/worlds" | |
) |
This file contains hidden or 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 | |
import ( | |
"fmt" | |
"math" | |
) | |
func makeBatches(batchSize int, size int) [][]int { | |
batches := [][]int{} | |
nbBatches := int(math.Ceil(float64(size) / float64(batchSize))) |
This file contains hidden or 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
/* MIT License | |
* | |
* Copyright (c) 2017 Roland Singer [roland.singer@desertbit.com] | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: |
This file contains hidden or 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
// Untar takes a destination path and a reader; a tar reader loops over the tarfile | |
// creating the file structure at 'dst' along the way, and writing any files | |
func Untar(dst string, r io.Reader) error { | |
gzr, err := gzip.NewReader(r) | |
if err != nil { | |
return err | |
} | |
defer gzr.Close() |
This file contains hidden or 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
// Tar takes a source and variable writers and walks 'source' writing each file | |
// found to the tar writer; the purpose for accepting multiple writers is to allow | |
// for multiple outputs (for example a file, or md5 hash) | |
func Tar(src string, writers ...io.Writer) error { | |
// ensure the src actually exists before trying to tar it | |
if _, err := os.Stat(src); err != nil { | |
return fmt.Errorf("Unable to tar files - %v", err.Error()) | |
} |
This file contains hidden or 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
var tokenEncoder = base64.RawURLEncoding | |
// parsePublicTokenPayload parses the public (unencrypted) token payload | |
// works even with expired tokens (that do not pass verification) | |
func parsePublicTokenPayload(token string) (*JSONToken, error) { | |
tokenPieces := strings.Split(token, ".") | |
if len(tokenPieces) < 3 { | |
// version.purpose.payload or version.purpose.payload.footer | |
// see: https://tools.ietf.org/id/draft-paragon-paseto-rfc-00.html#rfc.section.2 | |
return nil, errors.New("malformed token: expected at least 3 pieces") |
This file contains hidden or 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
{ | |
"workbench.colorCustomizations": { | |
"editorBracketMatch.border": "#0000", | |
"[Palenight Italic]": { | |
"editorBracketMatch.background": "#030407" | |
} | |
}, | |
"editor.tokenColorCustomizations": { | |
"[Joker Light (rainglow)]": { | |
"functions": "#007CBE", |
This file contains hidden or 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 | |
import ( | |
"bytes" | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/tls" | |
"crypto/x509" | |
"crypto/x509/pkix" | |
"encoding/pem" |