This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| flattens = (arr) => arr.reduce( (flat, toFlatten) => flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten) , []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"lastUpload":"2018-10-15T15:41:29.085Z","extensionVersion":"v3.1.2"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| fruits := make([]string, 5, 8) | |
| fruits[0] = "plum" | |
| fruits[1] = "apple" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| type user struct { | |
| name string | |
| surname string | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "sort" | |
| ) | |
| type user struct { | |
| name string | |
| surname string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //========================= 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() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
OlderNewer