Skip to content

Instantly share code, notes, and snippets.

View nitinbhojwani's full-sized avatar

Nitin Bhojwani nitinbhojwani

View GitHub Profile
@nitinbhojwani
nitinbhojwani / chart.tf
Created July 14, 2020 07:42
Add detector to the chart in terraform sfx
# inside chart add other label and publish it to link the detector
B = alerts(detector_id='${signalfx_detector.detector_name_here.id}').publish(label='B')
@nitinbhojwani
nitinbhojwani / GenericProcessor.java
Created August 1, 2020 13:11
Generics(Function and Class) in Java
/**
* Generic Function example
* GenericProcessor has a generic function that takes two generic arguments of type T
* One of them is the object of type T
* Another one is the object that processes objects of type T
*/
public class GenericProcessor {
private <T> void processObjectGivenProcessor(
T object,
Processor<T> processor) {
@nitinbhojwani
nitinbhojwani / LinkedList.kt
Created February 7, 2021 05:41
Basic LinkedList implementation in Kotlin
class LinkedList<T>() {
private var head: Node<T>? = null
private var lastNodePointer: Node<T>? = null
public fun add(value: T) {
val node = Node<T>(value)
if (head == null) {
head = node
lastNodePointer = node
} else {
@nitinbhojwani
nitinbhojwani / resolve-conflicts-with-poetry-lock.sh
Created July 2, 2021 07:19
Resolve git merge conflicts with poetry.lock
# Pick the change from the branch just merged
git checkout --theirs poetry.lock
# Update poetry.lock from pyproject.toml without any update
poetry lock --no-update
# Yey! the conflict is resolved and poetry.lock is updated with correct hash.
@nitinbhojwani
nitinbhojwani / create_temp_file.py
Created November 18, 2021 13:26
Create temporary file in Python
import tempfile
def _create_temp_file_with_content(file_content):
fp = tempfile.NamedTemporaryFile(delete=False)
fp.write(file_content)
return fp.name
@nitinbhojwani
nitinbhojwani / fix_git_committer_name_and_email.sh
Created February 12, 2024 16:32
Fix user name and email of multiple git commits
# Fix user name and email of multiple git commits
git config --local user.name "Nitin Bhojwani"
git config --local user.email "nitinbhojwani@outlook.com"
git rebase -r <last-right-git-commit-hash> --exec 'git commit --amend --no-edit --reset-author'