Skip to content

Instantly share code, notes, and snippets.

View litoarias's full-sized avatar
💭
I may be slow to respond.

Lito litoarias

💭
I may be slow to respond.
View GitHub Profile
@networkextension
networkextension / Ring.swift
Created June 22, 2021 05:36
SwiftUI Ring Animation AppleWatch Workout
import SwiftUI
struct ContentView: View {
@State private var showRedStroke = false
@State private var showGreenStroke = false
@State private var showBlueStroke = false
var body: some View
{
ZStack {
RadialGradient (gradient: Gradient (colors: [Color.black, Color.black]),
center: .center, startRadius: 5, endRadius: 500)
@29satnam
29satnam / SSLPinningSwift3.swift
Created September 9, 2017 10:18
SSL Pinning Swift 3
// Step 1: class ViewController: ..... URLSessionDelegate, URLSessionTaskDelegate
// Step 2: Usage
if let url = NSURL(string: "https://example.com") {
let session = URLSession(
configuration: URLSessionConfiguration.ephemeral,
delegate: NSURLSessionPinningDelegate(),
delegateQueue: nil)
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@edwardean
edwardean / CustomURLProtocol.swift
Created April 13, 2017 01:48 — forked from aerickson14/CustomURLProtocol.swift
Custom URLProtocol monitoring URLRequests over a URLSession in Swift 3
import UIKit
class CustomURLProtocol: URLProtocol {
struct Constants {
static let RequestHandledKey = "URLProtocolRequestHandled"
}
var session: URLSession?
var sessionTask: URLSessionDataTask?
@gservera
gservera / LegalInfoValidation.swift
Last active June 10, 2019 11:33
Validar DNI español o calcular su letra en Swift 2.0
import Foundation
/**
Valida el número y la(s) letra(s) de un cualquier documento nacional de identidad
español (NIF o NIE) utilizando una implementación del algoritmo oficial.
- parameter nationalID: El DNI que se validará. No distingue mayúsculas y minúsculas.
- returns: `true` si el DNI proporcionado es válido o `false` si no lo es.
*/
func validateSpanishNationalIdentifier(nationalID: String) -> Bool {
guard nationalID.characters.count == 9 else {
@kukat
kukat / MKMapView static map image.m
Created October 2, 2014 06:27
MKMapSnapshotter
- (void)setupMapSnapshot
{
CLLocationCoordinate2D coordinate = self.outlet.annotaion.coordinate;
MKMapSnapshotOptions* options = [MKMapSnapshotOptions new];
options.size = self.mapImageView.frame.size;
options.scale = [[UIScreen mainScreen] scale];
options.region = MKCoordinateRegionMakeWithDistance(coordinate, 2000.f, 2000.f);
MKMapSnapshotter* snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
@kristopherjohnson
kristopherjohnson / RoundRectButton.swift
Last active January 4, 2021 14:35
Swift: Custom UIButton subclass that displays a rounded rectangle in the background
import UIKit
/// UIButton subclass that draws a rounded rectangle in its background.
public class RoundRectButton: UIButton {
// MARK: Public interface
/// Corner radius of the background rectangle
public var roundRectCornerRadius: CGFloat = 8 {
@ynechaev
ynechaev / gist:8123997
Last active June 9, 2017 23:18
UITableViewCell popular animation (flipping around Y axis, depending on scroll direction)
@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UIImageOrientation scrollOrientation;
CGPoint lastPos;
}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.isDragging) {
UIView *myView = cell.contentView;
CALayer *layer = myView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR
@luca-bernardi
luca-bernardi / AVAsset+VideoOrientation.h
Created February 23, 2013 18:12
Find the video orientation of an AVAsset. (Useful if you need to send the video to a remote server)
//
// AVAsset+VideoOrientation.h
//
// Created by Luca Bernardi on 19/09/12.
// Copyright (c) 2012 Luca Bernardi. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
typedef enum {
LBVideoOrientationUp, //Device starts recording in Portrait