Skip to content

Instantly share code, notes, and snippets.

@boseabhishek
boseabhishek / curly.go
Last active May 23, 2024 12:59
Learning Go!
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
if len(os.Args) == 1 {
@boseabhishek
boseabhishek / waitfor.go
Last active April 5, 2024 16:42
Wait for a task to finish with timeout
// usage:
// go run waitfor.go <num>
// where, num can be 1 or 2 or 3 or 4.
package main
import (
"context"
"encoding/json"
"fmt"
@boseabhishek
boseabhishek / Panic vs os.Exit.md
Created January 26, 2024 12:56 — forked from Integralist/Panic vs os.Exit.md
[Golang: panic vs os.Exit] #go #golang #panic

panic signals "the programmer has made a fundamental mistake and execution cannot continue safely", whereas os.Exit signals "the programmer has decided that the process should terminate here" — different meanings. Also, important difference in behavior: panic will unwind the callstack, which means it will call any pending defer statements; os.Exit will just do a hard kill, so it won't.

@boseabhishek
boseabhishek / System Design.md
Created November 9, 2023 10:47 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@boseabhishek
boseabhishek / Basics.md
Last active April 13, 2023 15:46
X.509 Certificate/Keys | Java | BouncyCastle | DER | Base64 | Human

Notes

PEM vs Base64? Why both?

PEM - Format type Base64 - content of the file encoding type

PEM (originally “Privacy Enhanced Mail”) is the most common format for X.509 certificates, CSRs, and cryptographic keys(public/private keys).

A PEM file is a text file containing one or more items in Base64 ASCII encoding, each with plain-text headers and footers (e.g. -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----).

@boseabhishek
boseabhishek / WORKSPACE
Created June 23, 2020 12:22
typical WORKSPACE file for Golang Bazel Projects
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# add bazel `golang` rules
http_archive(
name = "io_bazel_rules_go",
sha256 = "a8d6b1b354d371a646d2f7927319974e0f9e52f73a2452d2b3877118169eb6bb",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.3/rules_go-v0.23.3.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.23.3/rules_go-v0.23.3.tar.gz",
@boseabhishek
boseabhishek / ElasticSearch.md
Last active March 15, 2022 14:22
Elasticsearch 101 | Using elasticsearch_dsl with Python from CRUD

Elasticsearch

Definition

From official website, Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease.

Concept

Data in Elasticsearch is organized into indices. Each index is made up of one or more shards. Each shard is an instance of a Lucene index, which you can think of as a self-contained search engine that indexes and handles queries for a subset of the data in an Elasticsearch cluster. For details on shards and indices, see here

@boseabhishek
boseabhishek / redis_cheatsheet
Last active October 28, 2019 14:16
REDIS Cheatsheet
# REDIS cheatsheet
### delete
1. delete all keys in ALL dbs
FLUSHALL
2. delete all keys in a specific DB
@boseabhishek
boseabhishek / main.go
Last active July 25, 2019 16:46
Async parallel calls to invoke two APIs using anonymous goroutine functions and channels to pipe the response
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
@boseabhishek
boseabhishek / ImplicitSenderTest.scala
Created February 1, 2017 12:00 — forked from mguillermin/ImplicitSenderTest.scala
Sample showing basic usage of Akka TestKit and TestActorRef
package sample.akka.testkit
import akka.actor.ActorSystem
import akka.actor.Actor
import akka.testkit.{TestKit, TestActorRef}
import org.scalatest.matchers.MustMatchers
import org.scalatest.WordSpec
class ImplicitSenderTest extends TestKit(ActorSystem("testSystem"))
// Using the ImplicitSender trait will automatically set `testActor` as the sender