Skip to content

Instantly share code, notes, and snippets.

@langdonx
langdonx / helper.js
Last active August 6, 2017 03:16
modify modules and html
const fs = require('fs');
// addComponentToModule('./src/library/library.module.js', 'Module', '', '', 'new-component', 'newComponent', 'NewComponent');
// addComponentToModule('./src/docs/docs.module.js', 'Demo', 'demos/', '-demo', 'new-component', 'newComponent', 'NewComponent');
// addComponentToDemoHtml('new-component', 'newComponent', 'NewComponent');
module.exports.addComponentToModule = function addComponentToModule(filename, variableSuffix, importPrefix, importSuffix, componentName, camelName, capitalName) {
// read the file
let content = fs.readFileSync(filename, 'utf8');
@langdonx
langdonx / giantbomb-create-ordered-from-unordered-list.js
Created January 24, 2017 02:39
Giant Bomb's web site doesn't let you convert your unordered list to an ordered one. That's annoying. This makes it less so.
// create instead of edit
$('form#user-list-form').get(0).action = location.href.replace(/lists(.*)/, 'lists/create/');
// add positions
$('ul#user_list_items li').each(function(index, element) {
$(element)
.find('input:first')
.after('<input type="number" name="user_list[items][' + index + '][position]" value="' + (index + 1) + '">');
});