This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fix user name and email of multiple git commits | |
git config --local user.name "Nitin Bhojwani" | |
git config --local user.email "[email protected]" | |
git rebase -r <last-right-git-commit-hash> --exec 'git commit --amend --no-edit --reset-author' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
def _create_temp_file_with_content(file_content): | |
fp = tempfile.NamedTemporaryFile(delete=False) | |
fp.write(file_content) | |
return fp.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.org.schedules | |
import com.example.org.services.ConstructorInjection | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | |
import org.springframework.scheduling.annotation.EnableScheduling | |
import org.springframework.scheduling.annotation.Scheduled | |
import org.springframework.stereotype.Component | |
/** | |
* TestScheduler to schedule a method to run with fixedDelay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import concurrent.futures | |
def test_function(n): | |
return n ** 2 | |
# initiate a process pool executor | |
# by default, number of workers = number of CPU cores | |
executor = concurrent.futures.ProcessPoolExecutor(max_workers=10) | |
# 1. submit jobs to the executor and track in a list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import concurrent.futures | |
def test_function(n): | |
return n ** 2 | |
# initiate a thread pool executor | |
executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) | |
# 1. submit jobs to the executor and track in a list | |
jobs = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# roles as Python list of dictionaries | |
roles = [ | |
{'org': 'ABC', 'permissions':['RO', 'RW']}, | |
{'org': 'DEF', 'permissions':['RO', 'RW']}, | |
{'org': 'GHI', 'permissions':['RO', 'RW']}, | |
{'org': 'JKL', 'permissions':['RO', 'RW']}, | |
] | |
# get user object | |
user = User.objects(id=ObjectId('user_id')).first() |
NewerOlder