Skip to content

Instantly share code, notes, and snippets.

View fredguth's full-sized avatar

Fred Guth fredguth

  • Brasília, DF, Brazil
View GitHub Profile
@jcheng5
jcheng5 / README.md
Last active July 20, 2024 03:12
Debounce and throttle for Shiny for Python

Sketch of debounce/throttle decorators for Shiny for Python

Drop ratelimit.py into your app directory to use in your own Shiny for Python app. See app.py for an example of these decorators in action.

Why is this a gist instead of a PR? Because to implement this "properly" for Shiny for Python, this would need to be beefed up to include type annotations, support for async, and unit/integration tests, which would all be more effort than this has taken so far. (To be clear, we want to do all that, but in the meantime, here's this gist.)

@Mlocik97
Mlocik97 / hooks.js
Last active March 2, 2024 18:03
example (writen by hand, not tested) of auth in SvelteKit. (deprecated)
export async function handle({ event, resolve }) {
const cookies = await cookie.parse(event.request.headers.get('cookie') || '');
if (event.url.pathname == '/login') {
// skip verifying user, and allow to load website
const response = await resolve(event);
return response;
}
const user = DB.User.findOne({session: cookies.token});