Skip to content

Instantly share code, notes, and snippets.

View MrMage's full-sized avatar

Daniel Gräfe MrMage

View GitHub Profile
[
["f", "Show next/latest diffs", "setProposedDiffBounds()"],
["n", "Next unreviewed file", "nextUnreviewedFile()"],
["p", "Previous unreviewed file", "prevUnreviewedFile()"],
[null, "Next personally unreviewed file", "nextPersonallyUnreviewedFile()"],
[null, "Previous personally unreviewed file", "prevPersonallyUnreviewedFile()"],
["shift+n", "Next changed file", "nextChangedFile()"],
["shift+p", "Previous changed file", "prevChangedFile()"],
[null, "Next visible file", "nextVisibleFile()"],
~/Documents/Xcode/Cloud/docker-caching-test ❯❯❯ docker build -t docker-caching-test . ✘ 130
Sending build context to Docker daemon 15.36kB
Step 1/12 : FROM swift:5.1.1-bionic AS build
---> f302143d0aa2
Step 2/12 : RUN mkdir -p /root/docker-caching-test
---> Using cache
---> b2b73d9fbfa2
Step 3/12 : WORKDIR /root/docker-caching-test
---> Using cache
---> 07aec73023eb
import Foundation
import Logging
import NIOConcurrencyHelpers
import NIO
import Async
import Service
public protocol CloseableResource: AnyObject {
var eventLoop: EventLoop { get }
public func attributeMarkdownString(_ string: String, defaultAttributes: [NSAttributedString.Key: Any]) -> NSAttributedString {
let result = NSMutableAttributedString(string: string, attributes: defaultAttributes)
let linkExpression = try! NSRegularExpression(pattern: "\\[([^]]+)\\]\\(([^)]+)\\)")
while let linkMatch = linkExpression.firstMatch(in: result.string, range: NSRange(location: 0, length: result.length)) {
let linkString = NSMutableAttributedString(attributedString: result.attributedSubstring(from: linkMatch.range(at: 1)))
linkString.addAttributes([
.foregroundColor: Appearance.colors.link,
.link: result.attributedSubstring(from: linkMatch.range(at: 2)).string,
], range: NSRange(location: 0, length: linkString.length))
extension Collection where Element: FutureType {
/// Flattens an array of futures into a future with an array of results.
/// - note: the order of the results will match the order of the futures in the input array.
public func flatten(on worker: Worker) -> Future<[Element.Expectation]> {
let eventLoop = worker.eventLoop
// Avoid unnecessary work
guard count > 0 else {
return eventLoop.newSucceededFuture(result: [])
}
import FluentPostgreSQL
extension QueryBuilder where Result: Model,
Result.Database == Database,
Database.Query: FluentSQLQuery,
Database.QueryField: SQLColumnIdentifier,
Database.QueryField: Hashable,
Database.QueryData == Dictionary<String, Database.Query.Expression> {
public func update<T>(_ keyPath: WritableKeyPath<Result, T>, to value: T) -> Future<Void> where T: Encodable {
Database.queryDataSet(Database.queryField(.keyPath(keyPath)), to: value, on: &query)
import NIOConcurrencyHelpers
import Vapor
public protocol CloseableResource: class {
var eventLoop: EventLoop { get }
var isClosed: Bool { get }
func close()
}
@MrMage
MrMage / echo.grpc.swift
Created February 23, 2018 18:59
Example for generated code without a package name set
/*
* DO NOT EDIT.
*
* Generated by the protocol buffer compiler.
* Source: echo.proto
*
*/
/*
* Copyright 2018, gRPC Authors All rights reserved.
@MrMage
MrMage / echo.grpc.swift
Created February 21, 2018 21:52
Result of exploratory codegen changes to improve the testability of SwiftGRPC generated code (see https://github.com/grpc/grpc-swift/issues/120).
/*
* DO NOT EDIT.
*
* Generated by the protocol buffer compiler.
* Source: Sync/Proto/echo.proto
*
*/
/*
* Copyright 2018, SwiftGRPC Authors All rights reserved.
@MrMage
MrMage / photos_add_photos_with_filenames.js
Created November 29, 2017 20:50
JXA (JavaScript for Automation) to add photos with a specific filename to a Photos album
var photos = Application("Photos");
var al = photos.albums.whose({ name: 'ALBUM_NAME' })[0].get();
photos.add([photos.mediaItems.whose({ filename: 'FILE_NAME.jpg' })[0].get()], { to: al });
// ...