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
// getComponent is a function that returns a promise for a component | |
// It will not be called until the first mount | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { |
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
class JsxControls extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
counter: 100 | |
} | |
} | |
render() { | |
return ( |
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
handleInputChange(name, value, args = {}) { | |
const { key, ...restArgs } = args; | |
let obj = {}; | |
if (typeof key !== 'undefined') { | |
if (Object.keys(restArgs).length === 0 && restArgs.constructor === Object) { | |
obj = { ...this.state[key], ...{ [name]: value } }; | |
} else { | |
obj = { ...this.state[key], ...{ [name]: value, ...restArgs } }; | |
} |
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
// Parsley plugin initialization with tweaks to style Parsley for Bootstrap 4 | |
$("#my-form").parsley({ | |
errorClass: 'is-invalid text-danger', | |
successClass: 'is-valid', // Comment this option if you don't want the field to become green when valid. Recommended in Google material design to prevent too many hints for user experience. Only report when a field is wrong. | |
errorsWrapper: '<span class="form-text text-danger"></span>', | |
errorTemplate: '<span></span>', | |
trigger: 'change' | |
}) /* If you want to validate fields right after page loading, just add this here : .validate()*/ ; | |
// Parsley full doc is avalailable here : https://github.com/guillaumepotier/Parsley.js/ |
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
{ | |
"window.zoomLevel": 0, | |
"editor.fontFamily": "Operator Mono Medium, Menlo, Monaco, 'Courier New', monospace", | |
"editor.fontSize": 14, | |
"editor.fontLigatures": true, | |
"editor.tabSize": 4, | |
"editor.mouseWheelZoom": true, | |
"editor.rulers": [120], | |
"editor.smoothScrolling": true, | |
"editor.tabCompletion": true, |
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
----- BEGIN LICENSE ----- | |
sgbteam | |
Single User License | |
EA7E-1153259 | |
8891CBB9 F1513E4F 1A3405C1 A865D53F | |
115F202E 7B91AB2D 0D2A40ED 352B269B | |
76E84F0B CD69BFC7 59F2DFEF E267328F | |
215652A3 E88F9D8F 4C38E3BA 5B2DAAE4 | |
969624E7 DC9CD4D5 717FB40C 1B9738CF | |
20B3C4F1 E917B5B3 87C38D9C ACCE7DD8 |
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
#Add the Ubuntu 12.04(precise) repositories | |
cat <<EOF >> /etc/apt/sources.list | |
deb http://archive.ubuntu.com/ubuntu precise main restricted universe | |
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe | |
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse | |
EOF | |
# Update the repos | |
apt-get update |
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
// Matching a ip address version 4 | |
const IPV4_1 = /^(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}$/; | |
const IPV4_2 = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/; | |
const IPV4WithPort = /^((?:2[0-5]{2}|1\d{2}|[1-9]\d|[1-9])\.(?:(?:2[0-5]{2}|1\d{2}|[1-9]\d|\d)\.){2}(?:2[0-5]{2}|1\d{2}|[1-9]\d|\d)):(\d|[1-9]\d|[1-9]\d{2,3}|[1-5]\d{4}|6[0-4]\d{3}|654\d{2}|655[0-2]\d|6553[0-5])$/; | |
// Matching a ip address version 6 | |
const IPV6_1 = /^([0-9a-f]|:){1,4}(:([0-9a-f]{0,4})*){1,7}$/i; | |
// Matching a Username | |
const username_1 = /^[a-z0-9_-]{5,16}$/; |
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
// Ref: | |
// 1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators | |
// 2. https://davidwalsh.name/es6-generators | |
// ------------------------------------ | |
function makeIterator(array) { | |
var nextIndex = 0; | |
return { |