Skip to content

Instantly share code, notes, and snippets.

Avatar
👍
voran!

Jochen Holzer Wooder

👍
voran!
  • Karlsruhe, Germany
View GitHub Profile
View IDFA_vs_IDFV.md
Requirement IDFA IDFV
User permission(ATT) needed Yes No
Same ID in all Apps of same device Yes No
Same ID in all Apps of vendor on same device Yes Yes
Same ID on different devices No No
Can be used for Ad Attribution Yes No
Can be used for Ad Frequency Capping Yes No (under certain circumstances yes - see article)
Can be used for Audience Targeting Yes Yes
View sonarqube-gitlab-ci.yml
sonarqube-check:
stage: test
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
View sonar-project.properties
# See https://docs.sonarqube.org/7.2/AnalysisParameters.html for documentation
sonar.projectKey=your_project_key
sonar.organization=default
sonar.links.homepage=https://gitlab.com/aaa/bbb
sonar.projectBaseDir=.
sonar.sources=YourApp/Classes
sonar.host.url=https://sonarqube-instance.yourdomain.com/
sonar.report.export.path=sonar-report.json
#sonar.login= add this if running sonar-client locally
sonar.qualitygate.wait=true
View useful_simctl_commands
# record video from iOS simulator
xcrun simctl io booted recordVideo appVideo.mov
View EmailValidator.swift
import Foundation
public class EmailValidator {
public init() {
}
public func validateEmailAddress(_ email: String) -> Bool {
let emailTest = NSPredicate(format: "SELF MATCHES %@", String.emailValidationRegEx)
return emailTest.evaluate(with: email)
View swift_safe_double_to_int_conversion_via_extension_and_failable_initializer.swift
extension Int {
init?(doubleVal: Doube) {
guard (doubleVal <= Double(Int.max).nextDown) && (doubleVal >= Double(Int.min).nextUp) else {
return nil
}
self.init(doubleVal)
}
View gist:79a0a547b42600c08a8671e74b3cebb4
Date in current timezone as string:
let longDateString = Date().description(with: .current)
let shortDateString DateFormatter.localizedString(from: expiryDate, dateStyle: .medium, timeStyle: .short)
View useful-unix-commands
### which shell is used?
echo $SHELL
echo $0
@Wooder
Wooder / IsDebuggerAttached.swift
Created Nov 21, 2017
Swift Code that check if the debugger is attached to your iOS Device (App runs in XCode) while running your app
View IsDebuggerAttached.swift
#if DEV
fileprivate func isDebuggerAttached() -> Bool {
var info = kinfo_proc()
var mib : [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
var size = MemoryLayout<kinfo_proc>.stride
let junk = sysctl(&mib, UInt32(mib.count), &info, &size, nil, 0)
assert(junk == 0, "sysctl failed")
return (info.kp_proc.p_flag & P_TRACED) != 0
}
#endif
View urlEncode.swift
private func urlEncodeString(_ string: String) -> String {
#if swift(>=3.0)
let allowedCharacterSet = (CharacterSet(charactersIn: "!*'();:@&=+$,/?%#[] ").inverted)
if let escapedString = string.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) {
return escapedString
}
#else
let allowedCharacterSet = (NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[] ").invertedSet)
if let escapedString = string.stringByAddingPercentEncodingWithAllowedCharacters(allowedCharacterSet) {
return escapedString