Skip to content

Instantly share code, notes, and snippets.

View DSdatsme's full-sized avatar
💭
¯\_(ツ) _/¯

Darshit Suratwala DSdatsme

💭
¯\_(ツ) _/¯
View GitHub Profile
@DSdatsme
DSdatsme / build_action_runner.sh
Created February 1, 2023 10:13
Script to build action runner locally
mkdir -p /tmp/runner-build
cd /tmp/runner-build
git clone https://github.com/actions/runner.git
cd runner/src
# NOTE: Change based on platform
./dev.sh layout Release linux-arm64
./dev.sh package Release
@DSdatsme
DSdatsme / basic-testing.yaml
Created January 25, 2023 11:04
GitHub Actions Condition testing
name: Basic Testing
run-name: "Basic Testing"
on:
workflow_dispatch:
jobs:
demo-job-1:
runs-on: ubuntu-22.04 # NOTE: Hardcoding for stability
@DSdatsme
DSdatsme / PubSub pull messages synchronously
Created January 5, 2023 09:57
Code to pull PubSub messages one at at time
# Import the necessary libraries
from google.cloud import pubsub_v1
# Set the variables for your project, subscription, and maximum number of messages to pull
project_id = "proj-id"
subscription_name = "darshit-sub"
max_messages = 1
# Create a subscriber client
subscriber = pubsub_v1.SubscriberClient()
@DSdatsme
DSdatsme / delete_datadog_monitors.py
Created October 6, 2022 11:09
A sample script to delete datadog monitors
#
# Setup
# pip3 install datadog-api-client
#
# Command to run
# DD_SITE="datadoghq.com" DD_API_KEY=$DATADOG_API_KEY DD_APP_KEY=$DATADOG_APP_KEY python3 delete_datadog_monitors.py
# Sample monitor_list.txt. All monitor IDs are stored in new line.
#
# cat monitor_list.txt
@DSdatsme
DSdatsme / Centos8-k3s-Vagrantfile.hcl
Created July 25, 2021 17:51
basic config to setup
HOST_IMAGE = "centos/8"
$master_provision = <<-SCRIPT
echo provisioning k3s cluster...
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
echo done provisioning
SCRIPT
Vagrant.configure("2") do |config|
@DSdatsme
DSdatsme / stopJob.groovy
Last active May 25, 2021 12:58
Stop a Jenkins job forcefully
Jenkins.instance.getItemByFullName("FULL_JOB_PATH").getBuildByNumber(BUILD_NUMBER).finish(
hudson.model.Result.ABORTED,
new java.io.IOException("Aborting build"));
/*
To run the above line, navigate to:
Jenkins homepage -> Manage Jenkins -> Script Console
OR
open https://<jenkins domain>/script
@DSdatsme
DSdatsme / kubernetes scale replicas
Last active August 20, 2020 20:10
this oneliner will scale down your all deployments except the regex specified in if condition in the specific namespace.
for i in $(kubectl get deploy -n <namespace> -o name); do if [[ ${i} != (*"mongodb"*|*"mysql"*) ]];then kubectl scale -n <namespace> --replicas 0 $i; fi; done
@DSdatsme
DSdatsme / ease_inventory_ssh
Last active December 29, 2019 20:12
inventory utility to quickly ssh to servers just by searching them in a file
#!/bin/bash
INVENTORY_FILE='/path/to/inventory_file'
SSH_USER='darshit'
server_ips=$(cat $INVENTORY_FILE | peco | awk '{print $1;}' )
iterm_newtab(){
osascript \
-e 'tell application "iTerm2" to tell current window to set newWindow to (create tab with default profile)'\
-e "tell application \"iTerm2\" to tell current session of newWindow to write text \"${@}\""
@DSdatsme
DSdatsme / MySquareImage java class
Created March 29, 2018 10:15
this is for generating square images which always takes width form parent and sets height equal to width
public class MySquareImages extends android.support.v7.widget.AppCompatImageView {
public MySquareImages(Context context) {
super(context);
}
public MySquareImages(Context context, AttributeSet attrs) {
super(context, attrs);
}