Skip to content

Instantly share code, notes, and snippets.

View Lukaz32's full-sized avatar
🇦🇹

Lucas Pereira Lukaz32

🇦🇹
  • Wien, Österreich
View GitHub Profile
// A URLSession extension that fetches data from a URL and decodes to some Decodable type.
// Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL)
// Note: this requires Swift 5.5.
extension URLSession {
func decode<T: Decodable>(
_ type: T.Type = T.self,
from url: URL,
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys,
dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate
@marco79cgn
marco79cgn / schnelltest-availability.js
Last active December 15, 2021 22:55
Shows the available amount of Covid Tests in your local drug store and online
let country = "de"; // replace with 'at' for shops in Austria
let storeId = 251;
let param = args.widgetParameter;
if (param != null && param.length > 0) {
if (param.indexOf(";") > 0) {
const paramSplit = param.split(";");
storeId = paramSplit[0];
country = paramSplit[1].toLowerCase();
} else {
storeId = param;
import SwiftUI
import os
@main
struct ios14DemoApp: App {
@StateObject var notificationCenter = NotificationCenter()
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
@arturgrigor
arturgrigor / Podfile
Created September 10, 2018 09:55
Sample Podfile for silencing warnings for CocoaPods dependencies
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target '%TargetName%' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for %TargetName%
# pod 'FBSDKCoreKit'
end
@dduan
dduan / XCTest+Eventually.swift
Last active January 11, 2023 00:26
A simple "eventually" method to aide asynchronous testing with XCTest
import XCTest
extension XCTestCase {
/// Simple helper for asynchronous testing.
/// Usage in XCTestCase method:
/// func testSomething() {
/// doAsyncThings()
/// eventually {
/// /* XCTAssert goes here... */
@steipete
steipete / ios-xcode-device-support.sh
Last active July 3, 2024 03:07
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@cravoley
cravoley / remote-workplaces-porto-alegre.md
Last active May 9, 2018 16:59
Locais para trabalho remoto em Porto Alegre

LOCAIS PARA TRABALHO REMOTO EM PORTO ALEGRE

BADEN CAFÉS ESPECIAIS

Endereço: Av. Jerônimo de Ornelas, 431, Santana. Tel. (51) 3209-7427

Horário: seg-sex 11h30 20h30 sáb 14h—20h

Infra: Tomadas (três pinos, modelo novo)

@fe9lix
fe9lix / remove_swift_headers.sh
Created February 16, 2016 19:08
Xcode: Remove header comments in Swift files
find . -type f -name "*.swift" -not -path "./Pods/*" -exec sed -i '' -e '1,/^import/{/^\/\/.*/d;}' -e '/./,$!d' {} \;
@txaiwieser
txaiwieser / UIBezierPath+Polygons.swift
Created May 11, 2015 19:20
UIBezierPath+Polygons.swift - UIBezierPath Swift extension for easy creation of polygon paths!
//
// UIBezierPath+Polygons.swift
//
//
// Created by Txai Wieser on 11/05/15.
// Copyright (c) 2015 TDW. All rights reserved.
// Based on: https://github.com/ZevEisenberg/ZEPolygon, thanks man!
import UIKit
@imkevinxu
imkevinxu / Device.swift
Last active March 4, 2023 16:09
iOS device checks for OS version and screen size in Swift
//
// Device.swift
// imHome
//
// Created by Kevin Xu on 2/9/15. Updated on 6/20/15.
// Copyright (c) 2015 Alpha Labs, Inc. All rights reserved.
//
import Foundation