Skip to content

Instantly share code, notes, and snippets.

View standinga's full-sized avatar

standinga

View GitHub Profile
//
// UDPListener.swift
//
// Created by Michael Robert Ellis on 12/16/21.
//
import Foundation
import Network
import Combine
@jakeajames
jakeajames / patch.sh
Last active June 29, 2024 16:22
Make h3lix work when installed not-via-Impactor. To be used with the latest h3lix.
if [ $# != 2 ]; then
echo "Usage: $0 /path/to/input_ipa /path/to/output_ipa"
exit 1
fi
if ! [ -f $1 ]; then
echo "'$1' does not exist"
exit 1
fi
extension UIWindow {
/// Traverse the window's view hierarchy in the same way as the Debug View Hierarchy tool in Xcode.
///
/// `traverseHierarchy` uses Depth First Search (DFS) to traverse the view hierarchy starting in the window. This way the method can traverse all sub-hierarchies in a correct order.
///
/// - parameters:
/// - visitor: The closure executed for every view object in the hierarchy
/// - responder: The view object, `UIView`, `UIViewController`, or `UIWindow` instance.
/// - level: The depth level in the view hierarchy.
func traverseHierarchy(_ visitor: (_ responder: UIResponder, _ level: Int) -> Void) {
@bradtraversy
bradtraversy / docker_wordpress.md
Last active July 21, 2024 05:00
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@FWEugene
FWEugene / SwiftConcurrency.md
Created January 10, 2019 17:37
All about concurrency

Threads

Foundation offers a Thread class, internally based on pthread, that can be used to create new threads and execute closures.

// Detaches a new thread and uses the specified selector as the thread entry point.
Thread.detachNewThreadSelector(selector: Selector>, toTarget: Any, with: Any)

// Subclass
class MyThread: Thread {
@erics
erics / executeGitInGradle.txt
Last active June 2, 2023 20:40
execute git command in gradle
def getGitCommand = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log','--date=local','--name-status','--after="2018.07.19"'
standardOutput = stdout
}
return stdout.toString().trim()
}
task prinGitLog{
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active July 12, 2024 03:33
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@omarojo
omarojo / imageToPixelBuffer.swift
Created February 23, 2017 23:02
Image To CVPixelBuffer in Swift
var thePixelBuffer : CVPixelBuffer?
let testImage : UIImage = UIImage.init(named: "twdEnds.png")!
self.thePixelBuffer = self.pixelBufferFromImage(image: testImage)
func pixelBufferFromImage(image: UIImage) -> CVPixelBuffer {