Blog

  • ebsynth_utility

    ebsynth_utility

    Overview

    AUTOMATIC1111 UI extension for creating videos using img2img and ebsynth.

    This extension allows you to output edited videos using ebsynth.(AE is not required)

    With Controlnet installed, I have confirmed that all features of this extension are working properly!
    Controlnet is a must for video editing, so I recommend installing it.
    Multi ControlNet(“canny” + “normal map”) would be suitable for video editing.

    I modified animatediff-cli to create a txt2video tool that allows flexible prompt specification. You can use it if you like.
    sample2.mp4

    Example

    • The following sample is raw output of this extension.

    sample 1 mask with clipseg

    • first from left : original
    • second from left : masking “cat” exclude “finger”
    • third from left : masking “cat head”
    • right : color corrected with color-matcher (see stage 3.5)
    • Multiple targets can also be specified.(e.g. cat,dog,boy,girl)
    sample_clipseg_and_colormacher.mp4

    sample 2 blend background

    • person : masterpiece, best quality, masterpiece, 1girl, masterpiece, best quality,anime screencap, anime style
    • background : cyberpunk, factory, room ,anime screencap, anime style
    • It is also possible to blend with your favorite videos.
    sample6.mp4

    sample 3 auto tagging

    • left : original
    • center : apply the same prompts in all keyframes
    • right : apply auto tagging by deepdanbooru in all keyframes
    • This function improves the detailed changes in facial expressions, hand expressions, etc.
      In the sample video, the “closed_eyes” and “hands_on_own_face” tags have been added to better represent eye blinks and hands brought in front of the face.
    sample_autotag.mp4

    sample 4 auto tagging (apply lora dynamically)

    • left : apply auto tagging by deepdanbooru in all keyframes
    • right : apply auto tagging by deepdanbooru in all keyframes + apply “anyahehface” lora dynamically
    • Added the function to dynamically apply TI, hypernet, Lora, and additional prompts according to automatically attached tags.
      In the sample video, if the “smile” tag is given, the lora and lora trigger keywords are set to be added according to the strength of the “smile” tag.
      Also, since automatically added tags are sometimes incorrect, unnecessary tags are listed in the blacklist.
      Here is the actual configuration file used. placed in “Project directory” for use.
    Sample.Anyaheh.mp4

    Installation


    Usage

    • Go to [Ebsynth Utility] tab.
    • Create an empty directory somewhere, and fill in the “Project directory” field.
    • Place the video you want to edit from somewhere, and fill in the “Original Movie Path” field. Use short videos of a few seconds at first.
    • Select stage 1 and Generate.
    • Execute in order from stage 1 to 7. Progress during the process is not reflected in webui, so please check the console screen. If you see “completed.” in webui, it is completed.
      (In the current latest webui, it seems to cause an error if you do not drop the image on the main screen of img2img.
      Please drop the image as it does not affect the result.)

    Note 1

    For reference, here’s what I did when I edited a 1280×720 30fps 15sec video based on

    Stage 1

    There is nothing to configure.
    All frames of the video and mask images for all frames are generated.

    Stage 2

    In the implementation of this extension, the keyframe interval is chosen to be shorter where there is a lot of motion and longer where there is little motion.
    If the animation breaks up, increase the keyframe, if it flickers, decrease the keyframe.
    First, generate one time with the default settings and go straight ahead without worrying about the result.

    Stage 3

    Select one of the keyframes, throw it to img2img, and run [Interrogate DeepBooru].
    Delete unwanted words such as blur from the displayed prompt.
    Fill in the rest of the settings as you would normally do for image generation.

    Here is the settings I used.

    • Sampling method : Euler a
    • Sampling Steps : 50
    • Width : 960
    • Height : 512
    • CFG Scale : 20
    • Denoising strength : 0.2

    Here is the settings for extension.

    • Mask Mode(Override img2img Mask mode) : Normal
    • Img2Img Repeat Count (Loop Back) : 5
    • Add N to seed when repeating : 1
    • use Face Crop img2img : True
    • Face Detection Method : YuNet
    • Max Crop Size : 1024
    • Face Denoising Strength : 0.25
    • Face Area Magnification : 1.5 (The larger the number, the closer to the model’s painting style, but the more likely it is to shift when merged with the body.)
    • Enable Face Prompt : False

    Trial and error in this process is the most time-consuming part.
    Monitor the destination folder and if you do not like results, interrupt and change the settings.
    [Prompt][Denoising strength] and [Face Denoising Strength] settings when using Face Crop img2img will greatly affect the result.
    For more information on Face Crop img2img, check here

    If you have lots of memory to spare, increasing the width and height values while maintaining the aspect ratio may greatly improve results.

    This extension may help with the adjustment.
    https://github.com/s9roll7/img2img_for_all_method


    The information above is from a time when there was no controlnet.
    When controlnet are used together (especially multi-controlnets), Even setting “Denoising strength” to a high value works well, and even setting it to 1.0 produces meaningful results.
    If “Denoising strength” is set to a high value, “Loop Back” can be set to 1.


    Stage 4

    Scale it up or down and process it to exactly the same size as the original video.
    This process should only need to be done once.

    • Width : 1280
    • Height : 720
    • Upscaler 1 : R-ESRGAN 4x+
    • Upscaler 2 : R-ESRGAN 4x+ Anime6B
    • Upscaler 2 visibility : 0.5
    • GFPGAN visibility : 1
    • CodeFormer visibility : 0
    • CodeFormer weight : 0

    Stage 5

    There is nothing to configure.
    .ebs file will be generated.

    Stage 6

    Run the .ebs file.
    I wouldn’t change the settings, but you could adjust the .ebs settings.

    Stage 7

    Finally, output the video.
    In my case, the entire process from 1 to 7 took about 30 minutes.

    • Crossfade blend rate : 1.0
    • Export type : mp4

    Note 2 : How to use multi-controlnet together

    in webui setting

    controlnet_setting

    In controlnet settings in img2img tab(for controlnet 0)

    controlnet_0

    In controlnet settings in img2img tab(for controlnet 1)

    controlnet_1

    In ebsynth_utility settings in img2img tab

    Warning : “Weight” in the controlnet settings is overridden by the following values controlnet_option_in_ebsynthutil


    Note 3 : How to use clipseg

    clipseg

    Visit original content creator repository
  • ObfuscateMe

    ObfuscateMe 🔒

    ObfuscateMe Logo

    ObfuscateMe is a very simple APK obfuscator with a graphical user interface (GUI) that helps developers obscure their Android application code by refactoring class names, method names, and field variables. It was developed as part of my undergraduate project at the University of Bedfordshire.

    The GUI allows users to easily select the APK, packages, classes, and methods to obfuscate, making the process more intuitive and user-friendly.

    The goal is to make reverse engineering more difficult by renaming sensitive parts of the APK code, making it harder for unauthorized parties to understand the logic behind the app. Although it’s simple and easy to use, it also provides flexible options for obfuscation and blacklisting specific parts of the code from obfuscation.


    Features ✨

    • APK Decompilation 🔍: Decompile APK files into readable smali code.
    • Obfuscation 🔏🌀: Refactor class names, method names, and field variables for enhanced security.
    • Blacklisting⚫📋/Whitelisting⚪📋: Select packages, classes, or methods that should not be obfuscated.
    • Recompilation & Signing 🔄🔐: Recompile the APK and sign it after obfuscation, ready for distribution.

    Usage 📖

    1. Select APK File: Choose the APK you want to obfuscate.

    2. Select Packages: Use the graphical interface to select the packages that should be included in the obfuscation process. You can review the available packages in your APK and make selections easily.

    3. Choose Obfuscation Options:

      • You can choose to obfuscate:
        • Classes
        • Methods
        • Field Variables
      • There are additional options like adding a prefix to obfuscated names or including a dynamic salt to ensure randomness.
    4. Blacklist Selection:
      You can choose specific classes, methods, or fields to exclude from obfuscation:

      • Manage Blacklist/Whitelist: The tool provides a tree view of the APK structure, allowing you to manually select or deselect parts of the code for obfuscation.
      • Class and Method Blacklisting: Entire classes and specific methods can be blacklisted from the obfuscation process to prevent them from being renamed.
    5. Refactoring: After configuring your selections, the tool will refactor the chosen components. It will also generate a mapping file for future reference, showing the original and obfuscated names.

    6. Recompilation & Signing: Once the obfuscation is complete:

      • Recompile the APK.
      • Optionally, sign the APK using either a custom key 🔑 or an auto-generated key to prepare it for distribution.

    Setup 🚀

    You can now download the ObfuscateMe setup from the releases page. The setup file allows for easy installation and execution of the tool. Here’s how to get started:

    1. Download the Latest Release: Head to the releases page and download the latest setup file.

    2. Run the Setup: Follow the installation instructions to install the tool on your machine.

    3. Launch ObfuscateMe: Once installed, you can easily launch ObfuscateMe and start obfuscating your APKs.


    Tools Used 🛠️

    Special thanks to the following tools used in this project:

    • APKTool: For APK decompilation and recompilation.
    • Uber APK Signer: For easy APK signing after the recompilation process.

    Known Issues & Future Improvements 🛠️

    While ObfuscateMe is simple and functional, a few areas require improvements:

    1. Local Variable Obfuscation 🐛: Currently, variables declared within methods are not refactored. This leaves some sections of the code vulnerable.

    2. Method Refactoring Conflicts 🔄: The tool may refactor methods with the same name in different classes, even if one of those classes is blacklisted. A more precise system to avoid refactoring conflicts between different classes is needed.

    3. Performance Enhancements 🐢: As APK sizes grow, refactoring can become slower. Optimizing the tool for larger APKs is part of the future roadmap.


    Screenshots 📸


    Main Class

    Main Class – Decompiling

    Package Selection

    Blacklisting

    Recompile Class

    Recompiling and Signing

    Contribution 🤝

    Feel free to fork the project, submit pull requests, or open issues if you encounter any bugs or have suggestions. I appreciate any contributions that help make ObfuscateMe better!

    Note: Please use NetBeans IDE for development, as the GUI was generated using the NetBeans GUI builder, and it ensures smooth editing and customization of the interface.


    Contact 📧

    For any queries, feel free to contact me:


    License ⚖️

    This project is licensed under the MIT License.


    Final Thoughts 💭

    ObfuscateMe is a great start for simple APK obfuscation needs, and while it still has room for improvement, it provides a solid foundation for anyone looking to protect their Android apps from reverse engineering. Thanks for checking out the project! 😊

    Happy obfuscating! 🔒📱

    Visit original content creator repository
  • hydra_login2f

    hydra_login2f

    hydra_login2f is a secure login provider for ORY Hydra OAuth2
    Server
    . hydra_login2f implements
    two-factor authentication via email.

    Installation

    hydra_login2f can be deployed directly from a docker image. You can
    find a working example in the example/ directory.

    Configuration

    hydra_login2f‘s behavior can be tuned with environment
    variables. Here are the most important settings with their default
    values:

    # The port on which `hydra_login2f` will run.
    PORT=8000
    
    # The path to the login page (ORY Hydra's `OAUTH2_LOGIN_URL`):
    LOGIN_PATH='/login'
    
    # The path to the dummy consent page (ORY Hydra's `OAUTH2_CONSENT_URL`).
    # `hydra_login2f` implements a dummy consent page, which accepts all
    # consent requests unconditionally, without showing any UI to the user.
    # This is sometimes useful, especially during testing.
    CONSENT_PATH='/consent'
    
    # The prefix added the user ID to form the Oauth2 subject field. For
    # example, if SUBJECT_PREFIX='user:', the OAuth2 subject for the user
    # with ID=1234 would be 'user:1234'.
    SUBJECT_PREFIX=''
    
    # Set this to a random, long string. This secret is used only to sign
    # the session cookies which guide the users' experience, and therefore it
    # IS NOT of critical importance to keep this secret safe.
    SECRET_KEY='dummy-secret'
    
    # Set this to the name of your site, as it is known to your users.
    SITE_TITLE='My site name'
    
    # Set this to an URL that tells more about your site.
    ABOUT_URL='https://github.com/epandurski/hydra_login2f'
    
    # Optional URL for a custom CSS style-sheet:
    STYLE_URL=''
    
    # Whether to issue recovery codes to your users for additional security
    # ('True' or 'False'). It is probably a good idea to use recovery codes
    # if the account to your service might be more important to your users
    # than their email account.
    USE_RECOVERY_CODE=True
    
    # Whether to hide the "remember me" checkbox from users. If this is set to
    # `True`, the "remember me" checkbox will not be shown. This might be useful
    # when saving the login credentials poses a risk.
    HIDE_REMEMBER_ME_CHECKBOX=False
    
    # Set this to the URL for ORY Hydra's admin API.
    HYDRA_ADMIN_URL='http://hydra:4445'
    
    # Set this to the URL for your Redis server instance. It is highly
    # recommended that your Redis instance is backed by disk storage. If not so,
    # your users might be inconvenienced when your Redis instace is restarted.
    REDIS_URL='redis://localhost:6379/0'
    
    # Set this to the URL for your SQL database server instance. PostgreSQL
    # and MySQL are supported out of the box. Example URLs:
    # - postgresql://user:pass@servername/dbname
    # - mysql+mysqlconnector://user:pass@servername/dbname
    SQLALCHEMY_DATABASE_URI=''
    
    # The size of the database connection pool. If not set, defaults to the
    # engine’s default (usually 5).
    SQLALCHEMY_POOL_SIZE=None
    
    # Controls the number of connections that can be created after the pool
    # reached its maximum size (`SQLALCHEMY_POOL_SIZE`). When those additional
    # connections are returned to the pool, they are disconnected and discarded.
    SQLALCHEMY_MAX_OVERFLOW=None
    
    # Specifies the connection timeout in seconds for the pool.
    SQLALCHEMY_POOL_TIMEOUT=None
    
    # The number of seconds after which a connection is automatically recycled.
    # This is required for MySQL, which removes connections after 8 hours idle
    # by default. It will be automatically set to 2 hours if MySQL is used.
    # Some backends may use a different default timeout value (MariaDB, for
    # example).
    SQLALCHEMY_POOL_RECYCLE=None
    
    # SMTP server connection parameters. You should set `MAIL_DEFAULT_SENDER`
    # to the email address from which you send your outgoing emails to users,
    # "My Site Name <no-reply@my-site.com>" for example.
    MAIL_SERVER='localhost'
    MAIL_PORT=25
    MAIL_USE_TLS=False
    MAIL_USE_SSL=False
    MAIL_USERNAME=None
    MAIL_PASSWORD=None
    MAIL_DEFAULT_SENDER=None
    
    # Parameters for Google reCAPTCHA 2. You should obtain your own public/private
    # key pair from www.google.com/recaptcha, and put it here.
    RECAPTCHA_PUBLIC_KEY='6Lc902MUAAAAAJL22lcbpY3fvg3j4LSERDDQYe37'
    RECAPTCHA_PIVATE_KEY='6Lc902MUAAAAAN--r4vUr8Vr7MU1PF16D9k2Ds9Q'
    
    # Set this to the number of worker processes for handling requests -- a
    # positive integer generally in the 2-4 * $NUM_CORES range.
    GUNICORN_WORKERS=2
    
    # Set this to the number of worker threads for handling requests. (Runs
    # each worker with the specified number of threads.)
    GUNICORN_THREADS=1

    Visit original content creator repository

  • RamanSpecCalibration

    RamanSpecCalibration

    Link to the article | DOI


    This work has been published in the following article:
    Toward standardization of Raman spectroscopy: Accurate wavenumber and intensity calibration using rotational Raman spectra of H2, HD, D2, and vibration–rotation spectrum of O2
    Ankit Raj, Chihiro Kato, Henryk A. Witek and Hiro‐o Hamaguchi
    Journal of Raman Spectroscopy
    10.1002/jrs.5955


    Set of functions in Python and IgorPro’s scripting language for the wavenumber calibration (x-axis) and intensity calibration (or correction of wavelength dependent sensitivity, i.e. y-axis) of Raman spectra. This repository requires the data on the rotational state (J), frequency, and the measured rotational Raman intensities from H2, HD, D2 and O2. Programs in Python and IgorPro are independent and perform the same job.

    • For wavenumber calibration, the pixel positions with error of rotational Raman bands from H2, HD, D2 and rotation-vibration bands from O2 are required, which can be obtained from band fitting. The code does Weighted Orthogonal Distance Regression (weighted ODR) for fitting x-y data pair ( corresponding to pixel – reference wavenumber), both having uncertainties, with a polynomial. Output are the obtained wavenumber axis from fit and an estimate of error.

    • For intensity calibration, the main scheme of the code is for the non-linear weighted minimization to obtain coefficients for a polynomial which represents the wavelength dependent sensitivity. The output is a curve extrapolated to same dimension as required by user for intensity calibration. An independent validation of the obtained sensitivity should be done for a measure of accuracy.


    Why we are doing this?

    Intensity calibration

    In any Raman spectrometer, light scattered by the molecules travels to the detector while passing through/by some optical components (for example, lens, mirrors, grating, etc..) In this process, the scattered light intensity is modulated by the non-uniform reflectance/transmission of the optical components. Reflectance and transmission of the optics are wavenumber dependent. The net modulation to the light intensity, defined as M(ν), over the studied spectral range can be expressed as product(s) of the wavenumber dependent performance of the ith optical element as

    Here, ci is a coefficient and wi(ν) is the wavenumber dependent transmission or reflectance of the ith optical component.

    In most cases, determining the individual performance of each optical element is a cumbersome task. Hence, we limit our focus to approximately determine the relative form of M(ν), from experimental data. By relative form, it is meant that M(ν) is normalized to unity within the studied spectral range. If M(ν) is known, then we can correct the observed intensities in the Raman spectrum by dividing those by M(ν). In general, this is the principle of all intensity calibration procedure in optical spectroscopy.

    In our work, we assume M(ν) ≅ C1(ν) C2(ν) / C0(ν) [The wavenumber dependence in not explicitly stated when C0, C1 and C2 are discussed in the following text. ] The three contributions, C0(ν) to C2(ν) are determined in two steps in this analysis.

    • In the first step, (C0 / C1) correction are determined using the wavenumber axis and the spectrum of a broad band white light source. (See example)
    • C2 is determined from the observed Raman intensities, where the reference or true intensities are known or can be computed. This can be done using (i) pure-rotational Raman bands of molecular hydrogen and isotopologues, (ii) vibration-rotation Raman bands of the same gases and (iii) vibrational Raman bands of some liquids.

    The multiplicative correction to the Raman spectrum for intensity calibration is then : (C0 / C1C2)

    The present work is concerned with the anti-Stokes and Stokes region (from -1100 to 1650 cm-1). For a similar analysis for the higher wavenumber region (from 2300 to 4200 cm-1) see this repository and article.


    Method

    Wavenumber calibration : Fit of the reference transition wavenumbers against the band position in pixels is performed to obtain the wavenumber axis(relative).

    • S. B. Kim, R. M. Hammaker, W. G. Fateley, Appl. Spectrosc. 1986, 40, 412.
    • H. Hamaguchi, Appl. Spectrosc. Rev. 1988, 24, 137.
    • R. L. McCreery, Raman Spectroscopy for Chemical Analysis, John Wiley & Sons, New York, 2000.
    • N. C. Craig, I. W. Levin, Appl. Spectrosc. 1979, 33, 475.

    Intensity calibration : Ratio of intensities from common rotational states are compared to the corresponding theoretical ratio to obtain the wavelength dependent sensitivity curve.

    • H. Okajima, H. Hamaguchi, J. Raman Spectrosc. 2015, 46, 1140. (10.1002/jrs.4731)
    • H. Hamaguchi, I. Harada, T. Shimanouchi, Chem. Lett. 1974, 3, 1405. (cl.1974.1405)

    Input data required

    Wavenumber calibration

    • List of band positions and error (in pixels) of rotational Raman spectra of H2, HD, D2 and rotational-vibrational Raman spectra of O2.

    Intensity calibration

    • List of all data required : rotational state (J), experimental band area ratio (Stokes/ anti-Stokes), theoretical band area ratio (Stokes/anti-Stokes), transition frequency (Stokes) in cm-1, transition frequency (anti-Stokes) in cm-1 and the weight (used for fit). For O2, when using the vibration-rotation transitions (S1- and O1-branch), include the data and the frequencies for these transitions. All of the above correspond to pair of observed bands originating from a common rotational state.

    See specific program’s readme regarding the use of the above data in the program for fit.

    Available programs

    • Set of Igor Procedures
    • A Python module for performing non-linear fit on the above mentioned data set to obtain the wavelength dependent sensitivity.

    Additionally, programs to compute the theoretical pure rotational Raman spectra (for H2, HD and D2) are also included.

    Usage

    Clone the repository or download the zip file. As per your choice of the programming environment ( Python or IgorPro) refer to the specific README inside the folders and proceed.

    Comments

    • On convergence of the minimization scheme in intensity calibration : The convergence of the optimization has been tested with artificial and actual data giving expected results. However, in certain cases convergence in the minimization may not be achieved based on the specific data set and the error in the intensity.

    • Accuracy of the calibration : It is highly suggested to perform an independent validation of the intensity calibration. This validation can be using anti-Stokes to Stokes intensity for determining the sample’s temperature (for checking the accuracy of wavelength sensitivity correction) and calculating the depolarization ratio from spectra (for checking the polarization dependent sensitivity correction). New ideas regarding testing the validity of intensity calibration are welcome. Please give comments in the “Issues” section of this repository.

    Credits

    Non-linear optimization in SciPy : Travis E. Oliphant. Python for Scientific Computing, Computing in Science & Engineering, 9, 10-20 (2007), DOI:10.1109/MCSE.2007.58

    Matplotlib : J. D. Hunter, “Matplotlib: A 2D Graphics Environment”, Computing in Science & Engineering, vol. 9, no. 3, pp. 90-95, 2007.

    Orthogonal Distance Regression as used in IgorPro and SciPy : (i) P. T. Boggs, R. Byrd, R. Schnabel, SIAM J. Sci. Comput. 1987, 8, 1052. (ii) P. T. Boggs, J. R. Donaldson, R. h. Byrd, R. B. Schnabel, ACM Trans. Math. Softw. 1989, 15, 348. (iii) J. W. Zwolak, P. T. Boggs, L. T. Watson, ACM Trans. Math. Softw. 2007, 33, 27. (iv) P. T. Boggs and J. E. Rogers, “Orthogonal Distance Regression,” in “Statistical analysis of measurement error models and applications: proceedings of the AMS-IMS-SIAM joint summer research conference held June 10-16, 1989,” Contemporary Mathematics, vol. 112, pg. 186, 1990.

    Support/Questions/Issues

    Please use “Issues” section for asking questions and reporting issues.


    This work has been published in the following article:
    Toward standardization of Raman spectroscopy: Accurate wavenumber and intensity calibration using rotational Raman spectra of H2, HD, D2, and vibration–rotation spectrum of O2
    Ankit Raj, Chihiro Kato, Henryk A. Witek and Hiro‐o Hamaguchi
    Journal of Raman Spectroscopy
    10.1002/jrs.5955


    Other repositories on this topic :

    The present repository is concerned with the anti-Stokes and Stokes region spanning from -1040 to 1700 cm-1 using H2, HD, D2 and O2. In a different work, spectral region in the higher wavenumber(from 2300 to 4200 cm-1) was investigated.

    Accurate intensity calibration of multichannel spectrometers using Raman intensity ratios
    Ankit Raj, Chihiro Kato, Henryk A. Witek and Hiro‐o Hamaguchi
    Journal of Raman Spectroscopy
    10.1002/jrs.6221

    See online repository IntensityCalbr and the above article (JRS.6221) for more details.

    Visit original content creator repository
  • chroma-zh

    alecthomas/chroma explain translate-svg

    「 纯 Go 中的通用语法高亮显示器 」

    中文 | english


    校对 ✅

    翻译的原文 与日期 最新更新 更多
    commit ⏰ 2018-10-21 last 中文翻译

    贡献

    欢迎 👏 勘误/校对/更新贡献 😊 具体贡献请看

    生活

    If help, buy me coffee —— 营养跟不上了,给我来瓶营养快线吧! 💰


    Chroma – 纯 Go 中的通用语法高亮显示器 Build Status Gitter chat

    **注意:**由于 Chroma 刚刚发布,其 API 仍在不断变化.也就是说,高级接口应该不会发生太大变化.

    Chroma 采用源码和其他结构的文本,将其转换为语法高亮的 HTML,ANSI 色彩文本等.

    Chroma 很大程度上依赖于Pygments :python,包括 Pygments 的词法分析器-lexers样式-styles的转移.

    目录

    支持的语言

    字首 语言
    A ABNF, ActionScript, ActionScript 3, Ada, Angular2, ANTLR, ApacheConf, APL, AppleScript, Awk
    B Ballerina, Base Makefile, Bash, Batchfile, BlitzBasic, BNF, Brainfuck
    C C, C#, C++, Cassandra CQL, CFEngine3, cfstatement/ColdFusion, CMake, COBOL, CSS, Cap’n Proto, Ceylon, ChaiScript, Cheetah, Clojure, CoffeeScript, Common Lisp, Coq, Crystal, Cython
    D Dart, Diff, Django/Jinja, Docker, DTD
    E EBNF, Elixir, Elm, EmacsLisp, Erlang
    F Factor, Fish, Forth, Fortran, FSharp
    G GAS, GDScript, GLSL, Genshi, Genshi HTML, Genshi Text, Gnuplot, Go, Go HTML Template, Go Text Template, Groovy
    H Handlebars, Haskell, Haxe, Hexdump, HTML, HTTP, Hy
    I Idris, INI, Io
    J Java, JavaScript, JSON, Jsx, Julia, Jungle
    K Kotlin
    L Lighttpd configuration file, LLVM, Lua
    M Mako, Markdown, Mason, Mathematica, MiniZinc, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
    N NASM, Newspeak, Nginx configuration file, Nim, Nix
    O Objective-C, OCaml, Octave, OpenSCAD, Org Mode
    P PacmanConf, Perl, PHP, Pig, PkgConfig, Plaintext, PL/pgSQL, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3
    Q QBasic
    R R, Racket, Ragel, reg, reStructuredText, Rexx, Ruby, Rust
    S Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, systemd, Systemverilog
    T TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
    V verilog, VHDL, VimL
    W WDTE
    X XML, Xorg
    Y YAML

    我将保持此部分的更新,但更及时与权威的列表在chroma --list.

    使用库

    与 Pygments 一样,Chroma 具有以下概念词法分析器-lexers,格式化-formatters款式-styles.

    Lexers 将源文本转换为标记流数据,styles 指定相应的标记类型如何映射到颜色,格式化程序将标记和 styles 转换为格式化输出.

    每个概念都有一个包,包含一个全局包Registry,其中具有所有已注册实现的变量。还有一些辅助函数可以让每个包都能使用注册表,例如按名称查找词法分析器,或匹配文件名等.

    在所有情况下,如果无法确定词法分析器,格式化程序或样式,nil将返回。在这种情况下,您可能希望默认为每个包中的Fallback值,此提供合理的默认值.

    让我们快速开始

    存在一个便利功能,可以用来简单格式一些源文本,而不需要任何努力:

    err := quick.Highlight(os.Stdout, someSourceCode, "go", "html", "monokai")

    识别语言

    要高亮代码,首先必须确定编写代码的语言.有三种主要方法:

    1. 从文件名中检测语言.

      lexer := lexers.Match("foo.go")
    2. 通过其 Chroma 语法 ID 明确指定语言(可从lexers.Names()中获取完整列表).

      lexer := lexers.Get("go")
    3. 从其内容中,分析语言.

      lexer := lexers.Analyse("package main\n\nfunc main()\n{\n}\n")

    在所有情况下,如果语言无法识别,返回一个nil.

    if lexer == nil {
      lexer = lexers.Fallback
    }

    在这一点上,应该指出一些词法分析者可能不尽如人意。为了缓解这种情况,您可以使用合并词法分析器,将相同标记类型的运行合并到一个标记中:

    lexer = chroma.Coalesce(lexer)

    格式化输出

    识别语言后,您需要选择格式化程序和样式(主题).

    style := styles.Get("swapoff")
    if style == nil {
      style = styles.Fallback
    }
    formatter := formatters.Get("html")
    if formatter == nil {
      formatter = formatters.Fallback
    }

    然后获取Token-标记上的迭代器:

    contents, err := ioutil.ReadAll(r)
    iterator, err := lexer.Tokenise(nil, string(contents))

    最后,从迭代器格式化标记:

    err := formatter.Format(w, style, iterator)

    HTML 格式化程序

    默认情况下,已注册的html格式化程序会生成带有嵌入式 CSS 的独立 HTML。更多的灵活性可以试试formatters/html包.

    首先,可以使用以下构造函数选项,自定义格式化程序生成的输出:

    • Standalone()– 使用嵌入式 CSS 生成独立 HTML.
    • WithClasses()– 使用类,而不是内联样式属性.
    • ClassPrefix(prefix)– 为每个生成的 CSS 类添加前缀.
    • TabWidth(width)– 以字符为单位设置渲染的标签宽度.
    • WithLineNumbers()– 渲染行号(LineNumbers样式).
    • HighlightLines(ranges)– 突出显示这些范围内的线条(LineHighlight样式).
    • LineNumbersInTable()– 使用table,来格式化行号和代码,而不是 span.

    如果是使用WithClasses(),可以从格式化程序中,获取相应的 CSS:

    formatter := html.New(html.WithClasses())
    err := formatter.WriteCSS(w, style)

    更多详情

    Lexers-词法分析器

    Pygments 文档有关实施词法分析器的详细信息.大多数概念直接适用于 Chroma,但请参阅现有的 lexer 实现,以获取实际示例.

    在许多情况下,可以使用附带的 Python 3 脚本pygments2chroma.py直接从 Pygments 那里,自动转换词法分析器。如下:

    python3 ~/Projects/chroma/_tools/pygments2chroma.py \
      pygments.lexers.jvm.KotlinLexer \
      > ~/Projects/chroma/lexers/kotlin.go \
      && gofmt -s -w ~/Projects/chroma/lexers/*.go
    

    pygments-lexers.go的笔记,其记录了有关词法分析器的列表,以及有关导入它们的一些问题的说明.

    格式化程序

    Chroma 支持 HTML 输出,以及 8 色,256 色和真彩色的终端输出.

    一个noop仅包含,输出标记文本的格式化程序,以及 一个tokensformatter 输出原始标记。后者对调试词法分析器非常有用.

    样式

    Chroma styles使用与Pygments相同的语法.

    所有 Pygments 样式都被_tools/style.py脚本转换为 Chroma的了.

    有关可用样式,及其外观的简易概述,请查看Chroma 主题画廊.

    命令行界面

    包括 Chroma 的命令行界面.它可以安装:

    go get -u github.com/alecthomas/chroma/cmd/chroma
    

    与 Pygments 相比有什么缺失?

    • 由于各种原因(欢迎提出请求),其中相当多的lexers:
      • Pygments对 复杂语言的词法分析器,通常包含处理某些方面的自定义代码,例如 Perl6 在正则表达式中嵌套代码的能力。这需要时间和精力来转换.
      • 我大多只转换我听过的语言,以降低移植成本.
    • 为简单起见,省略了 Pygments 的一些太深奥的功能.
    • 虽然 Chroma API 支持内容检测,但仅有少有语言支持。我计划在哪个时候实现一个统计分析仪,但时间不够.
    Visit original content creator repository
  • vlsi-release-plugins

    CI Status

    About

    This is a set of Gradle plugins to simplify release tasks

    Gradle version compatibilty

    • 3.x requires Gradle 7.2, Kotlin 1.5, Java 8
    • 2.x requires Gradle 4.1, Kotlin 1.4, Java 8
    • 1.x requires Gradle 4.1, Kotlin 1.4, Java 8

    Checksum Dependency Plugin

    Enables to validate the checksums of the project dependencies (both plugins and regular dependencies). Note: this plugin has nothing to do with generating checksums. What it does it prevents man-in-the middle attack by enabling developers to declare the expected checksums.

    See checksum-dependency-plugin description for installation and configuration options.

    Jandex Gradle Plugin

    Allows building Jandex class index. An alternative use case is verification of the class files: if jandex fails to parse the file, then the bytecode might be invalid.

    See jandex-plugin description for configuration options.

    Stage Vote Release Plugin

    Enables to stage and vote on release artifacts before they are released.

    See stage-vote-release-plugin description for configuration options.

    Gradle Extensions Plugin

    See gradle-extensions-plugin description for configuration options.

    Enables to access Project properties in a type-safe way:

    val skipJavadoc by props()     // defaults to false
    val enableTests by props(true) // defaults to true
    val hello by props("world")    // defaults to "world"
    if (project.props.bool("isOk", default=true)) { ... }

    It improves test output and build failures as well: Sample GitHub Actions log that shows test results highlighting

    CRLF Plugin

    Adds Kotlin DSL to specify CRLF/LF filtering for CopySpec. Enables to use .gitignore and .gitattributes for building CopySpec.

    See crlf-plugin description for configuration options.

    IDE Plugin

    • Configures copyright profile
    • Configures “generated sources”
    • Enables to configure “post import” tasks (== call task on project import to generate sources)

    License Gather Plugin

    The purpose of the plugin is to analyze and infer license names for the dependencies, and verify license compatibility.

    See license-gather-plugin description for configuration options.

    Gettext Plugin

    The plugin adds the following task classes to execute GNU gettext binaries:

    • GettextTask collects messages from the source files into .pot
    • MsgAttribTask processes .po files (e.g. for removal of obsolete messages)
    • MsgMergeTask updates .po files with missing messages from .pot
    • MsgFmtTask generates the resource bundle (e.g. Java source files for the resources)

    License

    This library is distributed under terms of Apache License 2.0

    Change log

    v1.90

    • stage-vote-release: generate and publish checksums to SVN even if release artifact is UP-TO-DATE (regression since 1.75)
    • stage-vote-release: added previewSvnDist task to preview SVN dist contents without publishing it

    v1.89

    • checksum-dependency: reduce the number of idle threads
    • crlf: ignore inaccessible files/folders in gitignore filter

    v1.88

    • stage-vote-release: avoid failures when “init” does not exist
    • chore: fixed build warnings
    • checksum-dependency: infer artifact classifier from the file name
    • checksum-dependency: copy requested attributes to the configuration that resolves PGP signatures

    v1.87

    • gradle-extensions: requiredString, requiredBool, requiredInt, requiredLong property accessors
    • gradle-extensions: display TestNG initialization failures

    Thanks to Endor H for contributing.

    v1.86

    • checksum-dependency: use full fingerprint for PGP verification

    v1.85

    • licence-gather: better support for build cache by adding PathSensitivity
    • checksum-dependency: cache PGP public keys under %{ROOT_DIR}/gradle/checksum-dependency-plugin/cached-pgp-keys
    • checksum-dependency: bump org.bouncycastle:bcpg-jdk15on to 1.70

    v1.84

    • no-op release, since some of the plugins failed to publish to Gradle Plugin Portal in v1.83

    v1.83

    • stage-vote-release: bump grgit to 4.1.1

    v1.82

    • gradle-extensions: render class name for JUnit4 parameterized tests with several test methods (they treated as suites in Gradle 7)

    v1.81

    • jandex: add @IgnoreEmptyDirectories to fix Gradle 7 warning
    • gettext: add @IgnoreEmptyDirectories to fix Gradle 7 warning

    v1.80

    • license-gather: use META-INF/licenses/$group/$module-$version for storing license files in jar
    • jandex: support Gradle Configuration Cache

    v1.79

    • license-gather: avoid generating directories that end with .jar to workaround OpenJDK’s JarIndex issue

    v1.78

    • chore: bump Gradle 6.7 -> 6.9.1
    • license-gather: ignore xml namespaces when parsing POM files (see issue #43)
    • license-gather: fix license inference from Bundle-License manifest attribute (see issue #48)
    • license-gather: implement VerifyLicenseCompatibilityTask for verifying license compatibility (see pr #49)
    • checksum-dependency: retrieve keys from https://keyserver.ubuntu.com, and https://keys.openpgp.org by default (drop SKS keyserver pool since it has been deprecated)

    Thanks to Florian Dreier for identifying bugs and suggesting fixes.

    v1.77

    • crlf-plugin: bump jgit to 5.13.0.202109080827-r
    • stage-vote-release: bump jgit to 5.13.0.202109080827-r

    v1.76

    • jandex-plugin: workaround warnings with forbiddenApis and compileTestJava

    v1.75

    • crlf-plugin: remove input specification from FindGitAttributes task properties to workaround non-declared task dependency warning (see gradle/gradle#18882)
    • license-gather-plugin: support jars that have both /LICENSE and /META-INF/LICENSE files
    • gradle-extensions: avoid printing stacktrace when Kotlin compilation fails
    • gradle-extensions: avoid printing stacktraces for autostyle failures
    • stage-vote-release: use task.state instead of archiveFile.exists() to skip sha512 and sign tasks
    • jandex-plugin: add dependency for javadoc and sourcesJar tasks on processJandexIndex

    v1.74

    • checksum-dependency: skip checksum verification when artifact resolves to a directory
    • stage-vote-release: add workaround for Gradle 7.0 compatibility (see gradle/gradle#16777)

    v1.73

    • jandex-plugin: fixed “Task with name ‘check’ not found” when the plugin is applied with plugins { ... }

    v1.72

    • jandex-plugin: add maxErrors option to show several errors rather than stop on the first one
    • gradle-extensions-plugin: fix output of exceptions with multiple nested suppressed exceptions

    v1.71

    • Add CI jobs with nightly and RC Gradle versions
    • jandex-plugin: build class file index via Jandex or verify the bytecode

    v1.70

    • stage-vote-release: fix Gradle 6.0 warnings

    v1.69

    • license-gather-plugin: fix ignoreMissingLicenseFor annotations

    v1.68

    • license-gather-plugin: remove @Internal annotation from ignoreMissingLicenseFor

    v1.67 Same as 1.66 (re-published because 1.66 artifacts were corrupted by Gradle Plugin Portal issue)

    v1.66

    • gradle-extensions-plugin: MavenPom.simplifyXml() to trim scope=compile and dependencyManagement from pom.xml
    • gradle-extensions-plugin: MavenPublication.versionFromResolution() to map versions in pom.xml to Gradle resolution results
    • gradle-extensions-plugin: Project.extraMavenPublications() to add extra Maven publications (e.g. publish shadow jar)

    v1.65

    • stage-vote-release-plugin: add nexus.connectTimeout and nexus.operationTimeout with default of 15 minutes (Maven Central is slow at times)
    • stage-vote-release-plugin: create rc and release tags only after artifacts are pushed to Nexus (e.g. if javadoc build fails, the tag is not required)
    • gradle-extensions-plugin: skip stacktrace for TaskSelectionException issue#35

    v1.64

    • stage-vote-release-plugin: upate nexus-staging 0.2.0 -> 0.4.0; gradle-nexus-staging-plugin 0.20.0 -> 0.21.2
    • update jgit: 5.6.0.201912101111-r -> 5.6.1.202002131546-r
    • update grgit: 3.1.1 -> 4.0.1

    v1.63

    • gradle-extensions-plugin: refine condition for stacktrace printing

    v1.62

    • gradle-extensions-plugin: add DomainObjectCollection.configureEach<T> extension
    • gradle-extensions-plugin: reduce verbosity of the default exception printer (print only well-known exceptions and stacktraces by default like NPE)
    • stage-vote-release-plugin: refine -Prc input parameter validation
    • license-gather-plugin: refine Apache2LicenseRenderer to render custom licenses
    • all plugins: publish to Maven Central with PGP signatures

    v1.61

    • gradle-extensions-plugin: significantly improve stacktrace formatting, add task failure summary
    • checksum-dependency-plugin: removed http://keys.fedoraproject.org/ from keyserver list as it no longer works

    v1.60

    • gradle-extensions-plugin: add GitHub Actions error markers to test output
    • gettext-plugin: cleanup Gradle annotations

    v1.59

    • Skipped

    v1.58

    • gradle-extensions-plugin: enable coloring in test results by default (-Pnocolor, -Pnocolor=true|false)

    v1.57

    • Add gettext-plugin
    • Add Test.printTestResults (print test results, color output) function to gradle-extensions-plugin

    v1.56

    • Skipped

    v1.55

    • Build with Gradle 6.1.1

    v1.54

    • Replace Spotless -> Autostyle for simpler code style management
    • Update org.eclipse.jgit: 5.4 -> 5.6
    • stage-vote-release-plugin: fix race condition in nexus-publish afterEvaluate: provide username/password always
    • stage-vote-release-plugin: generate description for nexus staging repository
    • ide-plugin: update gradle-idea-ext: 0.5 -> 0.7

    v1.53

    • stage-vote-release-plugin: expose NexusConfig#mavenCentral to enable publishing to Central

    v1.52

    • stage-vote-release-plugin: integrate signing, and support skipSign and useGpgCmd properties

    v1.51

    • stage-vote-release-plugin: expose releaseParams.svnDistEnabled to skip SVN publication
    • stage-vote-release-plugin: publish Git tag after publishing Nexus and SVN

    v1.50

    • stage-vote-release-plugin: expose releaseParams.gitRepoName to customize Git repository name

    v1.49.0

    • gradle-extensions-plugin: expose Project.props(Int), props(Long), props.string(…), props.int(…), props.long(…)
    • gradle-extensions-plugin: change Project.lastEditYear to find the maximum 4-digit integer
    • ide-plugin: expose ide.licenseHeader, ide.licenseHeaderJava, and ide.copyright(…). Fix default ASF copyright

    v1.48.0

    • stage-vote-release-plugin: workaround publishDist issue when SVN 1.9 is used

    v1.47.0

    • gradle-extensions-plugin: plugin for type-safe Project property access in build.gradle.kts

    v1.46.0

    • stage-vote-release-plugin: avoid failures in pushPreviewSite on Gradle version upgrade
    • stage-vote-release-plugin: allow uncommitted changes for generateVoteText / publishDist
    • crlf-plugin: fix handling of .gitignore files in subfolders

    v1.45.0

    • stage-vote-release-plugin: preserve **/.git/** in syncPreviewSiteRepo
    • stage-vote-release-plugin: avoid NPE in GitPushTask when pushing new tag
    • stage-vote-release-plugin: avoid rebuilding artifacts for generateVoteText/publishDist (fetch files from SVN dist)
    • ide-plugin: support generatedJavaSources for different sourceSets (main, test)
    • license-gather-plugin: use Gradle 7-compatible API workerExecutor.noIsolation instead of .submit

    v1.44.0

    • stage-vote-release-plugin: disable automatic execution of removeStaleArtifacts when publishing the release

    v1.43.0

    • stage-vote-release-plugin: support Gradle 6.0

    v1.42.0

    • stage-vote-release-plugin: fix logging in RemoveStaleArtifactsTask

    v1.41.0

    • stage-vote-release-plugin: implement removeStaleArtifacts task to cleanup dist.apache.org
    • stage-vote-release-plugin: hide technical tasks
    • stage-vote-release-plugin: improve logging in GitPushTask
    • stage-vote-release-plugin: detect “stage SVN revision”

    v1.40.0

    • stage-vote-release-plugin: avoid including artifact name in ReleaseArtifact.getSha512

    v1.39.0

    • stage-vote-release-plugin: validate asfTest…Username and asfTest…Password properties

    v1.38.0

    • stage-vote-release-plugin: release tag should be created for release candidate commit, not the current HEAD

    v1.37.0

    • stage-vote-release-plugin: execute sha512 and signing tasks only when input files exist

    v1.36.0

    • checksum-dependency-plugin: use MD5SUM format for .sha512 files so the checkums can be verified with shasum -c *.sha512

    v1.35.0

    v1.34.0

    • crlf-plugin: proper support of absolute paths in non-root gitignore files

    v1.33.0

    • checksum-dependency-plugin: reduce verbosity by using the actual duration of “PGP key retrieval” to decide if the timeout is loggable or not
    • stage-vote-release-plugin: treat generateVoteText as non-incremental task (avoid caching of the mails between rc1, rc2, and so on)
    • stage-vote-release-plugin: skip SHA-512 computation when the original artifact task is skipped

    v1.32.0

    • stage-vote-release-plugin: add releaseArtifacts {…} extension to pass artifacts across Gradle’s modules
    • stage-vote-release-plugin: validate Git username/password before release starts

    v1.31.0

    • checksum-dependency-plugin: added pgpMinLoggableTimeout (default 4 seconds) to reduce the verbosity of the plugin
    • checksum-dependency-plugin: added checksumUpdateAll property for simplified checksum.xml update without build failure

    v1.30.0

    • checksum-dependency-plugin: show PGP signature resolution time (#21)
    • checksum-dependency-plugin: disable verification when dependencyUpdates task is present on the task execution graph (#20)

    v1.29.0

    • checksum-dependency-plugin: resolve and verify PGP in parallel, compute SHA in parallel

    v1.28.0

    • checksum-dependency-plugin: fix resolution of copied configurations (== fix compatibility with https://github.com/ben-manes/gradle-versions-plugin)
    • checksum-dependency-plugin: add checksumIgnore property for disabling the plugin (e.g. when certain tasks are not compatible with verification)

    v1.27.0

    • checksum-dependency-plugin: support Gradle 4.4.1

    v1.26.0

    • checksum-dependency-plugin: fix logging for “PGP key…download time: 0ms”

    v1.24.0

    • checksum-dependency-plugin: failover across multiple keyservers and DNS responses

    v1.23.0

    • checksum-dependency-plugin: support Gradle 4.10.2

    v1.22.0

    • checksum-dependency-plugin: add <ignored-keys> to prevent resolution of known to be absent keys

    v1.21.0

    v1.20.0

    • checksum-dependency-plugin: properly track .pom artifacts (and other non-jar artifacts with default classifier)

    v1.19.0

    • checksum-dependency-plugin: include classifier and extension to artifact key

    v1.18.0

    • checksum-dependency-plugin: improve logging

    v1.17.0

    • checksum-dependency-plugin: new plugin to verify the downloaded dependencies on resolution
    • all plugins: remove Implementation-Version manifest attribute to make jars have consistent checksums across versions
    • stage-vote-release-plugin: make sitePreviewEnabled configurable via property

    v1.16.0

    • stage-vote-release-plugin: make -Prc optional for pushPreviewSite

    v1.15.0

    • stage-vote-release-plugin: validate Git credentials
    • stage-vote-release-plugin: use $it-site.git and $it-site-preview.git name conventions

    v1.14.0

    • stage-vote-release-plugin: use property value instead of name for Git credentials

    v1.13.0

    • stage-vote-release-plugin: allow to publish to AFF repository via -Pasf

    v1.12.0

    • Add .editorconfig
    • stage-vote-release-plugin: take RepositoryType.PROD/TEST from “asf” property
    • stage-vote-release-plugin: add releaseParams.rc, releaseParams.release and releaseParams.committerId properties
    • stage-vote-release-plugin: add GitCreateTagTask, GitPushTask
    • stage-vote-release-plugin: add option to automatically generate SHA512
    • stage-vote-release-plugin: allow to select between GitHub and GitBox push alternatives
    • stage-vote-release-plugin: add pre-release validations
    • stage-vote-release-plugin: create and push RC and Release tags
    • stage-vote-release-plugin: add ReleaseExtension#componentName (a sub-component under TLP)
    • stage-vote-release-plugin: load stagingRepositoryId for release task
    • stage-vote-release-plugin: avoid parallel execution of initializeNexusStagingRepository to improve task concurrency
    • ide-plugin: support generatedSources in Eclipse
    • license-gather-plugin: exclude txt-based licenses from the jar to save some space

    v1.11.0

    • stage-vote-release-plugin: require Nexus username/password only when release task is used

    v1.10.0

    • stage-vote-release-plugin: fix asfSvnUsername should be used instead of asfasfSvnUsername

    v1.9.0

    • stage-vote-release-plugin: properly support username/password for Nexus and SVN
    • stage-vote-release-plugin: make sitePreview optional

    v1.8.0

    • stage-vote-release-plugin: add ReleaseExtension#validateReleaseParams(Runnable) to enable fail-fast on releasing SNAPSHOT versions

    v1.7.0

    • crlf-plugin: add CrLfSpec { CopySpec.textAuto() } for simplified handling of text files

    v1.6.0

    • license-gather-plugin: build “predict license by text” model at the build time

    v1.5.0

    • stage-vote-release-plugin: Project.licensesCopySpec includes NOTICE and license by default

    v1.3.0

    • Move gitattributes and gitignore to crlf plugin (from stage-vote-release-plugin)
    • Add workaround for gradle/gradle#1191 (Copy tasks do not consider filter/eachFile/expansion properties in up-to-date checks)

    v1.2.0

    • stage-vote-release-plugin: support .gitignore and .gitattributes in building CopySpec

    v1.0.0

    • Initial release: basic license gathering

    Author

    Vladimir Sitnikov sitnikov.vladimir@gmail.com

    Visit original content creator repository