Skip to content

Instantly share code, notes, and snippets.

View jmlavoier's full-sized avatar
🏠
Working from home

João Lavoier jmlavoier

🏠
Working from home
View GitHub Profile
element.scrollIntoView({ behavior: 'smooth' });
fetch('https://swapi.co/api/people/', {
mode: 'cors',
credentials: 'include'
}).then((res) => res.json())
.then((result) => { console.log(result) })
.catch((err) => { console.log(err) });
fetch('https://swapi.co/api/people/', {
credentials: 'same-origin'
}).then((res) => res.json())
.then((result) => { console.log(result) })
.catch((err) => { console.log(err) });
fetch('https://swapi.co/api/people/').then((res) => res.json())
.then((result) => { console.log(result) })
.catch((err) => { console.log(err) });
$.ajax({
url: 'https://swapi.co/api/people/',
success: data => { console.log(data); }, // [object]
error: err => { console.log(err) }
});
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://swapi.co/api/people/');
xhr.responseType = 'json';
xhr.onload = function() { console.log(xhr.response); }; xhr.onerror = function() { console.log("Erro"); };
xhr.send();
let binarySearch = function (array, valueSearch) {
let start = 0;
let end = array.length - 1;
return function search(start, end) {
let mid = Math.round((start + end) / 2);
let length = end - start;
if (length < 0) return -1;
@jmlavoier
jmlavoier / Redux lesson 18.js
Created July 12, 2017 00:03
Redux lesson 18
//CDNs
//https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.min.js
//https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react.js
//https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react-dom.min.js
const todo = (state = {}, action) => {
switch(action.type) {
case 'ADD_TODO':
return {
id: action.id,
@jmlavoier
jmlavoier / Redux lesson 17.js
Created July 12, 2017 00:02
Redux lesson 17
//CDNs
//https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.min.js
//https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react.js
//https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react-dom.min.js
const todo = (state = {}, action) => {
switch(action.type) {
case 'ADD_TODO':
return {
id: action.id,
@jmlavoier
jmlavoier / Redux lesson 16.js
Created July 12, 2017 00:01
Redux lesson 16
//CDNs
//https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.min.js
//https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react.js
//https://cdnjs.cloudflare.com/ajax/libs/react/0.14.8/react-dom.min.js
const todo = (state = {}, action) => {
switch(action.type) {
case 'ADD_TODO':
return {
id: action.id,