Skip to content

Instantly share code, notes, and snippets.

View schalkneethling's full-sized avatar
🇺🇦
The world wants peace, not war ✌️

Schalk Neethling schalkneethling

🇺🇦
The world wants peace, not war ✌️
View GitHub Profile
@schalkneethling
schalkneethling / build-it-like-travis.md
Last active October 17, 2019 13:14
Useful things for Kuma development
Add DEBUG=False to your .env file

docker-compose down
make clean
docker-compose pull
docker-compose up -d
docker-compose exec -T web make localecompile webpack compilejsi18n compile-react-i18n
docker-compose exec -T web ./manage.py collectstatic
@schalkneethling
schalkneethling / config.js
Created May 15, 2019 16:27
Allow posts from beta domain
function setupConfig() {
// assume production as origin
var origin = "https://developer.mozilla.org";
// get the actual parent origin
var parentOrigin = window.parent.location.origin;
// is it the beta domain?
if (parentOrigin.search(/beta.developer.(mozilla|allizom)/) > -1) {
// then use it as the origin
origin = parentOrigin;
} else if (window.URL) {
@schalkneethling
schalkneethling / countries.txt
Last active May 1, 2019 19:59
All countries for select fields as text and select form element
United States
United Kingdom
Afghanistan
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antigua and Barbuda
@schalkneethling
schalkneethling / loadPresets.js
Last active January 27, 2019 15:29
Small tweak to Sean Larkins' LoadPresets script for Webpack
// Original: https://github.com/TheLarkInn/webpack-workshop-2018/blob/feature/build-utils/build-utils/loadPresets.js
/**
* Usage:
* Use via NPM script
* Passing a single preset:
* "prod:compress": "npm run prod -- --env.presets compress",
* "prod:analyze": "npm run prod -- --env.presets analyze",
* Passing a multiple preset as a , separate list:
* "prod:compress-analyze": "npm run prod -- --env.presets compress,analyze",
*/
@schalkneethling
schalkneethling / webpack.production.js
Created January 23, 2019 17:55
Hashed file output with Webpack
module.exports = () => ({
output: {
filename: "[chunkhash].js"
}
});
@schalkneethling
schalkneethling / iife.js
Created December 6, 2018 14:57
Sample IIFE
(function() {
function add(num1, num2) {
return num1 + num2;
}
})();
@schalkneethling
schalkneethling / compress-images.js
Created October 21, 2018 11:15
Example of batch compressing images using ImageMin with Node.js
#!/usr/bin/env node
const imagemin = require('imagemin');
const imageminJpegTran = require('imagemin-jpegtran');
const imageminPngQuant = require('imagemin-pngquant');
async function optim() {
const files = await imagemin(
['./live-examples/media/**/*.{jpg,png}'],
'./build/images',
@schalkneethling
schalkneethling / no-pointer-events.css
Created October 11, 2018 17:49
Snippet used in Preventing SVG from becoming the event.target
.local-anchor .icon {
color: #3d7e9a;
width: 16px;
height: 16px;
/* ensure svg will never be the target of mouse event */
pointer-events: none;
}
@schalkneethling
schalkneethling / event-handler.js
Created October 11, 2018 17:33
Snippet used in Preventing SVG from becoming the event.target
const mainDocument = document.getElementById('document-main');
mainDocument.addEventListener('click', function(event) {
var target = event.target;
// only handle clicks on anchor elements
if (target.tagName === 'A') {
// do stuff
}
});
@schalkneethling
schalkneethling / link.html
Created October 11, 2018 17:29
Snippet used in Preventing SVG from becoming the event.target