Skip to content

Instantly share code, notes, and snippets.

View arjunprakash027's full-sized avatar
🎯
Focusing

Arjun P arjunprakash027

🎯
Focusing
View GitHub Profile
@arjunprakash027
arjunprakash027 / python_dataStructs.ipynb
Last active November 21, 2023 15:19
A small notebook containing the most important data structures used in python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arjunprakash027
arjunprakash027 / markov_chain_rust.rs
Last active October 21, 2023 08:24
A simple markov chain program written in rust
use rand::distributions::WeightedIndex;
use rand::prelude::*;
struct MarkovChain{
transition_matrix: Vec<Vec<f64>>,
states: Vec<String>,
}
impl MarkovChain {
fn new(transition_matrix: Vec<Vec<f64>>, states: Vec<String>) -> MarkovChain {
@arjunprakash027
arjunprakash027 / markov_chain_python.py
Created October 20, 2023 06:37
A small program to demonstrate markov chains in python.
#this program is to create a markov chain in python
import numpy as np
class MarkovChain:
def __init__(self, transition_matrix,states):
self.transition_matrix = np.array(transition_matrix)
self.states = states
@arjunprakash027
arjunprakash027 / access_modifiers_py.py
Created October 11, 2023 11:28
A small example code for access modifiers in python
class all_modify:
#declaring public,proteced and private
var1,_var2,__var3 = None,None,None
def __init__(self,var1,var2,var3):
self.var1 = var1
self._var2 = var2
self.__var3 = var3
@arjunprakash027
arjunprakash027 / aiohttp_try.py
Last active October 7, 2023 19:21
Python codes to use aiohttp. Try using aiohttp instead of requests!
#simple example
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession() as session:
async with session.get('http://python.org') as response:
print(response.status)
print(response.headers)
html = await response.text()
@arjunprakash027
arjunprakash027 / context_managers_in_py.py
Last active October 7, 2023 17:07
A short python code to understand the use of context managers in python (with statement)
#below is the class based context manager
class ContextTest:
def __init__(self) -> None:
print("initialized the ContextManager")
def __enter__(self) -> None:
print("entered into the with block")
@arjunprakash027
arjunprakash027 / collobrative-filtering.ipynb
Last active September 24, 2023 07:06
A collobrative filtering notebook for book dataset using svd in python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arjunprakash027
arjunprakash027 / asyncdeftry.py
Created September 23, 2023 16:13
A simple async await program that gets data of universities using api in python
import asyncio
import time
import httpx
import json
url = 'http://universities.hipolabs.com/search'
async def get_all_universities_for_country_async(country: str, data: dict) -> None:
params = {'country': country}
async with httpx.AsyncClient() as client:
@arjunprakash027
arjunprakash027 / playing_around_reccomender_systems.ipynb
Created September 23, 2023 07:29
A small book reccomender system using python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arjunprakash027
arjunprakash027 / message_queue_redis.py
Last active September 22, 2023 18:41
A python code to implement producer and consumer in async redis queue
import redis
import sys
import time
import json
import random
redis_conn = redis.Redis(host='localhost', port=6379)
def producer():
for i in range(20):