See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
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(), |
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.
# Title of Your Project [](https://twitter.com/intent/tweet?text=Check%20out%20this%20cool%20project&url=https://github.com/Cool/Project&hashtags=project,opensource) | |
 | |
 | |
 | |
 | |
#### Description of your project |
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) | |
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.
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 |