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 / 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 / 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
<!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 / 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;
@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 / 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 / readme.md
Created March 21, 2022 15:46
Convert any js project to rust in 0.1ms

The following command will change 'use strict' to 'use rust'!

find . -name "*.js" -type f ! -path "*/node_modules/*" -exec sed -i "s/'use strict'/'use rust'/g" {} +

Example

Before we have a slow, legacy js project

@ghostdevv
ghostdevv / testing.md
Last active January 29, 2022 18:59
Testing zx

Hello

  1. First lets cd onto desktop
cd ~/Desktop
  1. Now lets create a folder called cheese and enter it
@ghostdevv
ghostdevv / router-state.md
Last active August 17, 2021 19:58
Type safe state in a file based router

Type safe state in a file based router

Here is the golden question, imagine we have a file based routing solution and we want state. Say to pass down the database connection, or some auth guards to avoid the ../../... hell. Whatever it is it needs to be easy to use and type safe

Say we have this:

import Router from 'packge';

const router = new Router('src/routes');