Skip to content

Instantly share code, notes, and snippets.

@arslanbilal
arslanbilal / contactPropertySelection.swift
Last active April 4, 2023 16:03
ContactsUI select contact property
import ContactsUI
class ExampleViewController: UIViewController {
private func dispayContacts() {
let contactPicker = CNContactPickerViewController()
contactPicker.delegate = self
contactPicker.displayedPropertyKeys = [CNContactGivenNameKey, CNContactPhoneNumbersKey]
contactPicker.predicateForEnablingContact = NSPredicate(format: "phoneNumber.@count > 0")
contactPicker.predicateForSelectionOfContact = NSPredicate(value: false)
@arslanbilal
arslanbilal / NetworkActivity.swift
Created December 14, 2018 10:57
NetworkActivity
//
// JuxNetworkActivityIndicator.swift
// Bilal Arslan
//
// Created by BILAL ARSLAN on 14.12.2018.
// Copyright © 2018 BILAL ARSLAN. All rights reserved.
//
import UIKit
@arslanbilal
arslanbilal / PlistDecoder.swift
Last active December 14, 2018 10:56
PropertyListDecoder with Codable
//
// PlistDecoder.swift
// Bilal Arslan
//
// Created by BILAL ARSLAN on 14.12.2018.
// Copyright © 2018 BILAL ARSLAN. All rights reserved.
//
import Foundation
@arslanbilal
arslanbilal / .swiftlint.yml
Last active January 7, 2024 10:55
Default swift lint file for projects
disabled_rules: # rule identifiers to exclude from running
# Number of function parameters should be low.
- function_parameter_count
# Type bodies should not span too many lines.
- type_body_length
# Complexity of function bodies should be limited.
- cyclomatic_complexity
@arslanbilal
arslanbilal / UIAlertController+TextField.swift
Last active September 24, 2018 19:31 — forked from ole/UIAlertController+TextField.swift
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@arslanbilal
arslanbilal / multipleRequest.swift
Last active August 21, 2023 21:55
Multiple Request with Dispatch Group
let firstRequestGroup = DispatchGroup()
let secondRequestGroup = DispatchGroup()
for () {
requestGroup.enter()
firstRequest() {
print("DEBUG: FIRST Request")
if success {
requestGroup.enter()
secondRequest() {

Videos

@arslanbilal
arslanbilal / download.sh
Created February 8, 2016 16:52
Simple download shell script. Customise the file is you need something different.
#!/bin/sh
echo downloading pdf..
wget www.pdf995.com/samples/pdf.pdf
echo pdf downloaded.
echo changing the name from pdf.pdf to new-name.pdf..
mv pdf.pdf new-name.pdf
@arslanbilal
arslanbilal / branchLog.sh
Last active August 29, 2015 14:23
Visualizing branch topology in git
git log --graph --full-history --all --color \
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
#Example Output:
* 3876a55 (origin/master, origin/HEAD, master) Merge branch 'master' of https://github.com/ArslanBilal/Instagram-Client
|\
| * 7d677fa Merge pull request #1 from ArslanBilal/develop
| |\
* | | d799dbc (HEAD, origin/develop, develop) Update README.md for new "Infinite scroll through paginated set of results" feature
* | | 88ac929 Infinite scroll through paginated set of results is added
@arslanbilal
arslanbilal / LogHandling.m
Created May 15, 2015 12:18
Objective-C Log Handling
#import <Foundation/Foundation.h>
#if DEBUG == 0
#define DebugLog(...)
#elif DEBUG == 1
#define DebugLog(...) NSLog(__VA_ARGS__)
#endif
int main()
{