Skip to content

Instantly share code, notes, and snippets.

@migueldeicaza
migueldeicaza / gist:adb5a3ccabab75a14381d02b25d6942e
Created May 19, 2022 20:39
Dumps passwords from the iOS keychain
func dump () {
let k = kSecClassGenericPassword
let query: [String: Any] = [
kSecClass as String: k,
kSecMatchLimit as String: kSecMatchLimitAll,
kSecReturnRef as String: true,
kSecReturnAttributes as String: true
]
var itemCopy: AnyObject?
let status = SecItemCopyMatching(query as CFDictionary, &itemCopy)
@migueldeicaza
migueldeicaza / gist:7b383f9481e95fab8b5d16943eccf545
Created April 21, 2022 21:39
Alternative to semaphore locking around a task
init () {
//let _ = LinuxTop (source: try! String (contentsOfFile: "/Users/miguel/cvs/CpuStatus/pi-top-output"))
//let _ = MacTop (source: try! String (contentsOfFile: "/Users/miguel/cvs/CpuStatus/mac-top-output"))
Task {
print ("await/Starting")
let x: Bool = await withCheckedContinuation { cc in
Task {
print ("await/Sleeping")
@migueldeicaza
migueldeicaza / MyTextLabel.swift
Created January 26, 2021 03:47 — forked from CrystDragon/MyTextLabel.swift
Most basic custom UITextInput conformance, without selection interaction, no UI elements but only pure texts.
import UIKit
class MyTextLabel: UIView {
var textLayer = CATextLayer()
var textStorage: String = "" {
didSet {
textLayer.string = textStorage
}
}
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/miguel/cvs/SwiftSH/SwiftSH/SSHLibrary.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Queue.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Session.swift /Users/miguel/cvs/SwiftSH/SwiftSH/ConsoleLogger.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Error.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Extensions.swift /Users/miguel/cvs/SwiftSH/SwiftSH/SFTP.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Logger.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Libssh2.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Shell.swift /Users/miguel/cvs/SwiftSH/SwiftSH/SCP.swift /Users/miguel/cvs/SwiftSH/SwiftSH/DNS.swift -primary-file /Users/miguel/cvs/SwiftSH/SwiftSH/Channel.swift /Users/miguel/cvs/SwiftSH/SwiftSH/Command.swift -emit-module-path /Users/miguel/DerivedData/SwiftSH-cyqzhumcvedcnhajuftnadmnmmiy/Build/Intermediates.noindex/SwiftSH.build/Debug-iphonesimulator/SwiftSH.build/Objects-normal/x86_64/Channel\~partial.swiftmodule -emit-module-doc-pa

I have a problem with a native library dependency in my project SwiftTerm, the native library dependency is a wrapper for libssh, and I compile this as a .framework which I then reference from SwiftTerm.

The problem is that on the same system where I build the .framework, something makes the build system go poking at the original site where the code was built, and produces this error:

/Users/miguel/cvs/SwiftTerm/SwiftSH.binaries/module.modulemap:1:8: error: redefinition of module 'Libssh2'
module Libssh2 {
 ^
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
* frame #0: 0x00000001008e32ac mlir-translate`llvm::FunctionType::getReturnType(this=0x0000000000000000) const at DerivedTypes.h:129:40
frame #1: 0x00000001008e3135 mlir-translate`llvm::CallInst::CallInst(this=0x000000010741a020, Ty=0x0000000000000000, Func=0x0000000000000000, Args=ArrayRef<llvm::Value *> @ 0x00007ffeefbf9c58, Bundles=ArrayRef<llvm::OperandBundleDefT<llvm::Value *> > @ 0x00007ffeefbf9c80, NameStr=0x00007ffeefbf9e10, InsertBefore=0x0000000000000000) at Instructions.h:1632:20
frame #2: 0x00000001008e3040 mlir-translate`llvm::CallInst::CallInst(this=0x000000010741a020, Ty=0x0000000000000000, Func=0x0000000000000000, Args=ArrayRef<llvm::Value *> @ 0x00007ffeefbf9cd0, Bundles=ArrayRef<llvm::OperandBundleDefT<llvm::Value *> > @ 0x00007ffeefbf9cf0, NameStr=0x00007ffeefbf9e10, InsertBefore=0x0000000000000000) at Instructions.h:1636:30
frame #3: 0x00000001008e2d82 mlir-translate`llvm::CallIn
$next = 0;
while (<>){
if (/DllImport/){
$import = $_;
$next = 1;
} elsif ($next){
($prefix, $func, $args) = $_ =~ /(.*) (TF_[A-Za-z0-9]*) (\(.*)/;
#print "Got [$prefix][$func][$args] - $_\n";
$res = $import;
$res =~ s/Library/Library, EntryPoint="$func"/;
@migueldeicaza
migueldeicaza / gist:624675f0edc9f5dd1a908bf547445987
Created April 2, 2018 15:56
Public type surface for System.Runtime.Extensions.dll
Assembly Information:
Culture=neutral
PublicKeyToken=b03f5f7f11d50a3a
System.AppDomain
System.AppDomainUnloadedException
System.ApplicationId
System.AssemblyLoadEventArgs
@migueldeicaza
migueldeicaza / gist:43b28ef3ceb8db59ffc00b70eb37f309
Created April 25, 2017 01:54
Dictionary-literal improvement to allow literals to be assigned to other Dictionary-shaped objects
--- /dev/null 2017-04-24 21:53:22.000000000 -0400
+++ README.md 2017-04-24 21:53:03.000000000 -0400
@@ -0,0 +1,67 @@
+Current work:
+
+Trying to allow the existing patch for dictionary literals that allows:
+
+ var a = ["key":"value"];
+
+Which creates an inferred Dictionary<string,string> above into
mono$ mono /usr/local//share/dotnet/sdk/1.0.0-preview3-004056/csc.exe
Could not load signature of Microsoft.CodeAnalysis.CommonCompiler:ResolveAnalyzersFromArguments due to: Could not load file or assembly 'System.Collections.Immutable, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:System.Collections.Immutable, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:<unknown type> member:<none>
Unhandled Exception:
System.TypeLoadException: Could not load type of field 'Microsoft.CodeAnalysis.CoreClrAnalyzerAssemblyLoader:_loadContext' (0) due to: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. assembly:System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:<unknown type> member:<none>
at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation (System.Collections.Generic.IEnumerable`1[T] o