Skip to content

Instantly share code, notes, and snippets.

View andr3a88's full-sized avatar

Andrea Stevanato andr3a88

View GitHub Profile
@andr3a88
andr3a88 / gitEditor.txt
Created November 25, 2019 11:51
Make VSCode default editor for GIT
git config --global core.editor "code --wait"
@andr3a88
andr3a88 / Dangerfile.swift
Created October 17, 2019 12:49
Dangerfile.swift use for Danger Swift
import Danger
let danger = Danger()
// Pull request size
let bigPRThreshold = 500
let additions = danger.github.pullRequest.additions!
let deletions = danger.github.pullRequest.deletions!
let changedFiles = danger.github.pullRequest.changedFiles!
if (additions + deletions > bigPRThreshold) {
@andr3a88
andr3a88 / build-binary-universal-framework.sh
Created July 24, 2019 08:43 — forked from quangDecember/build-binary-universal-framework.sh
Build Binary framework script for iOS, included fix for Xcode 10.2 headers, originally by DJ110
# Xcode 10.2
# please use within Xcode environment (Build Phases -> Run Script or Scheme -> Post Actions)
xcodebuild -version
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
env > env.txt
# Step 1. Build Device and Simulator versions
xcodebuild -project "${PROJECT_NAME}.xcodeproj" -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@andr3a88
andr3a88 / PodCache
Created July 23, 2019 13:16
Clear cocoapods cache
pod cache clear --all
pod cache clear 'alamofire'
pod cache clear 'alamofire' --all // delete all installed 'alamofire' pods
@andr3a88
andr3a88 / DecodingError.swift
Created March 22, 2019 14:04
Catch the decoding error
let decoder = RPJSONDecoder()
do {
let response = try decoder.decode(BaseDataArrayResponse<T>.self, from: json)
completion(response.data, nil)
} catch let DecodingError.dataCorrupted(context) {
completion(nil, DecodingError.dataCorrupted(context))
print("codingPath:", context.codingPath)
} catch let DecodingError.typeMismatch(type, context) {
completion(nil, DecodingError.typeMismatch(type, context))
print("Type '\(type)' mismatch:", context.debugDescription)
@andr3a88
andr3a88 / CleanUserDefaults.swift
Created March 4, 2019 11:28
An extension on UserDefaults, which’ll enable us to easily create an instance that has had all of its persisted values completely cleared
extension UserDefaults {
static func makeClearedInstance(
for functionName: StaticString = #function,
inFile fileName: StaticString = #file
) -> UserDefaults {
let className = "\(fileName)".split(separator: ".")[0]
let testName = "\(functionName)".split(separator: "(")[0]
let suiteName = "com.johnsundell.test.\(className).\(testName)"
let defaults = self.init(suiteName: suiteName)!
@andr3a88
andr3a88 / reflection.swift
Last active February 22, 2019 09:18
Reflection in Swift [Playground]
import UIKit
class UserSession {
let name: String = "Mario"
let id: String = "id_123123123"
let token: String = "s79s2waas9432j2jf23f2"
}
let userSession = UserSession()
@andr3a88
andr3a88 / SeparatorLine.tsx
Last active January 24, 2019 09:16
React native component for a separator line
import React from 'react';
import { View } from 'react-native';
interface IProps {
color?: string;
marginTop?: number;
marginBottom?: number;
}
export class SeparatorLine extends React.Component<IProps, any> {
@andr3a88
andr3a88 / UITableViewLongPressGestureRecognizer.swift
Last active June 8, 2022 12:05
Recognize long press gesture on a table view cell
class ViewController: UITableViewDataSource, UITableViewDelegate {
var longPressGesture: UILongPressGestureRecognizer!
override func viewDidLoad() {
super.viewDidLoad()
...
longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressGestureRecognized(_:)))
@andr3a88
andr3a88 / PasswordValidation.swift
Created November 7, 2018 11:42
Utils for password validation with different criterias
extension WTFViewModel {
let passwordMinChars: Int = 6
let passwordMinCriterias: Int = 3
/// Checks if the text meets the validity criteria
///
/// - Parameter text: The text
/// - Returns: The result
private func isPasswordCriteriaSatisfied(text: String) -> Bool {