Skip to content

Instantly share code, notes, and snippets.

View anthonyec's full-sized avatar
🐢
eat the food and live

Anthony Cossins anthonyec

🐢
eat the food and live
View GitHub Profile
@anthonyec
anthonyec / tooltip.jsx
Created April 17, 2023 10:05
Tooltip in Salad Room
import React, { useRef, useState } from 'react';
import { CSSTransition } from 'react-transition-group';
import TooltipBubble from './tooltip_bubble';
export default function Tooltip({ message, children }) {
const [showTooltip, setShowTooltip] = useState(false);
const childRef = useRef(null);
const child = React.Children.only(children);
@anthonyec
anthonyec / ts-pack-output.txt
Created April 13, 2023 20:21
TS Pack output for Vector2
🩺 Verifying Package.json...
Common JS Package Detected
✓ - Exports Common JS
✓ - Exported Common JS Correct File Extension
○ - Exports ES Module
○ - Exports Types for developers
Exporting types, while optional, aid developers who consume your library.
@anthonyec
anthonyec / composer.css
Last active April 1, 2023 20:14
Composer and text reference component
.composer {
background: white;
border-radius: 30px;
box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 4px 8px 0 rgba(0,0,0,0.21);
display: flex;
align-items: flex-end;
height: 60px;
position: relative;
transition: height 250ms cubic-bezier(0.45, 0, 0.55, 1);
}
@anthonyec
anthonyec / position.gd
Created March 25, 2023 17:48
Get mouse position relative to window in Godot
# Usually you can do:
get_viewport().get_mouse_position()
# For a window you can do:
@onready var window: Window = %Window
window.get_mouse_position()
@anthonyec
anthonyec / gamepad_debugger.gd
Last active June 23, 2026 09:23
Godot gamepad input visualisation for debugging (GDScript 2)
@tool
extends Control
@export var device: int = 0
func _process(delta: float) -> void:
queue_redraw()
func _draw() -> void:
# Set the size, the layout isn't dynamic and based on something I sketched!
@anthonyec
anthonyec / requestAnimationFrame.js
Created December 12, 2022 16:19
Request animation frame instead of setInterval
const FPS = 60;
let lastFrameTime = 0;
function update() {
const diff = Date.now() - lastFrameTime;
if (diff > (1000 / FPS)) {
// DO STUFF HERE.
@anthonyec
anthonyec / alternate.test.ts
Last active October 17, 2022 14:54
Alternate indices generator
describe("alternate", () => {
it("counts up when starting index is at the start", () => {
expect(Array.from(alternate(0, 10))).toStrictEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
})
it("counts down indices when starting index is at the end", () => {
expect(Array.from(alternate(10, 10))).toStrictEqual([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])
})
it("counts up when starting index is negatively out of bounds", () => {
@anthonyec
anthonyec / tween_and_yield.gd
Created September 4, 2022 11:10
Tween and yield
var tween = create_tween()
tween.set_trans(Tween.TRANS_SINE)
tween.tween_property(foot, "translation", home.transform.origin, move_duration)
yield(tween, "finished")
@anthonyec
anthonyec / journalctl_commands.md
Created March 21, 2022 09:49
Useful commands for getting logs off a remote server

Export all logs to a file

journalctl > all_logs.txt

Download logs from remote server

scp : 
const getDifferenceBetweenAmounts = (transactionA, transactionB) => {
return Math.abs(transactionA.amount - transactionB.amount);
};
const categorizeSimilarTransactions = (transactions) => {
return transactions.map((transaction) => {
if (transaction.category) {
return transaction;
}