Skip to content

Instantly share code, notes, and snippets.

def selection_sorty(input_list):
for i in range(len(input_list)):
min_index = i
for j in range(i+1, len(input_list)):
if input_list[min_index] == None:
min_index = j
input_list[i], input_list[min_index] = input_list[min_index], input_list[i]
@kashfifahim
kashfifahim / practice_9122022.py
Created September 12, 2022 21:21
List with Mixed Data
def solution_algo(input_list):
# if the list has 0 or 1 element, nothing to do
if len(input_list) <= 1:
return input_list
else:
# using a new list to insert elements from input list
w = []
# first getting all the not-NULL elements into the list
for e in input_list:
if e != None:
// LoYoLocalMainVC.swift
// LoYoLo
//
// Created by iOS on 9/24/18.
// Copyright © 2018 Kashfi Fahim. All rights reserved.
//
import UIKit
import Alamofire
import SwiftyJSON
Auth.auth().createUser(withEmail: emailTextfield.text!, password: passwordTextfield.text!) { (user, error) in
if error != nil {
print(error!)
} else {
print("Registration Successful!")
SVProgressHUD.dismiss()
self.performSegue(withIdentifier: "goToChat", sender: self)
if Auth.auth().currentUser != nil {
performSegue(withIdentifier: "goToChat", sender: self)
}
Auth.auth().signIn(withEmail: emailTextfield.text!, password: passwordTextfield.text!) { (user, error) in
if error != nil {
print(error!)
} else {
print("Log in successful!")
SVProgressHUD.dismiss()
func updateLabels( ) {
targetLabel.text = String(targetValue)
//here we are updating the text of the label
// and because the label holds string type
// we are converting the Int to String
// then assigning it to the text property of
// our targetLabel
}
// our method is called startNewRound and it does not take any parameters
func startNewRound( ) {
targetValue = 1 + Int(arc4random_uniform(100))
// This generates a new random number between 1 and 100
currentValue = 50
slider.value = Float(currentValue)
// So when a new round starts, the slider and the currentValue
@kashfifahim
kashfifahim / alerts.swift
Last active January 24, 2018 03:25
Notes on alerts
// first let's create a function for the alert
// remember to connect this code to a button on the storyboard.
@IBAction func showAlert() {
// We have to (1) set up the alert
// then (2) we have to set up the action to the alert (the button inside the alert)
let alert = UIAlertController(title: "Hello, World!", message: "This is my first alert!", prefferredStyle: .alert)
let action = UIAlertAction(title: "Awesome", style: .default, handler: nil)