This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Bond | |
| import ReactiveKit | |
| class UserProfileViewModel { | |
| let refreshing = Observable<Bool>(false) | |
| let username = Observable<String>("") | |
| let photos = Observable<[Photos]>([]) | |
| private let userViewModel: UserViewModel | |
| private let photosViewModel: PhotosViewModel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Сброс позволяет откатиться на определённую версию в истории изменений Git. Всего есть три вида сброса: | |
| git reset --hard {{some-commit-hash}} — вернуться на определённый коммит в истории. Все изменения, сделанные после этого коммита пропадут. | |
| git reset {{some-commit-hash}} — вернуться на определённый коммит в истории. Все изменения, сделанные после этого коммита, получат состояние «Not staged for commit». Чтобы вернуть их обратно, нужно использовать команды git add и git commit. | |
| git reset --soft {{some-commit-hash}} — вернуться на определённый коммит в истории. Все изменения, сделанные после этого коммита, получат состояние «Staged for commit». Чтобы вернуть их обратно, нужно использовать команду git commit. | |
| Поналачу эта информация может показаться бесполезной, однако, когда вы начнёте работать с разными версиями файлов, она вам очень пригодится. Например, я для себя выделил вот такие сценарии использования этих команд: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Install oh-my-zsh | |
| sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" | |
| 2. Clone necessary plugins. | |
| git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions | |
| git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search | |
| git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
| 3. Add plugins to ~/.zshrc as | |
| plugins = ( [plugins...] zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| func sum(_ lhs: String,_ rhs: String, carry: Int = 0) -> String { | |
| guard let lhsLast = lhs.last else { | |
| if rhs.count > 0 { | |
| return rhs | |
| } else { | |
| return carry == 1 ? "1" : "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://en.wikipedia.org/wiki/Heap%27s_algorithm | |
| import Foundation | |
| /** | |
| Generates all possible permutations of `data` using Heap's Algorithm | |
| - parameters: | |
| - data: The data to permute | |
| - output: A closure called with each permutation of the data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/osascript -l JavaScript | |
| // Open a new iTerm tab with a specified command. | |
| // Usage example: ./openTermCommand.js '/usr/local/bin/vim /tmp/test.txt' | |
| function run(argv) { | |
| const iTerm = Application('iTerm') | |
| iTerm.includeStandardAdditions = true | |
| iTerm.activate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //create the dispatch work item | |
| var dwi2:DispatchWorkItem? | |
| dwi2 = DispatchWorkItem { | |
| for i in 1...5 { | |
| print("\(dwi2?.isCancelled)") | |
| if (dwi2?.isCancelled)!{ | |
| break | |
| } | |
| sleep(1) | |
| print("DispatchWorkItem 2: \(i)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## @file | |
| ## Shows CLI diff between two plist files. | |
| ## | |
| ## Normally, Mac plist files are binary, so diffs do not display. However, | |
| ## there are cases where seeing diffs is important. For example, when tracking | |
| ## changes via Mackup's git storage option. | |
| ## | |
| ## Note this option allows seeing plist diffs without fully installing Xcode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function run (input, parameters) { | |
| const iTerm = Application('iTerm2') | |
| iTerm.activate() | |
| const windows = iTerm.windows() | |
| var window = iTerm.currentWindow() | |
| var tab = window.currentTab() | |
| var session = tab.currentSession() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AppKit | |
| public extension NSBezierPath { | |
| public var CGPath: CGPath { | |
| let path = CGMutablePath() | |
| var points = [CGPoint](repeating: .zero, count: 3) | |
| for i in 0 ..< self.elementCount { | |
| let type = self.element(at: i, associatedPoints: &points) | |
| switch type { |