Skip to content

Instantly share code, notes, and snippets.

@leemorgan
leemorgan / Fibonacci.swift
Last active November 11, 2024 19:51
Fibonacci series in Swift
// Fibonacci series
// F[n] = F[n-1] + F[n-2]
// 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
// Find the fibonacci number for n interations
func fibonacci(n: Int) {
var num1 = 0
var num2 = 1
@FrancesCoronel
FrancesCoronel / sampleREADME.md
Last active November 14, 2025 13:37
A sample README for all your GitHub projects.

Repository Title Goes Here

Frances Coronel

INSERT GRAPHIC HERE (include hyperlink in image)

Subtitle or Short Description Goes Here

ideally one sentence >

@nazywamsiepawel
nazywamsiepawel / UINavigationBarWithSubtitle.swift
Last active July 20, 2023 11:58
UINavigationBar with subtitle / swift
func setTitle(title:String, subtitle:String) -> UIView {
let titleLabel = UILabel(frame: CGRect(x:0, y:-5, width:0, height:0))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.text = title
titleLabel.sizeToFit()
@jpmcglone
jpmcglone / Array+Additions.swift
Last active March 14, 2019 17:38
array.filter into multiple arrays in one pass
public struct ConditionalArrayFilter <Element> {
let condition: (Element) -> Bool // the condition to meet
private var _array = Array<Element>()
var array: Array<Element> {
get { return _array }
}
init(condition: (Element) -> Bool) { self.condition = condition }
}
private extension ConditionalArrayFilter {
@Valentin-Kalchev
Valentin-Kalchev / Extensions.swift
Last active January 11, 2019 17:53
Swift Extensions
//
// Extensions.swift
//
// Created by Valentin Kalchev on 17/11/2015.
// Copyright © 2015 Valentin Kalchev. All rights reserved.
//
import Foundation
extension Array {
@andyyhope
andyyhope / SwiftEvolution_EnumCaseCountFunctionality_AndyyHope.md
Last active March 12, 2020 13:05
Swift Evolution - Enum Case Count Functionality

Swift Evolution Proposal

Author: Andyy Hope

Enum Values() Functionality (Update)

It has been brought to my attention that there was more use for the unintended values() functionality that I had outline in my "Other Languages" Java example below.

On the Swift Evolution mailing list, one developer outlined their requirement to loop through an array of enum case values to add different states to objects.

Another example where a values array would be useful if the developer wants to do something different for each different case, such as setting an image on a UIButton subclass for each different UIControlState

@guidomb
guidomb / database.json
Last active May 23, 2019 15:54
Firebase database model example for a Twitter-like application
{
"users": {
"280598f1-e31e-4ced-845e-c8dd10e11ec3": {
"first_name": "Guido",
"last_name": "Marucci Blas",
"username": "guidomb",
"email": "[email protected]"
},
"280598f1-e31e-4ced-845e-c8dd10e11ad5": {
@KoCMoHaBTa
KoCMoHaBTa / XCTestExtensions.swift
Last active January 11, 2019 17:50
Useful Extensions to XCTest framework
//
// XCTestExtensions.swift
// https://gist.github.com/KoCMoHaBTa/4ba07984d7c95822bc05
//
// Created by Milen Halachev on 3/18/16.
// Copyright © 2016 Milen Halachev. All rights reserved.
//
import Foundation
import XCTest
@mrkpatchaa
mrkpatchaa / README.md
Last active November 26, 2025 17:45
Bulk delete github repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.

@stinger
stinger / Swift3GCDURLSessionDataTask.swift
Last active March 26, 2018 21:36
Swift 3: GCD and URLSessionDataTask with a completionHandler
//: # Swift 3: CGD and URLSessionDataTask
import Foundation
import PlaygroundSupport
//: ### Create background queue
let queue = DispatchQueue.global(qos: .background)
//: ### Computed variable
var time:DispatchTime! {