Skip to content

Instantly share code, notes, and snippets.

View hewigovens's full-sized avatar
🐛
Fixing

Tao Xu hewigovens

🐛
Fixing
View GitHub Profile
@unixzii
unixzii / ContentView.swift
Last active March 30, 2024 08:36
GPU particle system using Metal.
import SwiftUI
struct SmashableView: NSViewRepresentable {
typealias NSViewType = _SmashableNSView
let text: String
class _SmashableNSView: NSView {
@JunyuKuang
JunyuKuang / MacCatalystFastQuitHelper.swift
Last active October 14, 2022 03:43
Prevent Mac Catalyst apps from running in the background for a long time, after user explicitly quit it.
//
// MacCatalystFastQuitHelper
//
// Copyright © 2022 Jonny Kuang. MIT
//
import UIKit
enum MacCatalystFastQuitHelper {
import lldb
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('command script add -f SwiftPrinter.printer pjson')
def printer(debugger, command, result, internal_dict):
debugger.HandleCommand('p print(String(data: try! JSONSerialization.data(withJSONObject:' + command + ', options: .prettyPrinted), encoding: .utf8 )!)')
@douglashill
douglashill / KeyboardScrollView.swift
Last active May 6, 2021 00:47
A UIScrollView subclass that allows scrolling using a hardware keyboard like NSScrollView. Supports arrow keys, option + arrow keys, command + arrow keys, space bar, page up, page down, home and end.
// Douglas Hill, November 2019
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A scroll view that allows scrolling using a hardware keyboard like `NSScrollView`.
/// Supports arrow keys, option + arrow keys, command + arrow keys, space bar, page up, page down, home and end.
/// Limitations:
/// - Paging scroll views (isPagingEnabled = true) are not supported yet.
/// - The scroll view must become its own delegate so setting the delegate is not supported yet.
@hewigovens
hewigovens / main.go
Last active December 5, 2019 06:23
call wallet core from go on macOS
package main
// #cgo CFLAGS: -I${SRCDIR}/wallet-core/include
// #cgo LDFLAGS: -L${SRCDIR}/wallet-core/build/ios -lTrezorCrypto -lTrustWalletCore -lprotobuf -lc++
// #include <TrustWalletCore/TWHDWallet.h>
// #include <TrustWalletCore/TWString.h>
import "C"
import "fmt"
@johnno1962
johnno1962 / swiftui.swift
Last active November 6, 2019 23:51
SwiftUI Injection
// First, install InjectionIII.app from the Mac AppStore
// https://apps.apple.com/us/app/injectioniii/id1380446739?mt=12
// Make these changes to your code:
// add the following to application(didFinishLaunchingWithOptions:)
#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
#endif
@ole
ole / UIAlertController+TextField.swift
Last active September 13, 2022 14:20
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@backus
backus / signTypedData.js.md
Created April 8, 2018 20:48
How signTypedData works

I couldn't find a good explanation of each step of signTypedData EIP with examples of inputs and outputs at each step. I wanted this so I could keep track.

Say this is our private key

const privKey = new Buffer(
  "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
  "hex"
);
@damienlaughton
damienlaughton / UIAccessorizedTextField.swift
Created March 28, 2018 15:16
UIAccessorizedTextField is an iOS friendly alternative to the drop down list
//
// UIAccessorizedTextField.swift
// AccessorizedTextField
//
// Created by Damien Laughton on 28/03/2018.
// 2018 Mobilology Limited. No rights reserved.
//
import Foundation
import UIKit
@HiImJulien
HiImJulien / Swift Meets CCxx.md
Last active March 30, 2024 19:00
This gist is a simple example on how to call a function written in swift from C/C++, without taking the detour via Objective-C/C++.

Swift Meets C/C++

This gist is a simple example on how to call a function written in swift from C/C++, without taking the detour via Objective-C/C++.


Analytics

In this example we're going to invoke a function called say_hello, which, as the name already suggests, prints "Hello, World!" to the terminal.