Skip to content

Instantly share code, notes, and snippets.

View jest-dotenv-config.json
{
"scripts": {
"test": "jest --setupFiles dotenv/config"
}
}
@wangsijie
wangsijie / electron-load-str-as-html.js
Created Oct 26, 2021
Electron直接加载字符串形式的HTML
View electron-load-str-as-html.js
window.loadURL('data:text/html;charset=UTF8,' + encodeURIComponent(htmlContent));
View see-things-differently.md

You don't travel to see different things, you travel to see things differently.

View get-git-file-create-time.sh
git log --diff-filter=A --follow --format=%aD -1 -- FILENAME
View set-nextcloud-chunk-size.sh
sudo -u www-data php occ config:app:set files max_chunk_size --value 1000000
View read-dot-env.sh
export $(grep -v '^#' .env | xargs)
View axios-upload-file-using-form-data.js
const FormData = require('form-data');
const axios = require('axios');
const file = (await axios.get('https://test.com/test.jpg', { responseType: 'stream' })).data;
const formData = new FormData();
formData.append('file', file);
const res = await axios.post(
'https://test.com/upload',
formData,
{
View vercel-pdf-js.md

在Vercel里直接运行pdf.js包

const pdfjsLib = require("pdfjs-dist/es5/build/pdf.js");

会报下面的错:

Unhandled rejection: Error: Setting up fake worker failed: "Cannot find module './pdf.worker.js'
View express-return-buffer.js
import stream from 'stream';
app.get('/', function (req, res) {
const buffer = Buffer.from('p8AuXbAKFihL9N1H4aYi7w==', 'base64');
const bufferStream = new stream.PassThrough();
bufferStream.end(buffer);
bufferStream.pipe(res);
});