Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Hacking...

antsmartian antsmartian

💭
Hacking...
  • India
View GitHub Profile
View docker-compose.yml
version: "3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
networks:
- elastic-jaeger
ports:
- "127.0.0.1:9200:9200"
- "127.0.0.1:9300:9300"
View answers.js
/*
1. In JavaScript, define a function `makeCounter` which takes one optional argument defining the intial value, `start`, with a default value of 0. The function should return an object containing keys that define 3 methods: - `value` returns the current value of the counter - `increment` increments the value of the counter by 1 and returns the new value - `decrement` decrements the value of the counter by 1 and returns the new value The returned object should not allow direct modification or retrieval of the value.
Example usage:
var counter = makeCounter();
console.log(counter.value()); // 0
var counter2 = makeCounter(4);
console.log(counter2.value()); // 4
console.log(counter2.increment()); // 5
console.log(counter2.value()); // 5
counter2.decrement();
View test.js
// import {plainToClass} from "class-transformer";
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-proposal-decorators"]
});
/*
{
"id": 1,
"firstName": "Johny",
"lastName": "Cage",
View eventloop.go
package main
import (
"net"
"os"
"strings"
"fmt"
"syscall"
"time"
"strconv"
View crawler.go
package main
import (
"fmt"
"net/http"
"io/ioutil"
"golang.org/x/net/html"
"bytes"
"github.com/PuerkitoBio/goquery"
"net/url"
View context-state.js
import React, { Component, createContext } from 'react'
function initStore(store) {
const Context = createContext();
class Provider extends React.Component {
constructor() {
super();
this.state = store.initialState;
}
View kqueue.go
package main
import (
"time"
"net"
"os"
"strings"
"fmt"
"syscall"
)
View simple_concurrent_map.go
package main
import (
"sync"
)
type DB struct {
mu sync.RWMutex
data map[string]string
}