Skip to content

Instantly share code, notes, and snippets.

View hebertialmeida's full-sized avatar
✈️

Heberti Almeida hebertialmeida

✈️
View GitHub Profile
@dkun7944
dkun7944 / CDView.swift
Last active January 14, 2024 23:45
SwiftUI + Swift.Shader CD
//
// CDView.swift
// CD
//
// Created by Daniel Kuntz on 7/3/23.
//
import SwiftUI
struct ShapeWithHole: Shape {
@fxm90
fxm90 / Combine+Pairwise.swift
Last active February 17, 2024 02:09
Extension for a Combine-Publisher that returns the current and previous value.
//
// Combine+Pairwise.swift
//
// Created by Felix Mau on 17.05.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import Combine
extension Publisher {
@mecid
mecid / Calendar.swift
Last active May 8, 2024 13:30
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@dimitribouniol
dimitribouniol / Bump Project Version.sh
Last active December 10, 2023 02:00
Automatically Bump Versions in Xcode
cd "${PROJECT_DIR}"
# Make sure working directory is clean.
if output=$(git status --porcelain) && [ -n "$output" ]; then
echo "error: Please commit any uncommitted files before proceeding:\n$output"
exit 1
fi
# Make sure we are on master (and not a feature branch, for instance)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
@kashiftriffort
kashiftriffort / URLSessionInterception.swift
Last active September 28, 2023 23:35
URLSession swizzling in Swift
extension URLSessionConfiguration {
@objc
static func setupSwizzledSessionConfiguration() {
guard self == URLSessionConfiguration.self else {
return
}
let defaultSessionConfiguration = class_getClassMethod(URLSessionConfiguration.self, #selector(getter: URLSessionConfiguration.default))
@nathan-fiscaletti
nathan-fiscaletti / symbolicate.sh
Last active September 24, 2023 21:44
A tool for symbolicating iOS crash reports.
#!/bin/bash
CRASH=$1
APP=$2
ARCH=$3
OUTPUT=$4
# This script will fully symbolicate an iOS Crash Report
# Usage: ./symbolicate.sh mycrash.crash MyApp.app arch64 output.crash
#
import UIKit
extension UIColor {
static func randomLightColor() -> UIColor {
let halfRange: ClosedRange<CGFloat> = 0.5 ... 1.0
return UIColor(
red: CGFloat.random(in: halfRange),
green: CGFloat.random(in: halfRange),
blue: CGFloat.random(in: halfRange),
alpha: 1
import UIKit
let crayonDictionary = ["Sepia": #colorLiteral(red: 0.6171875, green: 0.35546875, blue: 0.25, alpha: 1.0),
"Beaver": #colorLiteral(red: 0.5703125, green: 0.43359375, blue: 0.35546875, alpha: 1.0),
"Caribbean Green": #colorLiteral(red: 0.0, green: 0.796875, blue: 0.59765625, alpha: 1.0),
"Electric Lime": #colorLiteral(red: 0.796875, green: 0.99609375, blue: 0.0, alpha: 1.0),
"Gray": #colorLiteral(red: 0.54296875, green: 0.5234375, blue: 0.5, alpha: 1.0),
"Pacific Blue": #colorLiteral(red: 0.0, green: 0.61328125, blue: 0.765625, alpha: 1.0),
"Burnt Sienna": #colorLiteral(red: 0.91015625, green: 0.453125, blue: 0.31640625, alpha: 1.0),
"Manatee": #colorLiteral(red: 0.55078125, green: 0.5625, blue: 0.62890625, alpha: 1.0),
/*
Usage:
Adding this script to your doc:
- Tools > Script Manager > New
- Select "Blank Project", then paste this code in and save.
Running the script:
- Tools > Script Manager
- Select "ConvertToMarkdown" function.
- Click Run button.
- Converted doc will be mailed to you. Subject will be "[MARKDOWN_MAKER]...".
@xtravar
xtravar / AttributedStringStruct.swift
Created August 3, 2018 00:18
NSAttributedString doing interpolation and being all struct-y
public struct AttributedString {
fileprivate var _handle: NSMutableAttributedString
fileprivate init(handle: NSMutableAttributedString) {
self._handle = handle
}
fileprivate init(_ str: NSAttributedString) {
self.init(handle: str.mutableCopy() as! NSMutableAttributedString)