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
/* | |
Purpose: Represents your data layer (e.g. API responses, local database models). | |
*/ | |
class User { | |
final String name; | |
final int age; | |
User({required this.name, required this.age}); | |
} |
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
echo "**********************************" | |
echo "* Create sim if needed *" | |
echo "**********************************" | |
test_device_id=$(xcrun simctl list devices | grep "circleci-test-device" | sed 's/ *circleci-test-device *(//' | sed 's/).*//') | |
if [ -z "$test_device_id" ]; then | |
echo "Creating test device" | |
runtime=$(xcrun simctl list runtimes iOS | sed 's/iOS //' | sort -h | tail -1 | sed 's/.* - //' | tr -d '[:space:]') | |
devicetype=$(xcrun simctl list devicetypes "iPhone " | sort | tail -1 | sed 's/.*(//' | sed 's/).*//' | tr -d '[:space:]') | |
test_device_id=$(xcrun simctl create "circleci-test-device" "$devicetype" "$runtime" | tr -d '[:space:]') |
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 | |
let value = 10000 // Value stored in the database along with the currency code | |
let numberFormatter = NumberFormatter() | |
numberFormatter.numberStyle = .currency | |
numberFormatter.currencyCode = "USD" | |
print("\(Double(value)/pow(10, Double(numberFormatter.maximumFractionDigits)))") // 100.0 | |
numberFormatter.currencyCode = "JPY" |
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
zip -r smart.zip . -x "*.DS_Store" -x "__MACOSX" |
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
ENV ANDROID_HOME_DIR=/opt/tools/android-sdk-linux | |
ENV SDK_MANAGER=$ANDROID_HOME/cmdline-tools/bin/sdkmanager | |
ENV TEMP_DIR=<Path to a temporary directory you download files to. e.g. /tmp/install> | |
ENV ANDROID_TOOLS_VERSION=30.0.3 | |
ENV ANDROID_BUILD_VERSION=32 | |
ADD <path to SDK tools. Refer command line tools in https://developer.android.com/studio#downloads> $TEMP_DIR/ | |
RUN mkdir -p $ANDROID_HOME_DIR && \ | |
cd $ANDROID_HOME_DIR && \ | |
unzip $TEMP_DIR/<zip file name downloaded above> && \ |
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 UIKit | |
protocol TouchDetectingViewDelegate: NSObjectProtocol { | |
func touchDetectingViewDidDetectPan(view: TouchDetectingView, | |
direction: TouchDetectingView.Direction, | |
displacement: CGFloat, | |
state: UIGestureRecognizer.State) | |
func touchDetectingViewPanEnded(view: TouchDetectingView) | |
} |
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 Photos | |
class VideoHelper { | |
private static func createAlbum(name: String, completion: @escaping ((_ collection: PHAssetCollection?) -> Void)) { | |
//Get PHFetch Options | |
let fetchOptions = PHFetchOptions() | |
fetchOptions.predicate = NSPredicate(format: "title = %@", name) | |
let collection : PHFetchResult = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: fetchOptions) | |
//Check return value - If found, then get the first album out |
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 UIKit | |
extension NSAttributedString { | |
func image(size: CGSize) -> UIImage? { | |
UIGraphicsBeginImageContext(size) | |
self.draw(at: CGPoint.zero) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image |
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 | |
// This class simulates SWift's dictionary class | |
class MyDictionary <Key: Equatable, Value> { | |
private var values: [Value] = [] | |
private var keys: [Key] = [] | |
func set(value: Value, key: Key) { | |
if keys.contains(key), let index = keys.firstIndex(of: key) { | |
values[index] = value |
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
extension NSView { | |
func setBackgroundColor(color: NSColor) { | |
let layer = CALayer.init() | |
layer.backgroundColor = color.cgColor | |
self.layer = layer | |
} | |
} |
NewerOlder