This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using Playground | |
func insertionSort(_ numbers: Array<Int>) -> Array<Int> | |
{ | |
var nums = numbers | |
if (nums.count <= 1) { return nums } | |
for i in 1..<nums.count { | |
for j in (1...i).reversed() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using Playground | |
func bubbleSort(_ numbers: Array<Int>) -> Array<Int> | |
{ | |
var nums = numbers | |
if (nums.count <= 1) { return nums } | |
for i in 0..<nums.count { | |
for j in 0..<(nums.count - i - 1) { | |
if (nums[j+1] < nums[j]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using Playground | |
import Foundation | |
func selectionSort(_ numbers: Array<Int>) -> Array<Int> | |
{ | |
var nums = numbers | |
if (nums.count <= 1) { return nums } | |
for i in 0..<nums.count { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import AppKit | |
struct GroceryProduct: Decodable { | |
var name: String | |
var points: Int | |
var description: String? | |
enum CodingKeys: String, CodingKey { | |
case name = "Name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your settings in this file to overwrite the default settings | |
{ | |
"editor.fontSize": 15, | |
"editor.fontFamily": "'Droid Sans Mono Slashed for Powerline'", | |
"editor.cursorStyle": "block", | |
"workbench.iconTheme": "vs-seti", | |
"editor.minimap.enabled": true, | |
"workbench.colorTheme": "Dracula", | |
"workbench.startupEditor": "none", | |
"python.pythonPath": "python3", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate func createCenterConstraints(with subview: UIView) -> [NSLayoutConstraint] | |
{ | |
var constraints: [NSLayoutConstraint] = [NSLayoutConstraint]() | |
let views: [String: Any] = ["view": subview, "superview": self.view] | |
var horizontalOptions = NSLayoutFormatOptions() | |
horizontalOptions.insert(NSLayoutFormatOptions.alignAllCenterY) | |
let horizontalConstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:[superview]-(<=1)-[view]", options: horizontalOptions, metrics: nil, views: views) | |
var verticalOptions = NSLayoutFormatOptions() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - Keyboard Notifications | |
- (void)keyboardDisappeared:(NSNotification*)notification | |
{ | |
self.scrollView.contentInset = UIEdgeInsetsZero; | |
[self.scrollView setContentOffset:CGPointMake(0.0, 0.0) animated:YES]; | |
} | |
- (void)KeyboardWillChangeFrame:(NSNotification*)notification | |
{ | |
NSDictionary *keyboardInfo = [notification userInfo]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func CheckError(_ error: OSStatus, _ operation: String) -> Void | |
{ | |
if (error == noErr) { return } | |
let count = 5 | |
let stride = MemoryLayout<OSStatus>.stride | |
let byteCount = stride * count | |
var error_ = CFSwapInt32HostToBig(UInt32(error)) | |
var charArray: [CChar] = [CChar](repeating: 0, count: byteCount ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void | |
reverseString(char *str) | |
{ | |
if (str == 0 || *str == 0) return; | |
char *start = str; | |
char *end = start + strlen(str) - 1; | |
char temp; | |
while (start < end) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void | |
reverseStr(char *str) | |
{ | |
int len = 0; | |
int init = 0; | |
while (*(str + len) != '\0') { | |
len++; | |
} |