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:ae2a3ebf289169d413dc
Created June 16, 2015 01:53
Add IsAbstract property
diff --git a/Clang/Ast/CXXRecordDecl.cs b/Clang/Ast/CXXRecordDecl.cs
index 6acc7b3..16f5453 100644
--- a/Clang/Ast/CXXRecordDecl.cs
+++ b/Clang/Ast/CXXRecordDecl.cs
@@ -19,6 +19,13 @@ namespace Clang.Ast
public extern bool IsDerivedFrom (CXXRecordDecl baseDecl);
[MethodImpl (MethodImplOptions.InternalCall)]
+ extern int GetAbstract ();
+
@migueldeicaza
migueldeicaza / gist:8de4f89b182588927ba16f31b214e35a
Created September 25, 2016 14:17
Minimal HoloLens app with UrhoSharp.
using System;
using Windows.ApplicationModel.Core;
using Urho;
using Urho.Holographics;
using Urho.HoloLens;
internal class Program
{
[MTAThread]
private static void Main()