Skip to content

Instantly share code, notes, and snippets.

View emin-grbo's full-sized avatar
💻
Getting Schwifty

emin emin-grbo

💻
Getting Schwifty
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
@dqhieu
dqhieu / TwitterAnimation.swift
Last active April 6, 2023 00:50
Twitter's new animation ❤️
struct ContentView: View {
@State var scale: CGFloat = 0
@State var showingBlankHeart = true
@State var heartScale: CGFloat = 0
@State var textOpacity: Double = 1
@State var offset1: CGFloat = 0
@State var plus1Opacity: Double = 1
@State var offset2: CGFloat = 0
@State var plus2Opacity: Double = 1
//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
#!/usr/bin/env node
const
express = require( 'express' ),
app = express(),
passport = require( 'passport' ),
LocalStrategy = require( 'passport-local' ).Strategy,
bodyParser = require( 'body-parser' );
app.use( bodyParser.urlencoded( { extended: true } ) );
@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)