Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / brew.sh
Created December 12, 2016 12:04
Resinstall GD with Vagrant via PHPBrew
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
# Move phpbrew to somewhere can be found by your $PATH
sudo mv phpbrew /usr/bin/phpbrew
phpbrew ext install gd \
-- --with-libdir=lib/i386-linux-gnu \
--with-gd=shared \
--enable-gd-native-ttf \
@yratof
yratof / load.php
Last active January 30, 2023 08:41
ACF Load layouts into flex field
<?php
add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' );
static function craft_content_layouts( $field ) {
// Remove the layouts
// that are named in this list
$remove_list = [
'paragraph',
'banner',
@yratof
yratof / composer.json
Created December 8, 2016 15:16
Craft starter composer.json
{
"name": "new_project",
"type": "project",
"authors": [
{
"name": "Andrew smith",
"email": "[email protected]"
}
],
"repositories": [
@yratof
yratof / functions.php
Created December 7, 2016 16:01
Woocommerce remove unused attributes on product variations
<?php
add_action( 'init', function() {
ini_set( 'memory_limit', '2048M' );
set_time_limit( 0 );
$posts = get_posts( [
'post_type' => 'product',
'posts_per_page' => -1
] );
$count = 0;
@yratof
yratof / functions.php
Created November 28, 2016 16:17 — forked from andyleach/functions.php
WooCommerce Product Category Swatches
<?php
function display_product_colors() {
$colors = array();
$options = get_post_meta(get_the_ID(), '_swatch_type_options', true);
foreach($options as $option) {
foreach($option as $item) {
foreach($item as $att) {
$colors[] = $att['color'];
}
@yratof
yratof / functions.php
Created November 28, 2016 00:03
Woocommerce swatches and colours on product lists
<?php
static function show_all_available_colour_options() {
global $product;
// Only variations
if ( ! $product->is_type( 'variable' ) ) {
return;
}
@yratof
yratof / printer_os_chip.sh
Created November 26, 2016 14:08
Installing 3D PrinterOS on a chip
# Connect to wifi
nmcli device wifi list
sudo nmcli device wifi connect 'rasperrypi' ifname wlan0
nmcli device status
# Update device
sudo apt-get update && sudo apt-get upgrade
# Set language
sudo apt-get update && sudo apt-get install locales && sudo dpkg-reconfigure locales && sudo locale-gen
# Install depends
sudo apt-get install python2.7 libusb-1.0 python-numpy python-opencv ca-certificates unzip ssh
@yratof
yratof / functions.php
Last active November 21, 2016 10:16
Craft Header Reshuffle
<?php
/**
* How to rearrange your header when using Craft
*/
class craft_headers {
// Load classes before
static function setup(){
add_action( 'init', __CLASS__ . '::cleanup', 10 );
add_action( 'init', __CLASS__ . '::reshuffle', 20 );
@yratof
yratof / pizero.sh
Created November 18, 2016 08:29
SSH into Pi zero with Internet on MacOS
# Build your SD card with PiFiler
# Mount ROOT on your MacOS
# Open config.txt and place this at the bottom
dtoverlay=dwc2
# Save and open cmdline.txt
# find rootwait and add this after
modules-load=dwc2,g_ether
# On MacOS, head to settings
@yratof
yratof / chip.sh
Last active November 16, 2016 08:51
Installing pyradio on a c.h.i.p
# Install everything needed
sudo apt-get install -y python-setuptools python-dev build-essential mplayer
# Install PIP
sudo easy_install pip
# PIP Pyradio
pip install pyradio
# If you get permission errors, try `sudo pip install pyradio`