Skip to content

Instantly share code, notes, and snippets.

Stephen Mullen thewirelessguy

View GitHub Profile
thewirelessguy / ReconcileHelper.kt
Created Jun 8, 2020
Kotlin Playground - Display which numbers are in array 1, but not array 2
View ReconcileHelper.kt
// My solution to:
// Write a function called "reconcileHelper" that processes two arrays of integers.
// Each array will have only distinct numbers (no repeats of the same integer in
// the same array), and the arrays are not sorted.
// Your job is to find out which numbers are in array 1, but not array 2,
// and which numbers are in array 2, but not in array 1.
// Your function should return a string formatted as so:
// "Numbers in array 1 that aren't in array 2:
thewirelessguy / ConnectivityExtension.kt
Created Jan 16, 2020
Android Kotlin extension to check network connectivity
View ConnectivityExtension.kt
import android.content.Context
import android.os.Build
val Context.isConnected: Boolean
get() {
val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return when {
thewirelessguy / SwipeRefreshLayoutExt.kt
Created Oct 18, 2019
SwipeRefreshLayout Kotlin extensions
View SwipeRefreshLayoutExt.kt
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
fun SwipeRefreshLayout?.start() {
this?.apply {
isRefreshing = true
isEnabled = false
thewirelessguy / VerticalTextView.kt
Created Oct 15, 2019
VerticalTextView that extends AppCompatTextView
View VerticalTextView.kt
import android.content.Context
import android.text.BoringLayout
import android.text.Layout
import android.text.TextUtils
import android.util.AttributeSet
import android.view.Gravity
import androidx.appcompat.widget.AppCompatTextView
thewirelessguy / create_admin_user.php
Created Mar 20, 2018
Create new Magento admin user programmatically. Edit and add the php file below to the root of your Magento folder. Run it in the browser and the user will be created.
View create_admin_user.php
# Create new Magento admin user programmatically.
try {
$user = Mage::getModel('admin/user')
'username' => 'admin1',
thewirelessguy / getAppIcon.swift
Created Mar 14, 2017
Use current iOS app icon with UIImageView in Swift 3
View getAppIcon.swift
// GetAppIcon.swift
// Get the AppIcon from Assets and return it as a UIImage
// Created by Stephen Mullen
import UIKit
func getAppIcon() -> UIImage {
thewirelessguy / function.php
Last active Aug 24, 2018
How to use Google's Organisation Logo markup with WordPress Theme Logo
View function.php
function mytheme_setup() {
add_action('after_setup_theme', 'mytheme_setup');
thewirelessguy / app-icon-uiimageview.swift
Last active Apr 12, 2017
Use current iOS app icon with UIImageView in Swift 2 (Swift 3 example:
View app-icon-uiimageview.swift
let primaryIconsDictionary = NSBundle.mainBundle().infoDictionary?["CFBundleIcons"]?["CFBundlePrimaryIcon"] as? NSDictionary
let iconFiles = primaryIconsDictionary!["CFBundleIconFiles"] as! NSArray
let lastIcon = iconFiles.lastObject as! NSString //last seems to be largest, use first for smallest
let theIcon = UIImage(named: lastIcon as String)
let iconImageView = UIImageView(image: theIcon)
thewirelessguy / AndroidManifest.xml
Last active Aug 8, 2018
Setting up styles.xml and values-v21/styles.xml to use Material Design with AppCompat. Rename styles21.xml as styles.xml and place in your res/values-v21 folder (you may need to create a values-v21 folder if you don't already have one).
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
package="" >
android:theme="@style/AppTheme" >
thewirelessguy / Detect the last post in the WordPress loop
Last active May 19, 2020
Detect the last post in the WordPress loop
View Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
You can’t perform that action at this time.