Skip to content

Instantly share code, notes, and snippets.

@V8tr
V8tr / AutoLayoutDSL.swift
Last active October 31, 2023 17:42
Auto Layout DSL
import UIKit
/// Represents a single `NSLayoutConstraint`
enum LayoutAnchor {
case constant(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
constant: CGFloat)
case relative(attribute: NSLayoutConstraint.Attribute,
relation: NSLayoutConstraint.Relation,
@SergLam
SergLam / Steps.swift
Last active April 10, 2024 20:14
XCode quick install / update
// Original video tutorial
// https://www.youtube.com/watch?v=6iSuc2vxT8g
// 0. Install a Homebrew
// https://brew.sh/
// 1. Install Ruby to your Mac
// brew install ruby
// 2. Install aria2 tool
@borisovonline
borisovonline / debian-personalvpn.md
Last active June 25, 2024 14:25
Create a personal VPN server based on Linux Debian and strongSwan

Tutorial: how to create a personal VPN server based on Linux Debian, strongSwan, certificates authentification and ready to use .mobileconfig profiles to use on iPhone, iPad and Mac

This is a part of a big article I posted on Medium. Here is only a tutorial.

We're going to create a personal VPN server, using the following technologies:

  • IKEv2 as a VPN protocol
  • Linux Debian as a server OS
  • strongSwan as a VPN server
  • Certificates as an authentication method

You can use this tutorial on any hosting you prefer.

@dmsl1805
dmsl1805 / SnakeCase.swift
Last active September 3, 2023 16:11 — forked from ivanbruel/SnakeCase.swift
Camel case to snake case in Swift
extension String {
func snakeCased() -> String? {
let pattern = "([a-z0-9])([A-Z])"
let regex = try? NSRegularExpression(pattern: pattern, options: [])
let range = NSRange(location: 0, length: count)
return regex?.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2").lowercased()
}
}
@bpolania
bpolania / DataExtensions.swift
Last active January 25, 2024 07:10
Swift Extensions for Data, Int, UInt8, UInt16, and UInt32 types
// MIT License
// Copyright (c) 2018 Boris Polania
// 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:
@mattlawer
mattlawer / DisableGDB.swift
Created December 25, 2016 17:13
Disable GDB with Swift 3
import Foundation
func disable_gdb() {
let PT_DENY_ATTACH: CInt = 31
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW)
let sym = dlsym(handle, "ptrace")
typealias PtraceAlias = @convention(c) (CInt, pid_t, CInt, CInt) -> CInt
let ptrace = unsafeBitCast(sym, to: PtraceAlias.self)
_ = ptrace(PT_DENY_ATTACH, 0, 0, 0)
dlclose(handle)
@schickling
schickling / UIImageFixedOrientationExtension.swift
Last active February 4, 2024 15:00
Extension to fix orientation of an UIImage (Sets orientation to portrait)
extension UIImage {
func fixedOrientation() -> UIImage {
if imageOrientation == UIImageOrientation.Up {
return self
}
var transform: CGAffineTransform = CGAffineTransformIdentity