Skip to content

Instantly share code, notes, and snippets.

@ciscoheat
ciscoheat / +layout.server.ts
Last active September 1, 2023 21:05
Superforms with sveltekit-flash-message
export { load } from 'sveltekit-flash-message/server';
@ciscoheat
ciscoheat / +page.server.ts
Created July 5, 2023 20:43
Rate limiter for SvelteKit
import { RateLimiter } from 'sveltekit-rate-limiter/server';
import { superValidate } from '$lib/server';
import { setFlash } from 'sveltekit-flash-message/server';
import { fail } from '@sveltejs/kit';
import type { Actions } from '@sveltejs/kit';
import { schema as contactSchema } from './schema.js';
const limiter = new RateLimiter({
rates: {
@ciscoheat
ciscoheat / +page.server.ts
Created May 21, 2023 19:11
Checkbox validation test for Superforms
import type { Actions, PageServerLoad } from './$types';
import { superValidate } from 'sveltekit-superforms/server';
import { schema } from './schemas';
export const load = (async () => {
const form = await superValidate(schema);
return { form };
}) satisfies PageServerLoad;
export const actions = {
@ciscoheat
ciscoheat / rimraf.bat
Last active May 11, 2023 06:46
Batch file version of deleting large directories on Windows: https://stackoverflow.com/a/6208144/70894
@echo off
IF "%1" == "" (
echo Usage: rimraf ^[^/f^|-f^|--force^] dir
EXIT /B 1
)
IF "%1" == "/f" GOTO rimraf
IF "%1" == "/F" GOTO rimraf
IF "%1" == "-f" GOTO rimraf
@ciscoheat
ciscoheat / APIError.ts
Last active October 31, 2022 21:11
Javascript APIError class based on RFC7807
import type { Problem } from './Problem'
/**
* Javascript error class based on RFC7807.
* @link https://www.rfc-editor.org/rfc/rfc7807
*/
export class APIError extends Error implements Problem {
type: string;
title?: string;
status?: number;
### Keybase proof
I hereby claim:
* I am ciscoheat on github.
* I am ciscoheat (https://keybase.io/ciscoheat) on keybase.
* I have a public key whose fingerprint is A969 E858 3A9F B743 FE09 8EC0 9E88 8154 F58D CFB3
To claim this, I am signing this object:
@ciscoheat
ciscoheat / Log.hx
Created July 24, 2018 07:46
Haxe logging with nodejs, js-kit and papertrail
#if nodejs
import haxe.Timer;
import js.Node;
import js.node.Path;
import js.npm.Winston;
import js.npm.winston.transports.Console;
import js.npm.winston.transports.File;
#if !no_papertrail
import js.npm.winston.transports.Papertrail;
#end

Keybase proof

I hereby claim:

  • I am ciscoheat on github.
  • I am ciscoheat (https://keybase.io/ciscoheat) on keybase.
  • I have a public key whose fingerprint is E709 AD73 FCD9 B916 60D9 1D3B E9B6 A3C2 24D2 5822

To claim this, I am signing this object:

@ciscoheat
ciscoheat / jot.bat
Last active February 3, 2017 02:46
Jot - Quick creation and execution of Haxe files
@echo off
setlocal enabledelayedexpansion
if [%1]==[] goto usage
if [%1]==[init] goto init
if [%1]==[watch] goto watch
for %%i in ("%1") do (
set filepath=%%~di%%~pi
set filename=%%~ni
@ciscoheat
ciscoheat / Routes.hx
Last active August 26, 2016 19:51
Typesafe web routes with Haxe in less than 100 lines
// Code for this article:
// https://github.com/ciscoheat/mithril-hx/wiki/Typesafe-web-routes-with-Haxe-in-less-than-100-lines
#if macro
import haxe.Serializer;
import haxe.Unserializer;
import haxe.macro.Context;
import haxe.macro.Expr;
import sys.io.File;