Skip to content

Instantly share code, notes, and snippets.

View blacksmithop's full-sized avatar
🤔
Thinking

Abhinav blacksmithop

🤔
Thinking
View GitHub Profile
@blacksmithop
blacksmithop / switch_case_list_elements.py
Created June 21, 2022 06:15
python 3.10 switch case example list elements
# Python 3.10 switch case example for a list
def file_handler_v1(command):
match command.split():
case ["show"]:
print("List all files and directories: ")
# code to list files
case ["remove", *files]:
print("Removing files: {}".format(files))
# code to remove files
case _:
@blacksmithop
blacksmithop / Search my gists.md
Created June 13, 2022 12:30 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@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)
@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 / 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 / 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 / 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__(

AntWar.io

Logo.

Object

1) game

var methods = [];
undefined