Skip to content

Instantly share code, notes, and snippets.

Tommie N. Carter, Jr., BSIT, MBA mingsai

Block or report user

Report or block mingsai

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
mingsai / utils.php
Last active Jul 17, 2019
Useful PHP snippets
View utils.php
//assoc array?
function has_string_keys(array $array) {
return count(array_filter(array_keys($array), 'is_string')) > 0;
//obj to array?
$array = json_decode(json_encode($nested_object), true);
mingsai / RSSFeed.swift
Created Jan 15, 2019 — forked from kharrison/RSSFeed.swift
Swift Decodable With Multiple Custom Dates
View RSSFeed.swift
import Foundation
extension DateFormatter {
static let iso8601Full: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
formatter.calendar = Calendar(identifier: .iso8601)
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
mingsai / MNGManagedObjectExtensions.swift
Last active Jan 1, 2019
My attempt at extracting/reconstructing NSManagedObjects from dictionaries recursively in Swift. With the eventual goal of serializing dictionaries to data somewhere.
View MNGManagedObjectExtensions.swift
// MNGManagedObjectExtensions.swift
// rtj
// Created by Tommie N. Carter, Jr., MBA on 1/1/19.
// Copyright © 2019 MING Technology. All rights reserved.
import UIKit
mingsai / MNGExpandedTouchAreaButton.swift
Created Feb 12, 2016
A Swift UIButton subclass to expand the touch area of the button.
View MNGExpandedTouchAreaButton.swift
// MNGExpandedTouchAreaButton.swift
// Created by Tommie Carter on 7/7/15.
// Copyright © 2015 MING Technology. All rights reserved.
import UIKit
mingsai / Test4SQLiteOptions.txt
Created Dec 9, 2017
Swift to Query Apple's Compile time Options for SQLite
View Test4SQLiteOptions.txt
Stackoverflow Answer (
Highlights the useful code supplied by @Robert Hawkey
Shows full code and output for Xcode 9/Swift 4.0.3
Enables one to assess useful features of SQLite in iOS (eg. JSON SQL Functions)
Swift 4.0.3
func testSQLiteOptions(){
var db: OpaquePointer? = nil
var statement: OpaquePointer? = nil
sqlite3_open(self.dbPath, &db)
View UIImage+Color.swift
import UIKit
extension UIImage {
class func colorAsImage(from color:UIColor, for size:CGSize) -> UIImage? {
var img:UIImage?
let rect = CGRect(x:0.0, y:0.0, width: size.width, height: size.height)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0)
guard let context = UIGraphicsGetCurrentContext() else { return nil }
mingsai / MNGVideoPlayerView.swift
Last active Jan 21, 2018
Swift conversion of code for article on multiple video playback in iOS (original article/source:
View MNGVideoPlayerView.swift
// Created by Tommie N. Carter, Jr., MBA on 2/12/16.
// Copyright © 2016 MING Technology. All rights reserved.
import UIKit
import AVFoundation
class MNGVideoPlayerView: UIView {
mingsai / AsyncTask.swift
Created Dec 22, 2017
A simple background task class snippet (from:
View AsyncTask.swift
import Foundation
*AsyncTask v1.1 Updated: 2016-12-01
*Defines a task which executed asynchronously in background thread.
*Every AsyncTask instance has 3 life cycle events:
* 1. beforeTask execution (Optional) - executed on UI Main thread
* 2. bagkroundTask execution - executed in background thread
* 3. afterTask execution (Optional) - executed on UI Main thread
*When caller instantiates AsyncTask he\she can decide what data type to pass in and out, using
View sqlite-partial-struct.swift
//where Medicine is an encodable, decodable struct
fileprivate static let medicineTable = Table("medicine")
fileprivate static let counterTable = Table("counter")
fileprivate static let medicineColumn = Expression<Int>("medicine")
fileprivate static let idColumn = Expression<Int64>("id")
static func update(item: Medicine, onCompletion: (Bool, Error?) -> ()) {
guard let db = SQLiteDataEngine.shared.db else {
onCompletion(false, DataAccessError.Database_Connection_Error)
mingsai / Instructions.txt
Created Aug 18, 2017
How to use htpasswd to secure web folders
View Instructions.txt
put the htpaswd file outside of your root folder so it isn’t web accessible like:
In terminal one can generate a htaccess password
htpasswd -nb username password
Use a strong random number generator to create a salt of 16 bytes or longer.
Feed the salt and the password into the PBKDF2 algorithm.
Use HMAC-SHA-256 as the core hash inside PBKDF2.
You can’t perform that action at this time.