Skip to content

Instantly share code, notes, and snippets.


Plamen Andreev plam4u

View GitHub Profile
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)]
plam4u / generate_storyboard_constants.rb
Created Apr 21, 2018 — forked from ralfebert/generate_storyboard_constants.rb
Generate Swift constants for Xcode storyboards containing cell reuse identifiers, segue identifiers and storyboard identifier. More information:
View generate_storyboard_constants.rb
#!/usr/bin/env ruby
require 'nokogiri'
def show_usage(msg = nil)
puts "#{msg}\n\n" if msg
puts "Usage:\n\t#{$PROGRAM_NAME} [storyboard_file]"
View MediumBlogFontHandling_FullCode.swift
import Foundation
import UIKit
// Usage Examples
let system12 = Font(.system, size: .standard(.h5)).instance
let robotoThin20 = Font(.installed(.RobotoThin), size: .standard(.h1)).instance
let robotoBlack14 = Font(.installed(.RobotoBlack), size: .standard(.h4)).instance
let helveticaLight13 = Font(.custom("Helvetica-Light"), size: .custom(13.0)).instance
struct Font {
View TableHeaderView - variable height
extension UITableView {
/// Variable-height UITableView tableHeaderView with autolayout
/// Source:
func layoutTableHeaderView() {
guard let headerView = self.tableHeaderView else { return }
headerView.translatesAutoresizingMaskIntoConstraints = false
plam4u / git-pushing-multiple.rst
Created Oct 16, 2019 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.
View git-pushing-multiple.rst

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

plam4u /
Created Oct 20, 2019 — forked from myusuf3/
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
plam4u / NotificationTestCase.swift
Created Oct 23, 2019 — forked from fxm90/NotificationTestCase.swift
XCTest - Assert notification (not) triggered.
View NotificationTestCase.swift
import XCTest
class NotificationTestCase: XCTestCase {
func testTriggerNotification() {
expectation(forNotification: .fooBar,
object: nil,
handler: nil)
let notificationCenter = NotificationCenter.default
plam4u / UITapGesture.swift
Created Apr 21, 2020 — forked from leoiphonedev/UITapGesture.swift
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:
let textStorage = NSTextStorage(attributedString: label.attributedText!)
// Configure layoutManager and textStorage
View boilerplate.swift
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI {
VStack {
Text("Hello, World")
You can’t perform that action at this time.