Skip to content

Instantly share code, notes, and snippets.

View bilogub's full-sized avatar
🇺🇦

Yuriy Bilogub bilogub

🇺🇦
View GitHub Profile
@bilogub
bilogub / terminal-git-branch-name.md
Created April 16, 2019 14:16 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@bilogub
bilogub / iosShowAlert.swift
Created December 17, 2015 15:45
Show Alert message in iOS
let errorMessageCtrl = UIAlertController(title: "Location Services Disabled",
message: "To operate this application needs Location Services enabled on your device." +
"\nPlease change configuration in Settings menu accordingly.\nThank you", preferredStyle: .Alert)
let alertAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
errorMessageCtrl.addAction(alertAction)
navigationController?.presentViewController(errorMessageCtrl, animated: true, completion: nil)
@bilogub
bilogub / NullRelation.rb
Last active December 12, 2015 06:28
Rails Null Relation
# Takes relation or model as klass argument
# to produce empty relation
class NullRelation
class << self
def for(klass)
raise(ArgumentError, "Model class is not provided") unless klass
klass.where('1 = 0')
end
end
end