Skip to content

Instantly share code, notes, and snippets.

View forgot's full-sized avatar

Jesse Cox forgot

View GitHub Profile
extension View {
func animate(duration: CGFloat, _ execute: @escaping () -> Void) async {
await withCheckedContinuation { continuation in
withAnimation(.linear(duration: duration)) {
execute()
}
DispatchQueue.main.asyncAfter(deadline: .now() + duration) {
continuation.resume()
}
@cfreshman
cfreshman / wordle-answers-alphabetical.txt
Last active March 9, 2024 17:43
Original Wordle answers from source code in alphabetical order. And if you write a solver, here's a leaderboard! https://freshman.dev/wordle/leaderboard Additional allowed guesses: https://gist.github.com/cfreshman/cdcdf777450c5b5301e439061d29694c NYTimes version: https://gist.github.com/cfreshman/a7b776506c73284511034e63af1017ee
aback
abase
abate
abbey
abbot
abhor
abide
abled
abode
abort
@podkovyrin
podkovyrin / HTTPClient.swift
Last active January 20, 2024 00:25
Swift Combine HTTP Client with delayed retry
import Combine
import Foundation
struct HTTPClient {
let session: URLSession
let defaultRetryInterval: TimeInterval
let retryCount: Int
init(session: URLSession = .shared, retryCount: Int = 1, defaultRetryInterval: TimeInterval = 2) {
self.session = session
@merlos
merlos / SetSharePointCredentials.ps1
Created October 23, 2018 19:24
A PowerShell Script to set credentials as environment variables. Password is not stored as plain text.
# Description
# This Script sets Sharepoint Credentials as environment variables so
# you are not prompted on your script every time
#
# Usage
#
# PS> SetSharepointCredentials
#
# It will prompt the user to type site url, username, password. If it is successful
#
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active April 22, 2024 15:24
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@zcaceres
zcaceres / Include-in-Sequelize.md
Last active January 8, 2024 07:14
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@raven
raven / Breakpoints_v2.xcbkptlist
Last active August 30, 2019 00:53
Symbolic breakpoint for dynamically linking libReveal against UIApplicationMain
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
@michaelochs
michaelochs / .lldbinit
Created November 23, 2013 13:24
If you add this content to your ~/.lldbinit you can launch the Reveal library from within your debugger as long as you have the library added to your app bundle. For more info please see my blog post: http://ios-coding.com/improved-way-to-integrate-reveal/
command alias reveal_load expr (void*)dlopen([(NSString*)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2);
command alias reveal_start expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil];
command alias reveal_stop expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStop" object:nil];
@adamgit
adamgit / .gitignore
Last active April 8, 2024 12:58
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#