Skip to content

Instantly share code, notes, and snippets.

View ealipio's full-sized avatar
:bowtie:
:)

Eisson ealipio

:bowtie:
:)
View GitHub Profile
@ealipio
ealipio / server.js
Last active January 2, 2018 16:55
node http server
var express = require('express'),
app = express(),
cors = require('cors'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
path = require('path');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
@ealipio
ealipio / flatten.js
Created January 12, 2018 20:31
flatten an array
flattens = (arr) => arr.reduce( (flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten) , []);
@ealipio
ealipio / cloudSettings
Last active October 15, 2018 19:14
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-10-15T15:41:29.085Z","extensionVersion":"v3.1.2"}
package main
import (
"fmt"
)
func main() {
fruits := make([]string, 5, 8)
fruits[0] = "plum"
fruits[1] = "apple"
package main
import (
"fmt"
)
func main() {
// using the value semantic for of the range
friends := []string{"Annie", "Betty", "Charley", "Doug", "Edward"}
for _, v := range friends {
package main
import (
"fmt"
)
type user struct {
name string
surname string
}
package main
import (
"fmt"
"sort"
)
type user struct {
name string
surname string
//========================= utils ========================================
const url = n => `https://api.mathjs.org/v4/?expr=sqrt(${n})`;
const sumalos = arr => arr.reduce( (acc, v) => acc + v, 0);
const res = r => r.json();
//========================================================================
// get sqrt using api.mathjs
async function getSqrt(number) {
const request = await fetch(url(number))
return request.json()
}
function request(url) {
makeAjaxCall( url, (response) => it.next( response))
}
function main() {
const result = yield request('http://some.com/1')
const data = JSON.parse( result );
const result2 = yield request('http://some.com/2' + data.id);
const response = JSON.parse( result2 );
import React, { useState, useEffect } from 'react';
import axios from 'axios';
function App() {
const [data, setData] = useState({ hits: [] });
useEffect(() => {
const fetchData = async () => {
const result = await axios(
'https://hn.algolia.com/api/v1/search?query=redux'