This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function MyDebounceSearch(){ | |
| const [state, setState] = useState("") | |
| return ( | |
| <div> | |
| <DebounceInput | |
| minLength={2} | |
| value={state} | |
| debounceTimeout={300} | |
| onChange={event => setState(event.target.value)} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { getToken } from 'next-auth/jwt'; | |
| const token = await getToken({req}); | |
| const accessToken = token.accessToken as string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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") |
NewerOlder