Skip to content

Instantly share code, notes, and snippets.

View a2's full-sized avatar
🐼

Alex Akers a2

🐼
View GitHub Profile
@smileyborg
smileyborg / SelfSizingTableHeaderAndTableFooterViews.swift
Last active February 9, 2024 09:53
How to manually self-size UITableView tableHeaderView/tableFooterView in iOS 11
// For the best results, your tableHeaderView/tableFooterView should be a UITableViewHeaderFooterView with your content inside the contentView.
let tableHeaderView = UITableViewHeaderFooterView()
let fittingSize = CGSize(width: tableView.bounds.width - (tableView.safeAreaInsets.left + tableView.safeAreaInsets.right), height: 0)
let size = tableHeaderView.systemLayoutSizeFitting(fittingSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
tableHeaderView.frame = CGRect(origin: .zero, size: size)
tableView.tableHeaderView = tableHeaderView
// When you set this view to the tableHeaderView/tableFooterView on the table view, the table view will preserve the existing size of its frame.
// If you need to change the size, remove the tableHeaderView/tableFooterView, set a new frame on it, then re-set it on the table view again.
import Foundation
import XCTest
enum Safari {
static func launch() -> XCUIApplication {
// Open safariapp
let safariApp = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.mobilesafari")
@broomburgo
broomburgo / lenses-and-prisms-in-swift-a-pragmatic-approach.swift
Last active September 6, 2017 11:38
code for the article "Lenses and Prisms in Swift: a pragmatic approach"
/// source: https://broomburgo.github.io/fun-ios/post/lenses-and-prisms-in-swift-a-pragmatic-approach/
protocol LensType {
associatedtype WholeType
associatedtype PartType
var get: (WholeType) -> PartType { get }
var set: (PartType,WholeType) -> WholeType { get }
init(get: @escaping (WholeType) -> PartType, set: @escaping (PartType,WholeType) -> WholeType)
@alexaubry
alexaubry / Heroku-Vapor-Docker-Tutorial.md
Last active December 26, 2022 12:03
How to run Vapor with Docker in Heroku

How to run Vapor with Docker in Heroku

In this tutorial you'll learn how to run a Vapor server in a Docker container on Heroku.

Recently, Heroku added the ability to run Docker images on their Runtime. You can use this system instead of the traditional buildpack-based system for various reasons, mainly for having more control over the environment your server will run on.

Prerequisites

To complete this tutorial, you'll need:

@zwaldowski
zwaldowski / PersistentContainer.swift
Created September 2, 2016 06:48
NSPersistentContainer backport to iOS 7 with Swift 3
import CoreData
@objc(_PersistentStoreDescription) private protocol AnyPersistentStoreDescription: NSObjectProtocol, NSCopying {
var type: String { get set }
var configuration: String? { get set }
@objc(URL) var url: URL? { get set }
var options: [String : NSObject] { get }
func setOption(_ option: NSObject?, forKey key: String)
@warpling
warpling / CircularTextView.h
Last active March 21, 2017 23:26
CircularTextView (as seen in the iOS app Blackbox)
//
// CircularTextView.h
// Wormhole
//
// Created by Ryan McLeod on 5/5/15.
// Copyright (c) 2015 Ryan McLeod. All rights reserved.
//
#import <UIKit/UIKit.h>
@neoeno
neoeno / Gemfile
Last active November 6, 2024 23:13
Pokemon Go Slack Bot
source "https://rubygems.org"
gem "httparty"
gem "geocoder"
gem "slack-poster"
@HBehrens
HBehrens / TicToc.js
Last active October 25, 2016 18:06
// book keeping so that we can easily animate the two hands for the watchface
// .scale/.angle are updated by tween/event handler (see below)
var renderState = {
minute: {style: 'white', scale: 0.80, angle: 0},
hour: {style: 'red', scale: 0.51, angle: 0}
};
// helper function for the draw function (see below)
// extracted as a standalone function to satisfy common believe in efficient JS code
// TODO: verify that this has actually any effect on byte code level
@omz
omz / Add Web Tab.py
Last active April 15, 2025 01:31 — forked from steventroughtonsmith/Add Web Tab.py
Insert a custom browser tab into Pythonista
# coding: utf-8
from objc_util import *
import console
import urllib
import dialogs
WKWebView = ObjCClass('WKWebView')
UIViewController = ObjCClass('UIViewController')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
NSURLRequest = ObjCClass('NSURLRequest')
@jchiotaka
jchiotaka / burgerbot.rb
Last active November 4, 2015 19:01 — forked from daxadax/burgerbot.rb
BurgerBot Extended (Optimized for Mac)
#!/usr/bin/env ruby
# modified from https://gist.github.com/pbock/3ab260f3862c350e6b5f #
# Be aware that all scripts are run at your own risk and while every script has been written with the intention of minimising the potential for unintended consequences, the owners, hosting providers and contributers cannot be held responsible for any misuse or script problems.
require 'watir-webdriver'
require 'colorize'
class BurgerBot