Skip to content

Instantly share code, notes, and snippets.

@theodorejb
theodorejb / convert_array_access_braces.php
Last active September 18, 2025 10:29
Migrate deprecated curly brace array access syntax to bracket syntax. Requires PHP 7.4.
<?php
error_reporting(E_ALL);
$opts = getopt('f:d:rb:', ['ext:', 'php:', 'diff::']);
if ((int)isset($opts['d']) + (int)isset($opts['f']) !== 1) {
$self = basename(__FILE__);
echo <<<EOF
Usage:
php $self -f<php_script> [-b] [--php <path_to_php>] [ --diff [<file>]]
@maddisondesigns
maddisondesigns / functions.php
Last active August 5, 2025 09:32
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@ErikAugust
ErikAugust / spectre.c
Last active October 7, 2025 15:37
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@stuartduff
stuartduff / wc-exclude-product-category-from-shop-page.php
Last active May 6, 2022 00:20
This snippet will exclude all products from any categories which you choose from displaying on the WooCommerce Shop page.
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'clothing' ), // Don't display products in the clothing category on the shop page.
'operator' => 'NOT IN'
);
@ashvayka
ashvayka / attributes-demo.js
Last active August 25, 2022 21:17
Thingsboard Attributes API demo application
// Requires node.js and mqtt library installed.
var mqtt = require('mqtt');
var os = require("os");
const thingsboardHost = "demo.thingsboard.io";
// Reads the access token from arguments
const accessToken = process.argv[2];
// Default topics. See http://thingsboard.io/docs/reference/mqtt-api/ for more details.
const attributesTopic = 'v1/devices/me/attributes';
@joseconstela
joseconstela / hosts
Last active July 6, 2025 20:38
Prevent OSX calling home
################################################################################
# Prevent OSX calling home #
# #
# Mix of different /etc/hosts files found over internet, and calls filtered #
# using LittleSnitch for months. #
# #
# OSX sends a huge amount of requests to Cuppertino, even when you don't use #
# Spotlight suggestions, iCloud, updates and other services. Even if they are #
# disabled. #
# #
@claudiosanches
claudiosanches / functions.php
Last active September 1, 2025 08:18
WooCommerce - Hide the "In stock" message on product page.
<?php
/**
* Hide the "In stock" message on product page.
*
* @param string $html
* @param string $text
* @param WC_Product $product
* @return string
*/
function my_wc_hide_in_stock_message( $html, $text, $product ) {
@charlesbrandt
charlesbrandt / auth.py
Created July 19, 2015 12:33
Take pictures from directory and post them to a tumblr blog as a photoset (single post). This was adapted from: https://gist.github.com/velocityzen/1242662 Multiple photos in a photoset was adapted from: https://gist.github.com/derekg/1198576
import urlparse
import oauth2 as oauth
consumer_key = ''
consumer_secret = ''
request_token_url = 'http://www.tumblr.com/oauth/request_token'
access_token_url = 'http://www.tumblr.com/oauth/access_token'
authorize_url = 'http://www.tumblr.com/oauth/authorize'
@ShingoFukuyama
ShingoFukuyama / karabiner-my-mouse-settings.xml
Created June 28, 2015 12:54
My Mouse Settings for Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>My Mouse Settings</name>
<item>
<name>FFF Tilt Wheel to Back Forward (Command+[, Command+])</name>
<identifier>remap.my_tilt_wheel_to_back_forward</identifier>
<autogen>
__ScrollWheelToKey__ ScrollWheel::LEFT, ModifierFlag::NONE,
@gretel
gretel / ssc
Last active December 21, 2015 10:17
Use 'ssc' (this script) instead of 'ssh' to do your ssh logins. Without a 3rd argument it will list available screens. Given a 3rd argument it will either reattach an existing screen or create a new screen, i.e. 'ssc host.tld session'.
#!/usr/bin/env perl
#
# taken from https://stackoverflow.com/a/1075807/1972627 (Daniel Reeves)
# slightly modified by tom hensel <tom@jitter.eu>
# https://gist.github.com/gretel/c2ef247f51e3cf0c654e
#
# Use 'ssc' (this script) instead of 'ssh' to do your ssh logins.
# Without a 3rd argument it will list available screens.
# Given a 3rd argument it will either reattach an existing screen or create a new screen,
# i.e. 'ssc host.tld session'.