Skip to content

Instantly share code, notes, and snippets.

@andrebrait
andrebrait / keychron_linux.md
Last active May 10, 2024 20:07
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@ajskelton
ajskelton / wp-external-image-handler.php
Last active March 15, 2022 04:47
WordPress External Image Handler - Add External URL image as featured image for a post
/**
* Uploads an image from remote url and sets as featured image of the new post
*
* @param int $post_id The id of the new post
* @param string $thumbnail_url Url of the preview image hosted by BrightTalk
*/
private function image_handler( $post_id, $thumbnail_url ) {
$image_url = $thumbnail_url; // Define the image URL here
$image_name = basename( $thumbnail_url );
Reload .bashrc without logging out and back in:
==============================================
Two ways to do this:
1- source ~/.bashrc (or . ~/.bashrc)
2 - exec bash
With this, you won't even have to type "source ~/.bashrc":
Include your bashrc file:
@Auke1810
Auke1810 / use-parent-description-for-product-variations.php
Last active July 14, 2020 11:03
Use parent description for product variations. By default the woocommerce product feed manager will use the description from the product variation. This code will make sure you use the parent product description for every product variation.
/**
* Use parent description for product variations
*/
function use_parent_description_for_product_variations( $data, $feed_id, $product_id ) {
$wc_product = wc_get_product( $product_id );
if ( $wc_product && ( $wc_product instanceof WC_Product_Variation || $wc_product instanceof WC_Product_Variable ) ) {
$parent_id = $wc_product->get_parent_id( 'feed' );
$wc_parent = wc_get_product( $parent_id );
@jez500
jez500 / package.json
Created December 26, 2018 11:32
Simple Webpack 4 Compile SCSS to CSS config with autoprefix and minify
{
"name": "my-project",
"version": "1.0.0",
"description": "Simple SCSS complie with autoprefix and minify",
"scripts": {
"build": "webpack"
},
"devDependencies": {
"autoprefixer": "^9.0.0",
"breakpoint-sass": "^2.7.1",
@akshuvo
akshuvo / WordPress Repeater MetaBox.php
Last active April 18, 2024 09:23
Creating a “repeater meta-box” without a Plugin in WordPress
<?php
add_action('admin_init', 'gpm_add_meta_boxes', 2);
function gpm_add_meta_boxes() {
add_meta_box( 'gpminvoice-group', 'Custom Repeatable', 'Repeatable_meta_box_display', 'page', 'normal', 'default');
}
function Repeatable_meta_box_display() {
global $post;
$gpminvoice_group = get_post_meta($post->ID, 'customdata_group', true);
@ccurtin
ccurtin / get-a-users-public-ip-address.js
Last active August 17, 2020 21:41
Get User's Public IP Address
// FREE: no request linit for ipify.org
var request = new XMLHttpRequest()
var ipAddress = ''
request.open('GET', "https://api.ipify.org?format=jsonp=", true)
var ipAddress = request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
return ipAddress = request.responseText
} else {
// We reached our target server, but it returned an error
@felipemarcos
felipemarcos / wp-cpf-login.php
Last active July 3, 2023 15:12
Permitir login por CPF - WordPress
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Plugin Name: Login por CPF
* Description: Permite o usuário se logar utilizando o CPF.
* Author: Felipe Marcos
* Author URI: https://felipe.zip
* License: GNU General Public License v3 or later
@Auke1810
Auke1810 / wpa-clean-header.php
Last active May 9, 2024 14:14
create a clean wordpress header and remove unnecessary clutter.
<?php
/*
Plugin Name: wordpress assist clean header
Plugin URI: http://www.wordpressassist.nl/
Description: Remove shortlink hook
Version: 1.0
Author: AukeJomm
Author URI: http://www.aukejongbloed.nl
*/
@egoens
egoens / ssh-add.md
Last active March 18, 2024 19:13
Use this if ssh key keeps asking for password