Skip to content

Instantly share code, notes, and snippets.

View andyzaharia's full-sized avatar

Zaharia Andrei andyzaharia

  • Chisinau, Moldova
View GitHub Profile
@josevazquez
josevazquez / testDecodableExtensions.swift
Created June 16, 2023 17:44
Add parse() from a json string to any Decodable
import XCTest
extension Decodable {
init(_ json: String) throws {
self = try JSONDecoder().decode(Self.self, from: json.data(using: .utf8)!)
}
}
final class DecodableExtensions: XCTestCase {
@Thxonly
Thxonly / release_xcframework.sh
Created March 28, 2023 15:28 — forked from litoarias/release_xcframework.sh
Archive, make XCFramework, manage Github Release and distribute XCFramework
#!/bin/sh
# Check for arguments
if [ $# -eq 0 ]; then
echo "No arguments provided. First argument has to be version, e.g. '1.8.1', and second one the name of framework, e.g. 'NetworkModule'"
exit 1
fi
# Set properties
FRAMEWORK_VERSION=$1
@simonbs
simonbs / docc.sh
Last active May 2, 2023 08:04
Generates documentation with Apple's DocC for a target that supports both iOS and macOS.
#!/bin/bash
#######################################################################
# Generates documentation for a target, for example a Swift package,
# that supports both iOS and macOS.
#
# The script is designed to be placed in the root of a Swift package.
# Change the paths as needed if your project structure is different.
#
# In order for DocC to annotate all symbols with the platforms
@adam-rocska
adam-rocska / operators+throwIfOptional.swift
Last active March 30, 2022 13:25
A Swift operator unwrapping & returning an optional value if it exists, while throwing an error if it doesn't.
// TODO: Depend on https://github.com/21GramConsulting/Beton instead
@krzyzanowskim
krzyzanowskim / StringGetSizeThatFits.swift
Last active November 12, 2023 14:51
Calculate frame of String, that fits given width
// Excerpt from https://github.com/krzyzanowskim/CoreTextWorkshop
// Licence BSD-2 clause
// Marcin Krzyzanowski marcin@krzyzanowskim.com
func getSizeThatFits(_ attributedString: NSAttributedString, maxWidth: CGFloat) -> CGSize {
let framesetter = CTFramesetterCreateWithAttributedString(attributedString)
let rectPath = CGRect(origin: .zero, size: CGSize(width: maxWidth, height: 50000))
let ctFrame = CTFramesetterCreateFrame(framesetter, CFRange(), CGPath(rect: rectPath, transform: nil), nil)
@joevt
joevt / EDIDUtil.sh
Last active January 14, 2024 16:48
A set of shell functions used to view and edit EDIDs.
#!/bin/bash
#!/bin/zsh
# by joevt May 24/2023
#=========================================================================================
edid_decode=edid-decode
#=========================================================================================
# Modify EDID
@lcrilly
lcrilly / README.md
Last active October 16, 2021 13:11
Workshop: Deploying NGINX as an API Gateway

Workshop: Deploying NGINX as an API Gateway

NGINX is the world’s number one API gateway, delivering the vast majority of today’s API traffic, deployed as standalone gateways or embedded in API management products. This workshop is about deploying NGINX as a lightweight API gateway in a way that supports long-term maintenance and can be automated with common DevOps tooling.

In this hands-on workshop, you will configure NGINX to perform the common API gateway functions of request routing, rate limiting, and authentication for multiple APIs. We will also touch on advanced use cases such as HTTP method enforcement, and JSON validation.

Previous experience of NGINX is valuable, but not essential. Technical requirements:

  • Mandatory: laptop with internet connection
  • Highly recommended: clean installation of NGINX (minimum 1.14.0) - limited assistance for this task will be available at the workshop
@eugenebokhan
eugenebokhan / CGImage+Resize.swift
Last active April 11, 2024 21:28
UIImage + Resize
import CoreGraphics
import Accelerate
import CoreImage
import UIKit
extension CGImage {
public enum Error: Swift.Error {
case imageResizingFailed
case cgContextCreationFailed
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active June 27, 2024 10:27
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@smellman
smellman / my_postgre.conf
Last active September 20, 2023 22:47
OpenMapTiles 差分アップデート
listen_addresses = '*'
# Tuning at: https://pgtune.leopard.in.ua/
# DB Version: 9.6
# OS Type: linux
# DB Type: dw
# Total Memory (RAM): 16 GB
# CPUs num: 20
# Connections num: 100
# Hard drive type: ssd