Skip to content

Instantly share code, notes, and snippets.

View brownhash's full-sized avatar
👨‍💻
Probably coding

Harshit Sharma brownhash

👨‍💻
Probably coding
View GitHub Profile
@brownhash
brownhash / oncall_notify.py
Created January 18, 2019 10:42
To send automatic notifications on Microsoft Teams from OnCall
import time
import requests
import pymsteams
# retrieve details
#------------------------------------------------------------
resp = requests.get('oncall_url/api/v0/teams')
if resp.status_code != 200:
print("Error: {}", resp.status_code)
@brownhash
brownhash / paramiko.py
Created August 29, 2019 11:39
Using Python's Paramiko library to login to remote server
import paramiko
import sys
class paramiko_conn:
def connection(self, method, host, user, auth_value):
if str(method) == "-k" or str(method) == "--key":
try:
key = paramiko.RSAKey.from_private_key_file(str(auth_value))
@brownhash
brownhash / weighted_graph.py
Created January 12, 2020 07:22
Using weighted graphs in python
class Graph:
def __init__(self):
self.node = []
self.connections = {}
def addnode(self, node):
self.node.append(node)
def connect(self, node1, node2, weight):
if type(weight).__name__ != "int" and type(weight).__name__ != "float":
@brownhash
brownhash / go_routines.go
Created January 20, 2020 18:47
Using GoRoutines
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"time"
)
@brownhash
brownhash / airflow_log.py
Created December 31, 2020 14:30
Fetch task logs from airflow for a specific task of a specific dag
# NOTE: This works only when the executor is CeleryExecutor
import os
import requests
import json
import urllib.parse
class AirflowLog(object):
def __init__(self, airflow_addr, dag_id, task_id, execution_date, try_number='1'):
self.airflow_addr = airflow_addr
self.dag_id = dag_id
@brownhash
brownhash / airflow_trigger_dag.py
Created December 31, 2020 14:49
Trigger airflow dag using python
import os
import requests
import time
import json
class AirflowTrigger(object):
def __init__(self, airflow_addr, dag_id, trigger_conf):
self.airflow_addr = airflow_addr
self.dag_id= dag_id
self.trigger_conf = trigger_conf
@brownhash
brownhash / main.go
Last active December 5, 2021 14:27
Implementing rate limiting on api
package main
import (
"errors"
"time"
"net/http"
)
// Struct to hold channels
type PressureGauge struct {

Keybase proof

I hereby claim:

  • I am brownhash on github.
  • I am brownhash (https://keybase.io/brownhash) on keybase.
  • I have a public key ASA5y3qCMZdvbj5rSlKKgn-KetXeci8jOacbwHfJgxSyTwo

To claim this, I am signing this object:

@brownhash
brownhash / public_tap.rb
Last active March 5, 2022 10:29
Public HomeBrew tap formula
# formula/tool.rb
class ToolName < Formula
desc "tool description"
homepage "https://github.com/owner/repository"
version "1.0.0"
# For MacOs Intel based systems
if OS.mac? && Hardware::CPU.intel?
url "https://github.com/owner/repository/releases/download/v1.0.0/tool_darwin_amd64.tar.gz"
sha256 "fa49007fc8c3fef09c023352c3703469422e3e4d87e252142135c4617155bf43"
@brownhash
brownhash / private.rb
Created March 5, 2022 10:29
Private HomeBrew tap formula
# formula/lib/private.rb
require "download_strategy"
# GitHubPrivateRepositoryDownloadStrategy downloads contents from GitHub
# Private Repository. To use it, add
# `:using => :github_private_repo` to the URL section of
# your formula. This download strategy uses GitHub access tokens (in the
# environment variables `HOMEBREW_GITHUB_API_TOKEN`) to sign the request. This
# strategy is suitable for corporate use just like S3DownloadStrategy, because
# it lets you use a private GitHub repository for internal distribution. It