I use GM to render thumbnails of png and jpg images.
Sadly the GM installation guide doesn't describe how to get things working on AWS EC2.
| extension String { | |
| func matchingStrings(regex: String) -> [[String]] { | |
| guard let regex = try? NSRegularExpression(pattern: regex, options: []) else { return [] } | |
| let nsString = self as NSString | |
| let results = regex.matches(in: self, options: [], range: NSMakeRange(0, nsString.length)) | |
| return results.map { result in | |
| (0..<result.numberOfRanges).map { result.rangeAt($0).location != NSNotFound | |
| ? nsString.substring(with: result.rangeAt($0)) | |
| : "" | |
| } |
| # Install QEMU OSX port with ARM support | |
| sudo port install qemu +target_arm | |
| export QEMU=$(which qemu-system-arm) | |
| # Dowload kernel and export location | |
| curl -OL \ | |
| https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie | |
| export RPI_KERNEL=./kernel-qemu-4.1.7-jessie | |
| # Download filesystem and export location |
| import PostgresStORM | |
| extension PostgresStORM { | |
| /// Set Next ID Value to MAX ID | |
| /// | |
| /// This is a workaround for issue [ISS-546](http://jira.perfect.org:8080/browse/ISS-546) | |
| /// | |
| /// When inserting new rows then I'm getting errors like this: | |
| /// | |
| /// ERROR: duplicate key value violates unique constraint "president_key" |
| import PerfectPostgreSQL | |
| import PostgresStORM | |
| import StORM | |
| extension PostgresStORM { | |
| static func doWithTransaction<Result>(closure: () throws -> Result) throws -> Result { | |
| let thisConnection = PostgresConnect( | |
| host: PostgresConnector.host, | |
| username: PostgresConnector.username, | |
| password: PostgresConnector.password, |
I use GM to render thumbnails of png and jpg images.
Sadly the GM installation guide doesn't describe how to get things working on AWS EC2.
| import XCTest | |
| class URLRelativePathFromTests: XCTestCase { | |
| func process(_ p1: String, _ p2: String) -> String? { | |
| let u1 = URL(fileURLWithPath: p1) | |
| let u2 = URL(fileURLWithPath: p2) | |
| return u1.relativePath(from: u2) | |
| } | |
| func testNormal() { |
| #!/usr/bin/env ruby | |
| require 'fileutils' | |
| PATH_PG_DUMP = "/usr/lib/postgresql/9.6/bin/pg_dump" | |
| POSTGRES_HOST = "demoscene.t1qwy5zz3sn3.eu-southwest-3.rds.amazonaws.com" | |
| POSTGRES_PORT = 1234 | |
| POSTGRES_USERNAME = "admin" | |
| POSTGRES_PASSWORD = "doesnt look like anything to me" | |
| POSTGRES_DBNAME = "main" | |
| AWS_S3_BUCKET = "there.is.no.spoon" |
| let value0 = _tv(100) | |
| let value1 = _tv(200) | |
| print("the values are: \(value0) \(value1)") | |
| if _tv(1) > 0.5 { | |
| print("if-case") | |
| } else { | |
| print("else-case") | |
| } |
| import UIKit | |
| extension UIViewController { | |
| /// Taken from this great StackOverflow post by Phani Sai: https://stackoverflow.com/a/35473300/78336 | |
| func configureChildViewController(_ childController: UIViewController, onView: UIView?) { | |
| var holderView = self.view | |
| if let onView = onView { | |
| holderView = onView | |
| } | |
| addChildViewController(childController) |
| import PerfectHTTP | |
| class HandlerContext { | |
| let request: HTTPRequest | |
| let response: HTTPResponse | |
| init(request: HTTPRequest, response: HTTPResponse) { | |
| self.request = request | |
| self.response = response | |
| } |