Skip to content

Instantly share code, notes, and snippets.

@giridharmb
giridharmb / tmux-cheatsheet.markdown
Created October 3, 2023 16:40 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@giridharmb
giridharmb / main.rs
Created June 10, 2023 19:55
Fetch Virtual Machine Records using Resource Graph API
// Using Azure Resource Graph, fetch Virtual Machine Records
use azure_identity::{ClientSecretCredential, TokenCredentialOptions};
use std::{env, sync::Arc};
use std::any::Any;
use std::borrow::Cow;
use std::future::IntoFuture;
use std::str::FromStr;
use azure_core::{AppendToUrlQuery, ClientOptions, ExponentialRetryOptions, new_http_client, RetryOptions};
@giridharmb
giridharmb / bash_to_zsh_history.rb
Created December 13, 2022 18:52 — forked from goyalankit/bash_to_zsh_history.rb
Import bash history to zsh history.
#################################################################
# = This script transfers bash history to zsh history
# = Change bash and zsh history files, if you don't use defaults
#
# = Usage: ruby bash_to_zsh_history.rb
#
# = Author: Ankit Goyal
#################################################################
# change if you don't use default values
@giridharmb
giridharmb / README.md
Created November 23, 2022 20:39 — forked from valyala/README.md
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@giridharmb
giridharmb / gcs.go
Created November 22, 2022 22:41 — forked from techjanitor/gcs.go
Upload a file to Google Cloud Storage
package main
import (
"errors"
"fmt"
"golang.org/x/oauth2"
"golang.org/x/oauth2/jwt"
storage "google.golang.org/api/storage/v1"
"os"
)
@giridharmb
giridharmb / 0-go-os-arch.md
Created November 4, 2022 18:01 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@giridharmb
giridharmb / index.gohtml
Created September 13, 2022 20:51 — forked from ericlagergren/index.gohtml
Hot-reloading / hot-swapping live template files in Go
My name is {{.Name}} and I'm {{.Age}} years old!!
@giridharmb
giridharmb / tls_test.go
Created August 25, 2022 20:10 — forked from jdomzhang/tls_test.go
golang tls connection with TLS 1.2
package onboarding_test
import (
"crypto/tls"
"log"
"net"
"net/http"
"testing"
)
@giridharmb
giridharmb / go_decode.go
Created August 18, 2022 23:15 — forked from miguelmota/go_decode.go
Golang gob encoding and decoding example
package main
import (
"bytes"
"encoding/gob"
"fmt"
"log"
)
func main() {
@giridharmb
giridharmb / psql_useful_stat_queries.sql
Created August 16, 2022 21:42 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables