Skip to content

Instantly share code, notes, and snippets.

View jayesh15111988's full-sized avatar

Jayesh Kawli jayesh15111988

View GitHub Profile
@jayesh15111988
jayesh15111988 / .zshrc
Last active February 15, 2023 15:32
My zshrc file
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
setopt PROMPT_SUBST
@zirkler
zirkler / gist:d83f24aeffb332a47dc8372c90026e26
Last active April 19, 2023 13:27
stackview_scrollview
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
// 1.
lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .horizontal
stackView.spacing = 20
@kayoslab
kayoslab / swiftlint.yml
Created July 8, 2020 05:54
Default configuration for SwiftLint. This is the standard configuration I use in most of my projects.
### Global configuration
# Enable rules which are not in the default set
opt_in_rules:
# - anyobject_protocol # Prefer using `AnyObject` over `class` for class-only protocols.
# - array_init # Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.
# - attributes # Attributes should be on their own lines in functions and types, but on the same line as variables and imports.
- block_based_kvo # Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.
- class_delegate_protocol # Delegate protocols should be class-only so they can be weakly referenced.
- closing_brace # Closing brace with closing parenthesis should not have any whitespaces in the middle.
@stinger
stinger / CombineFetcher.swift
Last active January 28, 2023 18:07
Combine - fetching data using URLSession publishers
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 16, 2024 01:02
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@d-a-n
d-a-n / EuropeaniOSDevConferences2018.md
Last active October 8, 2018 11:45
European iOS Dev Conferences for 2018

European iOS Dev Conferences for 2018

Dates Conference Location
Jan 29. dotSwift Paris
March 15. - 16. appdevcon Amsterdam
March 22. - 23. iOSCon London
April 16. - 17. Appbuilders Lugano
May 08. - 11. Craft-Conf Budapest
May 13. - 16. UIKonf Berlin
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: view.topAnchor),
@ddunbar
ddunbar / xcbuild-debugging-tricks.md
Last active April 13, 2024 15:41
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@candostdagdeviren
candostdagdeviren / pre-commit
Last active April 22, 2023 09:32
Git Pre-Commit hook with SwiftLInt
#!/bin/bash
#Path to swiftlint
SWIFT_LINT=/usr/local/bin/swiftlint
#if $SWIFT_LINT >/dev/null 2>&1; then
if [[ -e "${SWIFT_LINT}" ]]; then
count=0
for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path