Skip to content

Instantly share code, notes, and snippets.

View pbteja1998's full-sized avatar

Bhanu Teja Pachipulusu pbteja1998

View GitHub Profile
@pbteja1998
pbteja1998 / middleware.ts
Created April 8, 2023 15:15 — forked from perkinsjr/middleware.ts
Using Clerk with Upstash for Middleware rate limiting and API Protection
import { getAuth, withClerkMiddleware } from "@clerk/nextjs/server";
import { NextResponse, NextFetchEvent } from "next/server";
import type { NextRequest } from "next/server";
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
const publicPaths = ["/", "/sign-in*", "/sign-up*", "/api/blocked"];
const ratelimit = new Ratelimit({
redis: Redis.fromEnv(),

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@pbteja1998
pbteja1998 / README.md
Created December 17, 2020 14:19 — forked from MichaelCurrin/README.md
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a selected GitHub repo, using GraphQL

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

# Title of Your Project [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20this%20cool%20project&url=https://github.com/Cool/Project&hashtags=project,opensource)
![Github License](https://img.shields.io/badge/license-MIT-green)
![Code Coverage](https://img.shields.io/badge/coverage-90%25-green)
![React Version](https://img.shields.io/badge/react-v16.12.0-blue.svg)
![example](https://mdn.mozillademos.org/files/10529/inspector.png)
#### Description of your project
@pbteja1998
pbteja1998 / ux-ui.md
Last active October 20, 2020 11:10 — forked from duttakapil/ux-ui.md
UI and UX Curriculum

User-Centric Design Research

  • Qualitative and Quantitative Research Practices
  • Information Architecture and Flow
  • User Need Identification
  • User Experience Interviewing
  • Proto-Personas
  • Insight Synthesis

Visual Prototyping and Wireframing

  • Adobe Photoshop
@pbteja1998
pbteja1998 / Python_sax_template.py
Created August 22, 2018 09:08 — forked from veryhappythings/Python_sax_template.py
As basic as a python SAX parser can get.
import sys, string
from xml.sax import saxutils, handler, make_parser
class ContentGenerator(handler.ContentHandler):
def __init__(self, out = sys.stdout):
handler.ContentHandler.__init__(self)
@pbteja1998
pbteja1998 / sidekiq_delete_jobs.md
Created July 3, 2018 11:44 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs

How to delete Sidekiq jobs in a Rails app using ActiveJobs

Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
def generate_RSA(bits=2048):
'''
Generate an RSA keypair with an exponent of 65537 in PEM format
param: bits The key length in bits
Return private key and public key
'''
from Crypto.PublicKey import RSA
new_key = RSA.generate(bits, e=65537)
public_key = new_key.publickey().exportKey("PEM")
private_key = new_key.exportKey("PEM")
def verify_sign(public_key, signature, hashed_data):
'''
Verifies with a public key from whom the data came that it was indeed
signed by their private key
param: public_key
param: signature String signature to be verified
return: Boolean. True if the signature is valid; False otherwise.
'''
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
def sign_data(private_key, hashed_data):
'''
param: private_key
param: hashed_data SHA256 hash of data to be signed
return: base64 encoded signature
'''
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from base64 import b64encode
key = private_key