Skip to content

Instantly share code, notes, and snippets.

View clinuxrulz's full-sized avatar

Clinton Selke clinuxrulz

View GitHub Profile
@clinuxrulz
clinuxrulz / csv_into_excel_dump_2.ps1
Created March 22, 2024 11:45
csv into excel dump via powershell written by ChatGPT
function ProcessFile {
param(
[string]$inputFilename,
[string]$outputFilename
)
$csv = @()
$sr = New-Object System.IO.StreamReader($inputFilename)
try {
while ($true) {
@clinuxrulz
clinuxrulz / csv_into_excel_dump.ps1
Created March 22, 2024 08:20
Dump CSV into Excel via powerscript.
Add-Type -ReferencedAssemblies ("Microsoft.Office.Interop.Excel") -TypeDefinition @"
using System;
using System.Collections.Generic;
using Excel = Microsoft.Office.Interop.Excel;
public static class Program {
public static void Main(string[] args) {
if (args.Length != 2) {
Console.WriteLine("Please pass input file name and output file name as arguments.");
return;
@clinuxrulz
clinuxrulz / PropertiesSchema.ts
Last active August 12, 2023 01:14
Type checked JSON parsing
import { Vec2 } from "../math/Vec2";
import { Result, err, ok } from "./Result";
export type PropertiesSchema<A> = PropertiesSchemaInvMap<unknown,A> | PropertiesSchema2<A>;
type PropertiesSchemaInvMap<A,B> = {
type: "InvMap",
propertiesSchema: PropertiesSchema<A>,
fn1: (a: A) => B,
fn2: (b: B) => A,
@clinuxrulz
clinuxrulz / fgr.rs
Last active January 29, 2023 08:55
Alternative fine grain reactivity implementation (untested)
use std::cell::{Cell, RefCell};
use std::rc::{Rc, Weak};
use std::ops::{Deref, DerefMut};
pub struct FgrCtx {
observer: Rc<Node>,
dirty_nodes: Vec<Rc<Node>>,
transaction_depth: usize,
}
@clinuxrulz
clinuxrulz / parser.rs
Last active February 10, 2022 02:30
Iteratee parsing in Rust
#[derive(Debug, PartialEq, Eq)]
pub enum ChunkNextResult {
Empty,
Char(char),
Eof,
}
pub struct Chunk<'a> {
next: Box<dyn FnMut()->ChunkNextResult+'a>,
unnext_stack: Vec<char>,
@clinuxrulz
clinuxrulz / Plugin.ts
Last active March 4, 2024 09:15
Browser Plugin Utility (bidirectional asynchronous function calls)
export class Plugin {
private src: String;
private callbacks: any;
private iframe?: HTMLIFrameElement;
private messageHandler: (e: MessageEvent) => void;
private recvMsgHandler: (msg: string) => void;
private nextCallId: number = 0;
private resolveMap: any;
onLoad: () => void = () => {};
@clinuxrulz
clinuxrulz / string_factory.rs
Created August 12, 2021 12:05
Recycling strings in Rust
use std::cell::RefCell;
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::rc::Rc;
thread_local! {
static STRING_FACTORY: RefCell<StringFactory> = RefCell::new(StringFactory::new());
}
struct MyRc<A>(Rc<A>);
@clinuxrulz
clinuxrulz / Window.tsx
Last active January 17, 2023 21:03
SolidJS reusable draggable/resizable window example (requires bootstrap style sheet and an icon for grip drag corner "svgs/icons/resize%20grip.svg")
import { batch, Component, createEffect, createMemo, onCleanup, onMount } from 'solid-js';
import { createStore } from 'solid-js/store';
const Window: Component<{
title?: string,
width?: number,
height?: number,
initX?: number,
initY?: number,
}> = (props) => {
@clinuxrulz
clinuxrulz / cell_arrayed_keyed.ts
Created June 18, 2019 11:15
Cell array keyed
export function cellArrayKeyed2<K,A,B>(keyEq: (a:K,b:K)=>boolean, keyExtractor: (a:A)=>K, transform: (a:A) => B, cas: sodium.Cell<A[]>): sodium.Cell<B[]> {
return sodium.Operational
.updates(cas)
.accumLazy(
cas.sampleLazy().map(as => as.map(a => T2.of(keyExtractor(a), transform(a)))),
(nextAs: A[], lastResult: T2<K,B>[]) => {
let nextResult: T2<K,B>[] = [];
for (let i = 0; i < nextAs.length; ++i) {
let a = nextAs[i];
let key = keyExtractor(a);
@clinuxrulz
clinuxrulz / cell_switchC_no_coalesce.ts
Last active June 16, 2019 10:52
Coalesce free Cell::switchC
export class Cell<A> {
.
.
.
static switchC<A>(cca : Cell<Cell<A>>) : Cell<A> {
return Transaction.run(() => {
const za = cca.sampleLazy().map((ba : Cell<A>) => ba.sample()),
out = new StreamWithSend<A>();
let outValue: A = null;