Skip to content

Instantly share code, notes, and snippets.

View insidegui's full-sized avatar

Guilherme Rambo insidegui

View GitHub Profile
@macshome
macshome / IOKit.swift
Last active April 29, 2024 14:42
This playground shows you a few different ways to get device info via IOKit.
// This playground shows you a few different ways to get device info via IOKit.
// If you want to explore IOKit and look for interesting data I would download
// the Additional Developer Tools from Apple and use the IORegistryExplorer app.
// It makes it super easy to poke around in the IOKit planes.
import IOKit
import Foundation
// For convient access we can make a computed getter for the PlatformExpert.
// Traditionally this has been where you go to find all sorts of data about the
@steventroughtonsmith
steventroughtonsmith / VisionViewPlaygroundApp.swift
Created September 21, 2023 19:22
Trivial visionOS non-rectangular window content layout example
//
// VisionViewPlaygroundApp.swift
// VisionViewPlayground
//
// Created by Steven Troughton-Smith on 21/09/2023.
//
import SwiftUI
@main
@insidegui
insidegui / lsremovearchives.sh
Created December 21, 2021 18:28
Remove Xcode app archives from macOS LaunchServices database
#!/bin/bash
# Recursivelly removes all apps from your Xcode archives from the LaunchServices database, preventing them from being used for widgets, launch at login, etc.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -R -f -u $HOME/Library/Developer/Xcode/Archives
{
"iOS": {
"iOS release": "01c1d682-6e8f-4908-b724-5501fe3f5e5c",
"iOS alternate": "c724cb61-e974-42d3-a911-ffd4dce11eda",
"iOS generic": "0c88076f-c292-4dad-95e7-304db9d29d34",
"iOS 11 developer beta": "b7580fda-59d3-43ae-9488-a81b825e3c73",
"iOS 11 AppleSeed beta": "f23050eb-bdfa-4b23-9eca-453e3b1a247c",
"iOS 11 public beta": "5839f7cf-9610-483a-980f-6c4266a22f17",
"iOS 12 developer beta": "ef473147-b8e7-4004-988e-0ae20e2532ef",
"iOS 12 public beta": "94bf0742-38e6-4379-adf9-ec9995dde586",
@douglashill
douglashill / MenuAlignment.swift
Last active April 15, 2023 15:45
Swizzles the iOS contextual menu and share sheet to improve usability by showing the icon on the leading side. Read more: https://douglashill.co/menu-icon-swizzling/
// Douglas Hill, March 2020
// Code for the article at https://douglashill.co/menu-icon-swizzling/
import UIKit
struct MenuAlignmentFixError: Error, CustomStringConvertible {
let description: String
}
@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 26, 2024 17:49
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@christopher-fuller
christopher-fuller / PagingController.swift
Last active February 22, 2018 09:19
Paged scrolling for UITableView and UICollectionView
//
// PagingController.swift
// Paged scrolling for UITableView and UICollectionView
// Created by Christopher Fuller
//
// MIT License
//
// Copyright © 2018 Christopher Fuller
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
@vi
vi / hextobin.c
Created August 25, 2017 15:10
Hex string to byte buffer in C
// Based on https://stackoverflow.com/a/23898449/266720
void tallymarker_hextobin(const char * str, uint8_t * bytes, size_t blen)
{
uint8_t pos;
uint8_t idx0;
uint8_t idx1;
// mapping of ASCII characters to hex values
const uint8_t hashmap[] =
{
@igorcferreira
igorcferreira / CardType.swift
Last active March 6, 2017 14:12
Basic implementation to apply different regexes over a card number String and find the card type
import Foundation
enum CardTypeError:Error {
case TypeNotFound
}
enum CardType:CustomStringConvertible {
case visa
case mastercard
case amex