Skip to content

Instantly share code, notes, and snippets.

View App.js
import React, { Component } from 'react'
import { connect } from 'react-redux'
import WorldPop from './components/WorldPop/WorldPop'
class App extends Component {
render() {
let $chart
switch (this.props.chart) {
case 'WorldPop':
View events.js
Node.prototype.on = HTMLElement.prototype.addEventListener
NodeList.prototype.on = function(event, cb) {
Array.prototype.forEach.call(this, el => el.addEventListener(event, cb))
}
// usage: $('.element').on('click', ...)
// usage: $('.list-of-elements').on('click', ...)
View visibility.js
HTMLElement.prototype.show = function() {
this.style.display = ''
}
HTMLElement.prototype.hide = function() {
this.style.display = 'none'
}
HTMLElement.prototype.toggle = function(bool) {
this.style.display = bool ? '' : 'none'
}
HTMLElement.prototype.visible = function() {
View iterator.js
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]
// usage: $$('.list-of-elements').forEach(...)
// usage: $$('.list-of-elements').map(...)
View query-selector.js
window.$ = document.querySelector.bind(document)
window.$$ = document.querySelectorAll.bind(document)
HTMLElement.prototype.$ = HTMLElement.prototype.querySelector
HTMLElement.prototype.$$ = HTMLElement.prototype.querySelectorAll
// usage: $('.select-on-element')
// usage: $$('.select-a-list-of-element')
View Makefile
SERVER_URL?='http://website.dev'
echo_server:
echo $(SERVER_URL)
View Makefile
livereload:
livereload --exts "less js html"
View Gruntfile.js
grunt.initConfig({
watch: {
all: {
files: ['*.less', '*.js', '*.html'],
options: {
livereload: true
}
}
}
});
View Makefile
watch:
watchy -w css/**/*.less -- make css
View Gruntfile.js
grunt.initConfig({
watch: {
less: {
files: ['css/**/*.less'],
tasks: ['css']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');