Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
NewerOlder