Skip to content

Instantly share code, notes, and snippets.

/**
Relates to https://github.com/SwiftyBeaver/SwiftyBeaver/issues/340
*/
extension SwiftyBeaver {
@usableFromInline
static let queue = DispatchQueue(label: "com.asensei.asensei.SwiftyBeaver")
@discardableResult
class func ts_addDestination(_ destination: BaseDestination) -> Bool {
@valeriomazzeo
valeriomazzeo / JSON.swift
Created May 18, 2020 10:20
A JSON data structure conforming to Codable
//
// JSON.swift
//
// Created by Valerio Mazzeo on 26/03/2018.
//
import Foundation
public enum JSON {
case object(JSON.Object)
import Foundation
import HTTP
extension HTTPMethod: RawRepresentable {
// swiftlint:disable:next cyclomatic_complexity function_body_length
public init?(rawValue: String) {
switch rawValue.uppercased() {
case "GET":
self = .GET
@valeriomazzeo
valeriomazzeo / dockerhub_versions
Created April 11, 2018 08:54
List docker container tags from docker hub
REPO_NAME=myorg/myrepo
# get token from Docker Hub
DOCKER_HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKER_HUB_USERNAME}'", "password": "'${DOCKER_HUB_PASSWORD}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
# get tags for repo
IMAGE_TAGS=$(curl -s -H "Authorization: JWT ${DOCKER_HUB_TOKEN}" https://hub.docker.com/v2/repositories/${REPO_NAME}/tags/?page_size=10000 | jq -r '.results|.[]|.name')
# generate a file containing each version on a new line excluding latest
printf '%s\n' ${IMAGE_TAGS#latest} > versions
@valeriomazzeo
valeriomazzeo / github_release.rb
Created July 5, 2017 21:24
Creates or update a GitHub release for the given tag name
#!/usr/bin/env ruby
require 'optparse'
require 'octokit'
options = {}
OptionParser.new do |opt|
opt.on('-s', '--secret SECRET', 'GitHub access token') { |o| options[:secret] = o }
opt.on('-r', '--repo-slug REPO_SLUG', 'Repo slug. i.e.: apple/swift') { |o| options[:repo_slug] = o }
opt.on('-c', '--changelog-file CHANGELOG_FILE', 'Changelog path') { |o| options[:changelog_file] = o }
public final class PageViewController: UIViewController {
// MARK: Initialization
public required init(viewControllers: [UIViewController]) {
self.viewControllers = viewControllers
super.init(nibName: nil, bundle: nil)
}
public required init?(coder aDecoder: NSCoder) {
import UIKit
open class PercentDrivenInteractiveTransition: NSObject {
// MARK: Initialization
public required init(animator: UIViewControllerAnimatedTransitioning) {
self.animator = animator
}
@valeriomazzeo
valeriomazzeo / ViewAdapter.swift
Last active August 10, 2016 14:07
Easy way to populate UIView properties with data.
//
// ViewAdapter.swift
//
// Created by Valerio Mazzeo on 10/08/2016.
// Copyright © 2016 Valerio Mazzeo. All rights reserved.
//
import UIKit
/**
@valeriomazzeo
valeriomazzeo / UIScrollView+Parallax.swift
Last active July 2, 2018 08:44
Add parallax effect to any scrollview subview
//
// UIScrollView+Parallax.swift
// Parallax
//
// Created by Valerio Mazzeo on 20/05/2016.
// Copyright © 2016 Valerio Mazzeo. All rights reserved.
//
import UIKit
@valeriomazzeo
valeriomazzeo / tview.m
Created February 26, 2016 10:46
Updating Height of Self-Sizing Table View Cell With Text View
@interface TView : UITextView
@property (nonatomic) CGFloat preferredMaxLayoutWidth;
@end
@implementation TView
- (instancetype)initWithFrame:(CGRect)frame
{