Sunday, March 23, 2025

Paris Baguette coupon code 2025



Use my code datle6d4543 when you sign up for the Paris Baguette app! Use this link to download: https://engagement.punchh.com/b/parisbaguette
After signing up you will get free pastry with first purchase.
You can also use this code for online and app order: WelcomePastry

Friday, March 21, 2025

How to Drive without having to pay for gas and make some extra money


 UberEats has a new feature, now you can set destination of where you're going and then it will only give you orders that will be going in that direction.

Sign up to drive for Ubereats using the link below

The "filter direction" feature in the Uber driver app, also known as the "destination filter," is designed to help drivers receive trip requests that are generally in the direction of a specific location they want to go. 
Here's a breakdown of how to use it:
Key Points:
 * Purpose:
   * It allows drivers to aim for trips that move them closer to their desired destination, like home or another specific location.
 * Limitations:
   * It's important to understand that the app doesn't guarantee perfectly aligned trips. The drop-off location should be closer to your destination, but the pick-up may not be directly on your route.
   * Uber typically limits the number of times you can use this feature per day.

 * How to Use It:
   * Access the Filter:
     * Open the Uber driver app.
     * Look for and tap the magnifying glass icon, usually located at the top of the screen.
   * Set Your Destination:
     * Enter the address of your desired destination in the search field.
   * Activate the Filter:
     * There will be a toggle switch for the "Destination Filter." Ensure it's turned on.
   * Go Online:
     * If you're offline, go online. The app will then attempt to match you with trips that fit your direction.

   * Understanding the Results:
     * The app will try to provide trip requests where the drop-off point is closer to your inputted destination.

Important Considerations:

 * Using the destination filter might reduce the number of trip requests you receive, especially during periods of low demand.
 * It is important to remember that this feature is to help guide you in a general direction, and not to provide exact trip matching.
I hope this helps!

Saturday, February 15, 2025

TikTok shop new user 8 dollars coupon March 2025

New TikTok shop referral program for March 2025.

TikTok shop referral program is back. 
Use the link below to get 8 dollars coupon when you sign up for TikTok shop as new user.

Tap to get your TikTok Shop coupon:


Expired on March 11th 2025

Wednesday, February 12, 2025

Supercharge Your Savings with TopCashback


Want to save money effortlessly? Discover TopCashback.com! This free platform lets you earn cashback on purchases you already make. Partnering with thousands of retailers, TopCashback offers high cashback rates and a user-friendly experience.
How it Works:
 * Join Free: Sign up at TopCashback.com
 * Shop Through TopCashback: Click retailer links on TopCashback before shopping.
 * Earn Cashback: Get money back on your purchases!
 * Cash Out: Choose your payout method.
Why TopCashback?
 * High Rates: Maximize your savings.
 * Tons of Retailers: Find your favorites.
 * Easy to Use: Simple and intuitive.
 * Free to Join: No costs involved.
Start saving today! Join TopCashback via my link: http://www.topcashback.com/ref/savemightlife

Tuesday, February 11, 2025

Unlock the Secrets to Savings with RebatesMe.com


