Skip to content

Instantly share code, notes, and snippets.

View MaximBazarov's full-sized avatar
💤
ZEN

Maxim Bazarov MaximBazarov

💤
ZEN
View GitHub Profile
@MaximBazarov
MaximBazarov / WhatToRethinkAndRefactor.sh
Created May 9, 2019 07:06
Show most changing files in the repository
git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -30
import Foundation
/// Gives your value thread protection
public final class AtomicValue<T> {
public var value: T {
get {
return lock.sync {
return self._value

Prerequisites

  1. Install brew
  2. brew install ffmpeg ?? brew install ffmpeg imagemagick gifsicle pkg-config
  3. brew cask install xquartz
  4. brew install gifsicle

Conversion

@MaximBazarov
MaximBazarov / .inputrc
Last active April 1, 2019 20:02 — forked from timf/.inputrc
~/.inputrc for OSX up and down arrow bash history completion (enter the beginning of a command and press up to scroll through matches)
set completion-ignore-case On
"\e[B": history-search-forward
"\e[A": history-search-backward
@MaximBazarov
MaximBazarov / history.md
Last active September 6, 2018 21:01
Mac OS, terminal history based commands autocompletion
  • Make sure you have Homebrew installed, and then use it to install the package bash-completion (by typing the command brew install bash-completion).
  • Homebrew should now tell you what you need to do to complete the installation. In this case, you need to add these three lines to your .bashrc file (using either a command-line text editor like nano which we used above, or a graphical one):
if [ -f $(brew --prefix)/etc/bash_completion ]; then
   . $(brew --prefix)/etc/bash_completion
fi
  • You should now have auto-completion in bash. Please note: for the changes to take effect in existing shells, .bashrc will need to be sourced. Alternatively, logout and login again, or just reboot.
struct UserDidSelectItem {
let item: Item
}
let action = UserDidSelectItem(item: item)
core.dispatch(action)
import Unicore
typealias ApplicationCore = Core<ApplicationState>
let core = ApplicationCore(
state: ApplicationState.initial,
mutate: mutate // pure function (ApplicationState, Action) -> ApplicationState
)
/// Action creator
func downloadProfile(state: ApplicationState) -> Action {
return Downloader.DownloadUserProfile(
baseURL: state.api.profile.baseURL
endpoint: state.api.profile.getProfile
profileID: state.profile.id
authToken: state.auth.token
retryCount: state.api.retryCount
)
}
func profileScreenisAboutToAppear() {
// at that moment we suppose to download information
let action = Downloader.DownloadUserProfile(
baseURL: state.api.profile.baseURL
endpoint: state.api.profile.getProfile
profileID: state.profile.id
authToken: state.auth.token
retryCount: state.api.retryCount
)
core.dispatch(action: action)
struct DownloadUserProfile: Action {
let baseURL: String
let endpoint: String
let profileID: String
let authToken: String
let retryCount: Int
}