Skip to content

Instantly share code, notes, and snippets.

View samwightt's full-sized avatar

Sam Wight samwightt

View GitHub Profile
@samwightt
samwightt / hello-world.js
Created April 20, 2024 17:27
Asking Claude to write Hello World
// I asked Claude to write Hello World. Then I continually asked it to extract new classes until we got the below.
// Introducing the world's most complicated Hello World program.
class Printable {
toString() {
throw new Error('toString() method must be implemented');
}
}
class MessageCreator {
@samwightt
samwightt / go.mod
Last active February 16, 2022 07:20
Ebiten example with perlin noise generation
module samw.dev/ebiten
go 1.15
require (
github.com/aquilax/go-perlin v1.1.0
github.com/hajimehoshi/ebiten/v2 v2.2.4
)
export function bootstrap() {
// All of your code for setting stuff up should go in here.
// This will be run once when our module loads, and then again on every reload.
}
export function teardown() {
// This is where you delete anything you created. For instance, if you add a canvas element
// using JS, you should remove that here. Any listeners should be removed as well.
}
@samwightt
samwightt / utils.ts
Created September 3, 2021 16:40
Non-shitty angle.js
//////////////////////////////////////////////////////////////////////////////
//
// Angel.js
//
//////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------
//
// Helper functions
//
import currentUser from "app/auth/queries/currentUser"
// You'd need some sort of transform to evaluate this function and turn it into an object
// that could be passed to the server. You could just replace the definition of the `currentUser`
// function with:
// const currentUser = (args) => args
// and then just send the returned params to the server.
export const query = currentUser();
// This displays when the query is loading.
@samwightt
samwightt / channelManager.ts
Last active May 18, 2023 22:15
Channel Manager
/**
* This is a small library I wrote when I was doing R&D work and needed a way to communicate
* between an iFrame on the same domain and its parent tab. The existing browser API kinda sucked
* and had a lot of issues, and it wasn't particularly enjoyable to use. So I made this small library to solve that.
*
* The library allows you to communicate using *channels*, which are just streams of events with a given name.
* You can subscribe to events of a particular type. Each event type has its own event queue, and each subscriber
* must subscribe to a particular event type. This keeps things simple and fast.
*
* Events are buffered and sent asychronously. There are two ways to send events: firing and blocking.
@samwightt
samwightt / machine.js
Created April 26, 2021 17:45
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
<!DOCTYPE html>
<html>
<head>
<title>Flexbox CSS Centering Example</title>
</head>
<body>
<div id="parent-div">
<div id="child-div">
<h1>This is an example</h1>
</div>

Keybase proof

I hereby claim:

  • I am samwightt on github.
  • I am samwight (https://keybase.io/samwight) on keybase.
  • I have a public key ASAxWEa3p9ttSN7u22BWC0XEQ6A2BNUMXKtfwLlTVY1S8Qo

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 1EhhD4U6HTVJ5vFzvL5MnF5rstuZj5RfUu https://explorer.blockstack.org/address/1EhhD4U6HTVJ5vFzvL5MnF5rstuZj5RfUu