Skip to content

Instantly share code, notes, and snippets.

View boutros's full-sized avatar

Petter Goksøyr Åsen boutros

  • Oslo Public Library
  • Oslo
View GitHub Profile
@joepie91
joepie91 / no-your-cryptocurrency-cannot-work.md
Last active May 15, 2024 01:23
No, your cryptocurrency cannot work

No, your cryptocurrency cannot work

Whenever the topic of Bitcoin's energy usage comes up, there's always a flood of hastily-constructed comments by people claiming that their favourite cryptocurrency isn't like Bitcoin, that their favourite cryptocurrency is energy-efficient and scalable and whatnot.

They're wrong, and are quite possibly trying to scam you. Let's look at why.

What is a cryptocurrency anyway?

There are plenty of intricate and complex articles trying to convince you that cryptocurrencies are the future. They usually heavily use jargon and vague terms, make vague promises, and generally give you a sense that there must be something there, but you always come away from them more confused than you were before.

@ribice
ribice / caller.go
Last active July 7, 2023 07:07
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
@samsch
samsch / stop-using-jwts.md
Last active April 23, 2024 05:47
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: https://www.youtube.com/watch?v=pYeekwv3vC4 (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: https://www.rdegges.com/2018/please-stop-using-local-storage/

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
@alexedwards
alexedwards / main.go
Created January 28, 2018 11:32
RequireLogin middleware
var sessionManager = scs.NewCookieManager("...")
func RequireLogin(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session := sessionManager.Load(r)
userID, err := session.GetInt("userID")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
@kyledcline
kyledcline / postgres-best-practices.md
Last active October 26, 2023 06:10
Postgres Best Practices

PSQL CLI Client

Psql is a fully-fledged CLI client for Postgres, but most people are unaware of its many advanced features.

~/.psqlrc can be edited to persist any behavior or configuration settings you want between psql sessions. It behaves just like ~/.bashrc or ~/.vimrc, sourced at psql launch. See More out of psql for some interesting configurations.

If you have a long query to write and rewrite, you can use \e to edit your query in an editor.

Use \watch at the end of a query in order to automatically re-run the query every few seconds - great for monitoring while making changes elsewhere in your application architecture.

@calebamiles
calebamiles / notes.md
Last active February 1, 2021 15:53
Notes on Open Source Governance Models

Node.js Foundation

  • Healthy Open Source
    • explicit goal to be a lightweight process
    • concrete ability to scale to hundreds of contributors
    • good fundamental goals
      • transparency
      • participation
      • efficacy
    • ecosystem projects encouraged but not required to adopt foundation governance templates
  • creation of projects under TSC explicity delegates authority from TSC to project TC
@kspeakman
kspeakman / Api.elm
Last active August 4, 2018 13:50
JsonStuff - Elm native module to auto-encode/decode JSON
port module Api exposing (..)
import JsonStuff exposing (ToJson, FromJson, getEncoder, getDecoder)
import Http
helpPostJson : String -> ToJson a msg -> FromJson b msg -> a -> Http.Request b
helpPostJson url toJson fromJson o =
Http.request
{ method = "POST"
, headers = []
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

var router = (function() {
var self = {}
var usehistory = window && window.history.pushState ? 1 : 0;
self.routes = {}
self.go = function(url,title,state){
self.push(url,title,state)
self.execute(url)
}
@sgrove
sgrove / learn_gamma.cljs
Last active August 29, 2015 14:21
Compare "Learn WebGL Lesson 1" with "Learn Gamma Lesson 1"
;; Gamma (shader-generation): https://github.com/kovasb/gamma
;; Gamma Driver (WebGL resource management, aka "Om for WebGL"): https://github.com/kovasb/gamma-driver
;; Gamma examples: https://github.com/kovasb/gamma-examples
(ns gampg.learn-gamma.lesson-01
(:require [clojure.string :as s]
[gamma.api :as g]
[gamma.program :as p]
[gamma.tools :as gt]
[gamma-driver.drivers.basic :as driver]