Skip to content

Instantly share code, notes, and snippets.

View slav0nic's full-sized avatar

Sergey Maranchuk slav0nic

View GitHub Profile
@olex0r
olex0r / mikrotik-wireguard-default-gw.sh
Last active May 12, 2023 18:35
Mikrotik wireguard client as default gateway
# You should change "XX.XX.XX.XX" to you wireguard server
# and set public-key,private-key,preshared-key,"YY.YY.YY.YY/YY" according to your config
/interface/wireguard/add name=wg0 private-key="[PRIVATE_KEY_HERE]"
/interface/wireguard/peers/add interface=wg0 endpoint-address=XX.XX.XX.XX endpoint-port=12321 public-key="[PUBLIC_KEY_HERE]" preshared-key="[PRESHARED_KEY_HERE]" persistent-keepalive=25s allowed-address=0.0.0.0/0
/ip/address/add interface=wg0 address=YY.YY.YY.YY/YY
/ip/route/add dst-address=XX.XX.XX.XX comment=wgserver disabled=yes
import plaster
import sys
def main():
if '--reload' in sys.argv:
import hupper
reloader = hupper.start_reloader(__name__ + '.main')
reloader.watch_files(['site.ini'])
loader = plaster.get_loader('site.ini', protocols=['wsgi'])
@soulmachine
soulmachine / jwt-expiration.md
Last active April 9, 2024 04:12
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@mmerickel
mmerickel / basic_auth_example.py
Last active April 27, 2021 18:27
Basic Auth in Pyramid with simple ACLs
from pyramid.authentication import BasicAuthAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPForbidden
from pyramid.httpexceptions import HTTPUnauthorized
from pyramid.security import ALL_PERMISSIONS
from pyramid.security import Allow
from pyramid.security import Authenticated
from pyramid.security import forget
from pyramid.view import forbidden_view_config
@NYKevin
NYKevin / accounting.sql
Last active April 3, 2024 15:46
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...