Skip to content

Instantly share code, notes, and snippets.

View phuctm97's full-sized avatar
πŸ‘¨β€πŸ’»
Coding

Minh-Phuc Tran phuctm97

πŸ‘¨β€πŸ’»
Coding
View GitHub Profile
@bbudd
bbudd / assets.md
Created June 13, 2019 12:30
Loading static assets using electron-forge v6 and the webpack plugin

I spent a few hours chasing down just how to get my static assets (css, fonts, images) to load in an Electron app built using electron-forge v6 (https://www.electronforge.io/) and its webpack plugin (https://www.electronforge.io/config/plugins/webpack) while in development mode. There really isn't any documentation available online, either in the electron-forge documentation or in places like blogs or gists or stackoverflow. So I thought I'd put it down here.

Step 1

Load CopyWebpackPlugin npm i -D copy-webpack-plugin


Step 2

Use the plugin to move your directories into place.

@phuctm97
phuctm97 / install-macos.sh
Last active April 17, 2020 08:55
πŸ’» Install macOS Catalina
#!/bin/bash
# Enable sudo Touch ID authentication.
sudo python <<HEREDOC
import re
pam_cfg = '/etc/pam.d/sudo'
auth_re = re.compile(r'^auth\s+sufficient\s+')
tid_re = re.compile(r'^auth\s+sufficient\s+pam_tid.so')
@phuctm97
phuctm97 / get-webpack-alias-from-tsconfig.js
Last active November 2, 2022 06:32
πŸ“Ž Get Webpack alias from tsconfig.json, aka. convert tsconfig.json paths to Webpack alias
const path = require('path');
/**
* Helper function infers Webpack aliases from tsconfig.json compilerOptions.baseUrl and
* compilerOptions.paths.
*
* @param {string} tsconfigPath - Path to tsconfig.json (can be either relative or absolute path).
* @return {object} An object representing analogous Webpack alias.
*/
module.exports = (tsconfigPath = './tsconfig.json') => {
@uditalias
uditalias / custom.css
Created September 21, 2020 20:32
Adding line numbers to Docusaurus 2 CodeBlocks using only CSS
/* Edit the `src/css/custom.css` file and add the following styles */
/*
* Reset the line-number counter for each .prism-code scope
*/
.prism-code {
counter-reset: line-number;
}
/*