Skip to content

Instantly share code, notes, and snippets.

if certbot fail, get free ssl from https://freessl.cn/
<VirtualHost *:80 *:443>
ServerName www.853rd.com
ServerAlias 853rd.com
ServerAdmin sten.li@foxmail.com
DocumentRoot /var/www/853rd.com
<Directory "/var/www/853rd.com/">
Options Indexes FollowSymLinks
sudo gpt -r show disk0 ->
Mackintosh HD part is 234045360 blob => 234045360*512 = 119831224320 B = 119.83122432 GB
***
How to convert between Gigabytes and Gibibytes (GB & GiB)?
1 GB = 0.931322574615 GiB
1 GiB = 1.073741824 GB
***
Apple prefers GB while Microsoft prefers GiB, for example I want a perfact Windows partision with size of 50.00G(from the view of Windows) on my Mac:
{
"server": "0.0.0.0",
"local_address": "127.0.0.1",
"local_port": 1080,
"port_password": {
"8850": "0",
"8851": "1",
"8852": "2",
"8853": "3"
},
@1isten
1isten / laravel_passport_jwt.md
Last active December 31, 2019 15:25
Use Laravel Passport to create and manage JWT Tokens (Personal Access Tokens)

Setup according to the documentation

  • Keep the default migrations as token info will be stored at db
  • Personal Access Token is what we will use as JWT
  • Token lifetime can be set in AuthServiceProvider via personalAccessTokensExpireIn
  • No need to use CreateFreshApiToken middleware
  • Client should store tokens using JavaScript (e.g., localStorage, or js-cookie)
  • Client should append the 'Authorization': 'Bearer xxx' header manually

Create the token, use the createToken method

@1isten
1isten / rFetch.js
Created January 14, 2020 13:41
recursively fetch Laravel paginated api
function rFetch(url) {
return new Promise((resolve, reject) => {
const list = [];
const getData = async url => {
try {
await new Promise((resolve, reject) => {
setTimeout(() => resolve(), 1000); // force delay~
});
const { data } = await axios.get(url);
console.log(data.current_page);
git checkout --orphan TEMP_BRANCH && git add -A && git commit -am "Initial commit" && git branch -D master && git branch -m master && git push -f origin master && git branch --set-upstream-to=origin/master master && git pull
git rm -r --cached . && git add . && git commit -m "fixed untracked files" && git push
@1isten
1isten / css.json
Last active April 8, 2020 14:08
VS Code CSS snippets
{
"General reset": {
"prefix": "reset",
"body": [
"html, $2body {",
" width: 100vw;",
" height: 100vh;",
" margin: 0;",
" border: 0;",
" padding: 0;",
@1isten
1isten / md-colors.js
Last active May 4, 2020 18:13
2014 Material Design color palettes in JS object format
// https://material.io/guidelines/style/color.html
module.exports = {
'red': {
'50': '#ffebee',
'100': '#ffcdd2',
'200': '#ef9a9a',
'300': '#e57373',
'400': '#ef5350',
'500': '#f44336',
@1isten
1isten / promise-chain-break.js
Last active June 9, 2020 19:32
the only way to early break Promise .then() chain is to make the code fall into .catch()
const myLimit = 3;
function checkLimit(data) {
if (data === myLimit) {
const err = new Error('let me exit!');
err.data = `${data} is the enough!!!`;
throw err; // or, return Promise.reject(err)
}
}
@1isten
1isten / forEach-break-continue-await.js
Created June 10, 2020 15:03
forEach does not support break or continue, each iteration involves a new callback
(async function () {
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
// SyntaxError: Illegal break statement
arr.forEach(n => {
if (n === 3) {
break;
}
console.log(n);
});