Skip to content

Instantly share code, notes, and snippets.

View eshaan7's full-sized avatar
💭
breaking things

Eshaan Bansal eshaan7

💭
breaking things
View GitHub Profile
@eshaan7
eshaan7 / attestation.txt
Created April 10, 2022 12:10
Attestation
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore16
Contributor # 267
Hash: f6240633 39c89148 dc90981a c706331c
38237746 d9475805 de73900c 2746b740
f42442e4 0cbe0577 1b11891f 13313993
00b447b6 cdcbdc3c d48c2a81 dbd5ccbc
@eshaan7
eshaan7 / migrate.py
Created November 22, 2021 11:06
Django management command to auto-create database in postgreSQL.
import re
from django.conf import settings
from django.core.management.commands.migrate import Command as MigrateCommand
from django.db import DEFAULT_DB_ALIAS, OperationalError, connections
from django.db.utils import ConnectionHandler
class Command(MigrateCommand):
"""
@eshaan7
eshaan7 / react-axios-progress-bar.jsx
Last active November 5, 2022 17:58
Use axios interceptors with react-top-loading-bar
import React from "react";
import LoadingBar from "react-top-loading-bar"; // https://github.com/klendi/react-top-loading-bar
import axios from "axios";
export default function TopLoadingBar() {
// loading bar component ref
const ref = React.useRef(null);
React.useEffect(() => {
// Add a request interceptor
import pluggy
hookimpl = pluggy.HookimplMarker("myproject")
class PluginXYZ:
"""A 2nd hook implementation namespace.
"""
@hookimpl
def myhook(self, arg1, arg2):
@eshaan7
eshaan7 / 001_migration.py
Created February 13, 2021 19:44
adding permission to group in migration [Django]
# Generated on 2021-02-13
from django.db import migrations
def _get_perm_obj(perm: str, apps=None):
Permission = apps.get_model("auth", "Permission")
app_label, codename = perm.split(".", 1)
perm_obj, _created = Permission.objects.get_or_create(content_type__app_label=app_label,
codename=codename)
@eshaan7
eshaan7 / update_to_v1.3.0.py
Created August 11, 2020 15:48
Helper script for users upgrading to v1.3.0 of Intel Owl from any prior version
"""
Helper script for users upgrading to v1.3.0 of Intel Owl from any prior version
"""
import django
if __name__ == "__main__":
django.setup()
from django.db import transaction
@eshaan7
eshaan7 / drf-simplejwt_custom_admin_view.py
Last active November 24, 2022 11:25
Custom admin view for simplejwt that allows bulk deletion, blacklisting and token creation. Issue on GitHub: https://github.com/SimpleJWT/django-rest-framework-simplejwt/issues/258
from django.contrib import admin
from rest_framework_simplejwt.token_blacklist.admin import OutstandingTokenAdmin
from rest_framework_simplejwt.token_blacklist.models import OutstandingToken
from rest_framework_simplejwt.tokens import SlidingToken, RefreshToken
class CustomOutstandingTokenAdmin(OutstandingTokenAdmin):
"""
Custom admin view for OutstandingToken model\n
allows bulk deletion, blacklisting and sliding token creation
@eshaan7
eshaan7 / git_hash_dumper.sh
Last active November 6, 2020 09:15
Recursively downloads all hashed objects from a .git repo exposed on a webserver which do not have directory listing enabled and places them perfectly in a newly initialized git repo.
#!/bin/bash
green='\033[1;32m'
NC='\033[0m' # No Color
function banner ()
{
echo -e "\n${green}------------------------------
\n## Developer: @eshaan7, github.com/eshaan7
## Use at your own risk. Usage might be illegal in certain circumstances.
@eshaan7
eshaan7 / git_sync_forkedRepo.md
Last active December 3, 2020 13:12
Syncing a forked repo with original repo

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
# Add the remote, call it "upstream":
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git

Fetch all the branches of that remote into remote-tracking branches,