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 / WMO.md
Last active August 31, 2017 12:47
Whole module optimization in swift

Whole module optimization does exactly what we want. It compiles all the files in one go. The problem with whole module optimization is that it optimizes, so its pretty slow. But if you add a user-defined custom flag; SWIFT_WHOLE_MODULE_OPTIMIZATION and set it to yes, as well as set the optimization level to none. It will do whole module optimization without optimizing. And it'll be super fast.
by https://www.skilled.io/u/swiftsummit/swift-with-a-hundred-engineers

@ManWithBear
ManWithBear / generateUserStoryModule
Last active May 6, 2017 20:38
Generate module of specific user story by using generamba
#!/bin/bash/
testPath="{ project name }Tests/PresentationLayer/UserStories/$1"
projectPath="{ project name }TODO/PresentationLayer/UserStories/$1"
generamba gen "$2" { template name } --test_path "$testPath" --module_path "$projectPath"
@objc protocol Refreshable
{
/// The refresh control
var refreshControl: UIRefreshControl? { get set }
/// The table view
var tableView: UITableView! { get set }
/// the function to call when the user pulls down to refresh
@objc func handleRefresh(_ sender: Any);
@ManWithBear
ManWithBear / liquidGenerator.rb
Created April 25, 2017 11:41
Generate files from provided template
require 'liquid'
require 'fileutils'
input_file = File.absolute_path(ARGV[0])
@template = Liquid::Template.parse(File.open(input_file, "r").read)
renderedTemplate = @template.render()
extn = File.extname(input_file)
output_file = File.dirname(input_file) + "/" + File.basename(input_file, extn)
File.open(output_file, "w") {|f| f.write(renderedTemplate) }
@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
@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 / 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 / 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 / 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 / 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