Skip to content

Instantly share code, notes, and snippets.

View kfsone's full-sized avatar

Oliver Smith kfsone

View GitHub Profile
@kfsone
kfsone / main.go
Created February 26, 2021 00:17
andlabs/ui combobox not rendering in a tab on windows
package main
import (
"fmt"
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
)
func makePage1() ui.Control {
return ui.NewLabel("Page 1")
> cmd
Microsoft Windows [Version 10.0.20241.1005]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\oliver\AppData\Local\Temp>mkdir d1 d2
C:\Users\oliver\AppData\Local\Temp>echo @echo BAT >d1\a.bat
C:\Users\oliver\AppData\Local\Temp>echo @echo BAT >d2\a.bat
C:\Users\oliver\AppData\Local\Temp>echo print('PY') >d1\a.py
C:\Users\oliver\AppData\Local\Temp>echo print('PY') >d2\a.py
C:\Users\oliver\AppData\Local\Temp>set PATHEXT=.COM;.EXE;.BAT;.PY
C:\Users\oliver\AppData\Local\Temp>set PATH=d1;d2;%PATH%
// This is a relatively common pattern:
while (true)
{
if (predicate())
continue;
...
break;
}
// so is this
<comment>
A pseudo-RXML of how you might implement a table-rendering based on a collection of YAML files,
using technologies built into Roxen since 1995, imagining the vcs tag had gained git support,
and that a yaml tag had been introduced similar to other parsing tags.
Roxen was based on uLPC, the MUD language, which was a dynamic (jit'd -> p-code) C++/Objective-C
like language, which meant it was capable of jit/caching dynamic content generation...
It featured a server-side XML-based scripting language called RXML which integrated with
your HTML fluidly the way modern HTML 5 introduced things like <template> etc.
import random
# time
t = 0
# how likely is replication to be successful
replication_success_ratio = 0.7
# estimate time for rna in a cell to reach a replication center,
# we'll also repurpose it as how long it takes a viable strand to
# start itself replicating (which is generous),
# and how long the virions in a dead cell take to find new cells.
// this is pseudo-c
struct Pointers {
const char *timestampStart;
const char *timestampEnd;
const char *pidStart;
const char *pidEnd;
const char *levelStart;
const char *levelEnd;
const char *prefixStart;
@kfsone
kfsone / failfn.go
Last active May 24, 2019 06:00
A proposal for formalizing and inlining error handling in the Go language
// Go's informal error handling syntax introduces a lot of boiler-plate and ambiguity:
// boiler-plate: you have to capture and test the value, and you frequently want to forward it, etc
// there is also the potential for people to violate convention/norms.
func sqrt(value float64) (float64, error, error) {
// what does the second error mean?
}
func v(value float64) (error) {
// just, what ?
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False
@kfsone
kfsone / zeroconfdump.py
Created January 27, 2019 06:18
Dumps a list of all zeroconf devices on the network
#! /usr/bin/env python
# requires zeroconf (e.g. pip install --user zeroconf)
from collections import defaultdict
from time import sleep
from zeroconf import Zeroconf, ServiceBrowser, ZeroconfServiceTypes
from json import dumps
verbose = False