Skip to content

Instantly share code, notes, and snippets.

View leeyspaul's full-sized avatar
🍵
probably writing something.

Paul leeyspaul

🍵
probably writing something.
View GitHub Profile
@leeyspaul
leeyspaul / dfexample.swift
Created December 11, 2021 01:06
dateFormat example
import Foundation
let date = Date()
let df = DateFormatter()
df.dateFormat = "MMM d, yyyy" // prints out "Dec 10, 2021"
print(df.string(from: date))
@leeyspaul
leeyspaul / df.swift
Created December 11, 2021 01:01
DateFormatter Styles
import Foundation
let date = Date()
let df = DateFormatter()
// FULL STYLE
df.dateStyle = DateFormatter.Style.full
df.timeStyle = DateFormatter.Style.full
print(df.string(from: date)) // Friday, December 10, 2021 at 5:00:41 PM Pacific Standard Time
@leeyspaul
leeyspaul / date.swift
Created December 8, 2021 21:34
Date in SwiftUI
// creates the Date object which gives to you the current date in your systems locale.
let date: Date = Date()
@leeyspaul
leeyspaul / auth.txt
Created December 7, 2021 02:12
Stytch Google OAuth Authenticate cURL sample
curl --request POST --url https://test.stytch.com/v1/oauth/authenticate -u 'YOUR-PROJECT-NAME:YOUR-SECRET' -H 'Content-Type: application/json' -d '{ "token": "YOUR-TOKEN-FROM-LOGIN-REDIRECT" }'
@leeyspaul
leeyspaul / login.html
Created December 7, 2021 02:01
Stytch Login Button
<html>
<head>
<style>
.container {
height: 200px;
position: relative;
}
.center {
display: flex;
@leeyspaul
leeyspaul / app.py
Last active December 7, 2021 02:23
Stytch Google OAuth
from flask import Flask
from flask import request
from flask import render_template
from flask import session
app = Flask(__name__)
app.secret_key = "development"
@app.route("/login")
@leeyspaul
leeyspaul / Calendar.swift
Created December 4, 2021 01:11
Calendar SwiftUI implementation using LazyVGrid
struct Calendar: View {
var cols: [GridItem] = [
GridItem(spacing: 35),
GridItem(spacing: 35),
GridItem(spacing: 35),
GridItem(spacing: 35),
GridItem(spacing: 35),
GridItem(spacing: 35),
GridItem(spacing: 35)
@leeyspaul
leeyspaul / test.py
Created December 1, 2021 20:11
OAuth2 Testing an API request to Google Calendar API
@app.route("/test-api-request")
def test_api_request():
"""Tests an API request to Google Calendar."""
# grab the credentials from our flask session, in production
# you will probably store this in some persistent database per user
credentials = google.oauth2.credentials.Credentials(
**flask.session['credentials'])
# build the Google Calendar service which we use to represent the Google Calendar
# API
@leeyspaul
leeyspaul / redirect.py
Created November 30, 2021 20:31
OAuth2 Google Calendar API Redirect Route Complete
@app.route("/authorize-user")
def auth_user():
"""
Redirects a user to Google's authorization server to show the OAuth
Consent screen and get user consent.
"""
return redirect(authorization_url)
@app.route("/oauth2redirect")
def oauth2_redirect():
@leeyspaul
leeyspaul / redirect.py
Last active November 30, 2021 20:29
OAuth2 Google Calendar API Redirect Route
@app.route("/oauth2redirect")
def oauth2_redirect():
"""
The redirect URI that Google hits after user grants access in the OAuth
consent screen where we fetch the access token from the access code given in the
URL and set them in the flask session.
"""
# grabs the URL response from the redirect after auth
authorization_response = request.url