Skip to content

Instantly share code, notes, and snippets.

View RealEmmettS's full-sized avatar
💻
Probably making something...

Emmett Shaughnessy RealEmmettS

💻
Probably making something...
View GitHub Profile
// GAME: GUESS THE NUMBER //
// Variable & Requirements Setup //
const prompt = require("prompt-sync")();
let number = 5;
// Game Function //
import Firebase
import FirebaseFirestore
import FirebaseAuth
import FirebaseAuthUI
import FirebaseFacebookAuthUI
import FirebaseGoogleAuthUI
import FirebaseOAuthUI
import FirebasePhoneAuthUI
import FirebaseEmailAuthUI
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()
//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)
//Replace 0 with the minimum, and replace 6 with the maximum
let randomInt = Int.random(in: 0..<6)
//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")
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(){
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)
}
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:
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