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 / PGNParsing.swift
Last active October 6, 2019 11:44
Draft for PGN parsing task
import Foundation
// MARK: - Portable Game Notation (PGN).
/// Portable Game Notation (PGN).
/// https://en.wikipedia.org/wiki/Portable_Game_Notation
struct PGN {
typealias TurnNumber = UInt
let counterparts: [Counterpart]
@MaximBazarov
MaximBazarov / Networking.swift
Last active September 2, 2019 17:35
Trying to make a Networking layer more clean
/// USAGE ///
// Declarative endpoint description
// MARK: - Endpoints
struct LoginRequest: Request {
let endpoint = "api/v3/auth"
let method = HTTPMethod.get
let headers: [String : String] = [:]
@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
)
}