Skip to content

Instantly share code, notes, and snippets.

View ManWithBear's full-sized avatar
🐻
Bear with it

Denis Bogomolov ManWithBear

🐻
Bear with it
View GitHub Profile
@ManWithBear
ManWithBear / UITableViewCell+ParentTableView.m
Created November 30, 2016 15:58
Find first tableView in hierarchy
- (UITableView *)parentTableView {
// iterate up the view hierarchy to find the table containing this cell/view
UIView *aView = self.superview;
while(aView != nil) {
if([aView isKindOfClass:[UITableView class]]) {
return (UITableView *)aView;
}
aView = aView.superview;
}
return nil; // this view is not within a tableView
@ManWithBear
ManWithBear / swiftlint.yml
Last active April 21, 2017 09:44
Common used rules for swiftlint
included:
- {Project folder}
- {Project test folder}
excluded:
- {Project folder}/Extensions/UIImage+Assets.swift # automatically generated file
opt_in_rules:
- closure_spacing # closure should have single space inside each brace
- empty_count # prefer isEmpty over comparing to 0
- number_separator # underscore should be used as thousand separator in large decimal numbers
disabled_rules:
@ManWithBear
ManWithBear / create-iso.sh
Last active December 10, 2016 12:03 — forked from julianxhokaxhiu/create-iso.sh
Simple bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
#!/bin/bash
#
# Credits to fuckbecauseican5 from https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/
# Adapted to work with the official image available into Mac App Store
#
# Enjoy!
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
@ManWithBear
ManWithBear / registry.m
Created December 22, 2016 11:22
Registry pattern for singleton factory
+ (instancetype)sharedInstance {
static dispatch_once_t once;
static NSMutableDictionary *sharedInstances;
dispatch_once(&once, ^{
// Creating of the container for shared instances for different classes
sharedInstances = [NSMutableDictionary new];
});
id sharedInstance = nil;
@ManWithBear
ManWithBear / Git commit message.md
Created December 28, 2016 15:50
The seven rules of a great git commit message
  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how
@ManWithBear
ManWithBear / GitAliases
Last active June 18, 2018 07:13
My git aliases
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --graph --pretty=format:\"%Cred%h%Creset %Cred|%Creset %s%C(cyan)%d%Creset\"
histFull = log --graph --pretty=format:\"%Cred%h%Creset %ad %Cred|%Creset %s%C(cyan)%d %Cgreen(%cr) %Cblue[%an]%Creset\" --date=short
last = log -n1 --graph --pretty=format:\"%Cred%h%Creset %ad %Cred|%Creset %s%C(cyan)%d %Cgreen(%cr) %Cblue[%an]%Creset\" --date=short
changes = log --pretty=format:\"%s\"
type = cat-file -t
@ManWithBear
ManWithBear / GitRebase.txt
Last active January 29, 2017 12:17
Rebase workflow commands
git checkout { your branch }
git checkout -b tmp
git checkout develop
git pull
git rebase develop { your branch }
{ complete all rebase steps }
git checkout develop
git merge --no-ff { your branch }
git push
git checkout { your branch }
@ManWithBear
ManWithBear / resetAllSimulators.sh
Created February 24, 2017 15:03 — forked from ZevEisenberg/resetAllSimulators.sh
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@ManWithBear
ManWithBear / NibLoadable.swift
Created March 26, 2017 11:16
Loading objects from Nib
// If you want to create some common way to load objects from nibs, you will probably try something like that:
protocol NibLoadable: class {
static func fromNib() -> Self?
static func nibName() -> String
}
extension NibLoadable {
static func nibName() -> String {
return String(describing: Self.self)
}
@ManWithBear
ManWithBear / QuickFocusRule.yml
Created March 29, 2017 13:18
Rule for swiftlint to show warnings on focused test to prevent commits with focus
custom_rules:
quick_focus:
included: ".*.swift"
name: "Focus on tests"
regex: "^\s*f(it|context|describe)\s*\("
match_kinds:
- identifier
message: "Focused tests should not be commited"
severity: warning