Category: Blog

  • moodle-vagrant-example

    Introduction

    This project serves as an example of how to use the Open LMS development box
    that is published to Atlas. While you can use this project directly, it is meant as a starting
    point for your own Vagrantfile where you can customize the Open LMS development box
    using Vagrant provisioning. So, forking of this project
    for customization is encouraged.

    This project does not attempt to provide the ideal development environment for every Moodle developer.
    The Open LMS team simply wants to share their development box and provide some documentation on how
    to use it. So, please keep that in mind when filing issues and pull requests.

    Overview of the box

    The Open LMS development box has the following technologies installed:

    • Ubuntu is the operating system
    • Nginx with PHP-FPM
    • PHP
    • Redis
    • Git
    • NodeJS, NPM and Grunt installed globally
    • Chrome and Firefox
    • Selenium for Behat
    • And other various tools required by Moodle.

    For the adventurous, you can explore the details of the box creation process in this project.

    Vagrant install

    To install and use this project:

    1. Clone this project: git clone https://github.com/open-lms-open-source/moodle-vagrant-example.git ~/vagrant
    2. Install recommended versions of Vagrant and VirtualBox for the latest box release on Vagrant Cloud.
    3. Install Vagrant Host Manager Plugin: vagrant plugin install vagrant-hostmanager
    4. Open your terminal and from within this project, run: vagrant up

    After the vagrant up command completes, your virtual machine will be ready. You can use vagrant ssh
    to access it.

    Vagrant updates

    Always confirm that you have the correct versions of Vagrant and VirtualBox installed. Refer to the
    above install section for the correct versions. If you upgrade Vagrant, be sure to upgrade the plugins:

    > vagrant plugin update
    

    Ensure that this project is up-to-date, use the following:

    > cd /path/to/this/project
    > git fetch origin
    > git merge --ff-only origin/master
    

    If the base box is updated, then you will have to re-create your virtual machine to get the updated box. Before
    doing that, backup any data on the virtual machine first, like databases and data directories. See the
    “Vagrant management” section on how to backup multiple databases.

    Once backups are complete, do the following:

    > vagrant box update
    > vagrant destroy
    > vagrant up
    

    Optionally, you can delete old versions of the box to free up disk space:

    > vagrant box prune
    

    Vagrant management

    To access your virtual machine:

    > vagrant ssh
    

    If you are not going to be using your virtual machine for a while or are going to be turning off
    your computer, then you can shutdown the virtual machine:

    > vagrant halt
    

    Then, when you want to use it again:

    > vagrant up
    

    If you need to restart it:

    > vagrant reload
    

    Lastly, if you ever need to start fresh, you can delete your virtual machine, but before
    doing so, backup any data that is in the box. Most importantly, your MySQL databases:

    > vagrant ssh
    > mysqldump -u root -p --databases database1 database2 database3 > /vagrant/mysql.bak.sql
    Enter password: [Type in root]
    

    Replace database1 database2 database3 with a list of databases you wish to backup. In addition
    archive any of your Moodle data directories as well.

    Once backups are complete, you can destroy your virtual machine:

    > vagrant destroy
    

    Lastly, you can re-create the virtual machine and restore your databases:

    > vagrant up
    > vagrant ssh
    > mysql -u root -p < /vagrant/mysql.bak.sql
    Enter password: [Type in root]
    

    How to connect to MySQL

    From your host machine with an application like Sequel Pro:

    • Host: 0.0.0.0
    • Username: root
    • Password: root

    From within the virtual machine:

    > vagrant ssh
    > mysql -u root -p
    Enter password: [Type in root]
    

    How to create databases

    Connect to MySQL using one of the methods mentioned above, then execute the following SQL:

    CREATE DATABASE `database-name` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    

    Replace database-name with the database name you would like to create.

    How to create a data directory

    The Moodle data directories can be created under the following directories:

    • /srv/moodledata/
    • /vagrant/moodledata/

    The /srv/moodledata location is in the virtual machine itself. This is generally
    faster and since they are stored in the virtual machine, they are deleted if the
    machine is ever destroyed. This can be good or bad depending on how you like to manage things.

    The /vagrant/moodledata/ location is in the NFS mount. This is generally slower,
    but it makes the data directories accessible to your host machine and they are not
    deleted if the virtual machine is ever destroyed.

    Example of how to create a new one, use the following commands:

    > vagrant ssh
    > mkdir /srv/moodledata/dirname
    > chmod 777 /srv/moodledata/dirname
    

    Replace dirname with the directory name you would like to create.

    How to install Moodle

    First, clone the Moodle repository into www/moodle directory.

    > git clone git://github.com/moodle/moodle.git www/moodle
    

    Next, create a database and data directory for the site. Follow
    the steps in above sections to do this.

    Lastly, go to moodle.test in your browser and
    follow the instructions to install Moodle.

    Note: you can install a second Moodle site into www/core-moodle
    and access it via core-moodle.test. For example,
    you may want to install your customized version of Moodle in www/moodle
    and install the core version of Moodle in www/core-moodle.

    Also note: the site configs for these directories are in /etc/nginx/sites-enabled
    where you can add new sites or modify existing ones.

    How to use XDebug

    You must install a XDebug extension in your browser and turn on debugging in the browser.
    Then in an IDE like PHPStorm, you can listen for debug connections.

    To profile a page, do the following:

    1. Add XDEBUG_PROFILE=1 to your URL.
    2. Refresh/rerun the page to generate the profile.
    3. The profiles are stored in the /srv/xdebug-profiles directory in the virtual machine.
    4. Visit webgrind.test to view and delete profiles.

    How to use MailHog

    If you would like to use MailHog then follow these steps:

    1. Edit your config file.
    2. Comment out the $CFG->noemailever line.
    3. Ensure you have this config: $CFG->smtphosts = '0.0.0.0:1025';
    4. Purge caches.

    MailHog will now capture any emails sent from Moodle and is available on port 8025, EG: http://moodle.test:8025

    How to run Behat

    First, you must update your config file with the following:

    $CFG->behat_prefix        = 'behat_';
    $CFG->behat_dataroot      = '/srv/moodledata/behat_moodledata';
    $CFG->behat_wwwroot       = $CFG->wwwroot.':9090';
    // $CFG->behat_faildump_path = '/vagrant/www/behat_screenshots'; // Uncomment for screenshots.
    $CFG->behat_profiles      = [
        'default' => [
            'browser' => 'chrome',
            'wd_host' => 'http://localhost:4444/wd/hub',
        ],
        'firefox' => [
            'browser' => 'firefox',
            'wd_host' => 'http://localhost:4444/wd/hub',
        ]
    ];
    

    Next, initialize the testing environment:

    > vagrant ssh
    > cd /vagrant/www/moodle
    > php admin/tool/behat/cli/init.php
    

    Take note of the output at the end of this script, it will tell you where your
    behat.yml file is located. From now on, this will be referred to as /path/to/behat.yml

    Finally, the tests can be run with the following:

    > vendor/bin/behat --config /path/to/behat.yml
    

    The above will run all of the Behat tests, which is probably not wanted. You can pass
    an additional argument to the behat command, like a directory of feature files, a single
    feature file, etc. See vendor/bin/behat -h for more details.

    By default, Behat is using Chrome. To use Firefox, use -p firefox.
    At time of writing though, Chrome was the fastest browser and has full support.

    If you make any sort of configuration changes or add additional tests, you will most likely
    need to regenerate the behat.yml file. To do that, run these commands:

    > vagrant ssh
    > cd /vagrant/www/moodle
    > php admin/tool/behat/cli/util.php --enable
    

    See Acceptance testing and
    Acceptance testing browsers
    for more information.

    Postgresql

    To connect to the default database to install Moodle use the following connection details:

    $CFG->dbtype    = 'pgsql';
    $CFG->dblibrary = 'native';
    $CFG->dbhost    = '0.0.0.0';
    $CFG->dbname    = 'postgres';
    $CFG->dbuser    = 'postgres';
    $CFG->dbpass    = 'root';
    

    To create a new database:

    > psql -c "create database database_name;" -U postgres template1
    

    To access Postresql from the CLI:

    > vagrant ssh
    > psql -U postgres
    

    Vagrant share

    Use this feature to access your virtual machine from any other device, including other
    virtual machines. See help document for more
    details.

    Warning: this makes your virtual machine available to the public, but they of course
    need to know the exact details to actually connect. These shares should only last
    for around eight hours and expire whenever you kill the vagrant share
    command.

    1. To start sharing, use vagrant share
    2. The above command will output a URL, you must edit your config
      file and update the $CFG->wwwroot with the URL.

    To stop Vagrant share, just go to the terminal window where you started
    it and hit control+c to exit the command. Don’t forget to revert your
    changes to the config file.

    Also, a current limitation of Vagrant share is that you will only be able to
    access the Moodle site and not the other virtual hosts provided by your
    virtual machine.

    Visit original content creator repository
    https://github.com/open-lms-open-source/moodle-vagrant-example

  • GPT-Brain

    🧠 GPT Brain

    python

    中文说明 | 日本語説明書 | English

    ⭐️ Like this repo? please consider a star!

    💡This project is inspired by youtuber All About AI‘s video on Second Brain. Please consider support him!

    💡As I am not a professional programmer and am fairly new to Python, this project may contain bugs. If you encounter any issues, please suggest them in the Issues section.

    Description

    This program leverages the power of GPT-3 & 3.5 to provide a summary of the content of atomic notes, as well as answer questions related specifically to your notes. The program scans a designated directory, which is typically a vault containing multiple notes, and appends the contents of all the notes to a single file. This file then serves as the context for the user’s query. The program is able to identify relationships between the contents of the notes, and generate a refined response that summarizes the key points.

    Although the program is compatible with other note-taking software that uses markdown or txt, it is primarily designed with Obsidian in mind.

    Feature

    • Use OpenAI GPT-3 and GPT-3.5 (ChatGPT) to generate response.
    • Use OpenAI embedding for semetic comparison of question and note content for enhanced searching.
    • Configurable prompts.
    • Customizable personal background information for more accurate answers.
    • Integration with Obsidian note local directory for easy note content updates.
    • Note content preview & content modification.
    • Section parsing using delimiters for targeted updates.
    • Obsidian YAML frontmatter filtering.
    • OpenAI API key management.
    • OpenAI Language model selection for different needs.
    • Basic & Advanced parameter sliders for OpenAI Language model configurations.

    Todo

    • Support PDF format。
    • Support PDF OCR scan。
    • Support Word document。

    Install

    1. What you need

    2. Set up the project for the first time

    1. Download the project
    2. Run SETUP.bat
    3. Enter your OpenAI API Key

    3. Run

    • Execute RUN.bat

    Demo

    Main Page

    screenshot1

    Brain Memory

    screenshot2

    Visit original content creator repository https://github.com/sean1832/GPT-Brain
  • ayx-developer-sdk

    Alteryx Developer SDK

    Downloads

    The latest SDK versions can be downloaded from the Alteryx Developer SDK GitHub Repo in the Releases section.

    Installation

    To install, extract the SDK archive to a directory of your choice, install required dependencies, and finally, proceed to any platform specific post installation steps below.

    Windows Installation Example

    Via PowerShell

    # Download the latest release
    # This is an example! Update the URL to the correct archive!
    Invoke-Webrequest -URL https://github.com/alteryx/ayx-developer-sdk/releases/download/v2022.12.0/ayx-sdk-cli-v2022.12.0-x86_64-pc-windows-msvc.zip -Outfile latest-sdk.zip
    
    # Extract somewhere
    Expand-Archive -Path latest-sdk.zip -DestinationPath C:\SDKs\Alteryx\

    Dependencies

    Python version 3.8.5 is currently required to use ayx-sdk-cli.exe plugin run. It is recommended to install this in a Miniconda environment.

    Creating a Miniconda Python Environment

    1. Follow the Miniconda installation instructions.
    2. From a terminal, create a new environment with Python 3.8.5:
    conda create -n MyEnvName python=3.8.5

    ℹ️ Note that if you are using the same Conda environment for use with ayx_plugin_cli, you may wish to also install Node.js v14.x and doit as seen below:

    conda create -n MyEnvName python=3.8.5 nodejs=14 doit

    Please refer to the AYX Python SDK v2 documentation for more information on ayx_plugin_cli and Python SDK v2 tool development.

    Post Installation

    Windows

    In a terminal change directories to the tools\win32\misc and run ./setup-sdk.ps1.

    ℹ️ You will need to close and re-open your terminal after running this script.

    Additional Reading

    Additional reading can be found within the docs directory found within releases.

    License

    LICENSE

    Visit original content creator repository
    https://github.com/alteryx/ayx-developer-sdk