Skip to content

Instantly share code, notes, and snippets.

Arne akamola

Block or report user

Report or block akamola

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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>
@akamola
akamola / hashbang.sublime-snippet
Created Mar 15, 2013
Sublime Text 2: Snippet for the hashbang with the regular path to Perl
View hashbang.sublime-snippet
<snippet>
<content><![CDATA[#!/usr/bin/perl]]></content>
<tabTrigger>hashbang</tabTrigger>
<scope>source.perl</scope>
<description>#!/usr/bin/perl</description>
</snippet>
You can’t perform that action at this time.