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 / 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
[[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
//Source (http://christiantietze.de/posts/2015/10/results-from-fetch-requests/)
import Foundation
import CoreData
enum CoreDataError: ErrorType {
case InconsistentCoreDataFetchRequestResults
}
@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 = {
@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
@mingsai
mingsai / MNGStarRating.swift
Created November 28, 2015 05:45
Star Rating Control
//
// MNGStarRating.swift
// CommonCents
//
// Created by Tommie N. Carter, Jr., MBA on 11/27/15.
// Copyright © 2015 MING Technology. All rights reserved.
//
import UIKit

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/
  Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'

UIActivityIndicatorView

@mingsai
mingsai / image.py
Created August 24, 2013 22:18 — forked from phughes/image.py
import os.path as path
import string
import argparse
import glob
import re
def basename(filename):
base = filename
if filename.find('@2x') > 0:
base = filename[:filename.find('@2x')]