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 | |
extension NSImage { | |
var ciimage: CIImage? { | |
guard let tiffData = self.tiffRepresentation, | |
let bitmap = NSBitmapImageRep(data: tiffData) else { | |
return nil | |
} | |
return CIImage(bitmapImageRep: bitmap) | |
} |
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
struct Heap { | |
var a = [Int]() | |
init(_ array: [Int]) { | |
a = array | |
for i in stride(from: a.count / 2 - 1, to: 0, by: -1) { | |
bubbleDown(i) | |
} | |
} | |
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
// swift-tools-version:4.2 | |
import PackageDescription | |
let package = Package( | |
name: "server", | |
products: [ | |
.library(name: "server", targets: ["App"]), | |
], | |
dependencies: [ | |
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"), |
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 FluentMySQL | |
import Vapor | |
final class Todo: Codable { | |
var id: Int? | |
var title: String | |
init(id: Int? = nil, title: String) { | |
self.id = id | |
self.title = title |
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 FluentMySQL | |
import Vapor | |
/// Called before your application initializes. | |
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws { | |
// Register providers first | |
try services.register(FluentMySQLProvider()) | |
// Register routes to the router | |
let router = EngineRouter.default() |
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
version: "3.7" | |
services: | |
db: | |
image: mysql:5 | |
env_file: | |
- .env | |
networks: | |
- todonet | |
ports: | |
- "3306:3306" |
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
DATABASE_HOST=db | |
MYSQL_ROOT_PASSWORD=root | |
MYSQL_USER=test | |
MYSQL_PASSWORD=test | |
MYSQL_DATABASE=todos |
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
# You can set the Swift version to what you need for your app. Versions can be found here: https://hub.docker.com/_/swift | |
FROM swift:4.2 as builder | |
ARG env | |
RUN apt-get -qq update && apt-get -q -y install \ | |
tzdata \ | |
&& rm -r /var/lib/apt/lists/* | |
WORKDIR /app | |
COPY . . |
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
version: "3.7" | |
services: | |
api: | |
build: | |
context: . | |
dockerfile: web.Dockerfile | |
image: api | |
networks: | |
- todonet | |
depends_on: |
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
version: "3.7" | |
services: | |
api: | |
image: borama.info/todos:latest | |
networks: | |
- boramanet | |
depends_on: | |
- "db" | |
env_file: | |
- .env |