Skip to content

Instantly share code, notes, and snippets.

Avatar

Arne akamola

View GitHub Profile
@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 / gist:5654020
Last active Dec 17, 2015
Objective-C: Enumerate the objects of an array using a block (enumerateObjectsUsingBlock)
View gist:5654020
[anArray enumerateObjectsUsingBlock:^(id value, NSUInteger index, BOOL *stop) {
NSLog(@"%lu: %@", index, value);
}];
@akamola
akamola / .gitignore
Last active Jun 15, 2019
Git: Basic ignore file (.gitignore)
View .gitignore
# Temporary files
*~
*.swp
# Metadata
.DS_Store
Thumbs.db
@akamola
akamola / sub.sublime-snippet
Created Mar 21, 2013
Sublime Text 2: Snippet for Perl subroutines
View sub.sublime-snippet
<snippet>
<content><![CDATA[sub ${1:function_name} {
${0:# Code ...}
}
]]></content>
<tabTrigger>sub</tabTrigger>
<scope>source.perl</scope>
<description>Subroutine</description>
</snippet>
You can’t perform that action at this time.