Skip to content

Instantly share code, notes, and snippets.

@gmoraleda
gmoraleda / git-purge
Last active May 27, 2024 11:28
git purge
#!/usr/bin/env sh
set -e
echo "⬇️ Pulling latest code..."
git pull --quiet
echo "🔥 Deleting local branches that were removed in remote..."
git fetch -p
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
echo "🌳 Remaining local branches:"
echo "-------------------------"
@gmoraleda
gmoraleda / prepare-commit-msg
Created May 23, 2024 11:29
Prepare commit message using conventional commits
#!/bin/bash
# Format commits using JIRA issue ID and conventional commits.
# E.g.
# Branch name: fix/ABC-123/bug-fixing
# Commit message: Bug fixed
# Formatted commit message: fix: [ABC-123] Bug fixed
REGEX_ISSUE_ID="[a-zA-Z0-9,\.\_\-]+-[0-9]+"
REGEX_ISSUE_TYPE="[a-z]+"
@gmoraleda
gmoraleda / localize.py
Last active February 19, 2021 10:44
POEditor Integration
import requests
def to_camel_case(snake_str):
components = snake_str.split("_")
return components[0] + "".join(x.title() for x in components[1:])
def getTerms():
data = (
("api_token", "your_api_token"),
("id", "your_project_id"),
if [ "${CONFIGURATION}" != "ReleaseProduction" ]; then
IFS=$'\n'
git checkout -- `find "${SRCROOT}/${PRODUCT_NAME}" -name AppIcon.appiconset -type d`
fi
#!/bin/bash
#
# Helpers
#
function installImageMagick() {
brew install imagemagick ghostscript
}
#
"${SRCROOT}/Scripts/IconVersioning.sh"
// MARK: - Keyboard Insets
extension UIViewController {
internal func updateInsets(for event: KeyboardEvent, scrollView: UIScrollView?) {
guard let scrollView = scrollView else { return }
let newKeyboardFrame = event.keyboardFrameEnd
let duration = event.duration
let newKeyboardHeight = newKeyboardFrame.origin.y < UIScreen.main.bounds.height ? newKeyboardFrame.height : Sizes.zero
let keyboard = KeyboardObserver()
override func viewDidLoad() {
super.viewDidLoad()
keyboard.observe { [weak self] (event) -> Void in
guard let self = self else { return }
switch event.type {
case .willShow, .willHide, .willChangeFrame:
// React to the keyboard and adapt your UI
private func setupStrings(for speaker: Speaker) {
titleLabel.text = speaker.name
positionLabel.text = speaker.position
descriptionTextView.text = speaker.description
updateTextViewFrame()
}
private func updateTextViewFrame() {
contentView.layoutIfNeeded()
[...]
// Add observer in layoutSubviews()
pictureImageView.observe(\UIImageView.frame, options: [.new]) { [weak self] (_, _) in
self?.updateTextViewFrame()
}
[...]