Skip to content

Instantly share code, notes, and snippets.

View AmazingTurtle's full-sized avatar
🐢
turtle on SPEED

Felix AmazingTurtle

🐢
turtle on SPEED
View GitHub Profile
@AmazingTurtle
AmazingTurtle / gist:dc4c20c5d2c170553796
Created April 6, 2015 16:32
c# not disposing new parameter
namespace Disposetest
{
class test : IDisposable
{
public void Dispose()
{
Console.WriteLine("disposing");
}
}
using System;
using System.Linq;
using System.Threading.Tasks;
using TWRC.Network;
using TWRC.Network.Handler;
using Dapper;
namespace TWRC.Game.Network.Handler
{
public class JoinServer : HandlerBase<Client.VirtualClient>
@AmazingTurtle
AmazingTurtle / ThrottlePlugin.cs
Created October 1, 2016 13:51 — forked from coryt/ThrottlePlugin.cs
ServiceStack plugin to throttle api requests
public class ThrottlePlugin : IPlugin
{
/// <param name="redisHost">host name</param>
/// <param name="redisPort">port</param>
/// <param name="redisPassword">password</param>
public ThrottlePlugin(string redisHost, int redisPort, string redisPassword = null)
{
_redisClient = new RedisClient(redisHost, redisPort, redisPassword);
}
import {AuthenticationError} from '../errors/authenticationError';
export default (app) => {
app.use((error, request, response, next) => {
if (error || response.sentry) { // using Sentry in my specific case aswell
if (error instanceof AuthenticationError) {
response.statusCode = 401;
response.end(
JSON.stringify({
{
"openapi": "3.0.0",
"info": {
"title": "redacted",
"description": "The redacted API description",
"version": "1.0",
"contact": {}
},
"tags": [],
"servers": [],
@AmazingTurtle
AmazingTurtle / icao-transliteration.ts
Last active January 31, 2022 12:35
ICAO MRZ Transliteration (by ICAO Doc 9303 Part 3)
// spec can be found here:
// https://www.icao.int/publications/Documents/9303_p3_cons_en.pdf
// prettier-ignore
// noinspection NonAsciiCharacters
const transliterationMapping: Record<number, string|string[]> = {
0x0020: '<',
0x002C: '<',
0x002D: '<',
0x00C0: 'A',
@AmazingTurtle
AmazingTurtle / config.ts
Created July 7, 2021 11:17
openai client
export const DEFAULT_ENGINE = 'davinci';
export const ENGINE_LIST = ['ada', 'babbage', 'curie', 'davinci', 'davinci-instruct-beta', 'curie-instruct-beta'];
export const ORIGIN = 'https://api.openai.com';
export const DEFAULT_API_VERSION = 'v1';
export const DEFAULT_OPEN_AI_URL = `${ORIGIN}/${DEFAULT_API_VERSION}`;
@AmazingTurtle
AmazingTurtle / command-complete.tsx
Created January 16, 2023 16:10
A customizable command autocompletion react component with arrow navigation and history
import React, {
ChangeEvent,
KeyboardEvent,
forwardRef,
HTMLAttributes,
InputHTMLAttributes,
useCallback,
useMemo,
useState,
FocusEvent,
@AmazingTurtle
AmazingTurtle / router-patch.tsx
Created December 8, 2024 10:30
NextJS App Router NProgress Compatibility Patch
'use client';
import { useEffect } from 'react';
import type { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';
import { usePathname, useRouter } from 'next/navigation';
import * as NProgress from 'nprogress';
export function RouterPatch() {
const router = useRouter();
const pathname = usePathname();
@AmazingTurtle
AmazingTurtle / @hey-api+client+fetch+0.8.1.patch
Created March 2, 2025 18:55
Patch for @hey-api/client-fetch security schemes
diff --git a/node_modules/@hey-api/client-fetch/dist/index.cjs b/node_modules/@hey-api/client-fetch/dist/index.cjs
index 747c765..0dcebb4 100644
--- a/node_modules/@hey-api/client-fetch/dist/index.cjs
+++ b/node_modules/@hey-api/client-fetch/dist/index.cjs
@@ -1,2 +1,2 @@
-'use strict';var A=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e},z=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},j=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},$={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>z(r,e,i)):z(r,e,a));}),r}},b={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},k={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,a])=>{a!=null&&(Array.isArray(a)?a.forEach(i=>j(r,e,i)):j(r,e,a));}),r.toString()}},U=t=>{switch(t){c