Skip to content

Instantly share code, notes, and snippets.

View mingsai's full-sized avatar
🎯
Focusing

Tommie N. Carter, Jr. mingsai

🎯
Focusing
View GitHub Profile
@mingsai
mingsai / MNGRecorderHandler.swift
Created July 3, 2015 00:01
A swift delegate for managing an AVAudioRecorder and it's related events.
//
// MNGRecorderHandler.swift
//
//
// Created by Tommie Carter on 6/29/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import AVFoundation
@mingsai
mingsai / MNGWaveformView.swift
Created July 3, 2015 00:03
A swift waveform custom view to create a sin wave relative to audio data being sent from a UIViewController
//
// MNGWaveformView.swift
//
//
// Created by Tommie Carter on 6/29/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import UIKit
@mingsai
mingsai / VideoPlayerViewController.swift
Created July 9, 2015 13:22
This controller is used to manage video playback of a video stored as binary data within Core Data. It solves the problem by saving a file into the temporary directory and sending it to an AVPlayerViewController that is within a container view of the VideoPlayerViewController.
//
// VideoPlayerViewController.swift
//
//
// Created by Tommie Carter on 7/8/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import UIKit
import AVKit
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleKeyboardDidShowNotification:)
name:UIKeyboardDidShowNotification
object:nil];
- (void)handleKeyboardDidShowNotification:(NSNotification *)notification
{
NSDictionary* info = [notification userInfo];
CGSize keyboardSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
@mingsai
mingsai / StarRatingControl.swift
Created July 14, 2015 12:57
Star rating control is the code behind a custom view to produce a number of stars that respond to touch. The stars become highlighted when touched and change a rating property.
//
// StarRatingControl.swift
// ths
//
// Created by Tommie Carter on 7/13/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import UIKit
If you have a Time Machine backup, you need this support page:
https://support.apple.com/kb/PH18848?locale=en_GB
If not, then you'll need to make a Yosemite USB installer of at least 8GB. (a USB3 one will be much quicker).
First download the OS X 10.10 Yosemite installer from the Mac App Store in the Purchases section (you may need to hold alt/option while selecting Purchases. Once it's downloaded, just quit the installer and set the downloaded file's name to InstallOSXYosemite.app (make sure only .app, not .app.app)
Plug in your USB drive into the computer and open Disk Utility (in Applications).
Select the USB drive from the left sidebar and click on Erase tab.
Choose Mac OS Extended (Journaled) in the format box and set the name be YosemiteInstaller
@mingsai
mingsai / MNGDataExtensions.swift
Last active February 12, 2016 14:53
A reader to quickly process data using a stream
extension NSData {
func mng_enumerateComponentsSeparatedBy(delimiter:NSData, block:(data:NSData,finalBlock:Bool) -> () ){
var loc:Int = 0
while true {
let rangeOfNewline = self.rangeOfData(delimiter, options: NSDataSearchOptions.Anchored, range:NSMakeRange(loc, self.length - loc))
if rangeOfNewline.location == NSNotFound {
break
}
@mingsai
mingsai / CoreDataStackManager.swift
Last active October 12, 2015 16:50
CoreDataStackManager ~ A typical Swift 2.0 implementation
class CoreDataStackManager {
// MARK: Properties
static let sharedManager = CoreDataStackManager()
static let applicationDocumentsDirectoryName = "com.example.apple-samplecode.Earthquakes"
static let mainStoreFileName = "Earthquakes.storedata"
static let errorDomain = "CoreDataStackManager"
/// The managed object model for the application.
lazy var managedObjectModel: NSManagedObjectModel = {
//Source (http://christiantietze.de/posts/2015/10/results-from-fetch-requests/)
import Foundation
import CoreData
enum CoreDataError: ErrorType {
case InconsistentCoreDataFetchRequestResults
}
@mingsai
mingsai / MNGNSFRVC.swift
Created November 24, 2015 17:14
An example of using the NSFetchedResultsViewController in Swift 2.0
//
// MNGNSFRVC.swift
// ProjectX
//
// Created by Tommie N. Carter, Jr., MBA on 11/15/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import UIKit
import CoreData