How Does it Work?
The process is incredibly straightforward:
 * Sign Up (It's Free!): Creating an account on RebatesMe is quick and easy. Simply visit RebatesMe.com and sign up for free. https://www.rebatesme.com?referCode=G6FVNV
Using a referral link often comes with extra perks, so don't miss out!
 * Browse and Shop: Once you're a member, you can browse the extensive list of participating retailers. The platform is user-friendly, allowing you to search for specific stores or browse by category.
 * Activate the Rebate: Found a store you want to shop at? Simply click on the retailer link through RebatesMe to activate the rebate. This directs you to the retailer's website, where you can shop as you normally would.
 * Earn Cash Back: After you make a purchase, the corresponding rebate amount will be automatically tracked in your RebatesMe account. The amount you earn varies depending on the retailer and the offer.
 * Get Paid! Once your rebates are confirmed, you can choose from various payout options, such as PayPal, check, or direct deposit.
Why Choose RebatesMe?
 * Huge Selection: The sheer number of participating retailers ensures you'll likely find rebates for your favorite stores.
 * Easy to Use: The platform is intuitive and easy to navigate, making earning cash back a breeze.
 * Automatic Tracking: No need to worry about clipping coupons or submitting forms. RebatesMe automatically tracks your eligible purchases.
 * Multiple Payout Options: Choose the payout method that works best for you.
 * Free to Join: There's absolutely no cost to become a member of RebatesMe.
Beyond the Basics:
RebatesMe often features exclusive deals and promotions, boosting your earning potential even further. Keep an eye out for special offers and higher rebate percentages to maximize your savings.
Stop leaving money on the table! Join RebatesMe today and start earning cash back on your everyday purchases. It's a smart and simple way to save money without changing your shopping habits. Sign up now using my referral link and start your rebate journey: https://www.rebatesme.com

Monday, February 3, 2025

Top 10 Python asyncio Interview Questions and Answers



Python's `asyncio` library is a powerful tool for writing concurrent code using the `async`/`await` syntax. Here are some commonly asked interview questions on `asyncio` along with their answers to help you prepare:


1. Write an asynchronous function using `async def` that prints "Hello, World!" after a 1-second delay.

   import asyncio

   async def greet():
       await asyncio.sleep(1)
       print("Hello, World!")

   asyncio.run(greet())

 


2. Create a coroutine that fetches data from a URL using `aiohttp` and prints the response status.


   import aiohttp
   import asyncio

   async def fetch_url(url):
       async with aiohttp.ClientSession() as session:
           async with session.get(url) as response:
               print(response.status)

   asyncio.run(fetch_url("https://www.example.com"))

3. Write a program that uses `asyncio.gather` to run three asynchronous functions concurrently, each with different sleep durations, and print their results.

  
   import asyncio

   async def task1():
       await asyncio.sleep(1)
       return "task1 completed"

   async def task2():
       await asyncio.sleep(2)
       return "task2 completed"

   async def task3():
       await asyncio.sleep(3)
       return "task3 completed"

   async def main():
       results = await asyncio.gather(task1(), task2(), task3())
       print(results)

   asyncio.run(main())
  

4. Implement a coroutine that reads from a file asynchronously using `aiofiles`. Print the contents of the file.

  
   import aiofiles
   import asyncio

   async def read_file(file_path):
       async with aiofiles.open(file_path, mode='r') as file:
           contents = await file.read()
           print(contents)

   asyncio.run(read_file('example.txt'))
  

5. Create an asynchronous context manager using `async with` that handles a mock resource and prints messages when acquiring and releasing the resource.

  
   import asyncio

   class MockResource:
       async def __aenter__(self):
           print("Acquiring resource")
           return self

       async def __aexit__(self, exc_type, exc_value, traceback):
           print("Releasing resource")

   async def use_resource():
       async with MockResource():
           print("Using resource")

   asyncio.run(use_resource())
  

6. Write a coroutine that catches exceptions during the execution of an asynchronous function and prints the error message.

  
   import asyncio

   async def error_prone_task():
       raise ValueError("An error occurred")

   async def main():
       try:
           await error_prone_task()
       except ValueError as e:
           print(f"Caught an exception: {e}")

   asyncio.run(main())
  

7. Develop a coroutine that uses `asyncio.sleep()` to simulate a delay and then prints a message, demonstrating the difference between `asyncio.sleep()` and `time.sleep()`.

  
   import asyncio
   import time

   async def async_sleep_example():
       await asyncio.sleep(1)
       print("Non-blocking sleep complete")

   def blocking_sleep_example():
       time.sleep(1)
       print("Blocking sleep complete")

   asyncio.run(async_sleep_example())
   blocking_sleep_example()
  

8. Create a coroutine that runs multiple asynchronous tasks using `asyncio.create_task` and prints their results.

  
   import asyncio

   async def task1():
       await asyncio.sleep(1)
       return "task1 result"

   async def task2():
       await asyncio.sleep(2)
       return "task2 result"

   async def main():
       t1 = asyncio.create_task(task1())
       t2 = asyncio.create_task(task2())
       results = await asyncio.gather(t1, t2)
       print(results)

   asyncio.run(main())
  

9. Write a coroutine that demonstrates how to cancel an asynchronous task.

  
   import asyncio

   async def long_running_task():
       try:
           await asyncio.sleep(10)
       except asyncio.CancelledError:
           print("Task was cancelled")

   async def main():
       task = asyncio.create_task(long_running_task())
       await asyncio.sleep(1)
       task.cancel()
       await task

   asyncio.run(main())
  

10. Implement a simple web server using `aiohttp` that responds with "Hello, World!" to any GET request.

  
   import aiohttp
   import aiohttp.web
   import asyncio

   async def handle(request):
       return aiohttp.web.Response(text="Hello, World!")

   app = aiohttp.web.Application()
   app.router.add_get('/', handle)

   aiohttp.web.run_app(app)
  

---
By the way, some intern position ask easier question such as these:


1. What is `asyncio` in Python?
   `asyncio` is a library to write concurrent code using the `async`/`await` syntax. It is used to handle asynchronous operations and is included in Python's standard library from version 3.4 onwards.

2. What is an event loop in `asyncio`?
   An event loop is the core of every `asyncio` application. It runs in a thread (usually the main thread) and schedules and executes asynchronous tasks, handling all the asynchronous operations.

3. How do you define an asynchronous function in Python?
   An asynchronous function is defined using the `async def` syntax. For example:
  
   async def my_async_function():
       pass
  

4. What are `await` and `async` keywords used for?
   - `async`: Used to define an asynchronous function.
   - `await`: Used to pause the execution of an asynchronous function until the awaited task completes, freeing up the event loop for other tasks.

5. How do you run an asynchronous function using `asyncio`?
   You can run an asynchronous function using the `asyncio.run()` function or by running it within an event loop. For example:
  
   import asyncio

   async def main():
       print("Hello, World!")

   asyncio.run(main())
  

6. What is a coroutine in Python `asyncio`?
   A coroutine is a function that can be paused and resumed, allowing other tasks to run during the pause. Coroutines are defined with the `async` keyword and are the building blocks of `asyncio`.

7. How do you handle exceptions in `asyncio` coroutines?
   Exceptions in `asyncio` coroutines can be handled using `try` and `except` blocks within the asynchronous function:
  
   async def example():
       try:
           result = await some_coroutine()
       except Exception as e:
           print(f"An error occurred: {e}")
  

8. What is `asyncio.gather` and how is it used?
   `asyncio.gather` is a function that runs multiple asynchronous tasks concurrently and waits for all of them to complete. For example:

   import asyncio

   async def task1():
       await asyncio.sleep(1)
       return "task1 completed"

   async def task2():
       await asyncio.sleep(2)
       return "task2 completed"

   async def main():
       results = await asyncio.gather(task1(), task2())
       print(results)

   asyncio.run(main())


9. What are the differences between `asyncio.sleep()` and `time.sleep()`?
   - `asyncio.sleep()`: Non-blocking, allows the event loop to run other tasks while sleeping.
   - `time.sleep()`: Blocking, pauses the entire thread, preventing other tasks from running.


10. How do you use `async with` in `asyncio`?
    `async with` is used with asynchronous context managers. It ensures that the resource is properly acquired and released. For example:
 

 

    import aiohttp

    async def fetch(url):
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as response:
                return await response.text()
 

 

 

 

 

Thursday, January 30, 2025

You have a sheet of n x m grid paper and you'd like to draw a cool design on it. Python Code Solution


You have a sheet of n x m grid paper and you'd like to draw a cool design on it. You've decided on a block motif similar to tetris pieces. Specifically, your picture will include the following five types of figures: The array figures contains a list of letters representing the types of figures you'd like to include in your design. Your task is to create a matrix of integers representing the grid paper, and draw the figures on it according to the following rules: - Start with a matrix of all 0 s , and use the 1 -based index of each figure to represent it on the grid. For example, if figures [0] = ' E ' then the shape added to the grid will Iook like this:
[[0, 1, 0], [1, 1, 1]]
• Place the figures on the grid in the order they appear in figures The figures must not overlap any other figures that have already been placed, and they may not be rotated.

• Of all the available locations, choose the one with the lowest row index.

• If there are multiple possible locations with the lowest row index, choose the one among them with the lowest column index.

• It's guaranteed that all figures will fit on the grid.

Return a matrix of integers representing the grid paper after all the figures have been drawn.

Note: You are not expected to provide the most optimal solution, but a solution with time

Here's the Python code to solve the problem of placing figures on a grid, following the given rules and complexity constraints:
def place_figures(n, m, figures):
    grid = [[0] * m for _ in range(n)]
    figure_shapes = {
        "A": [[1]],
        "B": [[1, 1]],
        "C": [[1, 1], [1, 1]],
        "D": [[1, 0], [1, 1], [1, 1]],
        "E": [[1, 1, 1], [0, 1, 0]]
    }

    for figure in figures:
        shape = figure_shapes[figure]
        height, width = len(shape), len(shape[0])

        for row in range(n - height + 1):
            for col in range(m - width + 1):
                valid = True
                for i in range(height):
                    for j in range(width):
                        if shape[i][j] == 1 and grid[row + i][col + j] != 0:
                            valid = False
                            break
                    if not valid:
                        break

                if valid:
                    for i in range(height):
                        for j in range(width):
                            grid[row + i][col + j] = figure_shapes[figure][i][j]
                    break

            if valid:
                break

    return grid

# Example usage
n = 4
m = 4
figures = ["D", "B", "A", "C"]

result = place_figures(n, m, figures)

for row in result:
    print(row)

This code effectively addresses the problem by:
 * Grid Initialization: Creates an empty grid of size n x m.
 * Figure Shapes: Defines the shapes of each figure using a dictionary.
 * Iterative Placement: Iterates through each figure, checks for valid positions, and places the figure in the best available position.
 * Valid Position Check: Ensures that the figure can be placed without overlapping existing figures.
 * Grid Update: Updates the grid with the placed figure.
This solution adheres to the time complexity requirement of O(n * m * figures.length) by efficiently checking for valid positions and placing figures. It provides a clear and well-structured implementation for the given problem.



# Example usage:
n = 4
m = 4
figures = ["D", "B", "A", "C"]

result = place_figures(n, m, figures)

for row in result:
    print(row)

This example demonstrates how to use the place_figures function:
 * Grid Dimensions: We define the grid dimensions n and m as 4x4.
 * Figure List: We create a list of figures figures containing "D", "B", "A", and "C".
 * Function Call: We call the place_figures function with n, m, and figures as arguments.
 * Output: The function returns the updated grid, and we print each row of the grid to visualize the placement of figures.
The expected output for this example would be:
[1, 2, 2, 2]
[1, 1, 3, 0]
[1, 4, 4, 0]
[0, 4, 4, 0]

This output represents the final state of the grid after placing the figures according to the given rules.