Skip to content

Instantly share code, notes, and snippets.

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

Eisson ealipio

:bowtie:
:)
View GitHub Profile
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
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);
@ealipio
ealipio / highFreq.js
Created September 25, 2019 04:18
get the most repeated number in an array
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)
// 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]

docker

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>
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'
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 );
//========================= 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()
}
package main
import (
"fmt"
"sort"
)
type user struct {
name string
surname string
package main
import (
"fmt"
)
type user struct {
name string
surname string
}