Skip to content

Instantly share code, notes, and snippets.

View blacksmithop's full-sized avatar
🤔
Thinking

Abhinav blacksmithop

🤔
Thinking
View GitHub Profile
@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]);
@blacksmithop
blacksmithop / q3.md
Last active November 11, 2020 05:27
Answer to C

Rasterisation

It is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (a series of pixels, dots or lines, which, when displayed together, create the image which was represented via shapes). The rasterised image may then be displayed on a computer display, video display or printer, or stored in a bitmap file format. Rasterisation may refer to the technique of drawing 3D models, or the conversion of 2D rendering primitives such as polygons, line segments into a rasterized format.

Scan conversion

@blacksmithop
blacksmithop / rdparser.c
Created October 20, 2020 04:07
Recursive Descent Parser in C
#include <stdio.h>
char input[100];
int i;
int T();
int F();
int TP();
int EP();
int E()
{
@blacksmithop
blacksmithop / stack.l
Last active September 29, 2020 05:29
lex,yacc program for stack (has bugs) - current code
%{
#include "y.tab.h"
//extern char * yytext
%}
%%
[0-9]+ {return digit;}
[a-z]+ {return id;}
[\t] ;
[\n] {return 0;}
. {return yytext[0];}
@blacksmithop
blacksmithop / arith..y
Created September 22, 2020 05:23
Arithmetic Expression Evaluation with lex, yacc
%{
/* Definition section */
#include<stdio.h>
int yylex();
void yyerror();
%}
%token NUMBER ID
// setting the precedence
// and associativity of operators
@blacksmithop
blacksmithop / calc.l
Created September 22, 2020 05:00
Calculator with lex, yacc
%{
/* Definition section */
#include<stdio.h>
#include "y.tab.h"
extern int yylval;
%}
/* Rule Section */
%%
[0-9]+ {