Skip to content

Instantly share code, notes, and snippets.

Stephen Mullen thewirelessguy

Block or report user

Report or block thewirelessguy

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
@thewirelessguy
thewirelessguy / ConnectivityExtension.kt
Created Jan 16, 2020
Android Kotlin extension to check network connectivity
View ConnectivityExtension.kt
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.os.Build
val Context.isConnected: Boolean
get() {
val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
@thewirelessguy
thewirelessguy / SwipeRefreshLayoutExt.kt
Created Oct 18, 2019
SwipeRefreshLayout Kotlin extensions
View SwipeRefreshLayoutExt.kt
package uk.co.thewirelessguy.thewirelessguy.extensions
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
fun SwipeRefreshLayout?.start() {
this?.apply {
isRefreshing = true
isEnabled = false
}
}
@thewirelessguy
thewirelessguy / VerticalTextView.kt
Created Oct 15, 2019
VerticalTextView that extends AppCompatTextView
View VerticalTextView.kt
package uk.co.thewirelessguy.thewirelessguy.widget
import android.content.Context
import android.graphics.Canvas
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
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
<?php
# Create new Magento admin user programmatically.
require_once('./app/Mage.php');
umask(0);
Mage::app();
try {
$user = Mage::getModel('admin/user')
->setData(array(
'username' => 'admin1',
@thewirelessguy
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
thewirelessguy / function.php
Last active Aug 24, 2018
How to use Google's Organisation Logo Schema.org markup with WordPress Theme Logo
View function.php
function mytheme_setup() {
add_theme_support('custom-logo');
}
add_action('after_setup_theme', 'mytheme_setup');
@thewirelessguy
thewirelessguy / app-icon-uiimageview.swift
Last active Apr 12, 2017
Use current iOS app icon with UIImageView in Swift 2 (Swift 3 example: https://gist.github.com/thewirelessguy/b0eba855c0307b47168be85291788746)
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
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="http://schemas.android.com/apk/res/android"
package="uk.co.thewirelessguy.myappname" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
@thewirelessguy
thewirelessguy / Detect the last post in the WordPress loop
Last active Mar 20, 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';
} ?>
@thewirelessguy
thewirelessguy / functions.php
Created Aug 9, 2013
Removing Custom Post Types in WordPress. This example removes the Orbit Custom Post Type from the Cornerstone WordPress starter theme. You would include it the functions.php of your child theme.
View functions.php
<?php
add_action( 'after_setup_theme','remove_cornerstone_features', 100 );
function remove_cornerstone_features() {
remove_action( 'init', 'Orbit');
}
?>
You can’t perform that action at this time.