Skip to content

Instantly share code, notes, and snippets.

View ghostdevv's full-sized avatar
🍋
Well, when, life, gives, you, lemons;

Willow (GHOST) ghostdevv

🍋
Well, when, life, gives, you, lemons;
View GitHub Profile
@ghostdevv
ghostdevv / script.js
Last active August 13, 2022 14:09
Ender Translator
{const ender_chars='⏃⏚☊⎅⟒⎎☌⊑⟟⟊☍⌰⋔⋏⍜⌿☌⍀⌇⏁⎍⎐⍙⌖⊬⋉'.split('');const eng_to_ender=Object.fromEntries('abcdefghijklmnopqrstuvwxyz'.split('').map((c,i)=>[c,ender_chars[i]]));const ender_to_eng=Object.fromEntries(Object.entries(eng_to_ender).map((x)=>x.reverse()));const to_ender=(c)=>eng_to_ender[c]??c;const to_eng=(c)=>ender_to_eng[c]??c;const translate=(str,fn)=>str.split('').map(fn).join('');function run(){const elements=document.querySelectorAll('[id^=message-content]:not([data-ender-parsed=true])',);for(const element of elements){element.innerHTML=element.innerHTML.replace(new RegExp(`[${ender_chars.join('')} ,.!?\\-;']+`,'gi'),(match)=>{return ender_chars.some((c)=>match.includes(c))?`<span title="${translate(match,to_eng)}">${ match }</span>`:match},);element.dataset.enderParsed='true'}}setInterval(run,1000);const template=`<form id="ender-translation-form"><input id="ender-translaion" name="text" required /><button type="submit">Translate</button></form>`;const element=document.createElement('div');element.in
@ghostdevv
ghostdevv / +page.server.js
Created October 3, 2022 13:09 — forked from stephane-vanraes/+page.server.js
Multi step forms with SvelteKit and actions
export const actions = {
first: async ({ request }) => {
const data = Object.fromEntries(await request.formData());
console.log('first', data);
return {
data,
step: 2
};
},
second: async ({ request }) => {
@ghostdevv
ghostdevv / ReorderableList.svelte
Last active December 10, 2022 05:27
Svelte Reorderable list
<script lang="ts">
import { faGripLines } from '@fortawesome/free-solid-svg-icons';
import Fa from 'svelte-fa';
type List = $$Generic<Array<any>>;
export let list: List;
let hovering: number | null = null;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
document.write(`<pre>${JSON.stringify({ width: window.innerWidth, height: window.innerHeight }, null, 2)}</pre>`)
@ghostdevv
ghostdevv / tsconfig.json
Created December 7, 2023 23:22
simple tsconfig
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "node16",
"moduleResolution": "node16", // or bundler depending
"allowSyntheticDefaultImports": true
@ghostdevv
ghostdevv / README.md
Last active January 12, 2024 19:16
CC Turtle Fuel Command

Fuel Command

Simple command to check the fuel level of the turtle.

Installation

wget https://gist.githubusercontent.com/ghostdevv/366cce6995906d6dce8b15ca13a8aad4/raw/8085d548d0ab634cc22dfc24bd98350989e4d9e6/fuel.lua
@ghostdevv
ghostdevv / theme.css
Created May 23, 2024 18:23
test revealjs theme
/**
* A simple theme for reveal.js presentations, similar
* to the default theme. The accent color is darkblue.
*
* This theme is Copyright (C) 2012 Owen Versteeg, https://github.com/StereotypicalApps. It is MIT licensed.
* reveal.js is Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
*/
@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap");
section.has-dark-background, section.has-dark-background h1, section.has-dark-background h2, section.has-dark-background h3, section.has-dark-background h4, section.has-dark-background h5, section.has-dark-background h6 {
color: #fff;
@ghostdevv
ghostdevv / flat.ts
Created November 21, 2024 01:50
flat array
function flat<T extends any[], D extends number = 1>(array: T, depth?: D): FlatArray<T, D>[] {
return typeof depth == 'undefined' || depth > 0
? array.reduce((a, x) => a.concat(Array.isArray(x) ? flat(x, (depth ?? 1) - 1) : x), [])
: array
}
@ghostdevv
ghostdevv / install.sh
Last active November 30, 2024 23:22
pi-install
#!/bin/bash
set -e
echo Updating
sudo apt update
if ! command -v jq &> /dev/null; then
echo Installing jq
sudo apt-get install jq