Skip to content

Instantly share code, notes, and snippets.

View charlesetc's full-sized avatar
🪁
Flying kites in NYC

Charles Chamberlain charlesetc

🪁
Flying kites in NYC
View GitHub Profile
//
// ContentView.swift
// Apricot
//
// Created by Charles Chamberlain on 12/10/22.
//
import SwiftUI
extension Color {
#!/usr/bin/env ruby
require 'tempfile'
require 'open3'
INF = 10000000000
def ap(file)
File.absolute_path file
end
@charlesetc
charlesetc / Uncertainty is the mind-killer
Created September 24, 2018 00:04
Dune output upon crashing
I must not segfault. Uncertainty is the mind-killer. Exceptions are
the little-death that brings total obliteration. I will fully express
my cases. Execution will pass over me and through me. And when it
has gone past, I will unwind the stack along its path. Where the
cases are handled there will be nothing. Only I will remain.
@charlesetc
charlesetc / objects.ml
Created July 30, 2018 02:35
Somwhat complex use of objects in OCaml
let rec non_empty_list next prev value =
object (self)
val mutable next = next
val mutable prev = prev
val mutable value = value
method append value =
let l = non_empty_list next (Some self) value in
next <- Some l
@charlesetc
charlesetc / compmisc_example.ml
Created April 25, 2018 04:56
OCaml compiler variation
(* 4.06 *)
let initial_env () =
Ident.reinit();
let initial =
if Config.safe_string then Env.initial_safe_string
else if !Clflags.unsafe_string then Env.initial_unsafe_string
else Env.initial_safe_string
in
let env =
build-c:
clang -fPIC -Wall -Wextra -O3 -g -MM stars_extension.c >stars_extension.d
clang -fPIC -Wall -Wextra -O3 -g -c -o stars_extension.o stars_extension.c
clang -shared -o libstars_extension.dylib stars_extension.o
@charlesetc
charlesetc / brie.vim
Created July 5, 2017 12:41
Simple syntax highlighting for Brie
if exists("b:current_syntax")
finish
endif
" Keywords
syntax keyword brieKeyword class define case self method field require
highlight link brieKeyword Keyword
" Block
@charlesetc
charlesetc / nspace
Last active May 25, 2017 16:32
Use pandoc to build directory md->html
#!/bin/bash
name=$(basename $(pwd))
style=kate
flags=" -s --highlight-style $style"
if [ -f "$name.html" ] ; then
flags="$flags -A $name.html "
$ pulseaudio
W: [pulseaudio] pid.c: Stale PID file, overwriting.
E: [pulseaudio] module-device-restore.c: Failed to open volume database '/home/charles/.config/pulse/fcc78b8e9d024418a028525a0943d256-device-volumes': Permission denied
E: [pulseaudio] module.c: Failed to load module "module-device-restore" (argument: ""): initialization failed.
E: [pulseaudio] hook-list.c: Assertion '!slot->dead' failed at pulsecore/hook-list.c:83, function pa_hook_slot_free(). Aborting.
[1] 1989 abort pulseaudio
use "options"
use "path:sys/ioctl"
use @ioctl[None](file: I32, magic: U32, winsize: MaybePointer[Winsize])
struct Winsize
var height: U16 = 0
var width: U16 = 0
new create() => None