This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.scssc, **/node_modules/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Find and replace in nodejs: | |
var fs = require('fs'); | |
fs.readdirSync('.').forEach(function(path) { fs.rename(path, path.split('}').join('')); }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var path = require('path') | |
var argCount = process.argv.length | |
var lastArg = process.argv[argCount - 1] | |
// From | |
// http://stackoverflow.com/questions/11194287/convert-a-directory-structure-in-the-filesystem-to-json-with-node-js | |
function dirTree(filename) { | |
var stats = fs.lstatSync(filename), | |
info = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exec = require('child_process').exec | |
exec("npm --save uninstall react react-dom", (err, o) => { | |
console.log(err, o); | |
}) | |
exec("npm --save install preact preact-compat", (err, o) => { | |
console.log(err, o); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use preact | |
# Switch a react project to using preact if its isn't using it already. | |
# | |
# EX: grep -rl "preact-compat" ./node_modules/react-scripts/config/ | |
# EX: find ./node_modules/react-scripts/config/*.config.* -type f -exec sed -i "s/alias: {/alias: {\n\t\t\t\'react\': \'preact-compat\',\n\t\t\t\'react-dom\': \'preact-compat\',/gi" {} \; | |
searchString=${1:-preact-compat} | |
filePattern=${2:-./node_modules/react-scripts/config/} | |
replaceString="alias: {" |