Skip to content

Instantly share code, notes, and snippets.

View dimorphic's full-sized avatar
🤖
*void 0*

Sabin Tudor dimorphic

🤖
*void 0*
View GitHub Profile
@dimorphic
dimorphic / anthropic.ts
Created May 7, 2024 07:34 — forked from CallumVass/anthropic.ts
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({
#!/bin/bash
set -e
######################################################################
# This Bootstrap Script installs Dokku latest on Ubuntu (use LTS or latest)
#
# This script also installs UFW (firewall), some basic Dokku plugins, and
# raises ulimits. Comment out any step you wish to skip.
#
# IMPORTANT: This script also disables password authentication via SSH for
@dimorphic
dimorphic / umbrellactl
Created March 7, 2024 18:39 — forked from jasmas/umbrellactl
umbrellactl: Bash script to check status, enable or disable Cisco Umbrella Roaming Security Module for AnyConnect on MacOS
#!/usr/bin/env bash
PLUGIN_BASE='/opt/cisco/secureclient/bin/plugins'
read -r -d '' USAGE << EGASU
Usage: `basename $0` [-s|-e|-d|-h]
-s, --status Print Umbrella Roaming Security module status
-e, --enable Enable Umbrella Roaming Security module
-d, --disable Disable Umbrella Roaming Security module
@dimorphic
dimorphic / gist:2e9f1b800dd46096e1f2d2c3e832248d
Created February 13, 2024 21:02 — forked from EricReiche/gist:3621855
Gource multi repo script
#!/usr/bin/env bash
# Generates gource video (h.264) out of multiple repositories.
# Pass the repositories in command line arguments.
# Example:
# <this.sh> /path/to/repo1 /path/to/repo2
# 960x540 is youtube resolution
RESOLUTION="960x540"
outfile="gource.mp4"
i=0
@dimorphic
dimorphic / HttpStatusCode.ts
Created November 25, 2022 14:34 — forked from scokmen/HttpStatusCode.ts
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body
@dimorphic
dimorphic / ultimate-ut-cheat-sheet.md
Created March 22, 2021 14:37 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@dimorphic
dimorphic / index.html
Created August 30, 2017 21:21 — forked from stesie/index.html
AWS IoT-based serverless JS-Webapp Pub/Sub demo
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>AWS IoT Pub/Sub Demo</title>
</head>
<body>
<h1>AWS IoT Pub/Sub Demo</h1>
<form>
<button type="button" id="connect">connect!</button>
@dimorphic
dimorphic / blob-filereader-localStorage.js
Created December 28, 2016 16:05 — forked from robnyman/blob-filereader-localStorage.js
Get file as a blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR and FileReader objects
var xhr = new XMLHttpRequest(),
@dimorphic
dimorphic / core.js
Created September 19, 2016 10:03 — forked from RobK/core.js
Generating AWS HMAC in Nodejs (RFC 2104 compliant HMAC)
var crypto = require("crypto");
/**
* Get the signature/digest of a supplied input string
* @param data [Required] The String to encode
* @param awsSecretKey [Required] Secret key shared with Amazon
* @param algorithm [Optional] Encryption algorithm, defaults to sha256
* @param encoding [Optional] The output encoding. Default to base64
* @returns Str with encoded digest of the input string
*/
function generateHmac (data, awsSecretKey, algorithm, encoding) {
@dimorphic
dimorphic / better-nodejs-require-paths.md
Created September 3, 2016 17:03 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions