Skip to content

Instantly share code, notes, and snippets.

@rluvaton
rluvaton / README.md
Last active September 17, 2024 11:27
Bundle install for mac that temporarly disable IPv6 for network interface while downloading

Fixed bundle install for MacOS

This is a zx script that fix bundle install

How to run:

The bundle-install file should be without extension (but not required) added the extension to make GitHub syntax highlighting work

So from now we just gonna use bundle-install instead of bundle-install.mjs

@bartekpacia
bartekpacia / RunnerTests.m
Last active May 2, 2025 14:39
This snippet shows how to dynamically create test cases in XCTest.
@import XCTest;
@import ObjectiveC.runtime;
@interface ParametrizedTests : XCTestCase
@end
@implementation ParametrizedTests
+ (NSArray<NSInvocation *> *)testInvocations {
NSLog(@"testInvocations() called");
@hartfordfive
hartfordfive / README.md
Last active April 28, 2025 05:58
Git pre-commit hook to verify committer email

Description

The goal of this hook is to allow you catch when you're committing with an email you shouldn't on a public repositories. In some cases, certain companies need to seperate their internal coporate email accounts from those that might be used for committing to public repositories.

Setting up.

The UNWANTED_EMAIL_SUFFIX should be the suffix (after the @ sign) of the email address you do not want to appear in the git logs. The DESIRED_AUTHOR_EMAIL and DESIRED_AUTHOR_NAME are the respective email and name you want to show up in the git logs.

@yoxisem544
yoxisem544 / KeychainStorage.swift
Created November 5, 2020 03:26
Property wrapper of keychain store
import Foundation
import KeychainAccess
//https://www.swiftbysundell.com/articles/property-wrappers-in-swift/
public protocol AnyOptional {
var isNil: Bool { get }
}
extension Optional: AnyOptional {
public var isNil: Bool { self == nil }
@jensim
jensim / add_default_reviewers.sh
Last active June 6, 2024 21:44
Add default reviewers to bitbucket-server pull requests where there are currently 0 reviewers
#!/bin/bash
#set -x
set -e
host='https://my-code.local'
if ! which jq ; then
echo 'jq not installed.' >&2
exit 1
@bryanbraun
bryanbraun / git-branching-diagram.md
Last active April 27, 2025 17:30
Example Git Branching Diagram

Example Git Branching Diagram

You can use this diagram as a template to create your own git branching diagrams. Here's how:

  1. Create a new diagram with diagrams.net (formerly draw.io)
  2. Go to File > Open From > URL
  3. Insert this url (it points to the xml data below): https://gist.githubusercontent.com/bryanbraun/8c93e154a93a08794291df1fcdce6918/raw/bf563eb36c3623bb9e7e1faae349c5da802f9fed/template-data.xml
  4. Customize as needed for your team.

@emctague
emctague / TupleToArray.swift
Created January 29, 2020 00:24
Tuple to Array Conversion for Swift
/**
# Tuple-to-array for Swift
By Ethan McTague - January 28, 2020
This source code is in the public domain.
## Example
To convert a tuple of Ints into an array of ints:
@ManWithBear
ManWithBear / Runtime_tests.md
Created October 7, 2019 14:30
How to create runtime tests in swift

You probably can't do it in pure swift since NSInvocation is not part of swift api anymore.

XCTest rely on + (NSArray<NSInvocation *> *)testInvocations function to get list of test methods inside one XCTestCase class. Default implementation as you can assume just find all methods that starts with test prefix and return them wrapped in NSInvocation. (You could read more about NSInvocation here)
So if we want to have tests declared in runtime, this is point of interest for us.
Unfortunately NSInvocation is not part of swift api anymore and we cannot override this method.

If you OK to use little bit of ObjC then we can create super class that hide NSInvocation details inside and provide swift-friendly api for subclasses.

/// Parent.h
@cyrilchandelier
cyrilchandelier / MinimumTouchAreaButton.swift
Created September 23, 2019 07:30
A Swift UIButton extension to ensure the hit-zone is at least 44x44
import UIKit
class MinimumTouchAreaButton: UIButton {
override func hitTest(_ point: CGPoint, with _: UIEvent?) -> UIView? {
guard !isHidden, isUserInteractionEnabled, alpha > 0 else {
return nil
}
let expandedBounds = bounds.insetBy(dx: min(bounds.width - 44.0, 0), dy: min(bounds.height - 44.0, 0))
return expandedBounds.contains(point) ? self : nil
}
@blochberger
blochberger / Info.plist
Last active January 14, 2024 14:12
macOS/iOS TLS 1.3 Support
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.howsmyssl.com</key>
<dict>