Navigation Menu

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 April 21, 2024 23:52
Draw a cube in canvas #litecanvas
litecanvas()
function init () {
loadScript('https://unpkg.com/@litecanvas/plugin-more-shapes/dist/dist.js', (res) => {
if (res) plugin(pluginMoreShapes)
})
size = 100
x = WIDTH/2 - size/2
y = HEIGHT/2 - size/2
@luizbills
luizbills / code.js
Created April 9, 2024 02:12
move points towards a angle #litecanvas #gamedev
litecanvas();
const max = 3
const dist = 360 / max
function init () {
x = CENTERX
y = CENTERY
a = 0
}
@luizbills
luizbills / code.php
Created February 14, 2024 16:58
Make a woocommerce coupon valid only in certain period of the day
<?php
/**
* @param bool $is_valid
* @param \WC_Coupon $coupon Coupon data.
* @return bool
*/
add_filter( 'woocommerce_coupon_is_valid', function ( $is_valid, $coupon ) {
if ( ! $is_valid ) return false;
@luizbills
luizbills / readme.md
Created December 14, 2023 23:20 — forked from xem/readme.md
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@luizbills
luizbills / main.php
Last active December 2, 2023 16:58
Custom shipping method for WooCommerce (minimal boilerplate required)
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Hooks
add_action( 'plugins_loaded', 'yourprefix_include_shipping_method' );
add_action( 'woocommerce_shipping_methods', 'yourprefix_register_shipping_method' );
@luizbills
luizbills / guide.md
Last active December 2, 2023 15:48
Manually install linux applications desktop files

Manually install linux applications desktop files

Create a desktop file:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/path/to/app/binary
@luizbills
luizbills / guide.md
Created December 2, 2023 15:42
Instalar manualmente aplicações no linux

Manually install linux applications desktop files

Create a desktop file:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/luiz/apps/GDevelop/GDevelop.AppImage
@luizbills
luizbills / code.js
Last active November 30, 2023 15:32
Kaboom.js - Tween Yoyo (go and back)
async function tweenYoyo (from, to, dur, setValue, easeFunc = null, repeat = Infinity) {
while(repeat > 0) {
await tween(
from,
to,
dur,
setValue,
easeFunc
);
await tween(
@luizbills
luizbills / code.js
Last active November 30, 2023 04:42
Kaboom.js - attack RPG-style
kaboom();
// debug.inspect = true
loadBean();
const player = add([
sprite('bean'),
pos(center()),
area(),
@luizbills
luizbills / code.php
Last active October 26, 2023 16:07
Programmatically populate the “Sale” product category with products on sale
<?php
/**
* Based on https://www.businessbloomer.com/woocommerce-sale-category-automatic/
*/
add_action( 'pre_get_posts', 'luizpb_wc_sale_category' );
function luizpb_wc_sale_category ( $query ) {
$term_slug = 'sale';
if ( $query->get( 'product_cat' ) !== $term_slug ) return;
$query->set( 'product_cat', null );