Skip to content

Instantly share code, notes, and snippets.

View blacksmithop's full-sized avatar
😃
Trying things differently

Abhinav blacksmithop

😃
Trying things differently
View GitHub Profile

Keybase proof

I hereby claim:

  • I am blacksmithop on github.
  • I am blacksmithop (https://keybase.io/blacksmithop) on keybase.
  • I have a public key ASBuWejMzpZk8vQ4xQ36WZDOfeSjPTP4PDuNZw1yygZquQo

To claim this, I am signing this object:

@blacksmithop
blacksmithop / better_dict.py
Last active August 28, 2021 03:17
Python dict, dot notation support
class Map(dict):
"""
Example:
m = Map({'first_name': 'Eduardo'}, last_name='Pool', age=24, sports=['Soccer'])
"""
def __init__(self, *args, **kwargs):
self.update(*args,**kwargs)
if kwargs:
for k, v in kwargs.items():

AntWar.io

Logo.

Object

1) game

var methods = [];
undefined
@blacksmithop
blacksmithop / metadata_scraper.py
Last active March 7, 2022 05:50
Get novel metadata
from requests import get
from bs4 import BeautifulSoup
class Novel:
"""
Represents a novel.
"""
def __init__(
@blacksmithop
blacksmithop / index.html
Last active April 27, 2022 05:41
Index page
<!DOCTYPE html>
<html lang="en" class="h-100">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Blacksmithop">
<meta name="generator" content="Hugo 0.88.1">
<title>Index of - Blacksmithop</title>
@blacksmithop
blacksmithop / decorator.py
Last active May 26, 2022 07:17
django - require http methods (restframework)
from functools import wraps
from django.http import HttpResponseNotAllowed
def require_http_methods(method_list):
"""
Decorator to make a view only accept particular request methods. Usage::
@require_http_methods(["GET", "POST"])
def my_view(request):
"""
@blacksmithop
blacksmithop / main.py
Created May 27, 2022 10:22
Sanitized file names from excel columns, compiled into a single json file
from os import listdir, path, remove, walk
from json import dump, load
from re import sub
dir = "data"
def createJSON():
fileName = input("> Title: ")
@blacksmithop
blacksmithop / aggregate_percentage.py
Last active June 8, 2022 11:25
Group a pandas Dataframe by a column with percentage data
from collections import Counter
import pandas as pd
data = [["A", 1], ["A", 2], ["B", 5], ["B", 5], ["B", 4], ["C", 6]]
df = pd.DataFrame(data, columns=["name", "id"])
id_all = df.groupby("name")["id"].agg(list)
id_unique = df.groupby("name")["id"].agg(set)