Skip to content

Instantly share code, notes, and snippets.

@paigeshin
paigeshin / ForegroundTextColor.swift
Created April 2, 2023 03:38 — forked from yannxou/ForegroundTextColor.swift
Foreground text color based on background color #SwiftUI
// Taken from Apple's App Dev Training: https://developer.apple.com/tutorials/app-dev-training/
/// This color is either black or white, whichever is more accessible when viewed against the scrum color.
var accessibleFontColor: Color {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
UIColor(self).getRed(&red, green: &green, blue: &blue, alpha: nil)
return isLightColor(red: red, green: green, blue: blue) ? .black : .white
}
@paigeshin
paigeshin / Data+Extensions.swift
Created October 21, 2022 14:40 — forked from nbasham/Data+Extensions.swift
Get a random date between two values. Swift 4.2+ uses Random(in:).
import Foundation
extension Date {
static func randomBetween(start: String, end: String, format: String = "yyyy-MM-dd") -> String {
let date1 = Date.parse(start, format: format)
let date2 = Date.parse(end, format: format)
return Date.randomBetween(start: date1, end: date2).dateString(format)
}
@paigeshin
paigeshin / convert.swift
Created October 17, 2022 09:58 — forked from SatoTakeshiX/convert.swift
Take capture a view by SwiftUI
//
// ContentView.swift
// TryGeometryReader
//
// Created by satoutakeshi on 2019/12/07.
// Copyright © 2019 satoutakeshi. Licensed under MIT.
//
import SwiftUI
@paigeshin
paigeshin / sign_in_with_apple.yml
Created September 3, 2022 08:22 — forked from liamnichols/sign_in_with_apple.yml
Localisations of the "Sign in with Apple" string taken from Xcode 11.1
SIGN_IN_WITH_APPLE:
- de: Mit Apple anmelden
- he: התחברות באמצעות Apple
- en_AU: Sign in with Apple
- ar: تسجيل الدخول باستخدام Apple
- el: Σύνδεση μέσω Apple
- ja: Appleでサインイン
- en: Sign in with Apple
- uk: Увійти з Apple
- es_419: Iniciar sesión con Apple
@paigeshin
paigeshin / social-meta-tags.html
Created March 8, 2022 15:07 — forked from machito/social-meta-tags.html
Example of social meta tags for videos
<meta property="og:site_name" content="YouTube">
<meta property="og:url" content="https://www.youtube.com/watch?v=Gb9E60E3duU">
<meta property="og:title" content="#6: IBM Head of Design, Phil Gilbert, wields $100M and 1,300 designers to bring design back to IBM">
<meta property="og:image" content="https://i.ytimg.com/vi/Gb9E60E3duU/hqdefault.jpg">
<meta property="og:description" content="Phil Gilbert is the GM and Head of Design at IBM. In this episode, he discusses creating IBM&#39;s proprietary design thinking methodology, their own design scho...">
<meta property="al:ios:app_store_id" content="544007664">
<meta property="al:ios:app_name" content="YouTube">
<meta property="al:ios:url" content="vnd.youtube://www.youtube.com/watch?v=Gb9E60E3duU&amp;feature=applinks">
@paigeshin
paigeshin / authorize.js
Created February 22, 2022 10:36 — forked from kndt84/authorize.js
Sample code: how to refresh session of Cognito User Pools with Node.js and Express
const AWS = require('aws-sdk');
const CognitoUserPool = require('amazon-cognito-identity-js-node').CognitoUserPool;
const CognitoUserSession = require('amazon-cognito-identity-js-node').CognitoUserSession;
const CognitoUser = require('amazon-cognito-identity-js-node').CognitoUser;
const CognitoIdToken = require('amazon-cognito-identity-js-node').CognitoIdToken;
const CognitoAccessToken = require('amazon-cognito-identity-js-node').CognitoAccessToken;
const CognitoRefreshToken = require('amazon-cognito-identity-js-node').CognitoRefreshToken;
const cfg = require('config').config;
const COGNITO_IDENTITY_POOL_ID = cfg.COGNITO_IDENTITY_POOL_ID;
@paigeshin
paigeshin / git-aliases.md
Created January 9, 2022 15:10 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
import SwiftUI
import HealthKit
struct ContentView: View {
@State var labelText = "Get Data"
@State var flag = false
let healthStore = HKHealthStore()
let allTypes = Set([
HKSeriesType.heartbeat(),
@paigeshin
paigeshin / FileUpload.js
Created September 8, 2021 03:24 — forked from nyx-code/FileUpload.js
This NodeJS API which will upload files onto the AWS S3 Bucket. Video -> https://youtu.be/TtuCCfren_I
require('dotenv/config')
const express = require('express')
const multer = require('multer')
const AWS = require('aws-sdk')
const uuid = require('uuid/v4')
const app = express()
const port = 3000