Skip to content

Instantly share code, notes, and snippets.

@CallumVass
CallumVass / anthropic.ts
Last active April 25, 2024 20:46
Haiku structured data - My own implementation of instructor for Haiku
import Anthropic from "@anthropic-ai/sdk";
import type { MessageParam } from "@anthropic-ai/sdk/resources";
import dotenv from "dotenv";
import { Instructor } from "./instructor";
import type { z } from "zod";
dotenv.config();
function sendToClaude<T>(message: MessageParam, schema: z.Schema<T>) {
const anthropicClient = new Anthropic({
@CallumVass
CallumVass / Program.cs
Created December 1, 2023 08:08
Wordpress To Markdown
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using HtmlAgilityPack;
const string baseUrl = "https://YOUR_DOMAIN_HERE";
// I know my site only had 14 pages, adjust accordingly
const int maxPageTraversal = 14;
var root = Directory.GetCurrentDirectory();
var converter = new ReverseMarkdown.Converter();
@CallumVass
CallumVass / middleware.go
Last active October 14, 2023 18:42
Go - Function vs Method
package main
import (
"context"
"net/http"
"github.com/alexedwards/scs/v2"
)
type application struct {
@CallumVass
CallumVass / migrator.fsx
Created July 29, 2021 14:36
Migration POC
#r "nuget: System.Data.SqlClient"
open System.Data
open System.Data.SqlClient
type Types =
| String
| Int
type Action =
@CallumVass
CallumVass / ES.fs
Last active February 3, 2021 19:04
open System
open System.Collections.Generic
type ProductShipped =
{ Sku: string
Quantity: int
DateTime: DateTime }
type ProductReceived =
{ Sku: string
@CallumVass
CallumVass / Result.ts
Created September 17, 2020 14:22
TS/F#
export interface ErrorValue {
ErrorValue: string;
}
export interface ResultValue<T> {
ResultValue: T;
}
export interface ErrorResult {
Case: "Error";
module Nav
open Feliz
open Feliz.Router
let nav =
let logo () = StaticFile.import "./imgs/logo.png"
Html.aside [ prop.className "relative bg-blue-700 lg:self-stretch lg:w-64 w-full shadow-xl flex flex-col"
prop.children [ Html.div [ prop.className "p-6 flex justify-between"
prop.children [ Html.a [ prop.href "/"
time1 will return the time the server started and won't change, ie will always be 27/06/2020 18:16:59
time2 will work as I expected it to work, showing the current time the page was loaded
"use strict";
require("angular");
require("angular-route");
var home = require("./controllers/home");
var testService = require("./services/testService");
angular.module("app", ["ngRoute"])
.config(function ($routeProvider) {
$routeProvider.when("/", {
@CallumVass
CallumVass / structure
Created July 24, 2014 08:53
Typical Angular Project Structure
|-- app.js
|-- common/
| |-- common.js
| |-- directives/
| | |-- someCommonDirective.js
| | |-- someOtherCommonDirective.js
|-- customers/
| |-- customerList.js
| |-- customerList.html
| |-- customerCreate.js