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 / Dockerfile
Created January 6, 2024 19:00
Configure Nginx for React application in Docker to prevent 404 on any route other than /
# Builder
FROM node:18-alpine3.17 as builder
WORKDIR /app
COPY . /app
WORKDIR /app/application_name
RUN npm install
@brownhash
brownhash / aes_gcm_256.js
Created September 22, 2022 10:47
AES GCM without passing the Authentication tag (Python & JS)
const crypto = require('crypto');
const assert = require('assert');
const AesGcm = (key, nonce) => {
const ALGO = 'aes-256-gcm';
const encrypt = (plaintext) => {
/*
Encrypts provided plain text with AES-GCM-256-bit encryption using the provided nonce(iv).
@brownhash
brownhash / release_go_assets.yaml
Last active March 5, 2022 10:55
Github workflow file for releasing artifacts of a golang tool
name: tool-release
on:
pull_request:
types: [closed]
jobs:
release:
name: tool-release
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master'
runs-on: ubuntu-latest
permissions:
@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
@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"

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 / 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 {
@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 / 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 / go_routines.go
Created January 20, 2020 18:47
Using GoRoutines
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"time"
)