Skip to content

Instantly share code, notes, and snippets.

Avatar

Arne akamola

View GitHub Profile
@akamola
akamola / functions.php
Created Feb 16, 2021
WordPress + Advanced Custom Fields Pro: Enable Google Maps API
View functions.php
<?php
// Add this code to the themes functions.php
const GOOGLE_MAPS_API_KEY = 'Your Google Maps API Key';
// Ensure Advanced Custom Fields Pro (ACF Pro) is enabled
//
// Check if plugin is enabled without additionally include the plugin manager for is_plugin_active()
// @see https://developer.wordpress.org/reference/functions/is_plugin_active/#comment-2427
if ( in_array( 'advanced-custom-fields-pro/acf.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
@akamola
akamola / README.md
Created Jan 22, 2021
PHP: Quick Helper Functions
View README.md

PHP: Quick Helper Functions

This is a small collection of quick helper functions for debugging and working with PHP.

Functions

axyz_d()

axyz_d( $var )
@akamola
akamola / update-unity.py
Last active Aug 22, 2020
Unity3D WebGL + AWS S3: Set correct content-type and content-encoding
View update-unity.py
#!/usr/bin/env python3
# coding: utf-8
# Sets the correct content-type and content-encoding for Unity3D files.
# @see https://forum.unity.com/threads/changes-to-the-webgl-loader-and-templates-introduced-in-unity-2020-1.817698/#post-5716621
import boto3
bucket_id = 'unity-model'
folder_prefix = 'model'
@akamola
akamola / checkurl.php
Last active Nov 5, 2016
PHP: Check if a URL does not contain "http://" or "https://"
View checkurl.php
<?php
if ( ( strpos( $url, 'http://' ) === false ) && ( strpos( $url, 'https://' ) === false ) ) {
$url = 'http://' . $url;
}
@akamola
akamola / arraykeys.php
Last active Nov 5, 2016
PHP: Find all entries of an array whose keys starts with "barfoo-"
View arraykeys.php
<?php
foreach ( $foobar as $key => $value ) {
if ( preg_match('/^barfoo-/', $key) ) {
// Array entries of $foobar whose keys starts with barfoo-
}
}
@akamola
akamola / grandparent.php
Last active Nov 5, 2016
MODX: Snippet to get the ID of the grandparent resource (see: http://goo.gl/prdscX)
View grandparent.php
<?php
$id = $modx->resource->get('id');
$parents = $modx->getParentIds($id, 2);
$grandparent = $parents[1];
return $grandparent;
@akamola
akamola / dateLocal.php
Last active Nov 5, 2016
MODX: Snippet for an output modifier to localize dates (see: http://goo.gl/HUpyFg)
View dateLocal.php
<?php
setlocale(LC_ALL, 'en_US');
return strftime($options, $input);
@akamola
akamola / .gitignore
Last active Feb 6, 2018
Xcode: Git ignore file for Xcode projects (.gitignore)
View .gitignore
# Temporary files
*~
*.swp
# Metadata
.DS_Store
Thumbs.db
@akamola
akamola / .htaccess
Created May 31, 2013
HTACCESS: Basic configuration for web projects for Apache web servers
View .htaccess
# PHP
php_flag register_globals off
php_flag short_open_tag off
# Set default charset to UTF-8
AddDefaultCharset UTF-8
# File types
@akamola
akamola / .gitignore
Last active Jan 22, 2021
Git: Basic ignore file (.gitignore)
View .gitignore
# Temporary files
*~
*.swp
# Metadata
.DS_Store
Thumbs.db