Skip to content

Instantly share code, notes, and snippets.

@evnik
evnik / Framework2XCFramework.sh
Created December 30, 2020 20:23
This script allows to convert an iOS framework binary to XCFramework
# Copyright (c) 2020 Eugene Berdnikov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@bantic
bantic / upload.swift
Created December 9, 2017 19:10
upload UIImage to server with swift
func saveImage(image: UIImage, name:String) {
let req = NSMutableURLRequest(url: NSURL(string:"http://127.0.0.1:3001/")! as URL)
let ses = URLSession.shared
req.httpMethod="POST"
req.setValue("application/octet-stream", forHTTPHeaderField: "Content-Type")
req.setValue(name, forHTTPHeaderField: "X-FileName")
let jpgData = UIImageJPEGRepresentation(image, 1.0)
req.httpBodyStream = InputStream(data: jpgData!)
let task = ses.uploadTask(withStreamedRequest: req as URLRequest)
task.resume()
@zakkak
zakkak / .git-commit-template
Last active May 15, 2024 00:06 — forked from adeekshith/.git-commit-template.txt
This commit message template that helps you write great commit messages and enforce it across your team.
# [<tag>] (If applied, this commit will...) <subject> (Max 72 char)
# |<---- Preferably using up to 50 chars --->|<------------------->|
# Example:
# [feat] Implement automated commit messages
# (Optional) Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# (Optional) Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@sooop
sooop / StreamReader.swift
Last active May 28, 2023 13:00
Read a large text file line by line - Swift 3
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
@nunogoncalves
nunogoncalves / CreditCardValidation.swift
Last active October 7, 2021 07:51
Credit card validation in Swift 3
import UIKit
import PlaygroundSupport
//http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number
enum CreditCardType {
case visa
case visaElectron
case mastercard
@marmelroy
marmelroy / UIViewPropertyAnimator.swift
Last active November 9, 2022 02:28
A quick example of UIViewPropertyAnimator
// Create a UIViewPropertyAnimator object. Here's a simple one with a UIKit animation curve:
let colorChange = UIViewPropertyAnimator(duration: 0.3, curve: .easeIn, animations: { [weak self] in
self?.view.backgroundColor = UIColor(red: 255.0/255.0, green: 80.0/255.0, blue: 43.0/255.0, alpha: 1.0)
})
// There's also support for easy spring-based animations - all you need to set is a damping ratio (a value between 0 and 1). Alternatively, you can create your own curves by adopting the UITimingCurveProvider protocol.
let alphaChange = UIViewPropertyAnimator(duration: 0.3, dampingRatio: 0.6, animations: { [weak self] in
self?.circleView.alpha = 0.0
})
@subfuzion
subfuzion / curl.md
Last active June 20, 2024 13:48
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@spllr
spllr / cloudkit-request.js
Last active August 28, 2023 12:04
Setting up an authenticated CloudKit server-to-server request
/**
* Demonstrates how to use Apple's CloudKit server-to-server authentication
*
* Create private key with: `openssl ecparam -name prime256v1 -genkey -noout -out eckey.pem`
* Generate the public key to register at the CloudKit dashboard: `openssl ec -in eckey.pem -pubout`
*
* @see https://developer.apple.com/library/prerelease/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/SettingUpWebServices/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW6
*
* @author @spllr
*/
@grgcombs
grgcombs / angleGradientImage.swift
Created November 30, 2015 18:45
angleGradientImage.swift
//: angleGradientImage - Ported to Swift from http://stackoverflow.com/a/33991838/136582
import UIKit
import CoreImage
public func angleGradientImage(size: CGSize, radius: Float?, scale: CGFloat?, colors: (start:UIColor, end:UIColor)?) -> UIImage? {
let gradientRadius = (radius != nil) ? radius! : Float(min(size.width,size.height) - 2)
let gradientScale = (scale != nil) ? scale! : UIScreen.mainScreen().scale
let startColor : CIColor
let endColor : CIColor
@madhikarma
madhikarma / build_framework.sh
Created October 13, 2015 12:26
Script to build a framework for multiple architectures
# Merge Script
# http://code.hootsuite.com/an-introduction-to-creating-and-distributing-embedded-frameworks-in-ios/
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.