Skip to content

Instantly share code, notes, and snippets.

View JavascriptMick's full-sized avatar

JavascriptMick JavascriptMick

View GitHub Profile
@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)
@JavascriptMick
JavascriptMick / kuramoto.go
Created June 19, 2022 03:25
Simple Kuramoto simulation in Go
package main
import (
"fmt"
"math"
)
// The coupling constant, higher values tend to converge the model faster
const k_const float64 = .006
@JavascriptMick
JavascriptMick / README.md
Created December 28, 2021 02:29
Simple Python SQS Unordered Job Queue Implementation

Instructions

  1. Create an AWS account
  2. Create an SQS queue (standard type, not fifo)
  3. Ensure that the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set
  4. use requirements.txt to get requirements (no I'm not using Celery at all, this is just a cheat way of getting the right dependencies)
  5. See usage.py for how to enqueue jobs
  6. run the worker to... work

python3 worker.py