Skip to content

Instantly share code, notes, and snippets.

View luizbills's full-sized avatar
I may be slow to respond.

Luiz Bills luizbills

I may be slow to respond.
View GitHub Profile
@luizbills
luizbills / code.js
Created August 23, 2025 15:15
Function to handle any browser error. Useful while developing a project.
/**
* Handle any browser error. Useful while developing.
*
* @author Luiz Bills <[email protected]>
* @licese MIT
* @version 1.1
*
* @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]
}
@luizbills
luizbills / code.js
Last active August 1, 2025 21:39
Roguelike tutorial with Litecanvas + ROT.js
// Rot.js' Roguelike tutorial with Litecanvas: https://roguebasin.com/index.php/Rot.js_tutorial
// Copy and paste this code in https://litecanvas.js.org/
litecanvas({
width: 640,
loop: { init, update, draw },
})
let mapSize = { w: 40, h: 30 },
map = {},
@luizbills
luizbills / readme.md
Last active July 15, 2025 14:41
Tutorial: Pixel Manipulation in Litecanvas

Pixel Manipulation in Litecanvas

Include these two functions

function loadPixels() {
  const imageData = ctx().getImageData(0, 0, W, H);
  const pixels = imageData.data
  pixels.parent = imageData
  return pixels
@luizbills
luizbills / code.js
Last active July 11, 2025 17:28
How to detect "double taps" (ou double click) in Litecanvas
litecanvas();
use(pluginDoubleTap)
const actor = {}
function init() {
actor.x = W/2
actor.y = H/2
@luizbills
luizbills / code.js
Created July 10, 2025 23:48
How to detect "swipe" gesture in Litecanvas
litecanvas();
const taps = new Map()
const actor = {}
function init() {
actor.x = W/2
actor.y = H/2
// on "swipe" move our actor
@luizbills
luizbills / code.js
Last active June 15, 2025 21:39
Abilty/skill cooldown in litecanvas
litecanvas()
const DURATION = 2 // cooldown duration in seconds
let cooldown = 0 // current cooldown (0 = off)
let buttonSize
function init() {
buttonSize = W/8
}
@luizbills
luizbills / code.php
Created May 21, 2025 14:01
Multiple admin emails for WordPress
<?php
/**
* Multiple administrator emails
* @author Luiz Bills
*/
add_filter( 'option_admin_email', function ( $value ) {
global $pagenow;
$ignored_pages = [ 'options-general.php' ];
if ( in_array( $pagenow, $ignored_pages, true ) ) {