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 Alamofire | |
let url = "https://example.com/" | |
let user = "me" | |
let pass = "pwd" | |
let headers: HTTPHeaders = [ | |
"Authorization": "Basic " + ("\(user):\(pass)".data(using:.utf8)?.base64EncodedString() ?? ""), | |
] |
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
😀 | grinning face | |
---|---|---|
😁 | beaming face with smiling eyes | |
😂 | face with tears of joy | |
🤣 | rolling on the floor laughing | |
😃 | grinning face with big eyes | |
😄 | grinning face with smiling eyes | |
😅 | grinning face with sweat | |
😆 | grinning squinting face | |
😉 | winking face | |
😊 | smiling face with smiling eyes |
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 Cocoa | |
import SystemConfiguration | |
// Usage | |
// if Reachability.isConnectedToNetwork() { | |
// print("We're online!") | |
// } | |
public class Reachability { | |
class func isConnectedToNetwork() -> Bool { |
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
guard let window = view.window else { print("Nope") ; return } | |
let panel = NSOpenPanel() | |
panel.canChooseFiles = false | |
panel.canChooseDirectories = true | |
panel.allowsMultipleSelection = false | |
panel.canCreateDirectories = true | |
panel.beginSheetModal(for: window) { (result) in | |
if result == NSFileHandlingPanelOKButton { | |
self.folderPath = panel.urls[0] | |
} |
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
// Save data to file | |
let fileName = "Test" | |
let DocumentDirURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) | |
let fileURL = DocumentDirURL.appendingPathComponent(fileName).appendingPathExtension("txt") | |
print("FilePath: \(fileURL.path)") | |
let writeString = "Write this text to the fileURL as text in iOS using Swift" | |
do { | |
// Write to the file |
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 String { | |
func fromBase64() -> String? { | |
guard let data = Data(base64Encoded: self) else { | |
return nil | |
} | |
return String(data: data, encoding: .utf8) | |
} | |
func toBase64() -> String { | |
return Data(self.utf8).base64EncodedString() | |
} |
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
package com.package.name | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.webkit.WebView | |
import android.webkit.JavascriptInterface | |
import android.content.Context | |
class WebViewJsInterface(private val context: Context, private val webView: WebView) { | |
@JavascriptInterface |
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
-- if uuid is set use that, otherwise create uuid | |
create trigger trigger_defaults_on_users | |
before insert on users | |
for each row | |
set new.uuid = coalesce(nullif(new.uuid, ''), uuid()) | |
; |
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
<?php | |
$API_KEY = '[Mailchimp API Key Goes Here]'; | |
$LIST_ID = "[Mailchimp List ID Here]"; | |
$AUTH_HEADER = "Authorization: Basic ".base64_encode("anystring:".$API_KEY)."\r\nContent-type: application/x-www-form-urlencoded\r\n"; | |
// Prob. fetched from db.. | |
$list_of_users = [ | |
(object)["first" => "John", "last" => "Smith", "email" => "[email protected]", "color" => "red"], | |
(object)["first" => "Jane", "last" => "Doe", "email" => "[email protected]", "color" => "blue"] |