Skip to content

Instantly share code, notes, and snippets.

View jimmyhoran's full-sized avatar
🛠️
Working on my own thing

Jimmy Horan jimmyhoran

🛠️
Working on my own thing
View GitHub Profile
@Jackman3005
Jackman3005 / Prisma.ts
Created May 20, 2024 04:45
Prisma Query Debugging code
function buildPrismaWithQueryDebugging(
sqlQueryReportingThresholdMs: number,
prismaActionReportingThresholdMs: number
) {
const prisma = new PrismaClient({
log: [
{
emit: "event",
level: "query",
@mjbalcueva
mjbalcueva / password-input.tsx
Last active July 27, 2024 05:47
shadcn ui custom password input
"use client"
import { forwardRef, useState } from "react"
import { EyeIcon, EyeOffIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Input, InputProps } from "@/components/ui/input"
import { cn } from "@/lib/utils"
const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
({ className, ...props }, ref) => {
extension UIButton {
// padding - the spacing between the Image and the Title
func centerTitleVertically(padding: CGFloat = 12.0) {
guard let imageViewSize = self.imageView?.frame.size, let titleLabelSize = self.titleLabel?.frame.size
else {
return
}
let totalHeight = imageViewSize.height + titleLabelSize.height + padding
extension UIButton {
// iconName - SFSymbol Name
// size - Size of the Symbol in points
// scale - .small, .medium, .large
// weight - .ultralight, .thin, .light, .regular, .medium, .semibold, .bold, .heavy, .black
// tintColor - Color of the Symbol
// backgroundColor - Background color of the button
func setSFSymbol(iconName: String, size: CGFloat, weight: UIImage.SymbolWeight,
scale: UIImage.SymbolScale, tintColor: UIColor, backgroundColor: UIColor) {
let symbolConfiguration = UIImage.SymbolConfiguration(pointSize: size, weight: weight, scale: scale)
observeKeyboardWillShowNotification(scrollView) { [weak self] keyboardSize in
guard let keyboardHeight = keyboardSize?.height else { return }
self?.someViewYouWantToMoveBottomConstraint?.constant = -keyboardHeight
}
observeKeyboardWillHideNotification(scrollView) { [weak self] _ in
self?.someViewYouWantToMoveBottomConstraint?.constant = .zero
}
protocol ScrollableContentKeyboardObserving {
func observeKeyboardWillShowNotification(_ scrollView: UIScrollView, onShowHandler onShow: ((CGSize?) -> Void)?)
func observeKeyboardWillHideNotification(_ scrollView: UIScrollView, onHideHandler onHide: ((CGSize?) -> Void)?)
}
extension ScrollableContentKeyboardObserving {
func observeKeyboardWillShowNotification(_ scrollView: UIScrollView, onShowHandler onShow: ((CGSize?) -> Void)? = nil) {
let block: (Notification) -> Void = { notification -> Void in
extension NSError {
/// A convenience initializer for NSError to set its description.
///
/// - Parameters:
/// - domain: The error domain.
/// - code: The error code.
/// - description: Some description for this error.
convenience init(domain: String, code: Int, description: String) {
self.init(domain: domain, code: code, userInfo: [(kCFErrorLocalizedDescriptionKey as CFString) as String: description])
@edvinasbartkus
edvinasbartkus / android.yml
Created November 20, 2019 14:45
Running Detox tests for Android on Github Actions Workflow
name: Android
on: [push]
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout
@stevencurtis
stevencurtis / subscriptCollection
Created November 20, 2019 12:19
subscriptCollection
extension Collection {
subscript(index i : Index) -> Element? {
return indices.contains(i) ? self[i] : nil
}
}
sliceOfArray[index: 0]
@stevencurtis
stevencurtis / indicies.contains
Created November 20, 2019 11:09
indicies.contains
if array.indices.contains(3) {
print (array[3])
}