Post data to a PHP endpoint and dynamically display a response with Alpine.js
<html x-data="utility">
<!-- ... -->
{ | |
"[javascriptreact]": { | |
"editor.defaultFormatter": "vscode.typescript-language-features" | |
}, | |
"[typescriptreact]": { | |
"editor.defaultFormatter": "vscode.typescript-language-features" | |
}, | |
"editor.bracketPairColorization.enabled": false, | |
"editor.cursorBlinking": "phase", | |
"editor.cursorSmoothCaretAnimation": "on", |
:root { | |
font-size: max(calc(16vmin * 100 / 1440), 16px); | |
} | |
*:where(:not(iframe, canvas, img, svg, video):not(svg *)) { | |
all: unset; | |
display: revert; | |
outline: revert; | |
} |
const sticker = (set: string[], canvas: HTMLElement | null) => { | |
let z = 0; | |
if (canvas) { | |
canvas.onclick = (event: MouseEvent) => { | |
let randomImage = set[Math.floor(Math.random() * set.length)]; | |
let randomRotation = Math.random() * (45 - -45) + -45 | |
const element = document.createElement('img'); |
export const drag = (elements: NodeListOf<HTMLElement>) => { | |
let z = 0; | |
if (elements) { | |
for (const element of elements) { | |
let [adjustedX, adjustedY, currentX, currentY] = [0, 0, 0, 0]; | |
let moved = false; | |
const dragMouseUp = (event: MouseEvent) => { | |
document.onmousemove = null; |
const rasterGlobe = (limit = 1000, x1 = -180, y1 = -180) => { | |
type Coordinates = { x: number; y: number }; | |
let base = Math.pow(limit, 1 / 2); | |
let root = Math.floor(base); | |
let data: Array<Coordinates> = []; | |
const rasterLine = (x2: number) => { | |
for (let i = 0; i < root; i++) { | |
let y = y1 + ((y1 * -2) / (root - 1)) * i; |
<?php | |
$response = (object) []; | |
$json = json_decode(file_get_contents('php://input')); | |
//... | |
if (!$json) { | |
$response->state = [ | |
'code' => 400, |
# https://github.com/nvm-sh/nvm | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
# https://github.com/zsh-users/zsh-autosuggestions | |
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh | |
# https://starship.rs/ | |
eval "$(starship init zsh)" |
format = """ | |
$directory\ | |
[](fg:#4f46e5 bg:#4338ca)\ | |
$git_branch\ | |
$git_status\ | |
[](fg:#4338ca bg:#3730a3)\ | |
$nodejs\ | |
$rust\ | |
$golang\ | |
$php\ |
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js"; | |
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js"; | |
import { | |
AnimationMixer, | |
Clock, | |
Color, | |
DirectionalLight, | |
HemisphereLight, | |
PerspectiveCamera, |