import random | |
N = 4 # Number of chores | |
p = 2 # Number of players | |
preferences = [] | |
for i in range(p): | |
vs = list(range(N)) | |
random.shuffle(vs) | |
preferences.append(vs) |
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
What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.
In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.
Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th
This is a compiled list of falsehoods programmers tend to believe about working with time.
Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.
- There are always 24 hours in a day.
- February is always 28 days long.
- Any 24-hour period will always begin and end in the same day (or week, or month).
// This function calls the JNI routine DefineClass for each class in the | |
// in-memory class table (see java-classes.h). The class loader parameter passed | |
// to define class is the result of calling ClassLoader.getSystemClassLoader(). | |
jthrowable java_load_classes() | |
{ | |
JNIEnv *environment; | |
jclass class_loader; | |
jmethodID get_system_loader; | |
jobject system_loader; | |
jthrowable exception; |
#!/usr/bin/env python3 | |
from bs4 import BeautifulSoup | |
import pycurl | |
from io import BytesIO | |
import re | |
import sys | |
END = "abcdefghijklmnopqrstuvwxyz0123456789" | |
BB_URL = "http://www.bodybuilding.com/exercises/list/index/selected/" |
Below are the Big O performance of common functions of different Java Collections. | |
List | Add | Remove | Get | Contains | Next | Data Structure | |
---------------------|------|--------|------|----------|------|--------------- | |
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array |
package com.studyblue.utils.pool; | |
import java.lang.ref.ReferenceQueue; | |
import java.lang.ref.WeakReference; | |
import java.util.IdentityHashMap; | |
import java.util.Map; | |
import java.util.Queue; | |
import java.util.concurrent.ArrayBlockingQueue; |