Skip to content

Instantly share code, notes, and snippets.

@xtabbas
xtabbas / SnapCarousel.swift
Created May 10, 2020 18:13
A carousel that snap items in place build on top of SwiftUI
//
// SnapCarousel.swift
// prototype5
//
// Created by xtabbas on 5/7/20.
// Copyright © 2020 xtadevs. All rights reserved.
//
import SwiftUI
@karwa
karwa / collection-split.swift
Last active February 12, 2020 21:09
Split collections by length
// MARK: - Sequence.
extension Sequence {
public func split(maxLength: Int) -> [ArraySlice<Element>] {
return Array(self)._eagerSplit(maxLength: maxLength)
}
}
extension Collection {
#! /usr/bin/swift
//
// - This is just some AppKit boilerplate to launch a window.
//
import AppKit
@available(OSX 10.15, *)
class AppDelegate: NSObject, NSApplicationDelegate {
let window = NSWindow()
let windowDelegate = WindowDelegate()
@koingdev
koingdev / ExportOptions.plist
Last active October 15, 2024 09:22
Script to automatically upload iOS App to AppStore and TestFlight (including versioning)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>destination</key>
<string>upload</string>
<key>method</key>
<string>app-store</string>
<key>provisioningProfiles</key>
<dict>
@koingdev
koingdev / Usage.swift
Created April 12, 2019 16:57
Swift way to create an autoweak closure (No more retain cycle/memory leak)
// From this
didFinishLoading = { [weak self] in
guard let self = self else { return }
self.tableView.reloadData()
}
// To this
didFinishLoading = weaker(self) { s in
// No more boilerplate code :)
s.tableView.reloadData()
@Maxnelson997
Maxnelson997 / PrintFontFamilyFonts.swift
Created February 2, 2019 20:52
Print all fonts from every font family included in your iOS swift app.
UIFont.familyNames.forEach { (familyName) in
let fontNames = UIFont.fontNames(forFamilyName: familyName)
print(familyName, fontNames)
}
@jamesdube
jamesdube / example .travis.yml
Created October 9, 2018 10:26 — forked from jay-johnson/example .travis.yml
example .travis.yml
sudo: required
language: ruby
services:
- docker
before_install:
- echo "Testing Docker Hub credentials"
- docker login -e=$DOCKER_EMAIL -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
//
// Signer.swift
// Sign
//
// Created by Yung-Luen Lan on 2018/8/17.
// Copyright © 2018 yllan. All rights reserved.
//
import Foundation
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@bpolania
bpolania / DataExtensions.swift
Last active February 7, 2025 07:01
Swift Extensions for Data, Int, UInt8, UInt16, and UInt32 types
// MIT License
// Copyright (c) 2018 Boris Polania
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: