View server.js
This file contains 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()); |
View flatten.js
This file contains 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) , []); |
View cloudSettings
This file contains 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"} |
View slices.go
This file contains 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" |
View slices_pointer_value_semantics.go
This file contains 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 { |
View maps_random_results.go
This file contains 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 | |
} |
View 3.4_maps_literall_construction_and_sort.go
This file contains 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 |
View async_fetch.js
This file contains 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() | |
} |
View generators_fetch_data.js
This file contains 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 ); |
View fetch_with_hooks.js
This file contains 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