Skip to content

Instantly share code, notes, and snippets.

@justinpawela
justinpawela / actor_dl_imge.swift
Created February 29, 2024 02:51 — forked from networkextension/actor_dl_imge.swift
actor async/await download imge Swift 5.5
extension UIImage {
@available(iOS 15, *)
var thumbnail: UIImage? {
get async {
let size = CGSize(width: 80, height: 40)
return await self.byPreparingThumbnail(ofSize: size)
}
}
}
enum FetchError:Error{
@justinpawela
justinpawela / UIViewControllerPreview.swift
Created December 6, 2019 16:02 — forked from mattt/UIViewControllerPreview.swift
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@justinpawela
justinpawela / higher-order-functions.scss
Created March 13, 2017 21:15 — forked from pdaoust/higher-order-functions.scss
Higher-order functions for Sass 3.3 -- now that we've got the `call()` function in Sass, we can start to compose functions. We don't have the benefit of anonymous functions, of course, but this is real functional programming, folks!
// 'map', 'transform', 'select', or 'project' function. Iterate over a list,
// performing a function on each item, and collecting the new items. Each
// function takes an item as a first argument and returns a transformed item.
// You can pass additional arguments to the function too, which is a decent poor
// man's function composition.
// (I didn't call this f-map because the term 'map' is already used in Sass to
// denote a hash or dictionary.)
@function f-apply($func, $list, $args...) {
$new-list: ();
@each $item in $list {
@justinpawela
justinpawela / DisableGuestAccount.applescript
Created October 9, 2016 04:10
Disable macOS Guest user account script
#!/usr/bin/osascript
-- License: https://justinpawela.github.io/default-gist-license/
(*
1) Disables signing in as Guest from the login screen.
2) Disables Guest access to file shares over AFP.
3) Disables Guest access to file shares over SMB.
Commands are chained together so that the user only needs to authorize once.
*)
@justinpawela
justinpawela / config
Created August 3, 2016 01:39
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region