Skip to content

Instantly share code, notes, and snippets.

View snuffyDev's full-sized avatar
😮‍💨
nice

snuffy snuffyDev

😮‍💨
nice
View GitHub Profile
@snuffyDev
snuffyDev / hooks.ts
Created February 4, 2022 23:18
Reddit OAuth2 (outdated) SvelteKit Hooks file
import type { Handle, GetSession } from '@sveltejs/kit';
import * as cookie from 'cookie';
import * as jsonwebtoken from 'jsonwebtoken';
import { handleTokenRefresh } from '$lib/helpers/refresh';
import { JWT_SECRET } from './env';
const getJWT = (cookie: string): jsonwebtoken.Jwt => {
if (typeof cookie !== 'string' || cookie.length === 0) return;
return jsonwebtoken.decode(cookie, { complete: true });
@snuffyDev
snuffyDev / PreloadingIndicator.svelte
Created February 21, 2022 15:38
Preload indicator
<!--
original implementation:
https://dev.to/shajidhasan/add-a-youtube-like-page-loading-animation-in-sveltekit-58kp
-->
<script lang="ts">
import { tweened } from 'svelte/motion';
import { cubicOut } from 'svelte/easing';
import { navigating } from '$app/stores';
import { writable } from 'svelte/store';
import { onMount } from 'svelte';
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
This file has been truncated, but you can view the full file.
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.32.1(29a273516805a852aa8edc5e05059f119b13eff0)
* Released under the MIT license
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
*-----------------------------------------------------------------------------*/
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
{
"items": [
{
"header": {
"title": "New albums & singles",
"browseId": "FEmusic_new_releases_albums"
},
"results": [
{
"title": "Sweetest Pie",
pub mod terminal;
use futures_util::{SinkExt, StreamExt};
use std::{io::Write, net::SocketAddr};
use terminal::{Pty, PtyProcess};
use tokio::net::{TcpListener, TcpStream};
use tokio_tungstenite::tungstenite::Result;
use tokio_tungstenite::{accept_async, tungstenite::Error, tungstenite::Message};
pub mod terminal;
use futures_util::{SinkExt, StreamExt};
use std::{io::Write, net::SocketAddr};
use terminal::{Pty, PtyProcess};
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::net::{TcpListener, TcpStream};
use tokio::process::{ChildStderr, ChildStdin, ChildStdout};
use tokio_tungstenite::tungstenite::Result;
pub mod terminal;
use futures_util::{SinkExt, StreamExt};
use std::net::SocketAddr;
use std::process::Stdio;
use std::sync::mpsc::{channel, Receiver, Sender, TryRecvError};
use std::sync::Arc;
use std::thread::{self, sleep};
use terminal::{Pty, PtyProcess};
pub mod terminal;
use futures_util::{SinkExt, StreamExt};
use std::net::SocketAddr;
use std::process::Stdio;
use std::sync::Arc;
use std::thread::{self, sleep};
use terminal::{Pty, PtyProcess};
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::net::{TcpListener, TcpStream};
pub mod terminal;
use futures_util::{SinkExt, StreamExt};
use std::net::SocketAddr;
use std::process::Stdio;
use std::thread::sleep;
use tokio::io::{AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::net::{TcpListener, TcpStream};
use tokio::process::{Child, Command};