Skip to content

Instantly share code, notes, and snippets.

@developit
developit / *constant-locals-loader.md
Last active February 4, 2022 17:15
Inline Webpack CSS Modules classNames, reducing bundle size. https://npm.im/constant-locals-loader

constant-locals-loader for Webpack

This loader optimizes the output of mini-css-extract-plugin and/or css-loader, entirely removing the potentially large CSS classname mappings normally inlined into your bundle when using CSS Modules.

Run npm install constant-locals-loader, then make these changes in your Webpack config:

module.exports = {
 module: {
@jonjack
jonjack / add-update-refresh-github-access-token-on-mac.md
Last active April 24, 2024 10:05
Adding & Updating GitHub Access Token on Mac

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-

Why You Should Not Use The ODbL for Your New Project

The ODbL is a license written for OpenStreetMap. Like a lot of other open licenses, it's not tried in court.

It's a 'sharealike' license: the main important provision is that combining ODbL data with other data requires the combined product to be licensed under the ODbL. In this way it's quite a bit more like the GPL and other old-fashioned open source licenses than MIT or BSD, and much less a license like Public Domain.

Why shouldn't you use ODbL for your project?

The sharealike provision is overly broad and has destructive consequences for potential large users: using derived works from an ODbL database, like geoocoding, routes, images, and so on, could make the entire new work under the ODbL. So, for instance, if you had a restaurant rating site, and you integrate geocoded locations into it from OSM, your entire database, including user data and reviews, may have to be 'opened'.

@CatTail
CatTail / htmlentity.js
Created November 30, 2012 08:27
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {