Skip to content

Instantly share code, notes, and snippets.

View aronbudinszky's full-sized avatar

Aron Budinszky aronbudinszky

View GitHub Profile
@aronbudinszky
aronbudinszky / migrations.swift
Last active October 2, 2022 13:30
Run a custom migration via raw query on a Vapor Fluent database.
struct CustomRawMigration: AsyncMigration {
func prepare(on database: Database) async throws {
try await (database as! SQLDatabase)
.raw("ALTER TABLE `table_name` MODIFY `field_name` ENUM('case1', 'case2', 'case3') DEFAULT 'case1'")
.run()
}
func revert(on database: Database) async throws {
try await (database as! SQLDatabase)
.raw("ALTER TABLE `table_name` MODIFY `field_name` ENUM('case1', 'case2') DEFAULT 'case1'")
@aronbudinszky
aronbudinszky / clipboard.php
Last active September 21, 2022 09:57
A php file to easily transfer stuff to iOS simulator. This is a workaround for the bug in Xcode 13 where the clipboard sync does not work between Simulator and macOS M1.
<?php
###### CONFIG ######
# Here is a link
$link = <<<EOF
https://www.google.com/
EOF;
# And some text to copy
import Fluent
import SQLKit
struct CreateVersionsCreatedAtIndex: AsyncMigration {
func prepare(on database: Database) async throws {
try await (database as! SQLDatabase)
.create(index: "versions_created_at_index") // Index name
.on("versions") // Table name
.column("created_at")
// You can also add more columns here if you want a multi-column index...
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
/// Defines the possible errors
public enum URLSessionAsyncErrors: Error {
case invalidUrlResponse, missingResponseData
}
@aronbudinszky
aronbudinszky / Image+Assets.swift
Created March 6, 2020 15:31
Support named assets via enum values (to avoid string literals).
import Foundation
import SwiftUI
/// Extend Image with named assets
extension Image {
enum Assets: String, RawRepresentable {
case appButtonImage
/// Place all your color assets here...the enum case should equal to the name you use in your Asset library
}
// We can get the Color for SwiftUI like so...
let color = Color(asset: .appTextColor)
// ...or a UIColor (which, unlike UIColor(named:) will be non-optional)...
let uiColor = UIColor(asset: .appTextColor)
@aronbudinszky
aronbudinszky / Color+Assets.swift
Last active March 6, 2020 15:32
Support named assets via enum values (to avoid string literals).
import Foundation
import SwiftUI
/// Extend Color to support named assets
extension Color {
enum Assets: String, RawRepresentable {
case appTextColor
/// Place all your color assets here...the enum case should equal to the name you use in your Asset library
}
@aronbudinszky
aronbudinszky / prism-dynamic.sh
Created January 4, 2020 14:56
Run prism in dynamic mode
# You can run prism in dynamic mode
prism mock -d ~/path/to/your/openapi.yaml
# Or you can force dynamic mode when you call a request
curl -v "http://127.0.0.1/endpoint?__dynamic=true"
@aronbudinszky
aronbudinszky / openapi.yaml
Created January 4, 2020 14:44
Pet example with x-faker tag.
Pet:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
x-faker: name.firstName
example: doggie
@aronbudinszky
aronbudinszky / generate-docs-gitlab.yml
Last active May 14, 2022 18:21
Generate docs from open api spec in Gitlab using a shared runner.
image: node:latest
pages:
stage: deploy
script:
- npm install -g redoc-cli
- redoc-cli bundle -o public/index.html documentation/openapi.yaml
artifacts:
paths:
- public