Skip to content

Instantly share code, notes, and snippets.

@jaclync
jaclync / swift2.3..develop.diff
Last active October 17, 2016 21:29
jaclyn/swift2.3..develop.diff
diff --git a/Quizlet-iPhone/AssistantModeViewController.swift b/Quizlet-iPhone/AssistantModeViewController.swift
index 6e68996..c739fba 100644
--- a/Quizlet-iPhone/AssistantModeViewController.swift
+++ b/Quizlet-iPhone/AssistantModeViewController.swift
@@ -20,7 +20,7 @@ class AssistantModeAnimator: NSObject, UIViewControllerAnimatedTransitioning {
let toView = toViewController.view
let fromView = fromViewController.view
- let containerView = transitionContext.containerView()!
+ let containerView = transitionContext.containerView()
@jaclync
jaclync / recorded_tests.diff
Created October 17, 2016 17:39
jaclyn/swift2.3..develop - recorded tests
diff --git a/Custom Frameworks/QuizletNetworkTestHelpers/QuizletNetworkTestHelpers.xcodeproj/project.pbxproj b/Custom Frameworks/QuizletNetworkTestHelpers/QuizletNetworkTestHelpers.xcodeproj/project.pbxproj
index 0034087..b00bd32 100644
--- a/Custom Frameworks/QuizletNetworkTestHelpers/QuizletNetworkTestHelpers.xcodeproj/project.pbxproj
+++ b/Custom Frameworks/QuizletNetworkTestHelpers/QuizletNetworkTestHelpers.xcodeproj/project.pbxproj
@@ -322,6 +322,7 @@
TargetAttributes = {
1F0B565D1D5D156200B2FD76 = {
CreatedOnToolsVersion = 7.3.1;
+ LastSwiftMigration = 0800;
};
@jaclync
jaclync / jsonDictionary.m
Created April 24, 2017 17:37
JSON <--> Dictionary
/// Dictionary --> JSON.
- (void)dictionaryToJson {
// `message: NSDictionary` to send to server.
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:message
options:0
error:nil];
[self.socket send:jsonData];
}
/// JSON --> Dictionary.
@jaclync
jaclync / questionOption.swift
Last active May 18, 2017 16:44
Multiple type constraints with generics
import UIKit
// Ref: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Generics.html#//apple_ref/doc/uid/TP40014097-CH26-XID_292
protocol OptionView: class {
func handleKeyCommand()
}
class QuestionView<V> where V: UIView, V: OptionView {
private let optionView: V
func QL_rotate(scale: CGFloat = 1, orientation: UIImageOrientation) -> UIImage {
guard let cgImage = cgImage else { fatalError() }
return UIImage(cgImage: cgImage, scale: scale, orientation: orientation)
}
@jaclync
jaclync / FixGooglePodInXcode9Beta.sh
Created June 8, 2017 00:19
Workaround for Google cocoapods permissions error (GoogleSignIn etc.) in Xcode 9 Beta
# Thanks to Alfredo Delli Bovi at WWDC
# Example error:
# Failed to change owner of file:...: Error Domain=MIInstallerErrorDomain Code=4 "Failed to remove ACL" UserInfo={NSUnderlyingError=0x7fa983614a10 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied" UserInfo={SourceFileLine=392, NSLocalizedDescription=open of ../path_to_simulator/data/Library/Caches/com.apple.mobile.installd.staging/temp.z2EhKm/Development.app/GoogleSignIn.bundle/ar.lproj/GoogleSignIn.strings failed: Permission denied, FunctionName=-[MIFileManager _removeACLAtPath:isDir:error:]}}, FunctionName=-[MIFileManager _removeACLAtPath:isDir:error:], SourceFileLine=392, NSLocalizedDescription=Failed to remove ACL}
chmod -R +rw path_to_google_pod_resources.bundle
function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();
if (now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setHours(hours);
@jaclync
jaclync / Within a mixed framework.md
Last active October 16, 2020 15:33
Swift <--> Objective-C import

Importing Objective-C into Swift

To import a set of Objective-C files in the same framework target as your Swift code, you’ll need to import those files into the Objective-C umbrella header for the framework.

  • Under Build Settings, in Packaging, make sure the Defines Module setting for that framework target is set to “Yes”.
  • In your umbrella header file (FrameworkName.h), import every Objective-C header you want to expose to Swift. For example:
#import <XYZ/XYZCustomCell.h>
#import <XYZ/XYZCustomView.h>
#import <XYZ/XYZCustomViewController.h>
@jaclync
jaclync / NMul.java
Created August 31, 2018 02:26
Working version
import java.util.Scanner;
import java.math.*;
public class NMul {
public static void main(String[] args) {
BigInteger sum;
long n;
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
@jaclync
jaclync / .swift-format
Created October 21, 2019 03:09
`swift-format`: default configurations
{
"blankLineBetweenMembers" : {
"ignoreSingleLineProperties" : true
},
"indentation" : {
"spaces" : 2
},
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : false,
"lineLength" : 100,