Skip to content

Instantly share code, notes, and snippets.

@toravir
toravir / bktree.go
Created April 3, 2018 22:41
BK-Tree Example for spell Check
package main
import "fmt"
/*
http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees
*/
type bkNode struct {
Word string
@toravir
toravir / stack.go
Created April 3, 2018 22:45
Stack of arbitrary data
package stack
//Stack Object to store the items in the order of pushed..
type Stack struct {
elems []interface{}
top int
}
//NewStack will return a Stack object - on which you can perform
//Push, Pop, Peek, Size operations
@toravir
toravir / heap.go
Created April 3, 2018 22:47
extensible Heap in Go
package heap
// HeapData has to be implemented by any data
// that will be inserted into the Heap Data structure.
// You can create MinHeap or MaxHeap.
type HeapData interface {
IsLessThan(h HeapData) bool
}
//Heap holds the entire heap object
@toravir
toravir / mapp.c
Created July 16, 2018 20:07
one way to keep enum tied to the string..
#include <stdio.h>
#define ERRNO_ENUM_ARG(enum_arg, errstr_arg) enum_arg
#define ERRNO_ERRSTR_ARG(enum_arg, errstr_arg) errstr_arg
#define ERRNO_ENUM_LIST_ALL(mac) \
mac(E_NOERROR, "No Error"), \
mac(E_INVALID_FILE, "Invalid File Error"), \
mac(E_NETWORK_DISC, "Network Disconnected Error"), \
mac(E_LAST_ERROR, "Unknown Error...") // This *HAS* to be the last in the list..
:9200/_cluster/health - get the cluster Health
:9200/_cat/indices - get the list of indices
:9200/<index>/_settings - get the settings for an index
:9200/_cat/nodes - get a high level health from each of the nodes (kind of like unix top)
:9200/_mapping - get a list of all mappings from all indices
:9200/<index>/_mapping - get the list of mapping for a given index - (index can be a wild card)
/volume # stacker --debug build -f stacker.yaml
building image first...
importing files...
Getting image source signatures
Copying blob sha256:aeb7866da422acc7e93dcf7323f38d7646f6269af33bcdb6647f2094fc4b3bf7
71.24 MiB / 71.24 MiB [====================================================] 5s
Copying config sha256:1e8ad5e15a62dea6c1a650a7ff14da420854aaac4f3b2b5e5da9f70fc6c22ec6
1.05 KiB / 1.05 KiB [======================================================] 0s
Writing manifest to image destination
Storing signatures
@toravir
toravir / lxc.log
Last active November 26, 2018 18:19
stacker build error from within the container..
root@ee9f23086720:/first# more ./.stacker/lxc.log
lxc .working 20181121020640.903 TRACE commands - commands.c:lxc_cmd_init:1249 - Creating abstract unix socket "/first/roots/.working/command"
lxc .working 20181121020640.903 TRACE start - start.c:lxc_init_handler:729 - Unix domain socket 3 for command server is ready
lxc .working 20181121020640.903 TRACE execute - execute.c:lxc_execute:157 - Doing lxc_execute
lxc .working 20181121020640.903 INFO lsm - lsm/lsm.c:lsm_init:47 - LSM security driver AppArmor
lxc .working 20181121020640.903 TRACE start - start.c:lxc_init:746 - Initialized LSM
@toravir
toravir / restGw.go
Last active December 3, 2018 18:59
REST Interface to cockroach DB (Go talks to cockroach DB using GORM)
package main
import (
"encoding/json"
"log"
"net/http"
"fmt"
"sort"
"github.com/gorilla/mux"
@toravir
toravir / ccgw.go
Created December 4, 2018 21:29
Rest Interface to Elasticsearch query...
package main
/*
To Get Results of a CC: [95% implemented]
curl -X GET http://localhost:12345/cc/742dd936-73f3-4bbf-850e-ff951af042e/results
To Trigger a CC: [50% implemented - does NOT trigger cc_analyzer...]
curl -X POST http://localhost:12345/cc -H 'Content-Type: application/json' \
@toravir
toravir / mux.go
Created February 15, 2019 06:00
Mux with Queries
package main
import (
"fmt"
"net/http"
"net"
"github.com/gorilla/mux"
)
/*