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 / 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 / Main.purs
Last active August 31, 2023 19:38
Lambda Calculus to CCC in Purescript
module Main where
import Prelude (Unit, ($), (+), (<>), (<$>), (<*>), (==), (>), discard)
import Effect (Effect)
import Effect.Console (log)
import Control.Category
import Control.Semigroupoid
import Data.Leibniz
import Data.Maybe
import Data.Exists
@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 / 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 / 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 / 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 / Main.purs
Last active June 12, 2020 16:42
JavaScript monad in PureScript
module Main where
import Prelude
import Data.Array.ST as STArray
import Control.Monad.Eff.Console (log) as Console
import Control.Monad.Eff (runPure, Eff)
import Control.Monad.Rec.Class (tailRecM)
import Control.Monad.ST (newSTRef, runST, readSTRef, writeSTRef, ST, STRef)
import Data.Array.ST (pushSTArray, emptySTArray, STArray)
import Data.Either (either, Either(Left, Right))