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
// GAME: GUESS THE NUMBER // | |
// Variable & Requirements Setup // | |
const prompt = require("prompt-sync")(); | |
let number = 5; | |
// Game Function // |
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 Firebase | |
import FirebaseFirestore | |
import FirebaseAuth | |
import FirebaseAuthUI | |
import FirebaseFacebookAuthUI | |
import FirebaseGoogleAuthUI | |
import FirebaseOAuthUI | |
import FirebasePhoneAuthUI | |
import FirebaseEmailAuthUI |
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
private func playVideo() { | |
guard let path = Bundle.main.path(forResource: "video", ofType:"m4v") else { | |
debugPrint("video.m4v not found") | |
return | |
} | |
let player = AVPlayer(url: URL(fileURLWithPath: path)) | |
let playerController = AVPlayerViewController() | |
playerController.player = player | |
present(playerController, animated: true) { | |
player.play() |
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
//Paste in an 'extra' (global) Swift file, or after the class in a viewController file | |
extension UIViewController { | |
func hideKeyboardWhenTappedAround() { | |
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard)) | |
view.addGestureRecognizer(tap) | |
} | |
@objc func dismissKeyboard() { | |
view.endEditing(true) |
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
//Replace 0 with the minimum, and replace 6 with the maximum | |
let randomInt = Int.random(in: 0..<6) |
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
//Store a value in UserDefaults | |
let defaults = UserDefaults.standard | |
defaults.set(25, forKey: "Age") | |
//Retrieve a value from UserDefaults | |
let age = defaults.integer(forKey: "Age") |
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
var api_result:[String]? | |
// The sample API request below is modeled off of the Gater API sample request. | |
// https://docs.gater.dev/the-basics/sending-and-receiving | |
// The default response to the sample API used below is | |
// {"main":{"status":"Gater is alive and well"}} | |
//MARK: API Request | |
func apiRequest(){ |
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
func showAlert(title: String, message: String, continueTitle: String, cancelTitle: String, addCancelButton cancel: Bool){ | |
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: nil)) | |
if cancel { | |
alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil)) | |
} | |
self.present(alert, animated: true) | |
} |
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 RPi.GPIO as GPIO | |
from time import sleep | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) | |
run = 1 | |
while run == 1: |
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
if <#condition#>{ | |
if #available(iOS 13.0, *) { | |
UIView.transition (with: self.view, duration: 0.3, options: .transitionCrossDissolve, animations: { | |
self.overrideUserInterfaceStyle = .dark //.light or .unspecified | |
}, completion: nil) | |
} | |
}else{ | |
if #available(iOS 13.0, *) { | |
UIView.transition (with: self.view, duration: 0.3, options: .transitionCrossDissolve, animations: { | |
self.overrideUserInterfaceStyle = .light //.light or .unspecified |
NewerOlder