Skip to content

Instantly share code, notes, and snippets.

@jbardon
jbardon / .bash_profile
Last active November 3, 2015 13:14
Update shell variable and maven configuration with proxy settings
# Copy that in ~/.bash_profile
# Call "proxy on|off|status" in your shell
proxy(){
case $1 in
on)
export http_proxy=http://cache.etu.univ-nantes.fr:3128
export https_proxy=https://cache.etu.univ-nantes.fr:3128
sed -ie 's/false/true/g' ~/.m2/settings.xml
git config --global http.proxy http://NUM_ETUDIANT:MDP_ETUDIANT@cache.etu.univ-nantes.fr:3128
@jbardon
jbardon / jquery-promises.js
Created June 28, 2017 09:31
Jquery promises examples
// Single async all
$.when(myFunction)
.then(followingFunction);
// Multiple async call
var promises = [ myFunction(), myFunction() ]
$.when(myFunction)
.apply($, promises)
.then(followingFunction);
<!doctype html>
<html>
<head>
<title>React</title>
</head>
<body>
<script src="https://unpkg.com/react@16.2.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.2.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.24.2/babel.min.js" charset="utf-8"></script>
<script src="https://unpkg.com/fetch@1.1.0/lib/fetch.js" charset="utf-8"></script>
#language: fr
@BadPractice
Fonctionnalité: Parcours de recherche d'une annonce voiture
Scénario: Recherche d'une annonce de voiture récente
Etant donné je ne suis pas identifié
Et je suis sur la page "accueil"
# Mieux que: je clique sur le champ ayant l'id "Pdl"
Quand je clique sur "Pays de la Loire"
const DatePicker = (props) => <input type="date" onChange={props.handleDateSelected}/>
class DatePickerController extends React.Component {
constructor (props) {
super(props);
this.state = { currentDate: null };
this.handleDateSelected = this.handleDateSelected.bind(this);
}
handleDateSelected ({target}) {
const Watch = (props) =>
<div>{props.hours}:{props.minutes}</div>;
ReactDOM.render(<Watch hours="Hello" minutes="World"/>, document.getElementById('app'));
// Equivalent to JSX: <Watch hours="9" minutes="15"/>
React.createElement(Watch, {'hours': '9', 'minutes': '15'});
// Using JS with React.createElement
React.createElement('form', null,
React.createElement('div', {'className': 'form-group'},
React.createElement('label', {'htmlFor': 'email'}, 'Email address'),
React.createElement('input', {'type': 'email', 'id': 'email', 'className': 'form-control'}),
),
React.createElement('button', {'type': 'submit', 'className': 'btn btn-primary'}, 'Submit')
)
// Using JSX
{
"type":"div",
"props":{ "className":"form-group" },
"children":[
{
"type":"label",
"props":{ "htmlFor":"email" },
"children":[ "Email address"]
},
{
// React.createElement naive implementation (using ES6 features)
function createElement(type, props, ...children) {
return { type, props, children };
}