This file contains 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 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 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 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 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 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 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 | |
} | |
} |
This file contains 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 class WDMainActivity extends AppCompatActivity implements WifiP2pManager.ConnectionInfoListener { | |
private static final String TAG = "WDMainActivity"; | |
private static final String KEY_BUDDY_NAME = "buddyname"; | |
private final IntentFilter intentFilter = new IntentFilter(); | |
private WifiP2pManager.Channel mChannel; | |
private WifiP2pManager mManager; |
This file contains 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
static func update(modifiedDate: Date, url: URL) { | |
do { | |
var values = try url.resourceValues(forKeys: [URLResourceKey.contentModificationDateKey]) | |
values.contentModificationDate = modifiedDate | |
try url.setResourceValues(values) | |
} catch { | |
print(error.localizedDescription) | |
} | |
} |
This file contains 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 Data { | |
private static let mimeTypeSignatures: [UInt8 : String] = [ | |
0xFF : "image/jpeg", | |
0x89 : "image/png", | |
0x47 : "image/gif", | |
0x49 : "image/tiff", | |
0x4D : "image/tiff", | |
0x25 : "application/pdf", | |
0xD0 : "application/vnd", | |
0x46 : "text/plain", |
NewerOlder