Skip to content

Instantly share code, notes, and snippets.

View SwiftLogic's full-sized avatar
Flowing

OhSass from Swift Skool SwiftLogic

Flowing
View GitHub Profile
@GuillaumeJasmin
GuillaumeJasmin / extract.js
Last active September 26, 2022 04:10
Extract substring between two strings
String.prototype.extract = function(prefix, suffix) {
s = this;
var i = s.indexOf(prefix);
if (i >= 0) {
s = s.substring(i + prefix.length);
}
else {
return '';
}
if (suffix) {
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewController composed of TableViews
Last active November 9, 2023 09:00
Sample iOS Unit Tests: Working with a ViewController composed of TableViews
import XCTest
@testable import YourAppTargetname
class SideMenuViewControllerTest: XCTestCase {
var viewControllerUnderTest: SideMenuViewController!
override func setUp() {
super.setUp()
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewController that presents a UIAlertController
Last active September 4, 2022 20:17
Sample iOS Unit Tests: Working with a ViewController that presents a UIAlertController
func testControllerShowsAlertIfUserLogsInWithEmptyUsernameAndPasswordTextField() {
// mock of LoginViewController
class MockLoginViewController: LoginViewController {
var presentViewControllerTarget: UIViewController?
override func presentViewController(viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) {
presentViewControllerTarget = viewControllerToPresent
}
}

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called

.gitignore

In your the root directory of your app and simply write

@saurav12994
saurav12994 / index.js
Created July 31, 2018 05:42
Delete Folder in Firebase cloud storage using Cloud Function
I hava a folder inside CustomerDocuments in Firebase cloud storage name xyz which contains many types of file like .pdf,.txt,.png etc.
function deletefromstorage(quoteiddelete)
{
//quoteiddelete contains folder name in CustomerDocuments which we want to delete.
const Storage = require('@google-cloud/storage');
const storage = new Storage();
const srcBucketName = 'abc.apot.com';
//
// CameraController.swift
//
import AVFoundation
import Photos
import UIKit
class CameraController: UIViewController {
enum Camera {
@vakhidbetrakhmadov
vakhidbetrakhmadov / AVAsset+util.swift
Last active April 28, 2025 08:57
Cropping video track to a specified crop rectangle.
import Foundation
import AVFoundation
extension AVAsset {
func cropVideoTrack(at index: Int, cropRect: CGRect, outputURL: URL, completion: @escaping (Result<Void, Swift.Error>) -> Void) {
enum Orientation {
case up, down, right, left
import Foundation
extension Character {
var isEmoji: Bool {
return unicodeScalars.allSatisfy { $0.properties.isEmoji }
}
}
func recentlyUsedEmoji() -> [Character]? {
#if os(iOS)
@clarkeben
clarkeben / UIKit-Animations.swift
Last active April 25, 2024 15:17
A list of simple yet effective animation extensions for UIKit
import UIKit
//MARK: - UIButton Animations
extension UIButton {
// Contract and retract animation
func contractRetractBtn(duration: Double) {
let contraction = CASpringAnimation(keyPath: "transform.scale")
contraction.duration = duration
contraction.fromValue = 0.96