Skip to content

Instantly share code, notes, and snippets.

View JavascriptMick's full-sized avatar

JavascriptMick JavascriptMick

View GitHub Profile
@JavascriptMick
JavascriptMick / README.md
Last active January 19, 2025 15:43
RevenueCat Rest API V2 with Typescript
@JavascriptMick
JavascriptMick / myapimethod.post.ts
Created September 11, 2024 16:52
Accept gzipped json POST request in Nuxt3/H3
import { H3Event, readBody, eventHandler } from 'h3';
import { createGunzip } from 'zlib';
import { pipeline } from 'stream';
import { promisify } from 'util';
const pipelineAsync = promisify(pipeline);
export default eventHandler(async (event: H3Event) => {
let rawBody = '{}';
if (event.headers.get('content-encoding') === 'gzip') {
const { req } = event; // deprecated but it works... open to suggestion, readBody fails
@JavascriptMick
JavascriptMick / PostCode.vue
Created February 6, 2024 13:52
Nuxt3 postcode selector component with background fetch
<template>
<div class="relative">
<input
v-model="inputValue"
@keyup.prevent="fetchData"
type="text"
placeholder="Enter postcode"
class="border border-gray-300 rounded p-2 w-full" />
<div
v-if="postcodesForSelection.length > 0 && showDropdown"
@JavascriptMick
JavascriptMick / README.md
Last active January 28, 2024 02:08
Simple Tag List Component in Vue 3 and Tailwind

TagList Component

Vue 3 + tailwind

uses v-model remove tags by clicking x add new tags by typing and pressing space, comma, period

@JavascriptMick
JavascriptMick / invoke_vector_function_from_prisma.sql
Last active January 22, 2024 08:52
Invoke PostgreSQL function with vector parameter using Prisma $queryRaw
--I'm assuming you have already added the 'pgvector' extension to PostgreSQL (https://github.com/pgvector/pgvector)
--looks wierd but you invoke the function using select, representing the vector as a string literal..
select * from public.test_function('[1.03, 2.45, 3.56]', .06);
@JavascriptMick
JavascriptMick / persistent_storage_service.dart
Created November 19, 2023 09:49
Flutter - Persistent storage of a list of custom objects
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:convert';
class PersistentStorageService {
static Future<List<MyObject>> getMyObjects() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<String> jsonStringList = prefs.getStringList('my_objects') ?? [];
return [
for (var jsonString in jsonStringList)
MyObject.fromJson(jsonDecode(jsonString))
@JavascriptMick
JavascriptMick / cookieconsent.client.ts
Created September 13, 2023 09:09
Nuxt 3 Plugin for Cookie Consent (GDPR)
// plugins/cookieconsent.client.ts
// npm i vanilla-cookieconsent
// detail about config options.. https://github.com/orestbida/cookieconsent#installation--usage
import "vanilla-cookieconsent/dist/cookieconsent.css";
import "vanilla-cookieconsent/src/cookieconsent.js";
export default defineNuxtPlugin((nuxtApp) => {
// @ts-ignore
const cookieConsent = window.initCookieConsent();
@JavascriptMick
JavascriptMick / Modal.vue
Created May 13, 2023 14:27
Modal Component wrapper for Nuxt 3 + DaisyUI
<script lang="ts" setup>
/*
pre-requisites.. Tailwind + DaisyUI
setup...
import { ModalType } from '~~/components/modal.type';
const myCoolModal = ref<ModalType>();
myCoolModal.value!.open();
@JavascriptMick
JavascriptMick / Header.vue
Created May 12, 2023 13:39
Vue 3 Toast notifications using Pinia and DaisyUI
<script setup lang="ts">
import { storeToRefs } from 'pinia';
const notifyStore = useNotifyStore();
const { notifications } = storeToRefs(notifyStore);
</script>
<template>
....
<div class="toast toast-end toast-top">
<div v-for="notification in notifications" :class="notification.type">
@JavascriptMick
JavascriptMick / AllNotesOff.scpt
Created January 7, 2023 13:15
MidiPipe Apple script for fixing problematic 'All Notes Off' midi signals from older keyboards
My Keyboard was 'enveloping' each Note On message with an 'All Notes Off' message
— This resulted in shitty results, especially chords which were morphed into single notes
— This Script ignores the initial 'All Notes Off' message and morphs the second one into an appropriate 'Note Up' message
property noteonchannel : {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
on runme(message)
if (item 2 of message = 123) then — All Notes Off
copy ((item 1 of message) - 175) to channel
if (item channel of noteonchannel > 0) then
set item 1 of message to (127 + channel)
set item 2 of message to (item channel of noteonchannel)