Month: October 2022

  • Reveres engineering Alienware keyboard

    USBPCAP
    Starting USBPCap with following command as per instructions from here ;

    USBPcapCMD.exe -d \\.\USBPcap1 -o - | "C:\Program Files\Wireshark\Wireshark.exe" -k -i -
    Selected capture options result in empty capture.
    

    Browsing the source we can see that this is caused when all these conditions are true
    https://github.com/desowin/usbpcap/blob/master/USBPcapCMD/cmd.c

      /* Sanity check capture configuration. */
        if ((data->capture_all == FALSE) &&
            (data->capture_new == FALSE) &&
            (data->address_list == NULL))
        {
            fprintf(stderr, "Selected capture options result in empty capture.\n");
            return;
        }
    
  • Death by QDS_LOADDB Wait type

    As the title implies ‘Death by QDS_LOADDB Wait type’

  • ScheduledExecutorService in Python with asyncio

    Running scheduled tasks with ease in Python. This implementation API is based on Java ScheduledExecutorService but it has been pythonized. There are other methods of running scheduled tasks in python but this seems like a natural choice for asyncio.

    The source code for the scheduler can be found here https://github.com/gregbugaj/marie-ai/blob/main/marie/concur/ScheduledExecutorService.py

    The schedule_with_fixed_delay is the primary method of the scheduler with the following signature.

        def schedule_with_fixed_delay(
            self,
            func: Callable,
            initial_delay: int,
            delay: int,
            unit: TimeUnit,
            *args,
            **kwargs,
        ) -> Any:
            """
            Creates and executes a periodic action that becomes enabled first after the given initial delay,
            and subsequently with the given period.
            Args:
                func:  the task to execute
                initial_delay:  the time to delay first execution
                delay: the period between successive executions
                unit:  the time unit of the initial_delay and period parameters
            Return:
                a ScheduledTask representing pending completion of the task
            """

    Creating a new scheduler and creating a task in just a few lines of code.

    # Task to execute
    async def async_task(name: str):
        print(f"{name} : {current_thread().name} {time.time()}  Start")
        await asyncio.sleep(1)
        print(f"{name} : {current_thread().name} {time.time()} Complete")
    
    
    # Create scheduler and schedule a task
    scheduler = ScheduledExecutorService.new_scheduled_asyncio_pool()
    t1 = scheduler.schedule_at_fixed_rate(async_task, 1, TimeUnit.MILLISECONDS, name="T1")
    
        
    

    Sample Usage

    import asyncio
    import threading
    import time
    
    from marie.concur import ScheduledExecutorService
    
    from threading import current_thread
    
    from marie.concur.ScheduledExecutorService import TimeUnit
    
    
    async def async_task(name: str):
        print(f"{name} : {current_thread().name} {time.time()}  Start")
        await asyncio.sleep(1)
        print(f"{name} : {current_thread().name} {time.time()} Complete")
    
    
    async def cancel_callback(task):
        print(f"canceling task : {task}")
        await task.stop()
    
    
    async def main():
        scheduler = ScheduledExecutorService.new_scheduled_asyncio_pool()
    
        t1 = scheduler.schedule_at_fixed_rate(
            async_task, 1, TimeUnit.MILLISECONDS, name="T1"
        )
    
        t2 = scheduler.schedule_at_fixed_rate(
            async_task, 2, TimeUnit.MILLISECONDS, name="T2"
        )
    
        asyncio.get_event_loop().call_later(3, asyncio.create_task, cancel_callback(t1))
    
    
    async def main_single():
        scheduler = ScheduledExecutorService.new_scheduled_asyncio_pool()
        t1 = scheduler.schedule_at_fixed_rate(
            async_task, 1, TimeUnit.MILLISECONDS, name="T1"
        )
    
        # call_later() only supports callbacks (regular functions); you  can’t pass in a coroutine.
        asyncio.get_event_loop().call_later(3, asyncio.create_task, cancel_callback(t1))
        # await t1.task
    
    
    async def main_delay():
        scheduler = ScheduledExecutorService.new_scheduled_asyncio_pool()
        t1 = scheduler.schedule_with_fixed_delay(
            async_task, 2, 1, TimeUnit.MILLISECONDS, name="T1"
        )
    
        await t1.start()
        print(t1.task)
    
        asyncio.get_event_loop().call_later(3, cancel_callback, t1)
    
        await t1.task
    
    
    if __name__ == "__main__":
        print("Main")
        loop = asyncio.get_event_loop()
        try:
            # asyncio.ensure_future(main_single())
            asyncio.ensure_future(main())
            loop.run_forever()
        except KeyboardInterrupt:
            pass
        finally:
            print("Closing Loop")
            loop.close()

    I am utilizing this in the Marie-AI project for my watchdog service.

  • Delven is a Domain Specific Language (DSL) designed for mining content

    Delven is a Domain Specific Language (DSL) designed for mining content from static and dynamic sources, It closely resembles SQL with features borrowed from other popular languages.

    This documentation is your guide to an advanced new world of real-time data connectivity.

    • To get an idea of what Delven is and how it can benefit your organization, visit the Introduction Section page.
    • New users and experienced users alike may refer to the Syntax section for all the information you need to create robust queries.
    • For new users, the Tutorial provides an introduction to basic query writing skills and a page of sample queries to get you started.
    • Programmers interested in embedding Delven within their application should visit the API Reference.