Skip to content

Instantly share code, notes, and snippets.

Avatar

Plamen Andreev plam4u

View GitHub Profile
@mattt
mattt / UIViewControllerPreview.swift
Last active Aug 5, 2020
Generic structures to host previews of UIView and UIViewController subclasses.
View UIViewControllerPreview.swift
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@leoiphonedev
leoiphonedev / UITapGesture.swift
Last active May 13, 2020
Extension for UITapGesture that contains a function to detect range of particular text in UILabel's text.
View UITapGesture.swift
extension UITapGestureRecognizer {
func didTapAttributedTextInLabel(label: UILabel, inRange targetRange: NSRange) -> Bool {
// Create instances of NSLayoutManager, NSTextContainer and NSTextStorage
let layoutManager = NSLayoutManager()
let textContainer = NSTextContainer(size: CGSize.zero)
let textStorage = NSTextStorage(attributedString: label.attributedText!)
// Configure layoutManager and textStorage
layoutManager.addTextContainer(textContainer)
@mitchellporter
mitchellporter / README.md
Created May 30, 2019 — forked from acrookston/README.md
Xcode pre-action to build custom Info.plist
View README.md

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of preaction.sh into the pre-action script box.

@kharrison
kharrison / RSSFeed.swift
Last active Dec 9, 2019
Swift Decodable With Multiple Custom Dates
View RSSFeed.swift
import Foundation
extension DateFormatter {
static let iso8601Full: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
formatter.calendar = Calendar(identifier: .iso8601)
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
View vimwiki-cheatsheet.md

VimWiki Cheatsheet

[number] refers to the wiki number, set by the order in your vimrc. The default is 1.

Wiki Management

  • [number] <leader> ww - open wiki index file
  • [number] <leader> wt - open wiki index file in new tab
  • <leader> ws - list and select available wikis
  • <leader> wd - delete wiki page
@simme
simme / debounce-throttle.swift
Created Dec 20, 2016
Swift 3 debounce & throttle
View debounce-throttle.swift
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {
@ryuichis
ryuichis / gist:755e6297aec13c900cdf
Last active Dec 29, 2019 — forked from gavrix/gist:5054182
Script integrating OCLint into XCode. Put it in "Run script" build phase.
View gist:755e6297aec13c900cdf
source ~/.bash_profile
cd ${SRCROOT}
xcodebuild clean
xcodebuild | xcpretty -r json-compilation-database
oclint-json-compilation-database -- -report-type xcode
@squarism
squarism / iterm2.md
Last active Aug 9, 2020
iterm2 cheatsheet
View iterm2.md

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@plam4u
plam4u / DebugWithKeyboard.m
Last active Jan 10, 2017
Debugging via keyboard shortcuts.return array of UIKeyCommand objects, which define a keyboard shortcut.The ViewController will execute corresponding actions mapped to the shortcut.Useful when you want to simulate interactivity but the UI is not ready yet or when you just need to do some debug work.
View DebugWithKeyboard.m
- (BOOL)canBecomeFirstResponder
{
return YES;
}
-(NSArray *)keyCommands
{
return @[
[UIKeyCommand keyCommandWithInput:@"1" modifierFlags:0 action:@selector(debugCommand1)],
[UIKeyCommand keyCommandWithInput:@"2" modifierFlags:0 action:@selector(debugCommand2)]
@mokagio
mokagio / install-xcode-cli-tools.sh
Created Sep 9, 2015
Install Xcode CLI Tools without GUI
View install-xcode-cli-tools.sh
#!/bin/bash
# See http://apple.stackexchange.com/questions/107307/how-can-i-install-the-command-line-tools-completely-from-the-command-line
echo "Checking Xcode CLI tools"
# Only run if the tools are not installed yet
# To check that try to print the SDK path
xcode-select -p &> /dev/null
if [ $? -ne 0 ]; then
echo "Xcode CLI tools not found. Installing them..."
You can’t perform that action at this time.