Author: 3iv5aqxcpy9e

  • SegmentedControl-Demo-Qt-Python

    SegmentedControl-Demo-Qt-Python

    PyQt hasn’t included a “stock” segmented control (set of mutually-exclusive, visually abbutting buttons), so I wrote one in Python.

    Usage:

    #Disabled, Two Buttons:
    sc0 = SegmentedControl()
    sc0.AppendSegmentButton("No")
    sc0.AppendSegmentButton("Yes")
    sc0.setEnabled(False)
    
    #Enabled, Three Buttons:
    sc1 = SegmentedControl()
    sc1.AppendSegmentButton("No")
    sc1.AppendSegmentButton("Maybe")
    sc1.AppendSegmentButton("Yes")
    
    #Enabled, NOT Mutually Exclusive:
    sc2 = SegmentedControl(False)
    sc2.AppendSegmentButton("No")
    sc2.AppendSegmentButton("Maybe")
    sc2.AppendSegmentButton("Yes")
    
    #Text with Icon:
    sc3 = SegmentedControl()
    sc3.AppendSegmentButton("No", "./../Images/img20x20.png", QtCore.QSize(12, 12))
    sc3.AppendSegmentButton("Maybe", "./../Images/img20x20.png", QtCore.QSize(12, 12))
    sc3.AppendSegmentButton("Yes", "./../Images/img20x20.png", QtCore.QSize(12, 12))
    
    #Icon Only:
    sc4 = SegmentedControl()
    sc4.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(14, 14))
    sc4.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(14, 14))
    sc4.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(14, 14))
    
    #Larger Icon:
    sc5 = SegmentedControl()
    sc5.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
    sc5.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
    sc5.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
    
    #Mixed; Four Buttons, with an Initial Selection:
    sc6 = SegmentedControl()
    sc6.AppendSegmentButton("No")
    sc6.AppendSegmentButton("Yes", "./../Images/img10x10.png", QtCore.QSize(10, 10))
    sc6.AppendSegmentButton("", "./../Images/img20x20.png", QtCore.QSize(20, 20))
    sc6.AppendSegmentButton("", "./../Images/img30x30.png", QtCore.QSize(30, 30))
    sc6.setButtonState(1, True)
    
    #Setting up Button Callbacks
    #Clicked:
    sc0.buttonIdClicked.connect(firstRowClickedButtonId)
    #Pressed:
    sc0.buttonIdPressed.connect(firstRowPressedButtonId)
    #Released:
    sc0.buttonIdReleased.connect(firstRowReleasedButtonId)
    

    Visit original content creator repository
    https://github.com/kleydon/SegmentedControl-Demo-Qt-Python

  • rails_admin_yamap_field

    Gem Version

    RailsAdminYamapField

    Simple implementation of Yandex maps in rails admin.

    Inspired by these projects:

    Installation

    Add this line to your application’s Gemfile:

    gem 'rails_admin_yamap_field'

    And then execute:

    $ bundle

    Usage

    Add attr_accessor ya_map to you model for which you need to show the map or define ya_map and ya_map= methods as you wish, for example:

    class Address < ApplicationRecord
      # others methods
      def ya_map=(lat_lon)
        self[:lat], self[:lon] = lat_lon.split(",")
      end
      def ya_map
        [lat, lon].join(",")
      end
      # others methods
    end

    Available options for configure in rails_admin:

    • center_lat – map center latitude
    • center_long – map center longitude
    • zoom_level – map zoom level
    • map_html_width – width div map container: default ‘100%’
    • map_html_height – height div map container: default ‘500px’
    • map_lang – language map: default ‘ru_RU’, for other values see this ref
    • api_key – api key for enterprise version: default ‘nil’
    • latitude_field – latitude attribute name in you model: default ‘latitude’
    • longitude_field – longitude attribute name in you model: default ‘longitude’

    Example:

    class Address < ApplicationRecord
      attr_accessor :ya_map
    
      rails_admin do
        field :lat, :hidden
        field :lon, :hidden
        field :ya_map, :yamap_field do
          map_html_width "600px"
          latitude_field :lat
          longitude_field :lon
         end
      end
    end

    Screenshot

    Sample screenshot

    References

    Contributing

    Feel free to send pull requests or write issue.

    License

    The gem is available as open source under the terms of the MIT License.

    Visit original content creator repository https://github.com/Yegorov/rails_admin_yamap_field
  • locate_pixelcolor_cythonmulti

    Detects colors in images 5-10 x faster than Numpy

    pip install locate-pixelcolor-cythonmulti

    Tested+compiled against Windows 10 / Python 3.10 / Anaconda

    If you can’t import it, compile it on your system (code at the end of this page)

    How to use it in Python

    import numpy as np
    import cv2
    from locate_pixelcolor_cythonmulti import search_colors
    # 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/
    picx = r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg"
    pic = cv2.imread(picx)
    colors0 = np.array([[255, 255, 255]],dtype=np.uint8)
    resus0 = search_colors(pic=pic, colors=colors0)
    colors1=np.array([(66,  71,  69),(62,  67,  65),(144, 155, 153),(52,  57,  55),(127, 138, 136),(53,  58,  56),(51,  56,  54),(32,  27,  18),(24,  17,   8),],dtype=np.uint8)
    resus1 =  search_colors(pic=pic, colors=colors1)
    ####################################################################
    %timeit resus0=search_colors(pic,colors0)
    32.3 ms ± 279 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
    
    b,g,r = pic[...,0],pic[...,1],pic[...,2]
    %timeit np.where(((b==255)&(g==255)&(r==255)))
    150 ms ± 209 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
    ####################################################################
    %timeit resus1=search_colors(pic, colors1)
    151 ms ± 3.21 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
    
    %timeit np.where(((b==66)&(g==71)&(r==69))|((b==62)&(g==67)&(r==65))|((b==144)&(g==155)&(r==153))|((b==52)&(g==57)&(r==55))|((b==127)&(g==138)&(r==136))|((b==53)&(g==58)&(r==56))|((b==51)&(g==56)&(r==54))|((b==32)&(g==27)&(r==18))|((b==24)&(g==17)&(r==8)))
    1 s ± 16.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
    ####################################################################

    The Cython Code

    # distutils: language = c++
    # cython: language_level=3
    # distutils: extra_compile_args = /openmp
    # distutils: extra_link_args = /openmp
    
    
    from cython.parallel cimport prange
    cimport cython
    import numpy as np
    cimport numpy as np
    import cython
    from collections import defaultdict
    
    @cython.boundscheck(False)
    @cython.wraparound(False)
    @cython.cdivision(True)
    cpdef searchforcolor(unsigned char[:] pic, unsigned char[:] colors, int width, int totallengthpic, int totallengthcolor):
        cdef my_dict = defaultdict(list)
        cdef int i, j
        cdef unsigned char r,g,b
        for i in prange(0, totallengthcolor, 3,nogil=True):
            r = colors[i]
            g = colors[i + 1]
            b = colors[i + 2]
            for j in range(0, totallengthpic, 3):
                if (r == pic[j]) and (g == pic[j+1]) and (b == pic[j+2]):
                    with gil:
                        my_dict[(r,g,b)].append(j )
    
        for key in my_dict.keys():
            my_dict[key] = np.dstack(np.divmod(np.array(my_dict[key]) // 3, width))[0]
        return my_dict

    setup.py to compile the code

    # distutils: language = c++
    # cython: language_level=3
    
    from setuptools import Extension, setup
    from Cython.Build import cythonize
    import numpy as np
    ext_modules = [
        Extension("colorsearchcythonmulti", ["colorsearchcythonmulti.pyx"], include_dirs=[np.get_include()],define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")])
    ]
    
    setup(
        name='colorsearchcythonmulti',
        ext_modules=cythonize(ext_modules),
    )
    
    
    # .\python.exe .\colorsearchcythonmultisetup.py build_ext --inplace

    Visit original content creator repository
    https://github.com/hansalemaos/locate_pixelcolor_cythonmulti

  • experiment-dynamic-dom

    Dynamic DOM experiment

    Project Status: playground, STOPPED

    A playground repository to reproduce RxJS-like behaviour with as goal to create a fully dynamic dependencyless DOM framework in vanilla JS.

    Conclusion

    Reactivity

    Bad idea to reinvent the RxJS wheel. Working on this codebase was a good learning experience to understand their design choices.

    Upon stumbling on issues, the workarounds make you automatically lean towards RxJS paradigms. Reproducing reactive logic would serve as a great lesson for advanced JS students to recognize memory leaks and zombie logic.

    Dynamic DOM

    The dyn(obj) syntax is AWESOME. It is very intuitive, but the elephant in the room is that your teardown logic will be inaccessible when Proxying setters using the a = b syntax. If the object is destroyed, the hooks/mutators (== RxJS subscriptions/pipes) will keep triggering.

    Proposed solution

    Teardown logic can be gathered in the return value of dyn(). An alternative is to automatically run teardown logic by using either custom elements like <dyn-div> which have access to HTMLElement lifecycle events or using hacks like animationstart to derive it from native HTML elements.

    In this sandbox, even reactive arguments were supported. It felt like a breakthrough to use them until combining two reactive arguments felt off. If you want to inject two reactive parameters and need them settled, you’d need to merge them beforehand and pass them as fn(...arguments), which will require some

    HTML/JS support

    Plain HTML starts to feel outdated. Where are the reactive programming languages? (angular somewhat solved it)

    Future

    Might come back to this later, but limitations of HTML5 let me down a bit too much to be sure.

    Visit original content creator repository
    https://github.com/toonvanvr/experiment-dynamic-dom

  • wpa-cracking-project-with-pwnagotchi

    WPA Cracking Project with Pwnagotchi

    Description

    This project is developed as part of a university thesis, focusing on creating a Pwnagotchi plugin that uploads WPA handshake captures. Additionally, a web application is implemented to process these handshakes using Hashcat.

    Pwnagotchi Plugin Installation and Configuration

    Installation

    First, you need to install the Pwnagotchi plugin. Download or place the plugin into the Pwnagotchi system, then follow the plugin installation instructions provided in the Pwnagotchi documentation or use the following command (replace plugin-name with the actual name of the plugin):

    sudo pwnagotchi plugins install plugin-name

    Configuration

    After installing the plugin, add the following configuration to your config.toml:

    main.plugins.pwnagotchi-plugin.enabled = true
    main.plugins.pwnagotchi-plugin.api_key = ""
    main.plugins.pwnagotchi-plugin.api_url = ""
    main.plugins.pwnagotchi-plugin.download_results = false
    main.plugins.pwnagotchi-plugin.whitelist = []

    You will receive the api_key when you register on the web application. This key is necessary for the plugin to authenticate and communicate with the backend.

    pwny

    Backend

    The backend is built using Node.js.

    Tools needed

    • Hashcat

    • hcxpcapngtool

    Databases

    • MongoDB

    • Redis

    .env example

    Create a .env file with the following environment variables:

    PORT=3000
    WORDLIST_PATH='wordlist.txt'
    MONGO_URI='mongodb://yourmongohost:27017/yourdatabase'
    REDIS_HOST='yourredishost'
    REDIS_PORT=6379
    JWT_SECRET='yoursecret'
    

    Frontend

    The frontend is built using React.

    .env example

    Create a .env file with the following environment variables:

    PORT=4000
    REACT_APP_BACKEND_URL='yourbackendurl'
    

    front

    Visit original content creator repository https://github.com/energydrinksjunkie/wpa-cracking-project-with-pwnagotchi
  • rt_usb_9axisimu_driver

    日本語 | English

    rt_usb_9axisimu_driver

    industrial_ci

    株式会社アールティが販売しているUSB出力9軸IMUセンサモジュール用のROS 2パッケージです。

    usb-9axisimu

    現在、以下のROSのディストリビューションに対応しております。

    1. 概要

    rt_usb_9axisimu_driverは株式会社アールティが販売している USB出力9軸IMUセンサモジュール のROS 2パッケージです。

    株式会社アールティによって開発、メンテナンスがなされています。

    1.1 座標軸について

    USB出力9軸IMUセンサモジュールは、センサとしてInvenSense社のMPU9250を使用しております。 このセンサの磁気センサの座標系はNED座標系(x-north, y-east, z-down)ですが、 モジュール内のマイコン(LPC1343)においてENU座標系(x-east, y-north, z-up)に変換され、 ジャイロセンサおよび加速度センサの座標系と揃えられております。 これはROSで使われる座標系のルールにも適合しています。詳しくは、REP-0103をご覧ください。

    1.2 ファームウェア開発について

    USB出力9軸IMUセンサモジュールはオープンハード・オープンソースのため、モジュール内のマイコンのファームウェアの変更が可能です。 このROSパッケージはデフォルトのファームウェアにのみ対応しております。ファームウェアを変更された場合、正常な動作ができなくなる恐れがございますので、ご了承ください。

    1.3 ver2.0でのご利用について

    2020年8月現在、販売されているUSB出力9軸IMUセンサモジュールはver2.0となります。 このバージョンのデフォルトのファームウェアには、ASCII出力とBinary出力の2つのデータ出力形式があります。 センサ出荷時点ではASCII出力に設定されています。出力形式の切り替え方法は、以下のリポジトリにあるマニュアルをご参照ください。 https://github.com/rt-net/RT-USB-9AXIS-00

    [ERROR] Error opening sensor device, please re-check your devices. が発生する場合

    ポートの権限を変更してください。

    $ sudo chmod 666 /dev/ttyACM0

    2. インストール

    2.1 バイナリをインストールする場合

    # ROS 2 Humble
    $ sudo apt install ros-humble-rt-usb-9axisimu-driver
    # ROS 2 Jazzy (ToDo)
    $

    2.2 ソースからインストールする場合

    $ cd ~/ros2_ws/src
    # Clone package & checkout ROS 2 branch
    $ git clone -b $ROS_DISTRO https://github.com/rt-net/rt_usb_9axisimu_driver
    
    # Install dependencies
    $ rosdep install -r -y -i --from-paths .
    
    # Build & Install
    $ cd ~/ros2_ws
    $ colcon build --symlink-install
    $ source ~/ros2_ws/install/setup.bash

    2.3 クイックスタート

    # Terminal 1
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 run rt_usb_9axisimu_driver rt_usb_9axisimu_driver
    # Terminal 2
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # Echo topics (Press Ctrl+C for exit)
    $ ros2 topic echo /imu/data_raw
    $ ros2 topic echo /imu/mag
    $ ros2 topic echo /imu/temperature

    3. ノード

    3.1 rt_usb_9axisimu_driver

    rt_usb_9axisimu_driverはUSB出力9軸IMUセンサモジュールの出力を受信し、角速度と並進加速度・磁束密度をパブリッシュします。

    3.1.1 パブリッシュされるトピック

    3.1.2 パラメータ

    • ~frame_id (string, default: imu_link)

      • IMUデータのヘッダーにセットされるフレーム名
    • ~port (string, default: /dev/ttyACM0)

      • モジュールが接続されているポート名
    • ~linear_acceleration_stddev (double, default: 0.023145)

      • 並進加速度の共分散行列の対角成分の平方根(m/s^2)
    • ~angular_velocity_stddev (double, default: 0.0010621)

      • 角速度の共分散行列の対角成分の平方根(rad/s)
    • ~magnetic_field_stddev (double, default: 0.00000080786)

      • 磁束密度の共分散行列の対角成分の平方根(T)

    4. ROS 2 特有の使い方

    4.1 Lifecycle

    Lifecycle 機能を使うことで、ノード実行中にUSBの抜き差しや、 トピックのパブリッシュを稼働/停止できます。

    各状態での動作内容は次のとおりです。

    4.1.1 Unconfigured state

    • USBポート(~port)にアクセスしません
    • トピックをパブリッシュしません

    4.1.2 Configuring transition

    • パラメータを反映します
    • USBポート(~port)をオープンし9軸IMUセンサと通信します
      • 9軸IMUセンサの認識に失敗したらUnconfigured stateに遷移します

    4.1.3 Inactive state

    • トピックをパブリッシュしません

    4.1.4 Activating transition

    • 9軸IMUセンサと定期通信を開始します
      • 9軸IMUセンサとの通信に失敗したらUnconfigured stateに遷移します
    • トピックのパブリッシュを開始します

    4.1.5 Active state

    • トピックをパブリッシュします
    • 9軸IMUセンサとの通信に失敗しても状態遷移しません

    4.1.6 Deactivating transition

    • 9軸IMUセンサとの定期通信を停止します
    • トピックのパブリッシュを停止します

    4.1.7 CleaningUp transition

    • USBポート(~port)をクローズし9軸IMUセンサと通信を終了します

    4.1.8 Example

    # Terminal 1
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 run rt_usb_9axisimu_driver rt_usb_9axisimu_driver
    # Terminal 2
    $ source ~/ros2_ws/install/setup.bash
    
    # User can plug-in/out the IMU module at unconfigure state.
    
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # The node start publishing the topics.
    
    # Stop publishing
    $ ros2 lifecycle set rt_usb_9axisimu_driver deactivate
    $ ros2 lifecycle set rt_usb_9axisimu_driver cleanup
    
    # User can plug-in/out the IMU module at unconfigure state.
    # User can set parameters of the node.
    $ ros2 param set /rt_usb_9axisimu_driver frame_id "imu2-link"
    $ ros2 param set /rt_usb_9axisimu_driver port "/dev/ttyACM1"
    
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # The node start publishing the topics.

    4.2 Component

    rt_usb_9axisimu_driver::Driverは Component として実装されているため、共有ライブラリとして実行できます。

    4.2.1 Example

    # Terminal 1
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 run rclcpp_components component_container
    # Terminal 2
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 component load /ComponentManager rt_usb_9axisimu_driver rt_usb_9axisimu_driver::Driver
    
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # The node start publishing the topics.
    Visit original content creator repository https://github.com/rt-net/rt_usb_9axisimu_driver
  • rt_usb_9axisimu_driver

    日本語 | English

    rt_usb_9axisimu_driver

    industrial_ci

    株式会社アールティが販売しているUSB出力9軸IMUセンサモジュール用のROS 2パッケージです。

    usb-9axisimu

    現在、以下のROSのディストリビューションに対応しております。

    1. 概要

    rt_usb_9axisimu_driverは株式会社アールティが販売している
    USB出力9軸IMUセンサモジュール
    のROS 2パッケージです。

    株式会社アールティによって開発、メンテナンスがなされています。

    1.1 座標軸について

    USB出力9軸IMUセンサモジュールは、センサとしてInvenSense社のMPU9250を使用しております。
    このセンサの磁気センサの座標系はNED座標系(x-north, y-east, z-down)ですが、
    モジュール内のマイコン(LPC1343)においてENU座標系(x-east, y-north, z-up)に変換され、
    ジャイロセンサおよび加速度センサの座標系と揃えられております。
    これはROSで使われる座標系のルールにも適合しています。詳しくは、REP-0103をご覧ください。

    1.2 ファームウェア開発について

    USB出力9軸IMUセンサモジュールはオープンハード・オープンソースのため、モジュール内のマイコンのファームウェアの変更が可能です。
    このROSパッケージはデフォルトのファームウェアにのみ対応しております。ファームウェアを変更された場合、正常な動作ができなくなる恐れがございますので、ご了承ください。

    1.3 ver2.0でのご利用について

    2020年8月現在、販売されているUSB出力9軸IMUセンサモジュールはver2.0となります。
    このバージョンのデフォルトのファームウェアには、ASCII出力とBinary出力の2つのデータ出力形式があります。
    センサ出荷時点ではASCII出力に設定されています。出力形式の切り替え方法は、以下のリポジトリにあるマニュアルをご参照ください。
    https://github.com/rt-net/RT-USB-9AXIS-00

    [ERROR] Error opening sensor device, please re-check your devices. が発生する場合

    ポートの権限を変更してください。

    $ sudo chmod 666 /dev/ttyACM0

    2. インストール

    2.1 バイナリをインストールする場合

    # ROS 2 Humble
    $ sudo apt install ros-humble-rt-usb-9axisimu-driver
    # ROS 2 Jazzy (ToDo)
    $

    2.2 ソースからインストールする場合

    $ cd ~/ros2_ws/src
    # Clone package & checkout ROS 2 branch
    $ git clone -b $ROS_DISTRO https://github.com/rt-net/rt_usb_9axisimu_driver
    
    # Install dependencies
    $ rosdep install -r -y -i --from-paths .
    
    # Build & Install
    $ cd ~/ros2_ws
    $ colcon build --symlink-install
    $ source ~/ros2_ws/install/setup.bash

    2.3 クイックスタート

    # Terminal 1
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 run rt_usb_9axisimu_driver rt_usb_9axisimu_driver

    # Terminal 2
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # Echo topics (Press Ctrl+C for exit)
    $ ros2 topic echo /imu/data_raw
    $ ros2 topic echo /imu/mag
    $ ros2 topic echo /imu/temperature

    3. ノード

    3.1 rt_usb_9axisimu_driver

    rt_usb_9axisimu_driverはUSB出力9軸IMUセンサモジュールの出力を受信し、角速度と並進加速度・磁束密度をパブリッシュします。

    3.1.1 パブリッシュされるトピック

    3.1.2 パラメータ

    • ~frame_id (string, default: imu_link)

      • IMUデータのヘッダーにセットされるフレーム名
    • ~port (string, default: /dev/ttyACM0)

      • モジュールが接続されているポート名
    • ~linear_acceleration_stddev (double, default: 0.023145)

      • 並進加速度の共分散行列の対角成分の平方根(m/s^2)
    • ~angular_velocity_stddev (double, default: 0.0010621)

      • 角速度の共分散行列の対角成分の平方根(rad/s)
    • ~magnetic_field_stddev (double, default: 0.00000080786)

      • 磁束密度の共分散行列の対角成分の平方根(T)

    4. ROS 2 特有の使い方

    4.1 Lifecycle

    Lifecycle
    機能を使うことで、ノード実行中にUSBの抜き差しや、
    トピックのパブリッシュを稼働/停止できます。

    各状態での動作内容は次のとおりです。

    4.1.1 Unconfigured state

    • USBポート(~port)にアクセスしません
    • トピックをパブリッシュしません

    4.1.2 Configuring transition

    • パラメータを反映します
    • USBポート(~port)をオープンし9軸IMUセンサと通信します
      • 9軸IMUセンサの認識に失敗したらUnconfigured stateに遷移します

    4.1.3 Inactive state

    • トピックをパブリッシュしません

    4.1.4 Activating transition

    • 9軸IMUセンサと定期通信を開始します
      • 9軸IMUセンサとの通信に失敗したらUnconfigured stateに遷移します
    • トピックのパブリッシュを開始します

    4.1.5 Active state

    • トピックをパブリッシュします
    • 9軸IMUセンサとの通信に失敗しても状態遷移しません

    4.1.6 Deactivating transition

    • 9軸IMUセンサとの定期通信を停止します
    • トピックのパブリッシュを停止します

    4.1.7 CleaningUp transition

    • USBポート(~port)をクローズし9軸IMUセンサと通信を終了します

    4.1.8 Example

    # Terminal 1
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 run rt_usb_9axisimu_driver rt_usb_9axisimu_driver

    # Terminal 2
    $ source ~/ros2_ws/install/setup.bash
    
    # User can plug-in/out the IMU module at unconfigure state.
    
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # The node start publishing the topics.
    
    # Stop publishing
    $ ros2 lifecycle set rt_usb_9axisimu_driver deactivate
    $ ros2 lifecycle set rt_usb_9axisimu_driver cleanup
    
    # User can plug-in/out the IMU module at unconfigure state.
    # User can set parameters of the node.
    $ ros2 param set /rt_usb_9axisimu_driver frame_id "imu2-link"
    $ ros2 param set /rt_usb_9axisimu_driver port "/dev/ttyACM1"
    
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # The node start publishing the topics.

    4.2 Component

    rt_usb_9axisimu_driver::Driverは
    Component
    として実装されているため、共有ライブラリとして実行できます。

    4.2.1 Example

    # Terminal 1
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 run rclcpp_components component_container

    # Terminal 2
    $ source ~/ros2_ws/install/setup.bash
    $ ros2 component load /ComponentManager rt_usb_9axisimu_driver rt_usb_9axisimu_driver::Driver
    
    $ ros2 lifecycle set rt_usb_9axisimu_driver configure
    $ ros2 lifecycle set rt_usb_9axisimu_driver activate
    # The node start publishing the topics.

    Visit original content creator repository
    https://github.com/rt-net/rt_usb_9axisimu_driver

  • CodeAlpha_simple_chatbot

    AI Chatbot with Flask

    A modern, responsive chatbot application built with Flask, featuring an iOS-style UI design and dynamic theme switching.

    Features

    • 🤖 Intelligent conversation handling with natural language processing
    • 🎨 Modern iOS-style user interface
    • 🌓 Dynamic dark/light theme switching
    • 🌈 Animated gradient backgrounds
    • 📱 Fully responsive design
    • ✨ Smooth animations and transitions
    • 💬 Real-time chat interactions

    Technical Stack

    • Backend: Python Flask
    • Frontend: HTML5, CSS3, JavaScript
    • Styling: Custom CSS with iOS-inspired design
    • Animations: CSS animations and transitions
    • Theme Management: JavaScript-based theme switching

    Areas of Expertise

    The chatbot is knowledgeable in various technical domains:

    • Data Science & Analytics
    • Machine Learning
    • Artificial Intelligence
    • Full Stack Development
    • Cybersecurity

    Installation

    1. Clone the repository:

    git clone https://github.com/Tony-Stone-Code/CodeAlpha_simple_chatbot.git
    cd simple-chatbot
    1. Install the required dependencies:
    pip install -r requirements.txt
    1. Run the application:
    python3 app.py
    1. Open your browser and navigate to:
    http://localhost:5001
    

    Features in Detail

    Intelligent Conversation

    • Natural language processing for understanding user queries
    • Context-aware responses
    • Expertise in multiple technical domains
    • Friendly and engaging conversation style

    Modern UI/UX

    • iOS-inspired design elements
    • Smooth message animations
    • Interactive button effects
    • Dynamic message bubbles
    • Responsive layout for all devices

    Theme System

    • Automatic system theme detection
    • Manual theme toggle
    • Smooth theme transitions
    • Animated gradient backgrounds
    • Backdrop blur effects

    Responsive Design

    • Mobile-first approach
    • Adapts to all screen sizes
    • Touch-friendly interface
    • Optimized for both desktop and mobile

    Project Structure

    Basic chatbot/
    ├── app.py              # Flask application and routing
    ├── static/
    │   ├── style.css      # CSS styles and animations
    │   └── script.js      # Frontend JavaScript
    ├── templates/
    │   └── index.html     # Main HTML template
    └── README.md          # Project documentation
    

    Contributing

    Contributions are welcome! Feel free to submit pull requests or open issues for any improvements or bug fixes.

    License

    This project is licensed under the MIT License – see the LICENSE file for details.

    Author

    Anthony Opoku-Achempong (Tony-Stone-Code) – Data Scientist & Full Stack Developer

    • Expertise in Data Science, ML, AI
    • Full Stack Development
    • Cybersecurity Focus

    Acknowledgments

    • Inspired by modern iOS design principles
    • Built with best practices in web development
    • Focused on user experience and accessibility

    Visit original content creator repository
    https://github.com/Tony-Stone-Code/CodeAlpha_simple_chatbot

  • litkey

    Litkey

    🔥 Litkey makes keyboard shortcuts simple and enjoyable.

    Install

    # Using npm
    npm install litkey
    
    # Using yarn
    yarn add litkey

    Usage

    import litkey from 'litkey';
    
    // Add a global keyboard shortcut
    litkey('mod+k', () => {
      // do something
    });
    
    // Add a keyboard shortcut to a specific element
    litkey('mod+k', () => {
      // do something
    }, myElement);

    Usage with React

    import { useShortcut } from 'litkey';
    
    let Component = () => {
      let [clicked, setClicked] = useState(false);
    
      useShortcut('mod+a', () => {
        setClicked(true);
      });
    
      // You can also specify hook dependencies which will 
      // get passed on to the underlying useEffect
      useShortcut('mod+k', () => {
        setClicked(true);
      }, [/* react hook dependency list */]);
    
      // Using the fourth parameter, you can specify a
      // specific DOM element, in which the keyboard 
      // shortcut will be fired
      useShortcut('mod+k', () => {
        setClicked(true);
      }, [], myElement);
    
      return (
        <p>{ clicked ? 'clicked' : 'not clicked' }</p>
      );
    };

    API

    litkey(shortcut, handler, [context])

    The litkey function is the default export of litkey.

    shortcut: string | string[]

    shortcut is a string or an array of strings, which specify the key combinations which will fire the callback.

    handler: (event: KeyboardEvent) => any

    The handler is a callback function which will be called if the keyboard shortcut is pressed.
    It receives the KeyboardEvent as its first parameter.

    context?: HTMLElement

    The context is optional and can be used to specify the HTMLElement, in which litkey will listen for keyboard shortcuts.

    useShortcut(shortcut, handler, [dependencies, [context]])

    shortcut: string | string[]

    shortcut is a string or an array of strings, which specify the key combinations which will fire the callback.

    handler: (event: KeyboardEvent) => any

    The handler is a callback function which will be called if the keyboard shortcut is pressed.
    It receives the KeyboardEvent as its first parameter.

    dependencies: any[]

    dependencies is an optional array, which will be passed on directly to useEffect to serve as React hook dependencies.

    context?: HTMLElement

    context is optional and can be used to specify the HTMLElement, in which litkey will listen for keyboard shortcuts.

    License

    MIT © Tobias Herber

    Visit original content creator repository
    https://github.com/herber-legacy-4-varld-1/litkey

  • Er-Pescator

    How to use the “Er Pescator” automatic fishing system | Destiny 2

    Requirements

    • Have python 3 installed on your machine (Python3.9 or newer is suggested). You can download it from here.

    Setup

    You will need to procure a few packages using the python package manager, so for the unitiated this is how to use it:

    Open up a terminal of your liking (since I assume you are on Windows, the CMD is fine, just type cmd in the seach bar), then the command to use pip is one of the following, most likely the first one will work for you:

    • pip install <package_name>
    • python -m pip install <package_name>
    • python3 -m pip install <package_name>

    Now, install via pip the following packages:

    • vgamepad (this library)
      This will require you to install, also, some drivers, that the library will use to simulate a game-pad, follow the instructions on the wizard that pops on screen as you install the package to do so.
      pip install vgamepad
    • keyboard (this library)
      pip install keyboard

    Finally, download the code for “Er Pescator” from this github page, click this link and press the download icon on the top right side of the text area!
    Alternatively, if you have git ready to use, you can directly clone this repository.
    Anyway, you will be downloading the python script called er_pescator.py that performs the fishing 🙂 .

    Note that, before using the script, you need to restart Destiny 2 (if it was running since before the package installation process), as it needs to recognize the drivers for the simulated controller, and it does so on startup.

    One last thing, make sure to have the controller rumble enabled in Destiny 2.

    Usage

    We shall now fish!

    • Open the er_pescator.py script with right-click and “open with IDLE” or “edit with IDLE” (choose the newest version of python if prompted to do so). This shall open a new window with the script’s code, ignore it for now.
    • In Destiny 2, reach a pond and get close to it until you see the prompt to start fishing.
    • On the IDLE window we previously opened up, press “F5” to run the script.
    • Now move to Destiny 2 and press 9.
    • Finally, you can even do other stuff with your computer now, Destiny 2 does not need to be in the foreground!

    Once the script is running, its commands are the following:

    • 9: start the fishing routine
    • 0: stop the fishing routine

    Important

    The script uses the rumble commands sent to the controller as cue to decide when to pick up the fish, as the rumble is slightly random, it might happen that it missfires and starts going idle, in that case just restart the fishing routine by pressing 9.
    If you are curious and want to tune the behavior of the script, you can enable the logging of rumble values by changing line 6 into:
    log_rumble_values = True
    And then you can play around with the lower bounds of the two values on line 18. The values range from 0 to 255, so leave the upper bounds untouched. I found the (200, 220) pair of lower bounds to be pretty reliable, bue feel free to try others!

    Visit original content creator repository
    https://github.com/EMJzero/Er-Pescator