Skip to content

Instantly share code, notes, and snippets.

🚜
Working

StanislavK StanislavK

🚜
Working
Block or report user

Report or block StanislavK

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TestFile.java
package com.dropbox.android.sample;
import android.os.AsyncTask;
import android.util.Log;
import com.dropbox.client.DropboxAPI;
public class LoginAsyncTask extends AsyncTask<Void, Void, Integer> {
private static final String TAG = "LoginAsyncTask";
View String+isNilOrEmpty.swift
//String extension that checks for an empty (after trimming whitespace) or nil string:
//
// Usage: var isEmpty = String.isNilOrEmpty(myString)
//
// Credit to: Kevin McNeish
// http://iosappsfornonprogrammers.com/forum/index.php?topic=1836.0
extension String {
public static func isNilOrEmpty(string: String?) -> Bool {
View Double+TimerIntervals.swift
extension Double {
var second: NSTimeInterval { return self }
var seconds: NSTimeInterval { return self }
var minute: NSTimeInterval { return self * 60 }
var minutes: NSTimeInterval { return self * 60 }
var hour: NSTimeInterval { return self * 3600 }
var hours: NSTimeInterval { return self * 3600 }
}
View Array+combine.swift
extension Array {
func combine(separator: String) -> String{
var str : String = ""
for (idx, item) in enumerate(self) {
str += "\(item)"
if idx < self.count-1 {
str += separator
}
}
return str
View SimpleLog.swift
func log(message: String) {
let thread = Thread.current.isMainThread ? "Main" : "Background"
print("\(thread) thread: \(message)")
}
View String+Extension.swift
import Foundation
extension String {
var isValidEmail: Bool {
let emailFormat = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailPredicate = NSPredicate(format:"SELF MATCHES %@", emailFormat)
return emailPredicate.evaluate(with: self)
}
}
View Alert.swift
import Foundation
import UIKit
class Alert {
class func showBasic(title: String, message: String, vc: UIViewController) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
vc.present(alert, animated: true)
}
View TaskManager.swift
import Foundation
class TaskManager {
static let shared = TaskManager()
let session = URLSession(configuration: .default)
typealias completionHandler = (Data?, URLResponse?, Error?) -> Void
var tasks = [URL: [completionHandler]]()
View CustomTextFieldWithPadding.swift
class CustomTextFieldWithPadding: UITextField {
let padding: CGFloat = 16
private var paddingEdgeInsets: UIEdgeInsets {
return UIEdgeInsetsMake(0, padding, 0, padding)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
View SsidBssid.swift
import UIKit
import SystemConfiguration.CaptiveNetwork
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print("SSID: \(currentID(for: kCNNetworkInfoKeySSID))\nBSSID: \(currentID(for: kCNNetworkInfoKeyBSSID))")
}
You can’t perform that action at this time.