Skip to content

Instantly share code, notes, and snippets.

View 0GiS0's full-sized avatar
📹
Now on YouTube!

Gisela Torres 0GiS0

📹
Now on YouTube!
View GitHub Profile
@0GiS0
0GiS0 / default-parameters-es6.js
Created January 27, 2019 21:03
default parameters with EMACScript 6
function add(a = 5, b = 10) {
return a + b;
}
console.log(add()); //15
var add = (a, b) => {
return a + b;
}
const delay = seconds => {
return new Promise(
resolve => setTimeout(resolve, seconds * 1000)
)
};
const counter = async() => {
await delay(1);
console.log('one second');
await delay(1);
@0GiS0
0GiS0 / fetch-and-async.js
Created January 27, 2019 21:31
Fetch and async working together
const repos = async(loginName) => {
try {
var response = await fetch(`https://api.github.com/users/${loginName}/repos`);
var json = await response.json();
var followerList = json.map(repo => repo.name);
console.log(followerList);
} catch (error) {
console.log(`Error: ${error}`);
}
@0GiS0
0GiS0 / regular-function.js
Last active January 27, 2019 21:33
Regular function
function add(a, b) {
return a + b;
}
//or
var add = function(a,b){
return a + b;
}
function* hello() {
yield 'Hello Gisela';
yield 'Hello Alicia';
yield 'Hello Bea';
}
var helloInstance = hello();
console.log(helloInstance.next());
console.log(helloInstance.next());
console.log(helloInstance.next());
<?php
// src/Controller/HelloAzureController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class HelloAzureController
{
/**
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="BlockAccessToPublic" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{URL}" pattern="/public/*" />
</conditions>
const ChuckNorrisFact = () => {
return new Promise((resolves, rejects) => {
const api = 'https://api.chucknorris.io/jokes/random';
const request = new XMLHttpRequest();
request.open('GET', api);
request.onload = () => {
if (request.status === 200) {
resolves(JSON.parse(request.response));
} else {
rejects(new Error(request.response));
fetch('https://api.chucknorris.io/jokes/random')
.then(res => res.json())
.then(console.log);