Skip to content

Instantly share code, notes, and snippets.


Hos.Mercury HosMercury

View GitHub Profile
jeremychone /
Created May 11, 2021 05:48
Rust to PostgreSQL with SQLX | Rust By Example
#![allow(unused)] // silence unused warnings while exploring (to comment out)
use sqlx::postgres::{PgPoolOptions, PgRow};
use sqlx::{FromRow, Row};
// Youtube episode:
// region: Section
// Start postgresql server docker image:
LukeMathWalker / audit.yml
Last active September 16, 2023 18:39
GitHub Actions - Rust setup
View audit.yml
name: Security audit
- cron: '0 0 * * *'
- '**/Cargo.toml'
- '**/Cargo.lock'
pub struct StrSplit<'haystack, D> {
remainder: Option<&'haystack str>,
delimiter: D,
impl<'haystack, D> StrSplit<'haystack, D> {
pub fn new(haystack: &'haystack str, delimiter: D) -> Self {
abou7mied / index.hbs
Created December 26, 2019 06:16
connect-flash + hbs example
View index.hbs
{{#each messages}}
Message: {{this}}
bpas247 /
Last active March 17, 2023 17:12
State Updates Are Asynchronous
samsch /
Last active September 21, 2023 06:37
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens:

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
rylev /
Created March 5, 2019 10:50
How to Learn Rust

Learning Rust

The following is a list of resources for learning Rust as well as tips and tricks for learning the language faster.


Rust is not C or C++ so the way your accustomed to do things in those languages might not work in Rust. The best way to learn Rust is to embrace its best practices and see where that takes you.

The generally recommended path is to start by reading the books, and doing small coding exercises until the rules around borrow checking become intuitive. Once this happens, then you can expand to more real world projects. If you find yourself struggling hard with the borrow checker, seek help. It very well could be that you're trying to solve your problem in a way that goes against how Rust wants you to work.

greyscaled /
Last active September 19, 2022 08:59
Sequelize + Express + Migrations + Seed Starter
rakd / template.go
Created December 6, 2017 05:20
template inheritance for echo/golang
View template.go
package main
import (