Skip to content

Instantly share code, notes, and snippets.

💻
Back to it...

Steven de Salas sdesalas

💻
Back to it...
Block or report user

Report or block sdesalas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sdesalas
sdesalas / .index.html
Last active Jul 11, 2019
Promises Mini-Dojo
View .index.html
<html>
<head>
<title>Frogmore High School - Fetch array, combine and reorder</title>
<script>
// Step 1: Copy this html file locally as index.html
// Step 2: Edit the <script> section to fetch data from these 2 urls
// - Students: https://api.myjson.com/bins/vm1oz
// - Marks: https://api.myjson.com/bins/fjccz
// Step 3: Combine it into one single array by student id
View students.html
<html>
<head>
var students = [
{"id":"905126","firstname":"Bob","lastname":"Smith","maths":9.9,"english":3.3},
{"id":"739559","firstname":"Harry","lastname":"Talbot","maths":5.6,"english":6.1},
{"id":"878999","firstname":"Pradosh","lastname":"Brown","maths":4.7,"english":8.1},
{"id":"421848","firstname":"Anna","lastname":"Ashley","maths":4.7,"english":5.5},
{"id":"073342","firstname":"Melanie","lastname":"Brown","maths":7.8,"english":4.2},
{"id":"503297","firstname":"Andrew","lastname":"Kimber","maths":8.3,"english":8.9},
{"id":"318977","firstname":"Peter","lastname":"Johnson","maths":9.3,"english":2.3},
View index.js
const moment = require('moment')
// TRABAJAR AQUI
module.exports = function timeago(date){
return moment(date).fromNow()
}
View gcd.js
module.exports = function gcd(a, b) {
let arra = [];
let arrb = []
for (let i=0; i<= a; i++){
if (a%i ===0) {
arra.push(i);
}
}
for (let j=0; j<= b; j++){
@sdesalas
sdesalas / http-request-response
Last active May 23, 2019
HTTP RAW REQUEST/RESPONSE
View http-request-response
---- HTTP REQUEST ----
GET /index.html HTTP/1.1
Host: sdesalas.com
User-Agent: Mozilla/5.0 (Windows NT 10.0)
--- HTTP RESPONSE ----
@sdesalas
sdesalas / Animal.js
Created Apr 22, 2019
OO JavaScript with super() in constructor
View Animal.js
module.exports = class Animal {
constructor(energy) {
this.energy = energy || 0;
}
move() {
if (this.energy > 0) {
console.log('moving...')
this.energy = this.energy - 10;
} else {
console.log('cannot move.. (no energy)')
@sdesalas
sdesalas / App.js
Created Apr 22, 2019
Simpsons avatars
View App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import User from './User';
class App extends Component {
render() {
return (
<div className="App">
@sdesalas
sdesalas / gandalf.css
Created Apr 4, 2019 — forked from evadav/gandalf.css
02 - Give style with CSS
View gandalf.css
body {
font-family: Arial, Helvetica, sans-serif;
}
.gandalf{
position:relative;
max-width: 420px;
height: 500px;
padding: 40px;
@sdesalas
sdesalas / quest.js
Last active Apr 4, 2019 — forked from evadav/quest.js
My first application Node.JS
View quest.js
process.stdin.resume()
process.stdin.setEncoding('utf8')
console.log('How old are you ? ')
process.stdin.on('data', (age) => {
console.log('you are' + age.trim() +'years old')
if (age > 99){
console.log ('Too old')
} else if (age < 1) {
console.log ('You have not been born yet')
View gist:1d5ebf6773e6550c2525030c3dfefe27
process.stdin.resume()
process.stdin.setEncoding('utf8')
console.log('How old are you ? ')
process.stdin.on('data', (age) => {
console.log('You are ' + age.trim() + ' years old ')
if (age > 99){
console.log('Too old!!')
} else if (age < 0) {
You can’t perform that action at this time.