Skip to content

Instantly share code, notes, and snippets.

View nishabe's full-sized avatar

nish abe nishabe

View GitHub Profile
@nishabe
nishabe / fonts.swift
Created June 2, 2020 20:18
Print All Font Families available in the Application
for family: String in UIFont.familyNames
{
print(family)
for names: String in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}
// GIF creation
ffmpeg -ss 00:00:03.000 -i SpendTogether.mp4 -pix_fmt rgb24 -r 10 -s 440x960 -t 00:00:8.000 SpendTogether4.gif
ffmpeg -ss 00:00:10.000 -i Expressions.mp4 -pix_fmt rgb24 -r 10 -s 524x1080 -t 00:00:12.000 Expressions1.gif
// For optimization
convert -layers Optimize SpendTogether2.gif output_optimized.gif
// Installation of Tools
brew install ffmpeg
brew install imagemagick
@nishabe
nishabe / Fastfile
Last active July 16, 2019 18:50
Fastfile
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
default_platform(:ios)
platform :ios do
desc "Description of what the lane does"
lane :metrics do
scan(scheme: "testSonar",
@nishabe
nishabe / sonar-project.properties
Last active August 3, 2022 19:00
sonar-project.properties
#
# Swift SonarQube Plugin - Enables analysis of Swift and Objective-C projects into SonarQube.
# Copyright © 2015 Backelite (${email})
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@nishabe
nishabe / Serialize an Object to JSON.swift
Created July 3, 2019 20:27
Serialize an Object to JSON in swift
do {
let jsonData = try JSONEncoder().encode(myObjectHere)
let json = String(data: jsonData, encoding: .utf8)
print(json!)
}
catch {
print(error)
}
@nishabe
nishabe / gist:0f3a60cd73bc2c7fcf9144d0442f674b
Last active July 1, 2019 15:50
Capitalize first letter of every word in a string (Swift)
extension String {
func capitalizingFirstLetter() -> String {
return prefix(1).capitalized + dropFirst()
}
func getCamelCasedString () -> String {
var camelCasedStringCollection = [String]()
let stringComponents = components(separatedBy: " ")
for var oneComponent in stringComponents {
oneComponent = oneComponent.capitalizingFirstLetter()
camelCasedStringCollection.append(oneComponent)
@nishabe
nishabe / unitTestSample.swift
Last active February 8, 2019 04:38
unitTestSample
// This test verfies the value of actual string is equal to the epected string
func test_behaviorBeingTested_contextItsTestedUnder() {
// Given
let objectUnderTest = SomeClass()
// When
objectUnderTest.performSomeAction()
let expected: String = "The expected change"
let actual: String = objectUnderTest.text
// Then
XCTAssertEqual(expected, actual)
@nishabe
nishabe / SWIFT: Set Tint for Application.swift
Created September 8, 2018 22:10
SWIFT: Set Tint for Application
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Configure Window
window?.tintColor = UIColor(red:0.99, green:0.47, blue:0.44, alpha:1.0)
return true
}
@nishabe
nishabe / SWIFT: Get Documents Directory Path
Created August 13, 2018 02:44
SWIFT: Get Documents Directory Path
public extension FileManager {
static var documentsDirectoryURL: URL {
return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
}
}
let docUrl = FileManager.documentsDirectoryURL
or
let docUrl = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
@nishabe
nishabe / SWIFT:Random Number Generation
Created August 12, 2018 18:50
SWIFT:Random Number Generation
let randomTasks = ["laundry","Grocery","Rent","Phone bill","Internet Bill","Excercise","Cycling","Cleaning"]
let randomNumber = arc4random_uniform(UInt32(randomTasks.count))