Skip to content

Instantly share code, notes, and snippets.

View samdods's full-sized avatar

Sam Dods samdods

  • The App Business
  • London
View GitHub Profile
@samdods
samdods / main.dart
Last active January 10, 2025 12:26
enc
import 'dart:convert';
void main() {
String mmst = 'security_token12345678';
String encrypted = encryptXOR('this is a sensitive API key or access token', mmst);
String encBase64 = base64.encode(encrypted.codeUnits);
print('encrypted and base64: $encBase64');
String decoded = String.fromCharCodes(base64.decode(encBase64));
url=https://gist.githubusercontent.com/samdods/1ac451370729c0e9df72cce8bfcaa828/raw/3548420695acec86c721ffa9c74424212dcc2283/impactChecker.swift
exe=/tmp/impactChecker`uuidgen`
curl -fsSL $url > $exe
chmod +x $exe
git diff `git merge-base origin/develop HEAD`..HEAD --name-only | $exe
rm $exe
url=https://gist.githubusercontent.com/samdods/1ac451370729c0e9df72cce8bfcaa828/raw/3548420695acec86c721ffa9c74424212dcc2283/impactChecker.swift
curl -fsSL $url > /tmp/impactChecker
chmod +x /tmp/impactChecker
#!/usr/bin/swift
import Foundation
extension Array where Element == String {
func sortedWithPodsLast() -> [String] {
self.sorted { lhs, rhs in
if lhs.hasPrefix("Pods_") && rhs.hasPrefix("Pods_") {
return lhs < rhs
{
"groups": [
{
"name": "reds",
"colors": [
{
"name": "red",
"hex": "FF0000"
},
{
override func viewDidLoad() {
super.viewDidLoad()
isModalInPresentation = true
navigationController?.presentationController?.delegate = self
}
/// conforming to UIAdaptivePresentationControllerDelegate
func presentationControllerDidAttemptToDismiss(_ presentationController: UIPresentationController) {
let controller = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
// ...
@samdods
samdods / AVSpeechSynthesizer+Shared.swift
Created October 9, 2019 10:11
Showing AVSpeechSynthesizer extension for Speak Selection blog post
extension AVSpeechSynthesizer {
static let forSpeakSelection: AVSpeechSynthesizer = {
let synthesizer = AVSpeechSynthesizer()
synthesizer.delegate = SpeechDelegate.shared
return synthesizer
}()
}
// MARK: - Private
@samdods
samdods / SelectableLabel-Truncated.swift
Created October 9, 2019 09:57
Snippet of the SelectableLabel.swift for a blog post on Speak Selection
final class SelectableLabel: UILabel {
// 1...
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupTextSelection()
}
private func setupTextSelection() {
enum Frank {
static func start(port: Int = 8080) {
// ... steps 1 to 8 from sample code above ...
}
}
typealias ResponseBodyProvider = () -> String
private var routedGET: [String: ResponseBodyProvider] = [:]
func get(_ path: String, bodyProvider: @escaping ResponseBodyProvider) {
get("/home") {
return "🏠"
}
get("/people") {
return """
<html><head><style>
h1 { font-size:4cm; text-align: center }
</style></head>
<body><h1>👫👫👫👫👫</h1></body>