Skip to content

Instantly share code, notes, and snippets.

View krzyzanowskim's full-sized avatar

Marcin Krzyzanowski krzyzanowskim

View GitHub Profile
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
// Created by Chris Eidhof on 04-01-16.
// Copyright © 2016 Chris Eidhof. All rights reserved.
//
// Large parts copy/pasted from https://github.com/Eonil/TCPIPSocket.Swift
import Foundation
struct TCPIPSocketAddress {
init(_ a:UInt8, _ b:UInt8, _ c:UInt8, _ d:UInt8) {
let a1 = UInt32(a) << 24
@rnapier
rnapier / 1-simplejson.swift
Last active February 3, 2018 22:59
Yeah, @krzyzanowskim is probably right. What problem were we solving?
import Foundation
// All the complexity needed to avoid this code probably isn't worth it in the majority of cases.
// Particularly note that the data model doesn't 100% line up with the JSON (some keys have
// slightly different names for instance). A system flexible enough to handle that (say, something
// like Go's json.Marshal) would be nice, but this code, while slightly tedious, isn't really bad.
// Basically I'm saying that a richer JSON<->Swift system built into stdlib would be nice, but the
// bar is pretty high to go pulling in a helper library.
//
// That said, compare the Go code below, and I think it really is much simpler, and scales much better
import Cocoa
enum CoroutineState {
case Fresh, Running, Blocked, Canceled, Done
}
struct CoroutineCancellation: ErrorType {}
class CoroutineImpl<InputType, YieldType> {
let body: (yield: YieldType throws -> InputType) throws -> Void
@steipete
steipete / gist:99f8aa8d6527fa027fd6
Last active August 29, 2015 14:25
Mirror for https://forums.developer.apple.com/thread/11098 since that needs moderation first (submitted Jul 16 2015)
We're working on supporting Bitcode in PSPDFKit but hit a blocking issue with OpenSSL (latest 1.0.2d).
We're using a script that downloads and builds OpenSSL into fat static libraries for both Mac and iOS. I've put the gist here:
https://gist.github.com/steipete/ce09ba176a4b8ef66b2d/bf053eab1c0f8494dcd3748079543c4ed4367b9c
Enabling Bitcode should be as easy as adding `-fembed-bitcode` as clang flag according to this entry. That's exactly what I did.
Now things build, but the script eventually stops with this error:
ld: could not open bitcode temp file: ../libcrypto.a(aes-x86_64.o) for architecture x86_64
@Ashton-W
Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@krzyzanowskim
krzyzanowskim / integerWithBytes
Last active May 30, 2018 03:36
integerWithBytes Swift way
// Playground - noun: a place where people can play
import Foundation
typealias Byte = UInt8
protocol GenericIntegerType: IntegerType {
init(_ v: Int)
init(_ v: UInt)
init(_ v: Int8)
@steventroughtonsmith
steventroughtonsmith / Demangle Swift.py
Created January 31, 2015 09:14
Hopper Swift demangler
import subprocess
def looksLikeBeginning(doc,seg,adr):
if doc.is64Bits() and seg.readByte(adr) == 0x55 and seg.readByte(adr + 1) == 0x48 and seg.readByte(adr + 2) == 0x89 and seg.readByte(adr + 3) == 0xE5:
return True
if not doc.is64Bits() and seg.readByte(adr) == 0x55 and seg.readByte(adr + 1) == 0x89 and seg.readByte(adr + 2) == 0xE5:
return True
return False
doc = Document.getCurrentDocument()
@ncase
ncase / SarahTheSpaceSpy.js
Last active June 22, 2023 01:46
A short story about a programmer, written in programming.
function StartDayAgain(){
sarah.wakeUp();
// What if my life was like a movie? In space?
sarah.goto("Bathroom");
sarah.exit(sarah.pajamas);
sarah.clean(sarah);
sarah.clean(sarah.teeth);
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule