Skip to content

Instantly share code, notes, and snippets.

View ObsidianCat's full-sized avatar

Lula Leus ObsidianCat

View GitHub Profile
package main
import (
"errors"
"fmt"
customError "github.com/pkg/errors"
)
type stackTracer interface {
function buildItenary(options, startCity) {
const citiesMap = new Map()
options.forEach(([origin, dest]) => {
if (citiesMap.has(origin)) {
const stored = citiesMap.get(origin)
stored.push(dest)
citiesMap.set(origin, stored)
} else {
citiesMap.set(origin, [dest])
}
package main
import (
"fmt"
)
type steps struct {
dayOfTheWeek string
greeting string
tasks []string
@ObsidianCat
ObsidianCat / go-slices-as-param.go
Created June 28, 2023 15:38
Unexpected behaviour of slices, when passed as argument in a function and mutated
package main
import (
"fmt"
)
func sliceExtender(sl []int) {
sl = append(sl, 33)
sl[0] = 5
fmt.Printf("len %d, cap %d, sliceOne[0]=%d, added last elemnt =%d \n", len(sl), cap(sl), sl[0], sl[len(sl)-1])
@ObsidianCat
ObsidianCat / go-pointers.go
Last active July 15, 2023 10:22
Different meaning of * Sign in Go, based on situation
package main
import "fmt"
type person struct {
name string
}
// the * denotes(indicate) a pointer to a value of the type that follows the *
// *person the func return pointer
package doughnuts_box
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPackDoughnutsBoxSubtests(t *testing.T) {
package doughnuts_box
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPackDoughnutsBoxTableTests(t *testing.T) {
package doughnuts_box
import (
"fmt"
)
type doughnutsBox struct {
capacity int
doughnuts []string
}
@ObsidianCat
ObsidianCat / tries.js
Created June 7, 2021 20:28
Basic auto-completion functionality with trie data structure
// Code originnaly belong to Front End Masters course
// 4 Semesters of CS in 5 Hours part II
//https://btholt.github.io/four-semesters-of-cs-part-two/
const CITY_NAMES = [
"New York",
"Los Angeles",
"Chicago",
"Houston",
"Philadelphia",
@ObsidianCat
ObsidianCat / pathfinding.js
Last active May 30, 2021 10:07
Pathfinding - useful for exercises like "floating islands" or finding path in a maze.
// Code source https://btholt.github.io/four-semesters-of-cs-part-two/pathfinding
const NO_ONE = 0;
const BY_A = 1;
const BY_B = 2;
const processSearchIteration = ()=>{
const aNeighbors = aQueue.reduce((acc, neighbor)=>{
return acc.concat(getNeighbors(visited, neighbor.x, neighbor.y))
}, [])