Skip to content

Instantly share code, notes, and snippets.

OpenWRT dedicated wireless SSID with Wireguard client (kill switch included)

Setup: These steps were performed OpenWRT 23.04.1.

Context: The goal of that manual is to create wireless SSID that will be connected to the Wireguard network as a client. Helpful link - that guide will create a Wireguard interface with kill switch (https://openwrt.org/docs/guide-user/services/vpn/wireguard/extras#kill_switch) In other words, that guide will help you create a deidated wireless SSID that will be connected directly to the wireguard.

  1. Set up Wireguard on remote server:
//
// PagingView.swift
// Wallaroo - https://wallaroo.app
//
// Created by Sean Heber (@BigZaphod) on 8/9/22.
//
import SwiftUI
// This exists because SwiftUI's paging setup is kind of broken and/or wrong out of the box right now.
@NSExceptional
NSExceptional / HookUIApplicationMain.m
Last active November 2, 2022 17:27
Hooking UIApplicationMain in Swift or Objc apps with Fishhook
// UIApplicationMain accepts Swift.String in Swift apps; a C forward declaration is needed
struct SwiftString {
uint8_t reserved[16];
};
typedef struct SwiftString SwiftString;
int (*orig_UIApplicationMain_objc)(int argc, char *argv[], NSString *_, NSString *delegateClassName) = nil;
int (*orig_UIApplicationMain_swift)(int argc, char *argv[], SwiftString _, SwiftString delegateClassName) = nil;
NSString *(*FoundationBridgeSwiftStringToObjC)(SwiftString str) = nil;

Debugging the Swift Toolchain

Use these steps to debug components of the Swift toolchain. This allows you to see Swift's source code from the debugger – instead of disassembly. The debugger can also provide some variable names and values. This has been initially tested with libswiftCore.dylib.

These instructions were updated as of Swift 5.2.1.

Prerequisites

@AliSoftware
AliSoftware / Demo.swift
Last active October 31, 2023 12:25
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {
@zntfdr
zntfdr / firebase-iOS-breakdown.swift
Last active July 25, 2024 08:35
Firebase iOS Version breakdown
// How to:
// 1. Open the Firebase Analytics Dashboard
// 2. Scroll to bottom, where you see the "Users by Device model" widget
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
// 5. Make sure to select “OS with version” and not “OS Version”
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date)
// 7. Click “Download file” on the new side bar, then “Download CSV"
// 8. Open the file and select the iOS/Android breakdown raw data
// 9. Replace the sample data in this script with your data
@DevAndArtist
DevAndArtist / fake_animation_completion.swift
Created September 18, 2019 12:24
SwiftUI Fake Animation completion for animations that do not overshoot the final value
fileprivate struct _CompletionPreferenceKey: PreferenceKey {
typealias Value = CGFloat
static let defaultValue: CGFloat = 0
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
}
}
@ZevEisenberg
ZevEisenberg / RxSignpost.swift
Last active March 16, 2022 01:54
Use os_signpost for performance logging of transformations in RxSwift
// RxSwift signposts
import os.signpost
import RxSwift
func signpost<T>(log: OSLog, name: StaticString, value: String, _ thing: () throws -> T) rethrows -> T {
let signpostID = OSSignpostID(log: log)
os_signpost(
.begin,
docker run \
-e USER="$(id -u)" \
-v $PWD:/src/workspace \
-v /tmp/build_output:/tmp/build_output \
-v ~/.config/gcloud:/root/.config/gcloud \
-w /src/workspace \
l.gcr.io/google/bazel:0.25.0 \
--output_user_root=/tmp/build_output \
--nohome_rc --bazelrc=.bazelrc-rbe-0.25.0 \
build //... \
@AliSoftware
AliSoftware / Bindings.swift
Last active July 9, 2024 22:02
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
/*:
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI
The only purpose of this code is to implement those wrappers myself
just to understand how they work internally and why they are needed,
⚠️ This is not supposed to be a reference implementation nor cover all
subtleties of the real Binding and State types.
The only purpose of this playground is to show how re-implementing
them myself has helped me understand the whole thing better