Skip to content

Instantly share code, notes, and snippets.

@vahotm
vahotm / VGrid.swift
Last active June 7, 2023 08:10
A non-lazy alternative to LazyVGrid. The difference from LazyVGrid is that VGrid gives equal height to its cells based on the highest cell, hence its non-laziness.
import Foundation
import SwiftUI
struct VGrid<Cell: View>: View {
struct CollectionRow<Cell: View>: View {
let indices: Range<Int>
let numberOfColumns: Int
let spacing: CGFloat
@vahotm
vahotm / script.sh
Last active December 12, 2018 15:12
Write git diff into file on Desktop
git rev-parse --git-dir 1>/dev/null && git add -N . && git diff > "${HOME}/Desktop/$(basename $(git rev-parse --show-toplevel))_$(date '+%d-%m-%Y_%H-%M-%S').diff"
{
"name": "LTHPasscodeViewController",
"version": "3.8.5",
"license": {
"type": "MIT",
"file": "LICENSE.txt"
},
"authors": {
"Roland Leth": "[email protected]"
},
@vahotm
vahotm / Regex for cyrillic chars.txt
Created January 20, 2016 09:55
Following regex matches cyrillic characters in localization keys for NSLocalizedString
// Following regex matches cyrillic characters in localization keys for NSLocalizedString
//---------------------------------------------------------------------------------------
NSLocalizedString\(@"([\w\s\d]*?)([а-яА-Я]+)([\w\s\d]*?)"
//----------------------------------
// Test cases
//----------------------------------
NSLocalizedString(@"Notification", nil)
NSLocalizedString(@"Notificatio n ъ s df
", nil)
@vahotm
vahotm / CenterInContainerWithVFL.m
Last active January 20, 2016 09:56
Snippet for constraints in Visual Format Language, that center view vertically and horizontally in its superview.
// Vertical center in container
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[superview]-(<=1)-[view]"
options:NSLayoutFormatAlignAllCenterY
metrics:nil
views:viewDict]];
// Horizontal center in container
[superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[superview]-(<=1)-[view]"
options:NSLayoutFormatAlignAllCenterX
metrics:nil