Skip to content

Instantly share code, notes, and snippets.

View 1024jp's full-sized avatar
👻
boo

1024jp 1024jp

👻
boo
View GitHub Profile
@defagos
defagos / ExampleView.swift
Created September 28, 2021 21:04
Send a message to the UIKit responder chain from a SwiftUI view
@objc protocol ExampleActions: AnyObject {
func pushUIKitViewController()
}
struct ExampleView: View {
@FirstResponder private var firstResponder
var body: some View {
Button {
firstResponder.sendAction(#selector(ExampleActions.pushUIKitViewController))
@rogerluan
rogerluan / String+Regex.swift
Created July 27, 2020 02:26
Handy Regex utility to find and replace matching groups in Swift.
extension String {
/// Finds matching groups and replace them with a template using an intuitive API.
///
/// This example will go through an input string and replace all occurrences of "MyGreatBrand" with "**MyGreatBrand**".
///
/// let regex = try! NSRegularExpression(pattern: #"(MyGreatBrand)"#) // Matches all occurrences of MyGreatBrand
/// someMarkdownDocument.replaceGroups(matching: regex, with: #"**$1**"#) // Surround all matches with **, formatting as bold text in markdown.
/// print(someMarkdownDocument)
///
/// - Parameters:
@niw
niw / example.swift
Created April 4, 2020 00:47
macOS 10.15.4 Catalyst erases the underline for input method marked text if content attributed text has `.underlineStyle`.
let textView = UITextView(frame: view.bounds)
textView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let text = NSMutableAttributedString(string: "test")
text.addAttributes([
.font: UIFont.systemFont(ofSize: 20.0),
.foregroundColor: UIColor.label,
.underlineStyle: 0
], range: NSRange(location: 0, length: text.length))
@niw
niw / README.md
Created July 26, 2019 03:44
A simple text file for Tweet to know if I could be trusted or not.

🐱 にゃーん

Context:

@niw
niw / download_macos_and_create_install_disk.sh
Last active July 18, 2023 10:44
A script to download macOS install image and create an install disk image
#!/usr/bin/env bash
set -e
VOLUME_PATH=/Volumes/installer
while getopts ":d:h" opts; do
case $opts in
d)
VOLUME_PATH=$OPTARG
;;
app = Application("CotEditor")
app.includeStandardAdditions = true
doc = app.documents()[0]
function replaceSelectedText1(newText) {
selectedRange = doc.selection.range()
if(!selectedRange[1]){
// omit
return newText
}
@LeonardoCardoso
LeonardoCardoso / GPG-Tower
Last active April 21, 2023 11:53
How to setup Tower to use the GPG Suite
# GPG on Tower
@mattshepherd
mattshepherd / apple help book example.txt
Last active November 3, 2022 13:32
To support the table of contents button in the OS X Help Book app you need to implement the following code. This isn't documented anywhere but I found it in Apple's own help files and tested it to work. I believe it only works in the more recent versions of OS X, so you if your app supports really old versions you might want to check it.
//disable TOC button
window.HelpViewer.showTOCButton(false);
//enable TOC button
//If you call this on window load it will flash active for a brief second and then disable again.
//Call if after a delay of 250ms and is works fine
//Not sure what the second variable does yet, but passing false works fine
window.HelpViewer.showTOCButton( true, false, function() {
//do something to toggle TOC in your webpage
});
@bmatcuk
bmatcuk / symbolizing_osx_crash_logs.md
Created May 29, 2014 21:43
How to symbolize OSX crash logs

How to Symbolize OSX Crash Logs

Unfortunately, xcode does not yet have support for importing OSX crash logs and symbolizing them. Therefore, you must use the command line and a little bit of manual work.

  1. Find your dSYM file.
    1. Assuming you are using xcode's archive functionality, open the Organizer window from the Window menu.
    2. Click the Archives tab.
    3. Right click on the appropriate build and select Show in Finder.
    4. When Finder opens, right click on the selected archive and select Show Package Contents.
    5. Navigate to the dSYM directory and copy the appropriate dSYM file to a temporary directory.
  2. Then navigate to Products, then Applications, and copy the app file to the same temporary directory.
@iwata
iwata / new_gist_file.md
Created March 23, 2014 09:48
文字コード

文字コード技術超入門

文字コード技術入門

ASCII?

American Standard Code for Information Interchange

7bit 1byte code