Skip to content

Instantly share code, notes, and snippets.

View luizbills's full-sized avatar

Luiz Bills luizbills

View GitHub Profile
@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 / README.md
Created July 18, 2023 12:56 — forked from franciscocpg/README.md
How to move the default /var/lib/docker to another directory for Docker on Linux

Take note that you can use this approach to move the /var/lib/docker directory to another disk or partition. Just make sure you create the destination directory in this new disk or partition.

  • Stop the server:
sudo systemctl stop docker
  • Create/edit the configuration at /etc/docker/daemon.json, for example:
{
@luizbills
luizbills / wc_order_status_changes.php
Created September 19, 2022 14:06 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@luizbills
luizbills / __upload_file.md
Created March 9, 2022 19:07 — forked from maxivak/__upload_file.md
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");
@luizbills
luizbills / animate-browser-title.js
Created December 10, 2021 14:25 — forked from mbohanon/animate-browser-title.js
Animate title text when page tab is not active in browser (onblur), this is NOT a marquee. To see example visit http://SHEmedia.us
//Here's an eye catching example to get your visitors back when your web page tab is not active within the browser (onblur). This script will animate the original title text with an intro, the original title text is restored when the tab is returned to active state (focus). When the tab is clicked the original page title is restored. For social media sharing it is highly recommended to include the original page title text with the prefaced animated text (onblur).
//Created by SHEmedia.us
window.jQuery(function($) {
var origTitle, animatedTitle, timer;
function animateTitle(newTitle) {
var currentState = false;
origTitle = document.title; // save original title
<?php
/*
* Create order dynamically
*/
add_action( 'woocommerce_before_checkout_form', 'create_order' );
function create_order() {
global $woocommerce;
@luizbills
luizbills / instagram.php
Last active February 8, 2019 16:54 — forked from taciara/instagram.php
Integração Instagram
<?php PRECISO QUE TENHA:FOTO/NUMERO DE CURTIDA / NUMERO DE COMENTARIO / DESCRICAO ?>
<?php
//SHORTCODE INSTAGRAM
add_filter( 'wpis_default_shortcode_attributes', 'custom_wpis_instagram_access_token' );
function custom_wpis_instagram_access_token ( $atts ) {
$atts['token'] = '2195092261.1677ed0.f7e6b044cdc54b859d0f9413e0e404c6';
return $atts;
}
@luizbills
luizbills / code.php
Last active August 11, 2018 20:33 — forked from mikejolley/gist:2044101
WooCommerce - Show number of items in cart, weight and total
<?php
$cart = WC()->cart;
$weigth_unit = 'kg';
$items = sprintf( _n( '%d item', '%d items', $cart->get_cart_contents_count() ), $cart->get_cart_contents_count() );
$weight = wc_get_weight( $cart->get_cart_contents_weight(), $weigth_unit ) . $weigth_unit;
$total = $cart->get_cart_total();
?>
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>">
<?php echo "$items - $weight - $total"; ?>
</a>
@luizbills
luizbills / functions.php
Created September 18, 2017 15:25 — forked from WooForce/functions.php
Introduce vendor names along with standard labels across shipping packages
define("PV_ATTRIBUTE", "vendor");
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Check if WooCommerce is active
*/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
if ( ! class_exists( 'TH_Shipping_Options' ) ) {
class TH_Shipping_Options {
/**
@luizbills
luizbills / functional-utils.js
Created January 13, 2016 01:05 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)