Skip to content

Instantly share code, notes, and snippets.

View rayning0's full-sized avatar
🤪

Raymond Gan rayning0

🤪
View GitHub Profile
@rayning0
rayning0 / main.go
Last active March 12, 2020 00:50
Different ways to read/write input in Golang
// Different ways to read/write input in Golang:
// ----------HackerRank----------
// read from 3 nums from command line
package main
import "fmt"
func main() {
var n int
var a int
@rayning0
rayning0 / System Design.md
Created February 25, 2020 20:52 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
# Not working yet
# a = [1, 5, 2, -2]
# s = [-1, 1, -1, 1]
# summation
def val(a, s)
sum = 0
a.size.times do |i|
sum += a[i] * s[i]
end
class Example12 {
public static void permutation(String str) {
permutation(str, "");
}
public static void permutation(String str, String prefix) {
if (str.length() == 0) {
System.out.println(prefix);
} else {
for (int i = 0; i < str.length(); i++) {
@rayning0
rayning0 / jwt-expiration.md
Created February 24, 2019 19:05 — forked from soulmachine/jwt-expiration.md
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:

const myfunc = (add1, add2) => {
return new Promise((resolve, reject) => {
const new_value = add1 + add2;
setTimeout(() => {
resolve(new_value);
}, 3000);
})
};
myfunc(1, 5)
{
"sublimeTextKeymap.promptV3Features": true,
"editor.multiCursorModifier": "alt",
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": true,
"editor.minimap.enabled": false,
"editor.wordWrap": "on",
"editor.tabSize": 2,
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
<!doctype HTML>
<html>
<script src="aframe.min.js"></script>
<script src="aframe-ar-modified.js"> </script>
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs>
<a-marker-camera preset='custom' type='pattern' url='pattern-marker.patt'>
<a-box position='0 0.5 0' material='color: red; opacity: 0.5;'></a-box>
</a-marker-camera>
<a-entity camera></a-entity>
@rayning0
rayning0 / README-Template.md
Created January 4, 2018 22:31 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites