Skip to content

Instantly share code, notes, and snippets.

View rayman22201's full-sized avatar

Ray Imber rayman22201

View GitHub Profile
@rayman22201
rayman22201 / liftboolprocs.nim
Last active March 19, 2020 06:16
lift boolean procs from basic types to component wise containers
import fenv
import macros
import sequtils
import strformat
# afaik we need this to get the types. I can't think of another way.
{.experimental: "dynamicBindSym".}
type
Vec*[N: static[int]] = array[N, float32]
@rayman22201
rayman22201 / index.html
Created January 31, 2020 20:07
60East Replication xkcd
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(16,346)">
@rayman22201
rayman22201 / evolve_mobile_mode.js
Created January 10, 2020 02:19
Use the raw Bubble.io api to create a more mobile friendly view for the Evolve lesson recordings
var pageRoot = document.querySelector(".Page");
var floatingHeader = document.querySelector(".floating-group");
var groupRoot = document.querySelector(".Group");
var subHeader = document.querySelector(".Group>.bubble-r-line");
var getVideoData = function(start, len) {
var headers = new Headers();
headers.append("content-type", "application/json");
var data = {
"app_version": "live",
@rayman22201
rayman22201 / evolveTZ.js
Created January 4, 2020 21:53
Bookmarklet to allow Changing the Time Zone on the Evolve Calendar Page
var timezones = [
"Africa/Abidjan",
"Africa/Accra",
"Africa/Algiers",
"Africa/Bissau",
"Africa/Cairo",
"Africa/Casablanca",
"Africa/Ceuta",
"Africa/El_Aaiun",
"Africa/Johannesburg",
@rayman22201
rayman22201 / main.nim
Last active November 7, 2019 01:19
explaining cross module templates
import templates
let myThing = someProcThatReturnsOption()
printFileBool(myThing, "string") # calls the template
# this essentially expands to:
# it's a fancy copy / paste, but creates a new scope. This is what is known in the lisp world as "hygenic".
# A template will not import other things into your module automatigically.
block:
if not myThing.isNone: # it's just a copy / paste. Nim will not automagically "import Option" for you.
@rayman22201
rayman22201 / gist:e76535c6c8ca2950aa7aa0c81870f7aa
Created October 2, 2019 19:42
Rays Laptop OpenGL details
C:\Users\ray\Downloads>wglinfo64.exe
[WGL] WGL extensions:
WGL_EXT_depth_float, WGL_ARB_buffer_region, WGL_ARB_extensions_string,
WGL_ARB_make_current_read, WGL_ARB_pixel_format, WGL_ARB_pbuffer,
WGL_EXT_extensions_string, WGL_EXT_swap_control, WGL_EXT_swap_control_tear,
WGL_ARB_multisample, WGL_ARB_pixel_format_float, WGL_ARB_framebuffer_sRGB,
WGL_ARB_create_context, WGL_ARB_create_context_profile,
WGL_EXT_pixel_format_packed_float, WGL_EXT_create_context_es_profile,
WGL_EXT_create_context_es2_profile, WGL_NV_DX_interop,
WGL_ARB_create_context_robustness.
@rayman22201
rayman22201 / genericTreeIssue.nim
Created January 16, 2019 23:55
minimal tree generic error
type
BBTree*[K,V] = ref object of RootObj # BBTree is a generic type with keys and values of types K, V
## `BBTree` is an opaque immutable type.
BBLeaf[K,V] = ref object of BBTree
key: K # the search key; must support the generic ``cmp`` proc
val: V # the data value associated with the key, and stored in a node
BBNode2[K,V] = ref object of BBLeaf
left: BBTree[K,V] # left subtree; may be nil
right: BBTree[K,V] # right subtree; may be nil
size: int # the size of the (sub-)tree rooted in this node
@rayman22201
rayman22201 / 8266_led.ino
Created December 18, 2018 00:59
Hello world of Arduino
#define LED 2 //Define blinking LED pin
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT); // Initialize the LED pin as an output
}
void loop() {
digitalWrite(LED, LOW); // Turn the LED on (Note that LOW is the voltage level)
delay(1000); // Wait for a second
@rayman22201
rayman22201 / .gitignore
Last active September 21, 2018 19:45 — forked from iffy/.gitignore
Comparing line-reading in Python/Nim/Node
hugefile.txt
myreader
fgetsreader
builtinreader
hugebin.txt
hugestr.txt
@rayman22201
rayman22201 / capture_template.nim
Created September 19, 2018 22:51
simple "closure" capture like nim template
template sqlList(name: untyped, statements: openArray[string]):untyped =
proc `name` (db:string) =
echo "Inside proc"
for statement in statements:
echo "statement: ", statement
sqlList(genProc, ["a", "b", "c"])
genProc("db")