This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Color+Codable.swift | |
// FirestoreCodableSamples | |
// | |
// Created by Peter Friese on 18.03.21. | |
// | |
import SwiftUI | |
// Inspired by https://cocoacasts.com/from-hex-to-uicolor-and-back-in-swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
title Activate Office 365 ProPlus for FREE - MSGuides.com&cls&echo ============================================================================&echo #Project: Activating Microsoft software products for FREE without software&echo ============================================================================&echo.&echo #Supported products: Office 365 ProPlus (x86-x64)&echo.&echo.&(if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16")&(if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16")&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_kms*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_mak*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&echo.&echo ============================================================================&echo Activating your Office...&cscript //nologo slmgr.vbs /ck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
killall Xcode | |
xcrun -k | |
xcodebuild -alltargets clean | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" | |
rm -rf /Applications/Xcode.app | |
rm -rf ~/Library/Caches/com.apple.dt.Xcode | |
rm -rf ~/Library/Developer | |
rm -rf ~/Library/MobileDevice | |
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for line in `adb devices | grep -v "List" |grep -v ":" | awk '{print $1}'` | |
do | |
device=`echo $line | awk '{print $1}'` | |
echo "Running commands for $device" | |
echo "Restarting $device in TCP mode on port 5555..." | |
adb -s "$device" tcpip 5555 | |
echo "Waiting for $device to switch to TCP mode..." | |
sleep 7 | |
ip_addr=$(adb -s "$device" shell ip route | grep wlan| grep -o ' 192.*$' | awk '{print $1":5555"}') | |
echo "Connecting to Device via WIFI on $ip_addr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVFoundation | |
class ViewController: UIViewController { | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
switch AVCaptureDevice.authorizationStatus(for: .video) { | |
case .notDetermined: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Foo: String, Codable { | |
case a | |
case b | |
case c | |
} | |
extension RawRepresentable where RawValue == String, Self: Codable { | |
init(from decoder: Decoder) throws { | |
var container = try decoder.unkeyedContainer() | |
let rawValue = try container.decode(String.self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVKit | |
import AVFoundation | |
import AssetsLibrary | |
func synchronized(_ object: AnyObject, block: () -> Void) { | |
objc_sync_enter(object) | |
block() | |
objc_sync_exit(object) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: self.characters.count) | |
return regex?.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2").lowercased() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func cropsToSquare() -> UIImage { | |
let refWidth = CGFloat(CGImageGetWidth(self.CGImage)) | |
let refHeight = CGFloat(CGImageGetHeight(self.CGImage)) | |
let cropSize = refWidth > refHeight ? refHeight : refWidth | |
let x = (refWidth - cropSize) / 2.0 | |
let y = (refHeight - cropSize) / 2.0 | |
let cropRect = CGRectMake(x, y, cropSize, cropSize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use: for testing against email regex | |
ref: http://codefool.tumblr.com/post/15288874550/list-of-valid-and-invalid-email-addresses | |
List of Valid Email Addresses | |
email@example.com | |
firstname.lastname@example.com | |
email@subdomain.example.com | |
firstname+lastname@example.com |
NewerOlder