Skip to content

Instantly share code, notes, and snippets.

View jordantwells42's full-sized avatar

Jordan Wells jordantwells42

View GitHub Profile
import { useEffect } from 'react'
import { useRouter } from 'next/router'
// Current URL is '/'
function Page() {
const router = useRouter()
useEffect(() => {
// Always do navigations after the first render
router.push('/?counter=10', undefined, { shallow: true, scroll: false })
export default function MyDebounceSearch(){
const [state, setState] = useState("")
return (
<div>
<DebounceInput
minLength={2}
value={state}
debounceTimeout={300}
onChange={event => setState(event.target.value)} />
import { getToken } from 'next-auth/jwt';
const token = await getToken({req});
const accessToken = token.accessToken as string;
@jordantwells42
jordantwells42 / Spotify.ts
Last active June 17, 2024 00:45
using Spotify Next Auth
const client_id = process.env.SPOTIFY_CLIENT_ID
const client_secret = process.env.SPOTIFY_CLIENT_SECRET
const authorization_code = Buffer.from(`${client_id}:${client_secret}`).toString('base64')
const getAccessToken = async (refresh_token: string) => {
const response = await fetch(`https://accounts.spotify.com/api/token`, {
method: 'POST',
headers: {
Authorization: authorization_code,
'Content-Type': 'application/x-www-form-urlencoded'
@jordantwells42
jordantwells42 / [...nextauth].ts
Created July 20, 2022 12:23
Next Auth with Spotify
import NextAuth, { User, type NextAuthOptions } from "next-auth";
import SpotifyProvider, { SpotifyProfile } from "next-auth/providers/spotify";
import CredentialsProvider from "next-auth/providers/credentials";
export const authOptions: NextAuthOptions = {
// Configure one or more authentication providers
providers: [
SpotifyProvider({
authorization:
@jordantwells42
jordantwells42 / Markdium-python.py
Created August 21, 2020 22:27
Markdium-A Guide to Serving Up Matplotlib Visualizations Two Ways
# Generating random arrays of floats
x1s = np.random.randn(20)
x2s = np.random.randn(20)
y1s = np.random.randn(20)
y2s = np.random.randn(20)
# Creating the pyplot,
# "co": cyan and circles, "r^" red and triangles
@jordantwells42
jordantwells42 / Markdium-python.py
Created August 21, 2020 22:27
Markdium-A Guide to Serving Up Matplotlib Visualizations Two Ways
# Creating a figure and an array of axes objects that
# is one row by two columns
fig, axs = plt.subplots(1, 2)
# Adjusting the figure parameters
fig.set_size_inches(9, 5)
fig.set_dpi(100)
# Plotting the data
@jordantwells42
jordantwells42 / Markdium-python.py
Created August 21, 2020 22:27
Markdium-A Guide to Serving Up Matplotlib Visualizations Two Ways
plt.figure(figsize=(9, 5), dpi = 100)
plt.plot(x1s, y1s, "co", label = "cyan dots")
plt.plot(x2s, y2s, "r^", label = "red pyramids")
# Adding more artists
plt.title("My Plot")
plt.xlabel("x")
plt.ylabel("y")
plt.legend()
@jordantwells42
jordantwells42 / Markdium-python.py
Created August 21, 2020 22:27
Markdium-A Guide to Serving Up Matplotlib Visualizations Two Ways
# Initializing a figure and axes object
fig, ax1 = plt.subplots()
# Adjusting the figure parameters
fig.set_size_inches(9, 5)
fig.set_dpi(100)
# Plotting the data
ax1.plot(x1s, y1s, "co", label = "cyan dots")
@jordantwells42
jordantwells42 / Markdium-python.py
Created August 21, 2020 22:27
Markdium-A Guide to Serving Up Matplotlib Visualizations Two Ways
# Initializing a figure and axes object
fig, ax1 = plt.subplots()
# Adjusting the figure parameters
fig.set_size_inches(9, 5)
fig.set_dpi(100)
# Plotting the data
ax1.plot(x1s, y1s, "co", label = "cyan dots")
ax1.plot(x2s, y2s, "r^", label = "red pyramids")