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
@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
@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():

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 / bot.py
Last active November 22, 2020 11:21
A basic Python discord Bot
from discord.ext import commands
from discord import Status, Game
from discord.errors import LoginFailure
bot = commands.Bot(command_prefix="?")
@bot.listen('on_ready')
async def bot_is_ready():
print(f"Logged in as: {bot.user}")
await bot.change_presence(status=Status.online, activity=Game(f"{bot.command_prefix}help"))
import sqlite3
from pprint import pprint
class DB:
def __init__(self):
self.con = sqlite3.connect('newdb.db')
self.cur = self.con.cursor()
def view_table(self):
self.cur.execute("Select * from NEW")
@blacksmithop
blacksmithop / icg.c
Created November 12, 2020 06:17
Intermediate Code -> Target Code
#include <stdio.h>
#include <string.h>
void main(){
char icode[10][30], str[30], opr[30];
int i=0;
printf("Enter Intermediate Code (terminated by exit):\n");
do{
scanf("%s", icode[i]);