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 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 smartpy as sp | |
class SpectrumColors(sp.Contract): | |
def __init__(self): | |
self.init( | |
# fixed dimensions of the board | |
columns = 16, | |
rows = 16, | |
# limit to the total number of colors possible | |
max_colors = 12, |
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
const std = @import("std"); | |
const Allocator = std.mem.Allocator; | |
pub const Error = error{ | |
EndOfStream, | |
Utf8InvalidStartByte, | |
} || std.fs.File.ReadError || std.fs.File.SeekError || std.mem.Allocator.Error; | |
pub fn Parser(comptime Value: type, comptime Reader: type) type { | |
return struct { |
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
// Multi Dimensional Slices in Zig | |
// Sort of akin to ndarrays in Python's numpy | |
const std = @import("std"); | |
const runtime_safety = std.debug.runtime_safety; | |
const mem = std.mem; | |
const NDSliceErrors = error{ | |
InsufficientBufferSize, | |
ZeroLengthDimensionsNotSupported, |
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
float evalCurve(float x, float tx, float ty, float sa, float sb) | |
{ | |
const float EPS = 1e-6f; | |
if (x < tx) { | |
return (ty * x) / (x + sa * (tx - x) + EPS); | |
} else { | |
return ((1-ty) * (x-1)) / ((1-x) - sb * (tx - x) + EPS) + 1.0f; | |
} | |
} |
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
{ | |
"bucket":"bucketname", | |
"key":"image-key", | |
"edits":{ | |
"resize":{ | |
"height":720, | |
"fit":"inside" | |
}, | |
"txtWatermark":{ | |
"options":{ |
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
Mute these words in your settings here: https://twitter.com/settings/muted_keywords | |
ActivityTweet | |
generic_activity_highlights | |
generic_activity_momentsbreaking | |
RankedOrganicTweet | |
suggest_activity | |
suggest_activity_feed | |
suggest_activity_highlights | |
suggest_activity_tweet |
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
// build all: $ zig build | |
// clean up: $ zig build dist-clean | |
const builtin = @import("builtin"); // list-up the content with `zig builtin` command | |
const Builder = @import("std").build.Builder; | |
//NOTE: this build code is for zig-0.4.0, maybe incompatible with zig >= 0.5 | |
pub fn build(b: *Builder) void { | |
{ //[case: WebAssembly wasm] build fft.wasm | |
const wasmStep = b.step("fft.wasm", "build fft.wasm"); | |
const wasm = b.addExecutable("fft.wasm", "fft.zig"); |
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
#if 0 // self-compiling code | |
gcc -std=c99 -Wall -Wextra -pedantic -Werror -g -O4 -march=native $0 -lm || exit 1 | |
exec time ./a.out | |
#endif | |
// Blue Noise texture generation using the void-and-cluster algorithm | |
// implemented by Martin Fiedler <[email protected]> | |
// using an algorithm description written by Alan Wolfe: | |
// https://blog.demofox.org/2019/06/25/generating-blue-noise-textures-with-void-and-cluster/ |
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
;; see also https://twitter.com/thing_umbrella/status/1111427898487898113 | |
(require '[clojure.spec.alpha :as s]) | |
;; spec that ensures the keys in renames match the keys in map | |
(s/def ::rename-keys-args | |
(s/and (s/cat :map map? :renames map?) | |
(fn [{:keys [map renames]}] | |
(every? map (keys renames))))) | |
;; ok |