Skip to content

Instantly share code, notes, and snippets.

View LeoNatan's full-sized avatar

Léo Natan LeoNatan

View GitHub Profile
So you'd like to manage your iOS devices by command line?
You can use libimobiledevice tools for that.
Easy on Linux. Let's see how it is on Mac OS X.
You'll need to:
1. install Xcode
2. start Xcode and agree to it's license
3. install Xcode command line tools (Start Xcode, Go to Preferences -> Downloads tab)
4. install homebrew by this command (sudo password will be prompted)
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@smileyborg
smileyborg / InteractiveTransitionCollectionViewDeselection.m
Last active January 15, 2023 13:03
Animate table & collection view deselection alongside interactive transition (for iOS 11 and later)
// UICollectionView Objective-C example
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];
if (selectedIndexPath != nil) {
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
if (coordinator != nil) {
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
@steipete
steipete / DispatchQueueSurprise.m
Last active December 21, 2018 15:07
This fails in iOS 9, but passes for iOS 10/11. What changed around serial/concurrent dispatch queues in iOS 10 so that this now works. Or rather, why does this not work in iOS 9?
- (void)testDispatchConcurrentExecutionWithNamedQueuesRaw {
let expectation = [self expectationWithDescription:@"Concurrent execution must happen"];
let semaphore = dispatch_semaphore_create(0);
// global queue, concurrent
let attributes = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_DEFAULT, 0);
let defaultQueue = dispatch_queue_create("com.pspdfkit.default-concurrent", attributes);
// serial sub-queues that dispatch to concurrent queue
let queue1 = dispatch_queue_create("com.pspdfkit.queue1", DISPATCH_QUEUE_SERIAL);
#import <Foundation/Foundation.h>
#import <assert.h>
//Compile with `clang -Os -framework Foundation -fno-objc-arc inlinestorage.m -o inline, run with `inline clever` or `inline naive`
/*
NaiveArray implements a simple immutable NSArray-like interface in probably the most obvious way: store a pointer to a C array of objects
*/
@interface NaiveArray : NSObject {
NSUInteger count;
@radianttap
radianttap / wwdc19.sh
Created June 6, 2019 11:23
Fetch all WWDC 2019 session videos and PDFs
#!/bin/bash
#Setup the environment
mkdir tmp_download
cd tmp_download
#Extract IDs
echo "Downloading the index"
wget -q https://developer.apple.com/videos/wwdc2019/ -O index.html
# find parts of the document where data-released=true, all the way to the first H4 header where title of that talk is
@keith
keith / simctl-commands.txt
Last active December 7, 2022 23:27
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 776.1 (Xcode 13.0 beta 5)
addmedia
addphoto
addvideo
appinfo
boot
bootstatus
clone
create
darwinup
delete
@steipete
steipete / OSLogStream.swift
Last active November 7, 2023 22:25
Access streaming OSLogStore at runtime with SPI. (FB8519418) https://steipete.com/posts/logging-in-swift/
//
// OSLogStream.swift
// LoggingTest
//
// Created by Peter Steinberger on 24.08.20.
//
// Requires importing https://github.com/apple/llvm-project/blob/apple/master/lldb/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h via bridging header
import Foundation
csrutil disable
sudo nvram boot-args="intcoproc_unrestricted=1 kext-dev-mode=1 amfi_allow_any_signature=1 amfi_unrestrict_task_for_pid=1 PE_i_can_has_debugger=1 cs_enforcement_disable=1 amfi_get_out_of_my_way=1 amfi=0xff cs_debug=1 ipc_control_port_options=0"
sudo spctl --global-disable
sudo defaults write /Library/Preferences/com.apple.security GKAutoRearm -bool NO
sudo defaults write /Library/Preferences/com.apple.security.coderequirements Entitlements -string always
sudo defaults write /Library/Preferences/com.apple.security.coderequirements AllowUnsafeDynamicLinking -bool YES
sudo defaults write /Library/Preferences/com.apple.security.libraryvalidation.plist DisableLibraryValidation -bool YES
defaults write com.apple.loginwindow DisableScreenLockImmediate -bool yes
import SwiftUI
import UIKit
extension Color {
var uiColor: UIColor {
if #available(iOS 14, *) {
// iOS 14 introduces an API to convert SwiftUI.Color to UIKit.UIColor
// but it does not produce a color which reacts to changes in color scheme
// (light mode/dark mode). To make that work we need to extract the color