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 / scripts.php
Created September 1, 2021 12:08
Add scripts to customizer for wordpress
<?php
/* Customiser script */
add_action( 'customize_register', 'custom_editor' );
function custom_editor( $wp_customize ) {
// Analytics section
$wp_customize->add_section('analytics_section', array(
'title' => __( 'Analytics', 'tuesday' ),
'description' => __( 'Enable tracking and analytics by placing your script tags in the correct location. <small><strong>Note:</strong> All scripts must be self-containing &lt;script&gt;&lt;/script&gt;, otherwise they will just print the code onto the website.</small>', 'tuesday' ),
@yratof
yratof / csv-merge.php
Created January 19, 2015 17:28
Combine CSV rows, but merge differences
<?php /* This changes the CSV into another CSV. But merges duplicated fields. */
$handle = fopen("CLUBEXP.csv", "r");
$row = 0;
$ClubNumberList = array();
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// ID
$ClubNumber = $data[0];
// Day
@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 / FlyCamera.cs
Created January 27, 2023 12:49 — forked from FreyaHolmer/FlyCamera.cs
A camera controller for easily flying around a scene in Unity smoothly. WASD for lateral movement, Space & Ctrl for vertical movement, Shift to move faster. Add this script to an existing camera, or an empty game object, hit play, and you're ready to go~
using UnityEngine;
[RequireComponent( typeof(Camera) )]
public class FlyCamera : MonoBehaviour {
public float acceleration = 50; // how fast you accelerate
public float accSprintMultiplier = 4; // how much faster you go when "sprinting"
public float lookSensitivity = 1; // mouse look sensitivity
public float dampingCoefficient = 5; // how quickly you break to a halt after you stop your input
public bool focusOnEnable = true; // whether or not to focus and lock cursor immediately on enable
@yratof
yratof / extended_Filterable_Portfolio.php
Created November 21, 2022 21:20
Adding excerpts to Filterable_Portfolio in DIVI
<?php
class Extra_ET_Builder_Module_Filterable_Portfolio extends ET_Builder_Module_Filterable_Portfolio {
function init() {
$this->name = esc_html__( 'Filterable Portfolio', 'et_builder' );
$this->plural = esc_html__( 'Filterable Portfolios', 'et_builder' );
$this->slug = 'et_pb_filterable_portfolio';
$this->vb_support = 'off';
$this->main_css_element = '%%order_class%%.et_pb_filterable_portfolio';
@yratof
yratof / divi-viewport-pinch-to-zoom.php
Created November 1, 2022 19:27 — forked from Garconis/divi-viewport-pinch-to-zoom.php
Divi | Add pinch and zoom (user scalable) to mobile viewport meta
<?php
// Removes et_add_viewport_meta from the wp_head phase
function remove_divi_actions() {
remove_action( 'wp_head', 'et_add_viewport_meta' );
}
// Call 'remove_divi_actions' during WP initialization
add_action('init','remove_divi_actions');
// add ability to pinch and zoom
@yratof
yratof / f.php
Last active September 16, 2022 10:44
acf load json files and sync
<?php
function acf_fields() {
// Load field files dynamically
$field_files = glob( dirname(__FILE__) .'/acf-fields/*.json' );
foreach ( $field_files as $file ) {
if ( apply_filters( 'midsona_allow_acf_file', true, $file ) ) {
$json = json_decode( file_get_contents( $file ), true );
$json[0]['local'] = 'json';
// $json[] =
acf_add_local_field_group( $json[0] );
@yratof
yratof / vanilla.js
Last active September 7, 2022 22:33
Toggle class with ES6 vanilla
// The element you're targetting
// The class you're toggling
const el = document.querySelector('.menu-item-has-children');
const handleToggle = () => el.classList.toggle('available');
el.onclick = () => handleToggle();
document.addEventListener('click', event => {
const isClickInside = el.contains(event.target)
if (!isClickInside) {
@yratof
yratof / mm_HeightToNormal.osl
Last active August 28, 2022 10:06
OTOY Octane Height_To_Normal.OSL
#include <octane-oslintrin.h>
// IMPORTANT: Make sure the input
// is using OSL delayed UV projection.
//
// This shader will convert a height map to a tangent normal map
// based on the average value, luminance or intensity of one of the RGB channels.
//
// If you need many of these nodes with Quality set to High,
// please consider using the baking texture node.
@yratof
yratof / morphagene_ableton.py
Created January 12, 2022 22:32 — forked from knandersen/morphagene_ableton.py
Allows you to use Ableton projects and exports as reels for the Make Noise Morphagene eurorack module.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
USAGE:
morphagene_ableton.py -w <inputwavfile> -l <inputlabels> -o <outputfile>'
Instructions in Ableton:
Insert locators as splice markers in your project (Create > Add Locator)
Export Audio/Video with
Sample Rate: 48000 Hz