Skip to content

Instantly share code, notes, and snippets.

View albertodebortoli's full-sized avatar

Alberto De Bortoli albertodebortoli

View GitHub Profile
@albertodebortoli
albertodebortoli / dev_hosted_runner_poc.yml
Created May 17, 2024 16:27
GitHub Actions dev-hosted runners PoC
name: dev-hoster runner PoC
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
@albertodebortoli
albertodebortoli / AASA_example.json
Created May 9, 2024 13:05
Universal Links matching against AASA
{
"applinks": {
"details": [
{
"appIDs": [
"XXXXXXXXXX.com.example.app"
],
"components": [
{
"/": "/",
@albertodebortoli
albertodebortoli / change_author_git_commit.md
Last active November 10, 2023 08:41
Change the author of a commit in Git

Using Interactive Rebase

git rebase -i -p <some HEAD before all of your bad commits>

Then mark all of your bad commits as "edit" in the rebase file, and when git asks you to amend each commit, do

git commit --amend --author "New Author Name <email@address.com>"

edit or just close the editor that opens, and then do

@albertodebortoli
albertodebortoli / BrokenDismiss.swift
Created May 7, 2023 18:15
Showcasing the ViewController's dismiss method being broken in packages
import XCTest
import UIKit
@testable import DismissTest
class TopLevelUIUtilities {
private var rootWindow: UIWindow!
func setupTopLevelUI(withViewController viewController: UIViewController) {
@albertodebortoli
albertodebortoli / tech_radar.json
Last active August 26, 2022 09:29
tech_radar.json
[
{
"name": "Four key metrics",
"ring": "Adopt",
"quadrant": "Techniques",
"isNew": false,
"description": "asd"
}
]
@albertodebortoli
albertodebortoli / AppDelegate.m
Created March 9, 2012 22:16
iPhone splash screen fade out animation
// in application:didFinishLaunchingWithOptions: in app delegate
// before [window makeKeyAndVisible];
UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
splashView.image = [UIImage imageNamed:@"background.png"];
// after [window makeKeyAndVisible];
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
splashView.image = [UIImage imageNamed:@"Default.png"];
[window addSubview:splashView];
@albertodebortoli
albertodebortoli / gist:2204433
Created March 26, 2012 10:55
Copy file from bundle to documents directory in iOS
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.filename = @"file.ext";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [documentPaths objectAtIndex:0];
self.filePath = [documentDir stringByAppendingPathComponent:self.filename];
[self createAndCheckDatabase];
@albertodebortoli
albertodebortoli / generate_toc.rb
Last active April 7, 2022 14:14
Generate Markdown TOC
#!/usr/bin/env ruby
File.open("your_file.md", 'r') do |f|
f.each_line do |line|
forbidden_words = ['Table of contents', 'define', 'pragma']
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ }
title = line.gsub("#", "").strip
href = title.gsub(" ", "-").downcase
puts " " * (line.count("#")-1) + "* [#{title}](\##{href})"
@albertodebortoli
albertodebortoli / gist:0058860ba4ec12a089d81a4c34c771ac
Created September 15, 2020 19:55
Naughty Xcode: Free space commands
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Developer/Xcode/Archives
rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport
rm -rf ~/Library/Caches/com.apple.dt.Xcode
xcrun simctl delete unavailable
@albertodebortoli
albertodebortoli / gist:67d0d4522400193aa521
Created November 28, 2014 21:18
UICollectionView: Paging for Smaller Width Cells
// NOTE: This delegate method requires you to disable UICollectionView's `pagingEnabled` property.
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint *)targetContentOffset {
CGPoint point = *targetContentOffset;
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
// This assumes that the values of `layout.sectionInset.left` and