Author: 99tpb32bkj25

  • ATACseq

    ATAC-Seq Pipeline Installation

    git clone https://github.com/tobiasrausch/ATACseq.git

    cd ATACseq

    make all

    If one of the above commands fail your operating system probably lacks some build essentials. These are usually pre-installed but if you lack them you need to install these. For instance, for Ubuntu this would require:

    apt-get install build-essential g++ git wget unzip

    Building promoter regions for QC and downloading motifs

    To annotate motifs and estimate TSS enrichments some simple scripts are included in this repository to download these databases.

    cd bed/ && Rscript promoter.R && cd ..

    cd motif/ && ./downloadMotifs.sh && cd ..

    Running the ATAC-Seq analysis pipeline for a single sample

    ./src/atac.sh <hg38|hg19|mm10> <read1.fq.gz> <read2.fq.gz> <genome.fa> <output prefix>

    Plotting the key ATAC-Seq Quality Control metrics

    The pipeline produces at various steps JSON QC files (*.json.gz). You can upload and interactively browse these files at https://gear-genomics.embl.de/alfred/. In addition, the pipeline produces a succinct QC file for each sample. If you have multiple output folders (one for each ATAC-Seq sample) you can simply concatenate the QC metrics of each sample.

    head -n 1 ./*/*.key.metrics | grep "TssEnrichment" | uniq > summary.tsv

    cat ./*/*.key.metrics | grep -v "TssEnrichment" >> summary.tsv

    To plot the distribution for all QC parameters.

    Rscript R/metrics.R summary.tsv

    ATAC-Seq pipeline output files

    The ATAC-Seq pipeline produces various output files.

    • Bowtie BAM alignment files filtered for duplicates and mitochondrial reads.
    • Quality control output files from alfred, samtools, FastQC and cutadapt adapter filter metrics.
    • Macs peak calling files and IDR filtered peak lists.
    • Succinct browser tracks in bedGraph format and IGV’s tdf format.
    • Footprint track of nucleosome positions and/or transcription factor bound DNA.
    • Homer motif finding results.

    Differential peak calling

    Merge peaks across samples and create a raw count matrix.

    ls ./Sample1/Sample1.peaks ./Sample2/Sample2.peaks ./SampleN/SampleN.peaks > peaks.lst

    ls ./Sample1/Sample1.bam ./Sample2/Sample2.bam ./SampleN/SampleN.bam > bams.lst

    ./src/count.sh hg19 peaks.lst bams.lst <output prefix>

    To call differential peaks on a count matrix for TSS peaks, called counts.tss.gz, using DESeq2 we first need to create a file with sample level information (sample.info). For instance, if you have 2 replicates per condition:

    echo -e "name\tcondition" > sample.info

    zcat counts.tss.gz | head -n 1 | cut -f 5- | tr '\t' '\n' | sed 's/.final$//' | awk '{print $0"\t"int((NR-1)/2);}' >> sample.info

    Rscript R/dpeaks.R counts.tss.gz sample.info

    Intersecting peaks with annotation tracks

    Peaks can of course be intersected with enhancer or conserved element tracks, i.e.:

    cd tracks/ && downloadTracks.sh

    bedtools intersect -a ./Sample2/Sample2.peaks -b tracks/conserved.bed

    Plotting peak density along all chromosomes

    There is a basic Rscript available for plotting peak densities.

    Rscript R/karyoplot.R input.peaks

    Citation

    Tobias Rausch, Markus Hsi-Yang Fritz, Jan O Korbel, Vladimir Benes.
    Alfred: Interactive multi-sample BAM alignment statistics, feature counting and feature annotation for long- and short-read sequencing.
    Bioinformatics. 2018 Dec 6.

    B Erarslan, JB Kunz, T Rausch, P Richter-Pechanska et al.
    Chromatin accessibility landscape of pediatric T‐lymphoblastic leukemia and human T‐cell precursors
    EMBO Mol Med (2020)

    License

    This ATAC-Seq pipeline is distributed under the BSD 3-Clause license.

    Visit original content creator repository
    https://github.com/tobiasrausch/ATACseq

  • PyOPM

    Object Pattern Matching for Python 3

    Object pattern matching (opm) is similar to regular expressions. Instead of matching a string against a pattern, we match objects. Some programming languages have this feature built-in, like Rust:

    let result = my_function();
    match result {
        Some(value) => do_this(value),
        _ => do_that(),
    }

    This is just a very simple example, but this a very powerful technique.

    However, this feature is not available in python by default. This repository contains the fruits of my work to implement this feature in python.

    Installation

    Simply install this package with pip:

    pip install --user pyopm

    Usage

    Note: Until now, only very basic features have been implemented.

    from pyopm import ObjectPattern
    
    p = ObjectPattern({
        'obj': {'eval': [lambda o: isinstance(o, dict)]},
        'obj.keys': {'eval': [lambda k: all(isinstance(x, (int, str)) for x in k())],
                     'bind': {'keys': lambda o: o()}},
        'obj.values': {'bind': {'values': lambda o: o()}},
        'obj.items': {'eval': [lambda i: all(isinstance(y, float if isinstance(x, int) else int)
                                             for x, y in i())],
                      'bind': {'items': lambda i: list(i())}},
    })
    
    m = p.match({0, 1, 2})  # not a dict -> m is None
    m = p.match({0: 0, 'one': 1})  # 0: 0 does not match the rules -> m is None
    m = p.match({0: 0.2, 'one': 1})  # match!
    
    with m:  # magic: use the objects bound to the names specified above
        print(keys)
        print(values)
        print(list(zip(keys, values)))  # should be the same as...
        print(items)  # ...this!

    This snippet above results in the following output:

    dict_keys([0, 'one'])
    dict_values([0.2, 1])
    [(0, 0.2), ('one', 1)]
    [(0, 0.2), ('one', 1)]
    

    Roadmap

    The next thing to implement: proper with block handling

    To Do

    • proper with block handling (locals do not work)
    • SwitchBlock (throw in any object with my_switch_block.switch(obj) and the appropriate function will be called)
    • overload

    If you have any feature requests or suggestions, feel free to open an issue on github. Of course, this also applies to bug reports and questions!

    Support this project

    You can contribute to this project by

    • forking it.
    • giving suggestions and feedback here.
    • using and sharing it.

    Currently, it is not very pythonic to use (especially the ObjectPattern init). I would be glad to improve the situation, but I do not want to loose the flexibility this method provides. If you have any ideas, please open an issue!

    Visit original content creator repository
    https://github.com/ep12/PyOPM

  • 18WSD030-Advanced-Project

    lu-logo-transparent-2

    18WSD030-Advanced-Project

    Repository for my MEng Advanced Project.

    Diversity Techniques for riverside Wireless Sensor Nodes over Software Defined Radios

    Project Description

    This project will investigate the effectiveness of multiple antennas on wireless sensor nodes to improve radiofrequency reliability. Different diversity techniques will be investigated, and a suggestion as to which is the most suitable will be made. During the project, the student will model and measure a multiple input single output system. Firstly in a lab and secondly outdoors. The platform used will be software defined radios.

    Project Aim

    To measure the effectiveness of using multiple antennas on sensor nodes close to, and upon water using software defined radios.

    Project Progress

    Set up test

    1. Carrier Wave detection Rx Target with Host interface

    FM SISO

    1. FM audio Tx Target (SISO)
    2. FM audio Rx Target and Host

    FM SIMO

    1. FM audio Rx Target and Host SIMO

    LoRa (beyond project aim – further progress)

    1. LoRa Rx on Target and Host with fosphor (waterfall)
    2. LoRa Tx on Target using Host generated IQ
    3. Arduino code for LoRa32 v2 Tx and RX
    4. LoRa Tx and Rx now works for targets and host – decoding not always successful

    Experimental setup

    1. Created three antenna mounts to test spatial and polarisation diversity
    2. Data collected has also been included for completion

    MATLAB code

    1. Spectrum function that creates Power Density Dunction (PDF) to the input signal
    2. SC,EGC,MRC – functions that perform Selection Combining, Maximal Ratio Combining and Equal Gain Combining to input signals
    3. Read and write complex binary files – this is to read from GNU Radio file sinks – code was taken from gr-utils

    Project Outcome

    Based on the results obtained the optimal arrangment for a 2-branch SIMO system is an antenna separion of a full wavelength (434MHz=>70 cm) with no antenna polirisation. MRC seems to be the best combining technique with EGC being the second best and SC the worst.

    The effects of spatial diversity were very clear through out the set of measurments but the effects of polarisation diversity were inclusive.

    Usage instructions

    The majority of the code developed for this project was done in GNU Radio companion and python. To use the above code, you will need to install GNU Radio it the Ettus USRP dependancies.

    GNU Radio is a free and open-source software development toolkit that provides signal processing blocks to implement software radios. GNU Radio can be installed by following the instructions here [https://wiki.gnuradio.org/index.php/InstallingGR].

    If you are looking to implement the code using hardware (SDRs), you will have to install the appropriate libraries. The above code was developed to be used on the Ettus E310 USRP using the UHD library from Ettus [https://files.ettus.com/manual/page_build_guide.html].

    After installing the required dependencies (explained above), you can download or clone the repository to your host machine. The file structure is simple. Code for Targets (SDRs) can be found in the /Targets folder. Please note that in my case the Target/1 is my Rx and Target/2 is my Tx. The differences between the two folders should be minimal.

    The /Host_Examples folder includes all the code written for the host computer. Host code will usually involve some kind of GUI for either real-time viewing of the data coming in or for controlling the setup or both. The GUI applications can be demanding, so my recommendation is to either use a Rasberry Pi or any other mid to high range computer running a recent version of Ubuntu. Using VMs can usually complicate things but haven’t tested it.

    The /MATLAB folder includes the functions used to read, analyse and combine the IQ data obtained through the SDR. The functions are quite simple. They are fully document in the code. Please refer to that. Also note that the read and write_complex_binary functions were not developed by me. The come with a GNU Radio installation under gr-utils.

    I am not sure if I will keep maintaining this after the end of the project but if any alterations are made they will be indicated here.

    License

    All code developed and shared above is developed by me, Kyprianos Diamantides (unless stated otherwise above).

    Copyright (C) 2018 K. Diamantides

    This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

    Visit original content creator repository https://github.com/themightykay/18WSD030-Advanced-Project
  • Android-Template-Activity-with-MVP-and-Repository-Pattern

    Android Studio Templates

    An Android Studio templates for Android development.

    To use these templates you will need Android Studio.

    Copy the appropriate folders into <androidStudio-folder>/plugins/android/lib/templates/ and they will appear in the project explorer context menu.

    The templates folder contains these templates:

    • [MVPActivity]: creates an android activity creates MVPActivity with Repositary layer
    • [MVPLoginActivity]: creates an android activity creates MVPActivity for LoginScreen

    MVP with Respositary Pattern

    Creates a new blank activity with a MVP with Respositary Pattern.

    Copy MVP with Respositary Pattern folder in your Android Studio installation in this folder: <androidStudio-folder>/plugins/android/lib/templates/activities

    Restart Android Studio, and you will find it in: New -> Activity -> MVP with Respositary Pattern Screen Screen Screen Screen

    Encourgement

    Acknowledgements

    • Thanks to Android Studio’s original templates

    Credits

    Author: Attiq Ur Rehman (attiq.ur.rehman1991@gmail.com)

    Follow me on LinkedIn Follow me on Google+ Follow me on Twitter

    License

    MIT License

    Copyright (c) 2017 Attiq ur Rehman

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


    Visit original content creator repository https://github.com/attiqrehman1991/Android-Template-Activity-with-MVP-and-Repository-Pattern
  • Android-Template-Activity-with-MVP-and-Repository-Pattern

    Android Studio Templates

    An Android Studio templates for Android development.

    To use these templates you will need Android Studio.

    Copy the appropriate folders into <androidStudio-folder>/plugins/android/lib/templates/ and they will appear in the project explorer context menu.

    The templates folder contains these templates:

    • [MVPActivity]: creates an android activity creates MVPActivity with Repositary layer
    • [MVPLoginActivity]: creates an android activity creates MVPActivity for LoginScreen

    MVP with Respositary Pattern

    Creates a new blank activity with a MVP with Respositary Pattern.

    Copy MVP with Respositary Pattern folder in your Android Studio installation in this folder: <androidStudio-folder>/plugins/android/lib/templates/activities

    Restart Android Studio, and you will find it in: New -> Activity -> MVP with Respositary Pattern
    Screen
    Screen
    Screen
    Screen

    Encourgement

    Acknowledgements

    • Thanks to Android Studio’s original templates

    Credits

    Author: Attiq Ur Rehman (attiq.ur.rehman1991@gmail.com)


    Follow me on LinkedIn


    Follow me on Google+


    Follow me on Twitter

    License

    MIT License

    Copyright (c) 2017 Attiq ur Rehman

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the “Software”), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.


    Visit original content creator repository
    https://github.com/attiqrehman1991/Android-Template-Activity-with-MVP-and-Repository-Pattern

  • vsomeip

    vSomeIP

    Copyright

    Copyright (C) 2015-2024, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)

    License

    This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
    If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

    Contributing Guidelines

    For comprehensive details on how to contribute effectively to the project, please refer to our CONTRIBUTING.md file.

    vSomeIP Overview


    The vSomeIP stack implements the http://some-ip.com/ (Scalable service-Oriented MiddlewarE over IP (SOME/IP)) Protocol.
    The stack consists out of:

    • a shared library for SOME/IP (libvsomeip3.so)
    • a shared library for SOME/IP’s configuration module (libvsomeip3-cfg.so)
    • a shared library for SOME/IP’s service discovery (libvsomeip3-sd.so)
    • a shared library for SOME/IP’s E2E protection module (libvsomeip3-e2e.so)

    Optional:

    • a shared library for compatibility with vsomeip v2 (libvsomeip.so)
    Build Instructions for Linux

    Dependencies

    • A C++17 enabled compiler is needed.
    • vSomeIP uses CMake as buildsystem.
    • vSomeIP uses Boost >= 1.66.0:

    For the tests Google’s test framework https://code.google.com/p/googletest/[gtest] is needed.
    — URL: https://googletest.googlecode.com/files/gtest-.zip

    To build the documentation doxygen and graphviz are needed:
    sudo apt-get install doxygen graphviz

    Compilation

    For compilation call:

    mkdir build
    cd build
    cmake ..
    make

    To specify a installation directory (like --prefix= if you’re used to autotools) call cmake like:

    cmake -DCMAKE_INSTALL_PREFIX:PATH=$YOUR_PATH ..
    make
    make install
    Compilation with predefined unicast and/or diagnosis address

    To predefine the unicast address, call cmake like:

    cmake -DUNICAST_ADDRESS=<YOUR IP ADDRESS> ..

    To predefine the diagnosis address, call cmake like:

    cmake -DDIAGNOSIS_ADDRESS=<YOUR DIAGNOSIS ADDRESS> ..

    The diagnosis address is a single byte value.

    Compilation with custom default configuration folder

    To change the default configuration folder, call cmake like:

    cmake -DDEFAULT_CONFIGURATION_FOLDER=<DEFAULT CONFIGURATION FOLDER> ..

    The default configuration folder is /etc/vsomeip.

    Compilation with custom default configuration file

    To change the default configuration file, call cmake like:

    cmake -DDEFAULT_CONFIGURATION_FILE=<DEFAULT CONFIGURATION FILE> ..

    The default configuration file is /etc/vsomeip.json.

    Compilation with signal handling

    To compile vSomeIP with signal handling (SIGINT/SIGTERM) enabled, call cmake like:

    cmake -DENABLE_SIGNAL_HANDLING=1 ..

    In the default setting, the application has to take care of shutting down vSomeIP in case these signals are received.

    Note on Ubuntu 24.04 Build Issues

    If you encounter build issues on Ubuntu 24.04, consider using Ubuntu 22.04 as a temporary fix. This is due to the ongoing transition of the GitHub Actions runner to Ubuntu 24.04, which may cause compatibility issues.

    Build Instructions for Android

    Dependencies

    • vSomeIP uses Boost >= 1.66. The boost libraries (system, thread and log) must be included in the Android source tree and integrated into the build process with an appropriate Android.bp file.
    Compilation

    In general for building the Android source tree the instructions found on the pages from the Android Open Source Project (AOSP) apply (https://source.android.com/setup/build/requirements).

    To integrate the vSomeIP library into the build process, the source code together with the Android.bp file has to be inserted into the Android source tree (by simply copying or by fetching with a custom platform manifest).
    When building the Android source tree, the Android.bp file is automatically found and considered by the build system.

    In order that the vSomeIP library is also included in the Android image, the library has to be added to the PRODUCT_PACKAGES variable in one of a device/target specific makefile:

    PRODUCT_PACKAGES += \
        libvsomeip \
        libvsomeip_cfg \
        libvsomeip_sd \
        libvsomeip_e2e \
    
    Build Instructions for Windows

    Setup

    • Visual Studio Code
    • Visual Studio Build Tools with:
      • Desktop development with C++
      • MSVC v143 – VS 2022 C++ x64/x86 build tools
      • Windows 10/11 SDK
      • CMake for Windows
    • vSomeIP uses CMake as buildsystem.
    • vSomeIP uses Boost >= 1.71.0:
    • GIT

    For the tests Google’s test framework https://code.google.com/p/googletest/[gtest] is needed.
    — URL: https://googletest.googlecode.com/files/gtest-.zip
    or
    — git clone https://github.com/google/googletest.git

    Compilation

    For compilation call:

    rmdir /s /q build
    cd build
    cmake .. -A x64 -DCMAKE_INSTALL_PREFIX:PATH=$YOUR_PATH
    cmake --build . --config [Release|Debug]
    cmake --build . --config [Release|Debug] --target install

    For compilation outside vsomeip-lib folder call:

    rmdir /s /q build
    cmake -B "buildlib" -DCMAKE_BUILD_TYPE=[Release|Debug] -DCMAKE_INSTALL_PREFIX=$YOUR_PATH -A x64 vsomeip-lib
    #vsomeip-lib compilation
    cmake --build build --config [Release|Debug] --parallel 16 --target install
    #examples compilation
    cmake --build build --config [Release|Debug] --parallel 16 --parallel 16 --target examples
    cmake --build build --config [Release|Debug] --parallel 16 --target install
    #unit-tests compilation
    cmake --build build/test --config [Release|Debug] --parallel 16 --parallel 16 --target build_unit_tests
    #all tests compilation
    cmake --build build/test --config [Release|Debug] --parallel 16 --parallel 16 --target all build_tests

    Visit original content creator repository
    https://github.com/COVESA/vsomeip

  • ecoleta

    Logo
    Recicle! ajude o meio ambiente!

    Made by Rocketseat License
    Run in Insomnia

    Índice

    🔖 Sobre

    O Ecoleta é uma aplicação Web e Mobile para ajudar pessoas a encontrarem pontos de coleta para reciclagem.

    Essa aplicação foi construída na trilha Booster da Next Level Week distribuída pela Rocketseat. A ideia de criar uma aplicação voltada ao meio ambiente surgiu da coincidência da data do curso e a data da semana do meio ambiente

    📚 Documentação

    Para reforçar alguns conceitos e registrar comandos que são dificeis de se lembrar eu fiz uma pequena DOCUMENTAÇÃO para ajudar quem esta iniciando com TypeScript, Node, ReactJS e React Native.

    🚀 Tecnologias Utilizadas

    O projeto foi desenvolvido utilizando as seguintes tecnologias

    ✔️ 💻 Resultado Web

    • O layout está disponível no Figma;

    Web

    ✔️ 📱 Resultado Mobile

    Mobile Home Mobile Detail

    🔥 Como usar

    • Pré-requisitos

      • É necessário possuir o Node.js instalado na máquina
      • Também, é preciso ter um gerenciador de pacotes seja o NPM ou Yarn.
      • Por fim, é essencial ter o Expo instalado de forma global na máquina
    1. Faça um clone :
      $ git clone https://github.com/vitorserrano/ecoleta.git
    1. Executando a Aplicação:
      # Instale as dependências
      $ npm install
    
      ## Crie o banco de dados
      $ cd server
      $ npm run knex:migrate
      $ npm run knex:seed
    
      # Inicie a API
      $ npm run dev
    
      # Inicie a aplicação web
      $ cd web
      $ npm start
    
      # Inicie a aplicação mobile
      $ cd mobile
      $ npm start

    ♻️ Como contribuir

    • Faça um Fork desse repositório,
    • Crie uma branch com a sua feature: git checkout -b my-feature
    • Commit suas mudanças: git commit -m 'feat: My new feature'
    • Push a sua branch: git push origin my-feature

    🎓 Quem ministrou?

    As aulas foram ministradas pelo mestre Diego Fernandes nas aulas da Next Level Week.

    📝 License

    Esse projeto está sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.


    Feito com 💜 by Vitor Serrano

    Visit original content creator repository https://github.com/vitorserrano/ecoleta
  • atonego

    AtOneGo

    make webapp && make ios && make android – an experiment with JavaScript/NodeJS and Phonegap

    Build Status

    AtOneGo

    This is the repo of the app AtOneGo

    This file contains the documentation for developers.

    Author: Michael Wager mail@mwager.de

    TechStack – Overview

    App

    Native App via Phonegap for iOS and Android. (WebApp served via Node.js)

    • Zepto 1.0
    • Require.js
    • Lodash/Backbone.js 1.0.0
    • SocketIO (0.9.x, not used anymore)
    • mobiscroll (date & time scroller)
    • Parts from Html5Boilerplate v4.X
    • Grunt
    • Inspired by the TodoMVC project and Yeoman
    • Phonegap (v3.x)

    API and Website via Node.js (at-one-go.com)

    • Express framework (v3)
    • Mongoose (v3)
    • see api/package.json
    • Hosting at OpenShift (free plan)

    Testing

    • Mocha: bdd client- and serverside
    • PhantomJS/CasperJS: headless webkit testing
    • testem

    Cordova/Phonegap

    Plugins:

    Installiere alle Plugins:

    NOTE: To update cordova plugins we need to remove and re-add !

    cordova plugin add org.apache.cordova.console && \
    cordova plugin add org.apache.cordova.device  && \
    cordova plugin add org.apache.cordova.dialogs && \
    cordova plugin add org.apache.cordova.network-information && \
    cordova plugin add org.apache.cordova.splashscreen && \
    cordova plugin add org.apache.cordova.statusbar && \
    cordova plugin add org.apache.cordova.vibration && \
    cordova plugin add org.apache.cordova.globalization && \
    cordova plugin add https://github.com/phonegap-build/PushPlugin.git
    

    Remove all:

    cordova plugin rm org.apache.cordova.console && \
    cordova plugin rm org.apache.cordova.device  && \
    cordova plugin rm org.apache.cordova.dialogs && \
    cordova plugin rm org.apache.cordova.network-information && \
    cordova plugin rm org.apache.cordova.splashscreen && \
    cordova plugin rm org.apache.cordova.statusbar && \
    cordova plugin rm org.apache.cordova.vibration && \
    cordova plugin rm org.apache.cordova.globalization && \
    cordova plugin rm com.phonegap.plugins.PushPlugin && \
    rm -rf plugins/ios.json && rm plugins/android.json
    

    Relevant directories & files

    • /app – app sources (yeoman requirejs/backbone boilerplate)
    • /api – node.js sources (REST API, SocketIO, DB, Tests, etc)
    • /api_deployment – The openshift repo (we just copy the sources from api to this directory and push it up to openshift)
    • /api/server/website – Static files of the website at-one-go.com
    • /api/server/website/app – The WebApp will be served from here (optimized sources from /dist will be copied to this directory via make webapp)
    • /api/server/test – All backend tests
    • /test – All frontend tests
    • /dist – Created via Grunt. The optimized sources will be used in the phonegap app and the webapp
    • /mobile/ – Phonegap project directory (v3.x)
    • /docs – All software documentation

    Files

    • Makefile – The Makefile for everything
    • /app/index.html – The base html file for the phonegap app (goes to /mobile/ios/www/ or /mobile/android/assets/www/ via Makefile)
    • /app/webapp.html – The base html file for the web app (goes to api/server/website/app/ via Makefile)

    Important client side JavaScript files

    • /app/scripts/config.js – The RequireJS config file for development (see also /app/scripts/config.production.js)
    • /app/scripts/main.js – The main bootstrapper, all initial event handling (domready/deviceready, global click/touch handlers, global ajax config…)
    • /app/scripts/router.js – The AppRouter, all client side navigation is done via history api (pushstate is on phonegap apps not needed). All routes of the app are defined here, and the router takes care of the rendering of root-views (screens)

    Local installation

    1. The App

    $ cd path/to/your/projects
    $ git clone repo-url.git atonego
    $ cd atonego
    # install local build system using grunt [optional]
    $ npm install
    # NOTE: The folder `atonego` should be served via a locally installed webserver like apache
    $ open http://127.0.0.1/atonego # should serve index.html now
    

    Via phonegap

    $ make ios_build_dev && clear && t mobile/ios/cordova/console.log

    Checkout the Makefile for more information.

    2. The API

    A RESTful API for the app is written in JavaScript using Node.js, the website at-one-go.com and the webapp will be served through Node.js too.

    NOTE: The production config file api/server/config/environments/production.json is not under version control.

    $ cd api
    $ npm install       # install dependencies only once
    $ mongod &          # start mongodb if not already running
    $ node server.js    # start the node app in development mode
    

    Now checkout something like:

    Code quality && -style

    Static code analysis via JSHint (back end && front end)

    # in the project root run:
    $ jshint . # see .jshintrc and .jshintignore
    

    Before committing, jshint MUST return zero:

    $ jshint .      # see .jshintrc and .jshintignore
    $ echo $?       # output 0 ?
    
    # enable jshint git "pre-commit" hook
    touch .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
    echo "jshint ." > .git/hooks/pre-commit
    

    Codestyle

    Inspired from here

    • Space indentation (4)
    • Single-quotes
    • Semicolons
    • Strict mode
    • No trailing whitespace
    • Variables at the top of the scope (where possible)
    • Multiple variable statements
    • Space after keywords and between arguments and operators
    • JSHint valid (see rules in the project root)

    Example: (client side using requirejs)

    define(function(require) {
        'use strict';
    
        var a = require('a'),
            b = require('b');
    
        function Foo() {}
    
        Foo.prototype = {
            bar: function() {
                return 'baz';
            }
        };
    
        return Foo;
    });

    Markers

    We mark problems and todos in the code comments via the marker XXX since using the well known marker TODO in a todo app seems not to be a good idea.

    Tests

    Overview

    All following commands should run without errors: (all from the project root)

    $ cd api && npm test
    $ testem ci
    $ casperjs test test/functional
    
    # there is a command for all of them:
    $ make all_tests
    

    API

    All server side unit & functional tests (bdd style) in: /api/server/test.

    $ cd api
    $ npm test  # mongod running? (possibly in another shell)
    

    CLIENT

    Tests in /test.

    Quick View of the Testsuite

    Clientside UNIT Tests via Mocha and testem.

    CodeCoverage /app/scripts via Blanket.js, see Tests in the Browser via testem.

    $ cd project_root
    $ testem      # default mode - Browsers can run the testsuite at http://localhost:7357
    $ testem ci   # ci mode      - run the suite in all available browsers
    

    Execute the tests in a simulator or on a device:

    $ make test_build # copies `/app` und `/test` in mobile's `www` directories
    # after that, the file config.xml (ios/android) has to be edited:
    
    <content src="https://github.com/mwager/test/index_browser.html" />
    
    Then just run:
    $ make ios # build the phonegap app with the current content of `mobile/ios/www`
    $ make android # same for `mobile/android/assets/www`...
    
    # shortcuts (config.xml!)
    $ make test_build && make ios
    $ make test_build && make android
    

    Functional tests

    Tests in /test/functional via (casperjs.org)[http://casperjs.org].

    # NOTE: Node and MongoDB must be running locally
    $ casperjs test test/functional
    

    Continuous Integration – Travis

    Build Status

    See .travis.yml and the travis page.

    Testing/Debugging via weinre

    Checkout weinre

    # Install & Run:
    $ [sudo] npm install -g weinre
    $ weinre --boundHost 192.168.1.233 --httpPort 8081 --verbose --debug --deathTimeout 60 --readTimeout 60
    >>> 2013-03-28T11:27:10.401Z weinre: starting server at ...
    

    Then include smt like this in app/index.html right after <body>:

    <script type="text/javascript">
    window.onerror = function(e) {
        alert(e);
    }
    </script>
    <script src="http://192.168.1.233:8081/target/target-script.js#anonymous"></script>
    

    and open this page with a browser.

    The API, error handling & multilingualism

    Authorization & Authentication

    We use HTTP Basic auth over SSL everywhere. On login (or signup), a secret API TOKEN gets generated from the user’s ID and a random string. This token will be encrypted via AES and sent over to the client. As RESTful APIs should be stateless, each following request must include this token in the password field of the Authorization-Header to authenticate against the service.

    Example:

    Authorization: "Basic base64encode('$username:$API_TOKEN')"
    

    NOTE:

    We cannot use custom certs and stuff on the openshift free plan so we cannot determine via node if the incoming request is secure (ssl) or not.

    Texts

    The App and the API/website were developed with support for multilingualism. The following directories include all Texts:

    • /app/scripts/libs/locales -> Texts of the App
    • /api/server/locales -> Texts of the Website & API

    Error Handling

    Models are always returning the Error as the first parameter in the callback (Node.js-Style, null on success), the second parameter can be used as return value, e.g. callback(null, user)).

    Example

    // in a model-method e.g. todolist.fetchList()
    if (!list) {
        utils.handleError('damnit some error message'); // optional logging
        return callback({key: 'listNotFound'});
    }
    return callback(err);
    
    // later: (e.g. in controllers)
    if(err && err.key) {
        // Error already logged (Log-files)
        // Usage of key via `__(key)`
        var text = __(err.key);
        // `text` is now smt like "List not found" or
        // "Liste nicht gefunden" (e.g. based on current request)
        return displayErrToUserSomehow(text);
    }
    

    Deployment

    Be sure to check out the Makefile for more infos.

    Deployment of the App via Phonegap

    Via PhoneGap for iOS [and Android]. There is a Makefile for automating tasks like optimizing the sources or compiling the native Apps via Phonegap.

    We generate one optimized JavaScript file (aog.js) via the requirejs optimizer, which will look something like this.

    $ make clean        # clean build directories
    $ make ios_device   # optimize sources, copy to ios `www` and build
    $ make ios          # build for ios via phonegap cli tools
    $ make android      # build for android via phonegap cli tools
    # NOTE: Shortcuts for running and logging: (phonegap catches "console.log()" calls)
    # We want a clean log file: (running in simulator)
    # 1. iOS
    $ echo "" > mobile/ios/cordova/console.log && make ios_build && clear && t mobile/ios/cordova/console.log
    # 2- Android
    # be sure to connect a real device before running the following one, else the android simulator could screw up your system (-;
    $ make android_build && make android_run && clear && adb logcat | grep "Cordova"
    

    App Store Submission (iOS)

    Then just switch “Run” and “Archive” configs to “Distribution” under “edit scheme…” in xcode.

    Google Play Store Submission

    App Versioning

    We use git tags for versioning. However, the file mobile/www/config.xml [and api/package.json and AndroidManifest.xml] should be manually updated on releases.

    Deployment of the API

    The API has its own repository at openshift. (URL: atonego-mwager.rhcloud.com) We are using a “Node.js-Catridge”, default Node-Version is 0.6.x (May 2013), but of course we want a newer version of Node.js, so we also set up this:

    https://github.com/ramr/nodejs-custom-version-openshift

    Deploy the Node App to production

    NOTE: this requires additional files (see /.gitignore).

    # 1. This command will optimize the sources using grunt and copy the generated stuff from `/dist/` to `/api/server/website/app/`:
    $ make webapp
    
    # 2. This command copies the sources from `api/*` over to `api_deployment/`
    # and pushes the stuff from there up to the openshift server.
    $ make api_deploy
    
    # restart from cli:
    $ make api_restart
    

    Openshift’s CLI Tool “rhc”

    # install: (needs ruby)
    $ gem install rhc
    
    > rhc app start|stop|restart -a {appName}
    > rhc cartridge start|stop|restart -a {appName} -c mysql-5.1
    
    When you do a git push, the app and cartridges do get restarted.  It is best if you can find any indication of why it stopped via your log files.  Feel free to post those if you need any further assistance.
    
    You can access your logs via ssh:
    > ssh $UUID@$appURL (use "rhc domain show" to find your app's UUID/appURL
    > cd ~/mysql-5.1/log (log dir for mysql)
    > cd ~/$OPENSHIFT_APP_NAME/logs (log dir for your app)
    
    # RESTART DATABASE ONLY:
    $ rhc cartridge start -a atonego -c rockmongo-1.1
    
    # RESTART APP ONLY:
    $ rhc app start -a atonego
    

    Fix quota errors at openshift: (https://www.openshift.com/kb/kb-e1089-disk-quota-exceeded-now-what)

    $ ssh ...
    $ du -h * | sort -rh | head -50
    $ rm -rf mongodb-2.2/log/mongodb.log*
    $ rm -rf rockmongo-1.1/logs/*
    $ echo "" > nodejs/logs/node.log
    
    # and remove the mongodb journal files:
    $ rm -rf  mongodb/data/journal/*
    

    Locally:

    rhc app tidy atonego
    

    openshift

    Cronjob:

    On the Production-Server at openshift, there runs a minutely cronjob, checking all todos with notifications, so Email-, PUSH- and SocketIO-messages can be sent to notify users.

    See api/.openshift/cron/minutely/atonego.sh

    The cronjob has its own logfile:

    $ ssh ...to openshift....
    $ tail -f app-root/repo/server/logs/production_cronjob.log
    

    PhoneGap Notes

    Reading

    Getting Started

    The mobile projects were created like this:

    1. downloaded: PhoneGap2.x (current 2.9.x cat mobile/ios/CordovaLib/VERSION)

    2. created ios and android projects

       $ mkdir mobile && cd mobile
       $ alias create="/path/to/phonegap-2.7.0/lib/ios/bin/create"
       $ create ios     de.mwager.atonego AtOneGo
       $ alias create="/path/to/phonegap-2.7.0/lib/android/bin/create"
       $ create android de.mwager.atonego AtOneGo
      

    Phonegap-Updates – Workflow: (#update, #upgrade, #phonegap)

    • download latest from phonegap.com
    • checkout guides per platform
    • copy all stuff manually
    • iOS: check this

    Some links:

    PUSH Notifications

    NOTE: see “Cronjobs” und also the demo script: api_deployment/server/ssl/push_demo.js

    # run demo script via
    ### DEBUG=apn node ./api_deployment/server/ssl/push_demo.js
    DEBUG=apn node ./api/server/push_demo.js
    

    Some links:

    Creating a development push certificate

    In the Apple dev member center:

    1. create development provisioning profile for app id de.mwager.atonego, download and install
    2. create development push certificate within the app id de.mwager.atonego
    3. download this certificate, open with keychain access, export private key (.p12 file)
    4. checkout this PUSH Tutorial to create the certificates for the server

    Testing the certificate:

    Note: use gateway.sandbox.push.apple.com in development (same port)

    $ openssl s_client -connect gateway.push.apple.com:2195 -cert api/server/ssl/ck.pem -key api/server/ssl/ck.pem
    # Output should be smt like:
    Enter pass phrase for api/server/ssl/ck_dev.pem:
    ******
    CONNECTED(00000003)
    ...
    Server certificate
    -----BEGIN CERTIFICATE-----
    ....
    
    Node.js and PUSH Notifications
    • create ssl files
    • see api/server/ssl/push_demo.js -> sends a push message to hardcoded device token
    The phonegap’s PushPlugin

    See the GitHub Page.

    Installed via plugman:

    $ cd mobile
    $ plugman --platform android --project ./platforms/android --plugin https://github.com/phonegap-build/PushPlugin.git
    $ plugman --platform ios --project ./platforms/ios --plugin https://github.com/phonegap-build/PushPlugin.git
    

    Problems, Solutions, Workarounds, Known Bugs

    Performance

    1. check this
    2. and that

    Underscores in filenames

    Avoid underscores in files and folders because Phonegap may fail to load the contained files in Android. This is a known issue.

    Edits

    Zepto, Backbone

    In a mobile environment like phonegap, memory management will be much more important than in the web. Variables in the global namespace are not cleaned up by the js engine’s garbage collector, so keeping our variables as local as possible is a must. To avoid polluting the global namespace as much as possible, Zepto, Backbone and some other files in /app/scripts/libs were edited, see “atonego”.

    Libs which are still global:

    • window._ -> /app/scripts/libs/lodash.js
    • window.io -> /app/scripts/libs/socket.io.js [not used anymore]
    Zepto errors

    Zepto’s touch module was edited to prevent lots of strange errors like:

    TypeError: 'undefined' is not an object file:///var/mobile/Applications/XXXXXXXXXX/atonego.app/www/scripts/libs/zepto.js on line 1651
    

    Search /app/scripts/lib/zepto.js for “atonego”.

    iOS does not allow HTTP Requests against self-signed/invalid certs…

    On iOS devices, there were problemes with the api endpoint at https://atonego-mwager.rhcloud.com/api. The following workaround is necessary!

    The file /mobile/ios/atonego/Classes/AppDelegate.m was edited: (at the bottom)

    @implementation NSURLRequest(DataController)
    + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
    {
        return YES;
    }
    @end
    

    ratchet.css && junior.js

    The files /app/styles/ratchet.css and /app/scripts/libs/junior_fork.js were edited to match our requirements.

    Thanks to:

    Disabled attributes & the tap event

    The “disabled state” (“<button … disabled …/>”) will not be captured. So on every “tap” we must check if the element has an disabled attribute or class.

    Ghostclicks

    This is one of the most annoying problems I have ever had. Checkout main.js and router.js for some workarounds.

    Socket IO

    UPDATE: We do not use socket io anymore as its kind of senseless having an open connection in a todo-app. PUSH notifications should be enough. If you want to use websockets via phonegap on iOS, better do not use socketio version 0.9.

    The app always crashed on resume after a (little) longer run. I was about to give up, then I found this

    SocketIO’s “auto reconnect” somehow crashed the app on the iOS test devices (seg fault!). As a workaround I disconnect the websocket connection on Phonegap’s pause-event, and manually re-connect (using same socket/connection again) on the resume-event.

    See also:

    Testflight Notes:

    • Create the *.IPA file via XCode: check “iOS device”, then: Product > Archive

    Install the app on a real iOS device via xCode

    • Create provisioning profile, download, copy profile via organizer to device , (dblclick installs in xcode first)
    • XCode: update codesigning identity according to the downloaded provisioning profile (project AND target)

    The cronjob

    A minutely cronjob runs on the server, checking all todos which are due now, so we can notify users. However, I could not figure out a good solution to re-use my existing (running) node app for this. The current workaround is to listen for a POST to a specific URL, and POSTing to that URL via curl from the cronjob with some pseudo credentials set to “make sure” that the request came from the shell script, not from outside )-:

    Search /api/worker.js -> “cron”

    Console testing

    Open the app in chrome or safari (dev or live), then open the dev console and put in some of the following commands to play with the app:

    # as there is (almost) nothing global, we must require stuff first, use this as template:
    > var $ = require('zepto'), app = require('app'), common = require('common');
    
    # then try some of these (-:
    > app.VERSION
    > app.isMobile
    > app.changeLang('de') // or app.changeLang('en') if currently in german
    > app.router.go('help')
    > window.history.back()
    > var list = app.todolists.get('object id of list from url or app.todolists');
    > list.toJSON()
    // URL: #todolists
    list.set('title', 'hello world')
    > app.fetchUser() // watch network tab
    
    var list = app.todolists.get('get id hash from url');
    list.set('title', '');
    

    Todos

    See docs/TODOs.md

    Visit original content creator repository https://github.com/mwager/atonego
  • StrainNet

    StrainNet

    StrainNet is a deep learning based method for predicting strain from images

    Teaser image

    Table of Contents

    Getting Started

    Set-up

    Begin by cloning this repository:

    git clone https://github.com/reecehuff/StrainNet.git
    cd StrainNet
    

    Next, install the necessary Python packages with Anaconda.

    conda create -n StrainNet python=3.9
    conda activate StrainNet
    pip install -r requirements.txt
    

    Finally, make sure that Python path is correctly set. The commmand

    which python
    

    should display the path to the Anaconda’s environment Python path, e.g., /opt/anaconda3/envs/StrainNet/bin/python

    Downloading pre-trained models and data

    To download the data and pretrained models for this project, you can use the download.sh script. This script will download the data and models from a remote server and save them to your local machine.

    Warning: The data is approximately 15 GB in size and may take some time to download.

    To download the data and models, run the following command:

    . scripts/download.sh
    

    This will download the data and models and save them to the current working directory. See the datasets for all of the ultrasound images (both synthetic and experimentally collected) and see the models folder for the pre-trained StrainNet models.

    Demo: Applying StrainNet to a Synthetic Test Case

    To see a demo of StrainNet in action, you can apply the model to a synthetic test case. The synthetic test case is a simulated image with known strains that can be used to test the accuracy of the model.

    To apply StrainNet to the synthetic test case, use the following command:

    . scripts/demo.sh
    

    You should now see a results folder with some plots of the performance on a synthetic test case where the largest strain is $4%$ (see the 04DEF in StrainNet/datasets/SyntheticTestCases/04DEF).

    Generating a training set

    For a full tutorial, see generateTrainingSet/README.md.

    Training StrainNet

    After generating a training, StrainNet can be trained. To train StrainNet, you will need to run the train.py script. This script can be invoked from the command line, and there are several optional arguments that you can use to customize the training process.

    Here is an example command for training StrainNet with the default settings:

    python train.py
    

    You can also adjust the training settings by specifying command-line arguments. For example, to change the optimizer and learning rate, you can use the following command:

    python train.py --optimizer SGD --lr 0.01
    

    Arguments

    Below is a list of some of the available command-line arguments that you can use to customize the training process:

    Argument Default Description
    --optimizer Adam The optimizer to use for training.
    --lr 0.001 The learning rate to use for the optimizer.
    --batch_size 8 The batch size to use for training.
    --epochs 100 The number of epochs to train for.
    --train_all False Whether to train all of the models.

    For a complete list of available command-line arguments and their descriptions, you can use the --help flag:

    python train.py --help
    

    Or examine the core/arguments.py Python script.

    Resuming training

    You can also resume training on models for StrainNet by specifying the --resume flag and the path to the pre-trained model. For example:

    python train.py --resume "path/to/dir/containing/model.pt"
    

    Training all models

    By default, train.py will only train one of the four models needed for StrainNet. To train all the models needed for StrainNet, you can use the train.sh script. This script will invoke the necessary training scripts and pass the appropriate arguments to them.

    To run the train.sh script, simply execute the following command from the terminal:

    . scripts/train.sh
    

    Viewing the progress of your training with Tensorboard

    By default, running train.py will write an events.out file to visualize the progress of training StrainNet with Tensorboard. After running train.py, locate the events.out in the newly-created runs folder.

    Viewing the Tensorboard Webpage

    To view the Tensorboard webpage, you will need to start a Tensorboard server. You can do this by running the following command in the terminal:

    tensorboard --logdir="path/to/dir/containing/events.out"
    

    Replace "path/to/dir/containing/events.out" with a path to a folder containing events.out file(s) (e.g., runs). This will start a Tensorboard server and print a message with a URL that you can use to access the Tensorboard webpage.

    To view the Tensorboard webpage, open a web browser and navigate to the URL printed by the Tensorboard server. This will open the Tensorboard webpage, which allows you to view various training metrics and graphs.

    Viewing the Tensorboard File in VSCode

    To view the Tensorboard events.out file in Visual Studio Code, you may use the Tensorboard command.

    1. Open the command palette (View → Command Palette… or Cmd + Shift + P on macOS)
    2. Type “Python: Launch Tensorboard” in the command palette and press Enter.
    3. Select Select another folder and select the runs folder to view events.out file(s).

    Evaluating the performance of StrainNet

    After training the model, you can evaluate its performance on a test dataset to see how well it generalizes to unseen data. To evaluate the model, you will need to have a test dataset in a format that the model can process.

    To evaluate the model, you can use the eval.py script. This script loads the trained model and the test dataset, and runs the model on the test data to compute evaluation metrics such as accuracy and precision.

    To run the eval.py script, use the following command:

    python eval.py --model_dir "path/to/trained/models" --val_data_dir "path/to/validation/data"
    

    Replace val_data_dir with the actual path to the trained models, and "path/to/validation/data" with the actual path to the validation data.

    Arguments

    You can see a list of all the available arguments for the eval.py script by using the --help flag:

    python eval.py --help
    

    Or examine the core/arguments.py Python script.

    Evaluating StrainNet on the synthetic test cases

    To apply the pretrained models to the synthetic test cases, you can use the eval.sh script. This script will invoke the necessary evaluation scripts and pass the appropriate arguments to them.

    To run the eval.sh script, simply execute the following command from the terminal:

    . scripts/eval.sh
    

    Citation

    @article{huff2024strainnet,
      title={Deep learning enables accurate soft tissue tendon deformation estimation in vivo via ultrasound imaging},
      author={Huff, Reece D and Houghton, Frederick and Earl, Conner C and Ghajar-Rahimi, Elnaz and Dogra, Ishan and Yu, Denny and Harris-Adamson, Carisa and Goergen, Craig J and O’Connell, Grace D},
      journal={Scientific Reports},
      volume={14},
      number={1},
      pages={18401},
      year={2024},
      publisher={Nature Publishing Group UK London}
    }
    

    LICENSE

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

    Visit original content creator repository https://github.com/reecehuff/StrainNet
  • AngleSharp.XPath

    logo

    AngleSharp.XPath

    GitHub Tag NuGet Count Issues Open Gitter Chat StackOverflow Questions CLA Assistant

    AngleSharp.XPath extends AngleSharp with the ability to select nodes via XPath queries instead of CSS selector syntax. This is more powerful and potentially more common for .NET developers working with XML on a daily basis.

    Basic Use

    With this library using XPath queries is as simple as writing

    var contentNode = document.Body.SelectSingleNode("//div[@id='content']");

    Besides SelectSingleNode we can also use SelectNodes. Both are extension methods defined in the AngleSharp.XPath namespace.

    If wanted we can also use XPath directly in CSS selectors such as in QuerySelector or QuerySelectorAll calls. For this we only need to apply the following configuration:

    var config = Configuration.Default.WithXPath();

    Now we can write queries such as

    var secondLi = document.QuerySelector("*[xpath>'//li[2]']");

    It is important that the original selector has all elements (*) as the intersection of the ordinary CSS selector and the XPath attribute is considered. The XPath attribute consists of a head (xpath>) and a value – provided as a string, e.g., //li[2].

    Features

    • Uses XPathNavigator from System.Xml.XPath
    • Includes XPath capabilities to CSS query selectors if wanted

    Participating

    Participation in the project is highly welcome. For this project the same rules as for the AngleSharp core project may be applied.

    If you have any question, concern, or spot an issue then please report it before opening a pull request. An initial discussion is appreciated regardless of the nature of the problem.

    Live discussions can take place in our Gitter chat, which supports using GitHub accounts.

    This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.

    For more information see the .NET Foundation Code of Conduct.

    .NET Foundation

    This project is supported by the .NET Foundation.

    License

    The MIT License (MIT)

    Copyright (c) 2018 – 2025 Denis Ivanov, AngleSharp

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Visit original content creator repository https://github.com/AngleSharp/AngleSharp.XPath