Skip to content

Instantly share code, notes, and snippets.

View luizbills's full-sized avatar

Luiz Bills luizbills

View GitHub Profile
@luizbills
luizbills / code.js
Created November 18, 2025 01:05
Draw random asteroid shape in Litecanvas
litecanvas({})
function init() {
framerate(1)
}
function draw() {
cls(0)
// linedash([10,5])
// circ(W/2, H/2, 150, 2)
@luizbills
luizbills / code.js
Created November 13, 2025 17:34
Rect with animated dashed border in Litecanvas
litecanvas({
width: 320,
autoscale: false
})
let offset = 0
let pos = vec(10, 10)
function tapped(x, y) {
vecSet(pos, x, y)
@luizbills
luizbills / code.js
Created October 4, 2025 13:26
Animated background using Litecanvas
let pos = {},
speed = 100,
ts = 32,
bg
litecanvas({
width: 320,
autoscale: 0
})
@luizbills
luizbills / .htaccess
Last active October 27, 2025 21:39
Hotlink protection for Apache or OpenLiteSpeed
# BEGIN HOTLINK PROTECTION
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|svg)$ - [NC,F,L]
@luizbills
luizbills / plugin-buttons.js
Last active September 19, 2025 14:25
Simple Litecanvas plugin to handle buttons/actions. Useful to multiple controls.
/**
* @version 1.1.0
*/
function pluginButtons(engine) {
let _btns
const buttons = (data) => {
_btns = data || {}
for (const [key, values] of Object.entries(_btns)) {
_btns[key] = values.map((v) => v.toLowerCase())
@luizbills
luizbills / platformer.js
Last active September 21, 2025 01:20
Simple platformer with Litecanvas + Utils
litecanvas({
width: 320,
autoscale: false
})
const J = 340 // jump force
const G = 550 // gravity
const TS = 32 // tile size
const p = {
pos: vec(32,0),
@luizbills
luizbills / code.js
Last active September 17, 2025 12:30
Function to catch and handle browser errors. Useful while developing a project.
/**
* Catch browser errors. Useful while developing.
*
* @author Luiz Bills <[email protected]>
* @licese MIT
* @version 1.2
*
* @param {(message: string, event: Event) => void} callback A function called when an error happens
* @returns {function} A function to remove the event listeners
*/
@luizbills
luizbills / index.html
Created August 19, 2025 23:31
Pico.css full page layout with accordions
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
>
@luizbills
luizbills / code.js
Last active August 6, 2025 23:48
Handle keyboard events in mobile devices (only tested on Android)
let str = ""
litecanvas()
// create a invisible input
const input = document.createElement("input")
document.body.append(input)
input.style.cssText = "position:absolute;transform:translate(-99999px,-99999px)"
function tapped(tapx, tapy) {
@luizbills
luizbills / code.js
Created July 17, 2025 01:12
Get the date in YYYY-MM-DD format
const date = () => {
const offset = (new Date()).getTimezoneOffset()
return new Date(Date.now() - (offset*60*1000)).toISOString().split('T')[0]
}