Skip to content

Instantly share code, notes, and snippets.

View adurbalo's full-sized avatar
:octocat:
status check

Andrii Durbalo adurbalo

:octocat:
status check
  • Amsterdam, NL
View GitHub Profile
@adurbalo
adurbalo / CleanUp Repo.md
Last active August 2, 2023 12:33
Clean up git repo

To remove the “leftover” submodules after checking out a different branch, you can run the following. This command will recursively clean the main repository and all submodules.Warning: this will remove all untracked files as well.

git clean -xffd && git submodule foreach --recursive git clean -xffd

To see which files will be deleted without actually deleting yet, add the -n flag.

git clean -nxffd && git submodule foreach --recursive git clean -nxffd
mint run fengniao --project . --exclude fastlane Pods Bundles Umbrella Documentation.docc "Project/Resources/Images/Assets.xcassets/Countries"
# Source https://github.com/onevcat/FengNiao
@adurbalo
adurbalo / repo_clean.sh
Last active October 24, 2022 18:44
Clean up old branches in repo
echo `git fetch --prune origin`
isRemoveEnabled=false
while [ -n "$1" ]
do
case "$1" in
--remove)
isRemoveEnabled=true
;;
-) shift
<%
func capitalizedName(for variable: Variable) -> String {
return "\(String(variable.name.first!).capitalized)\(String(variable.name.dropFirst()))"
}
func customDecodingMethod(for variable: Variable, of type: Type) -> SourceryMethod? {
return type.staticMethods.first { $0.selectorName == "decode\(capitalizedName(for: variable))(from:)" }
}
func defaultDecodingValue(for variable: Variable, of type: Type) -> Variable? {
return type.staticVariables.first { $0.name == "default\(capitalizedName(for: variable))" }
}

Group Anagrams leetcode (M)

class Solution {
    
    func groupAnagrams(_ strs: [String]) -> [[String]] {
        
        var memo: [[Int]: [String]] = [:]
            
 for s in strs {
@adurbalo
adurbalo / Configure rbenv on MacOS.md
Last active October 26, 2023 18:30
Configure rbenv
1. Using ZSH in your Terminal

MacOS Catalina has changed the default terminal from Bash to ZSH. As a result, we'll be adding configs to ~/.zshrc instead of ~/.bash_profile like we used in the past. You can manually change from Bash to ZSH anytime by running the following command:

chsh -s /bin/zsh
2. Install Homebrew

First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source. Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes. Open Terminal and run the following command:

@adurbalo
adurbalo / AutoInitDefaultValues.stencil
Created June 4, 2020 08:10
Sourcery template that extends AutoInit by setting default values as nil to optional's fields
{% for type in types.structs %}
{% if type|annotated:"AutoInitDefaultValues" or type.implements.AutoInitDefaultValues %}
{% set spacing %}{% if type.parentName %} {% endif %}{% endset %}
{% map type.storedVariables into parameters using var %}{{ var.name }}: {{ var.typeName }}{% if var.defaultValue %} = {{var.defaultValue}}{% elif var.typeName.isOptional %} = nil{% endif %}{% endmap %}
// sourcery:inline:auto:{{ type.name }}.AutoInitDefaultValues
{{spacing}} {{ type.accessLevel }} init({{ parameters|join:", " }}) { // swiftlint:disable:this line_length
{{spacing}} {% for variable in type.storedVariables %}
{{spacing}} self.{{ variable.name }} = {{ variable.name }}
{{spacing}} {% endfor %}
{{spacing}} }