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
<?php | |
// Route::get('/', ... | |
// ... | |
Route::fallback(function () { | |
$static = 'static'; // static folder in project root | |
$static_file = request()->path() === '/' ? base_path($static) : implode(DIRECTORY_SEPARATOR, array_merge(array(base_path($static)), explode('/', request()->path()))); | |
if (is_dir($static_file)) { |
Three JS key concepts:
-
Functions can be nested: a child function inside a parent function (and can be returned by the parent function).
-
Lexical scope: variables from outter scope are available to inner functions (when these inner functions are created).
-
Variables which can be accessed by any function anyhow will never be garbage collected (until that function is garbage collected).
A "closure" is a place (scope) where those variables are stored at and is only available for that function who needs to access them. Except for that function, there is no other API to access/modify those variables in the closure.
- Do not start Nest server, instead, just export an async function which returns its initialized app instance:
// path/to/nest/src/main.ts
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter, NestExpressApplication } from '@nestjs/platform-express'; // Optional because the `@nestjs/platform-express` package is used by default
import { AppModule } from './app.module';
async function bootstrap() {
In /usr/local/etc/nginx/nginx.conf (default config), Valet has included these lines:
# ...
include "/Users/sten/.config/valet/Nginx/*";
include servers/*; # 👈
include valet/valet.conf;
# ...
uninstall if necessary
brew services stop mariadb
brew uninstall mariadb
rm -rf /usr/local/var/mysql /usr/local/etc/my.cnf # be sure to backup first
(re)install
brew install mariadb
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 toBase64 = (file) => new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = (e) => resolve(e.target.result); | |
reader.onerror = (err) => reject(err); | |
}); | |
const compressBase64 = (src, quality = 0.5) => new Promise((resolve) => { | |
const img = new Image(); | |
img.src = src; |
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
(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); | |
}); |
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
// https://material.io/guidelines/style/color.html | |
module.exports = { | |
'red': { | |
'50': '#ffebee', | |
'100': '#ffcdd2', | |
'200': '#ef9a9a', | |
'300': '#e57373', | |
'400': '#ef5350', | |
'500': '#f44336', |
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 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); |
NewerOlder