This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppDelegate.swift | |
// UDPTest | |
// | |
// Created by Paul Wilkinson on 22/10/19. | |
// Copyright © 2019 Paul Wilkinson. All rights reserved. | |
// | |
import Cocoa | |
import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func zalgo(_ string: String, intensity: Int = 5) -> String { | |
let combiningDiacriticMarks = 0x0300...0x036f | |
let latinAlphabetUppercase = 0x0041...0x005a | |
let latinAlphabetLowercase = 0x0061...0x007a | |
var output: [UnicodeScalar] = [] | |
for scalar in string.unicodeScalars { | |
output.append(scalar) | |
guard (latinAlphabetUppercase).contains(numericCast(scalar.value)) || | |
(latinAlphabetLowercase).contains(numericCast(scalar.value)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Works with Xcode 9 (Confirmed) | |
#1. Go to "Edit Schemes" | |
#2. Go to "Build" | |
#3. Go to "Pre-Actions" | |
#4. Select YOUR app in "Provide Build Settings from:" | |
#5. Paste Below Script in Box | |
#6. Build Project | |
#Build Number ++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Synology NAS - How to make a program run at startup | |
The other day I created a little node.js project to keep track of some finances. Synology has a node.js package but that just installs the tools - it has no 'container' or any other support to drop files and have it run automagically. Maybe one day. | |
In the meantime, you can start your project when you SSH into the NAS. My project has a 'www' script which bootstraps my project, so to start I simply type 'node bin/www' from the project directory. But, it only runs while I'm logged in, and if I log out for any reason, the process dies. That's hardly useful when I'm away from home, or on a different PC. So I decided to have a look at starting my project as a Linux service. | |
After doing a lot of research into how Synology does services, and a few failed attempts at init scripts, I found that Synology DSM (since version 5 perhaps) bundles Upstart, which is a neat little tool to deal with services on Linux. It's most prevalent on Debian and derivatives (notably Ub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config: | |
# target: "ws://localhost:3000/websocket" | |
target: "wss://deployed-server/websocket" | |
phases: | |
- | |
duration: 60 | |
arrivalRate: 10 | |
ws: | |
# Ignore SSL certificate errors | |
# - useful in *development* with self-signed certs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$internalErrors = array( | |
'MJ01' => 'Could not determine APIKey', // SERRCouldNotDetermineAPIKey | |
'MJ02' => 'No persister object found for class: "%s"', // SErrNoPersister | |
'MJ03' => 'A non-empty value is required', // SErrValueRequired | |
'MJ04' => 'Value must have at least length %d', // SErrMinLength | |
'MJ05' => 'Value may have at most length %d', // SErrMaxLength | |
'MJ06' => 'Value must be larger than or equal to %s', // SErrMinValue | |
'MJ07' => 'Value must be less than or equal to %s', // SErrMaxValue | |
'MJ08' => 'Property %s is invalid: %s', // SErrInProperty | |
'MJ09' => 'Value is not in list of allowed values: (%s)', // SErrValueNotInList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSTimer { | |
/** | |
Creates and schedules a one-time `NSTimer` instance. | |
- Parameters: | |
- delay: The delay before execution. | |
- handler: A closure to execute after `delay`. | |
- Returns: The newly-created `NSTimer` instance. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface MyTextView : NSView { | |
NSMutableAttributedString *_text; | |
} | |
@end | |