This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const jwt = require('jsonwebtoken'); | |
| module.exports = (redisC) => { | |
| const secret = process.env.JWT_SECRET; | |
| const accessExpiresIn = 60 * 15; | |
| const refreshExpiresIn = 60 * 60; | |
| const sign = ({ payload = {}, options = {}, type = 'access' }) => { | |
| payload = {...payload, type}; | |
| options = options.expiresIn ? options : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.5' | |
| services: | |
| mongo: | |
| image: mongo | |
| ports: | |
| - '27017:27017' | |
| environment: | |
| MONGO_INITDB_ROOT_USERNAME: root | |
| MONGO_INITDB_ROOT_PASSWORD: root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stddef.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| void _swap (int *arr, size_t i, size_t j) { | |
| int tmp = arr[i]; | |
| arr[i] = arr[j]; | |
| arr[j] = tmp; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #============================================================================= | |
| # dark_powered.toml --- dark powered configuration example for SpaceVim | |
| # Copyright (c) 2016-2020 Wang Shidong & Contributors | |
| # Author: Wang Shidong < wsdjeg at 163.com > | |
| # URL: https://spacevim.org | |
| # License: GPLv3 | |
| #============================================================================= | |
| # All SpaceVim option below [option] section | |
| [options] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! myspacevim#before() abort | |
| """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " BASICS | |
| """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| syntax on | |
| set updatetime=1000 | |
| "for performance issue | |
| set re=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const bits = 2048 | |
| const { publicKey } = crypto.generateKeyPairSync('rsa', { | |
| modulusLength: bits, | |
| publicKeyEncoding: { | |
| type: 'pkcs1', | |
| format: 'pem' | |
| } | |
| }) | |
| const test = (len) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <setjmp.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define COROUTINE_START int r = setjmp(current->context);\ | |
| switch (r) {\ | |
| case 0: | |
| #define COROUTINE_PREEMPT if (current->iter % 500 == 0) {\ | |
| longjmp(m, 1);\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void remove_bad_utf8 (uint8_t *src, size_t srclen) | |
| { | |
| uint8_t *dst = src; | |
| uint8_t *srcend = src + srclen; | |
| while (src < srcend) { | |
| // 0xxxxxxx | |
| if ((src[0] & 0x80) == 0x00) { | |
| if (src[0] < 0x20 || src[0] == 0x7F) { | |
| /* printf("not printable one-byte char...%02X\n", src[0]); */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ucontext.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define handle_error(msg) \ | |
| do { perror(msg); exit(EXIT_FAILURE); } while (0) | |
| #define CO_STACK_SIZE 2048 | |
| typedef struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdatomic.h> | |
| #include <errno.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <pthread.h> | |
| #include <linux/futex.h> |