Skip to content

Instantly share code, notes, and snippets.

Avatar
:bowtie:
:)

Eisson Alipio ealipio

:bowtie:
:)
View GitHub Profile
View gist:564ee9cb2483f29c353331bf57196586
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
View excersice1.js
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 Sep 25, 2019
get the most repeated number in an array
View highFreq.js
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)
View sumContainsTarget.js
// 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]
View docker-k8_cheatsheet.md

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>
View fetch_with_hooks.js
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'
View generators_fetch_data.js
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 async_fetch.js
//========================= 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 3.4_maps_literall_construction_and_sort.go
package main
import (
"fmt"
"sort"
)
type user struct {
name string
surname string
View maps_random_results.go
package main
import (
"fmt"
)
type user struct {
name string
surname string
}