docker run ubuntu # download the image and run it
docker pull ubuntu # download the image only
# ----------------------------------------------------
docker ps # list all running containers only
docker ps -a # list all containers
# ----------------------------------------------------
docker stop <container ID | name> # stops docker container
docker kill <container ID | name>
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
I get this error installing docker in debian WSL 2 | |
The docker installer uses iptables for nat. Unfortunately Debian uses nftables. You can convert the entries over to nftables or just setup Debian to use the legacy iptables. | |
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy | |
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy | |
dockerd, should start fine after switching to iptables-legacy. | |
sudo service docker start |
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
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
const printMessagetoUser = ({name, age}) => { | |
if (!isNaN(age)) { | |
const yearOf100 = new Date().getFullYear() + (100 - age); |
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
arr = [12, 10, 8, 12, 7, 6, 4, 10, 12]; | |
const unique = [...new Set(arr)] | |
let obj = {}; | |
for(let i=0;i<arr.length;i++) { | |
obj[arr[i]] = (obj[arr[i]] || 0 )+1 | |
} | |
const max = Math.max(...Object.values(obj)) | |
const [highFreq] = unique.filter(i => obj[i] === max) |
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
// Write an algorithm to check if the sum of any two elements in an | |
// array/list matches a given target, and return their indexes in | |
// an array. | |
// | |
// Parameters: [0, 6, 8, 4], 10 | |
// Result: [ 1, 3] | |
// Parameters: [20, 18, 5, 4, 10, 22], 42 | |
// Result: [ 0, 5] | |
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' |
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 ); |
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() | |
} |
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 |
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 | |
} |
NewerOlder