Skip to content

Instantly share code, notes, and snippets.

View akamola's full-sized avatar

Arne akamola

View GitHub Profile
@akamola
akamola / functions.php
Created February 16, 2021 09:06
WordPress + Advanced Custom Fields Pro: Enable Google Maps API
<?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
Last active May 13, 2021 05:09
PHP: Quick Helper Functions

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 July 23, 2022 05:28
Unity3D WebGL + AWS S3: Set correct content-type and content-encoding
#!/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 November 5, 2016 09:55
PHP: Check if a URL does not contain "http://" or "https://"
<?php
if ( ( strpos( $url, 'http://' ) === false ) && ( strpos( $url, 'https://' ) === false ) ) {
$url = 'http://' . $url;
}
@akamola
akamola / arraykeys.php
Last active November 5, 2016 09:55
PHP: Find all entries of an array whose keys starts with "barfoo-"
<?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 November 5, 2016 09:01
MODX: Snippet to get the ID of the grandparent resource (see: http://goo.gl/prdscX)
<?php
$id = $modx->resource->get('id');
$parents = $modx->getParentIds($id, 2);
$grandparent = $parents[1];
return $grandparent;
@akamola
akamola / dateLocal.php
Last active November 5, 2016 09:01
MODX: Snippet for an output modifier to localize dates (see: http://goo.gl/HUpyFg)
<?php
setlocale(LC_ALL, 'en_US');
return strftime($options, $input);
@akamola
akamola / .gitignore
Last active February 6, 2018 09:06
Xcode: Git ignore file for Xcode projects (.gitignore)
# Temporary files
*~
*.swp
# Metadata
.DS_Store
Thumbs.db
@akamola
akamola / .htaccess
Created May 31, 2013 08:34
HTACCESS: Basic configuration for web projects for Apache web servers
# 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 January 22, 2021 11:25
Git: Basic ignore file (.gitignore)
# Temporary files
*~
*.swp
# Metadata
.DS_Store
Thumbs.db