Skip to content

Instantly share code, notes, and snippets.

@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.

@Coding-Enthusiast
Coding-Enthusiast / BitwiseOperations.md
Last active April 25, 2024 12:53
Bitwise operations cheat sheet

AND (&)

100  
101  
---  
100  

OR (|)

100  
101  
---  

101

@sorenlouv
sorenlouv / useComponentId.js
Last active June 16, 2023 15:26
React hook for getting a unique identifier for a component
import { useRef } from 'react';
let uniqueId = 0;
const getUniqueId = () => uniqueId++;
export function useComponentId() {
const idRef = useRef(getUniqueId());
return idRef.current;
}
@gmolveau
gmolveau / firefox_dark_background.md
Last active April 30, 2024 21:38
Firefox dark background / theme for new tab and loading screen

Firefox Dark Background

  • How to change the background on Firefox to a dark one on new tab / loading screen ?

Procedure

  • Type about:config in the URL bar
  • Search toolkit.legacyUserProfileCustomizations.stylesheets and double-click the field to set it to true
  • Type about:support in the URL bar
  • Look for Profile folder field and click on the open button next to it.
@plfort
plfort / webpack.config.js
Created January 5, 2018 08:22
Symfony Encore trick for completion in PHPStorm (Can't analyse webpack.config.js)
...
let config = Encore.getWebpackConfig();
if(!Encore.isProduction()) {
fs.writeFile("fakewebpack.config.js", "module.exports = "+JSON.stringify(config), function(err) {
if(err) {
return console.log(err);
}
console.log("fakewebpack.config.js written");
});
}
@Jon007
Jon007 / functions.php
Last active December 4, 2023 08:17
Add default Product Attributes to all WooCommerce products
/*
* Example adds certain named Product Attribute fields to the product Edit screen ready for completion.
* (Pre-requisite )
* This saves the Shop Admin having to add them manually.
*
* Why might you want to do this instead of adding Custom fields? There's plenty of nice documentation on adding custom fields
* for example: http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
*
* Well a Product Attributes are a built in WooCommerce feature, using Terms which are a built in Wordpress feature.
* - no add-ons required
@hereswhatidid
hereswhatidid / custom-package-name.php
Created October 18, 2016 13:48
Create custom shipping packages and manually set their display names in WooCommerce
<?php
add_filter( 'woocommerce_shipping_package_name', 'rmg_package_names', 10, 3 );
function rmg_package_names( $package_name, $i, $package ) {
if ( ! empty( $package['name'] ) ) {
$package_name = $package['name'];
}
@vjandrea
vjandrea / phpversion.sh
Last active June 19, 2023 20:44
Change php cli version in plesk
#!/bin/sh
printf "Switching php to version 5.6 with symlinks.\n"
printf "Press any key to continue...\n"
read CONTINUE
printf "Creating backups..."
# Backup original binaries
@samsch
samsch / README.md
Created January 21, 2016 16:38
How to set PDO MySQL SSL Constants in Symfony

I created this because I was frusterated by having to change the integer values when the environments changed for my projects. A simple update of PHP 5.6 (I think it was PHP 5.6.16 to 5.6.17) changed the integer values, which are usually what is suggested to be used in parameters.yml or config.yml.

By using the constants, you don't have to worry about stupid stuff like that. (Since that's what they were designed for.)

@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent