### Basic CMake Project Setup Source: https://github.com/github-linguist/linguist/blob/main/samples/CMake/filenames/CMakeLists.txt This snippet demonstrates the fundamental structure of a CMakeLists.txt file. It sets the minimum CMake version, defines the project name, configures installation paths, includes subdirectories, builds an executable, links a library, and specifies installation rules. ```cmake cmake_minimum_required(VERSION 2.8) project(Foo) set(CMAKE_SKIP_RPATH TRUE) set(CMAKE_INSTALL_PREFIX "/usr/local") add_subdirectory(bar) add_executable(foo foo.c) target_link_libraries(foo pthread) install(TARGETS foo DESTINATION bin) ``` -------------------------------- ### Install org-ruby Gem Source: https://github.com/github-linguist/linguist/blob/main/samples/Org/org.org Install the org-ruby gem using the standard RubyGems command. ```bash sudo gem install org-ruby ``` -------------------------------- ### Bootstrap Development Environment Source: https://github.com/github-linguist/linguist/blob/main/AGENTS.md Run this script to install dependencies and set up the local development environment for Linguist. ```bash script/bootstrap ``` -------------------------------- ### Program Execution and Setup Source: https://github.com/github-linguist/linguist/blob/main/samples/TI Program/srcalpha.8xp.txt Initiates program execution and sets up the display environment. Includes conditional logic for program updates. ```Assembly Goto SET prgmSRCFUNC prgmSRCGUI prgmSRCSORT Lbl SET .start, set up ClrDraw StoreGDB DiagnosticOff Fix 5 Full !If GetCalc(Str1,[Y1]) sub(NEW) StoreGDB End GetCalc(Str1,[Y1]) If {[Y1]+0} !If sub(CODE) Goto END End End Asm(FDCB249E) If {[Y1]+6} Asm(FDCB24DE) End Goto DLIST ``` -------------------------------- ### Install pkgdown from GitHub Source: https://github.com/github-linguist/linguist/blob/main/samples/HTML/pkgdown.html Install the development version of pkgdown directly from its GitHub repository using devtools. ```r devtools::install_github("r-lib/pkgdown") ``` -------------------------------- ### Develop SciPy with Symlink Install Source: https://github.com/github-linguist/linguist/blob/main/samples/reStructuredText/HACKING.rst.txt Use `setupegg.py develop` for a symlink install, which is an alternative to modifying PYTHONPATH. This method integrates the development version into your Python environment. ```bash python setupegg.py develop --prefix=${HOME} ``` -------------------------------- ### Install Dependencies on Ubuntu Source: https://github.com/github-linguist/linguist/blob/main/CONTRIBUTING.md Installs necessary dependencies for Linguist on Ubuntu systems. This includes build tools, Ruby, and Docker. ```bash apt-get install cmake pkg-config libicu-dev docker.io ruby ruby-dev zlib1g-dev build-essential libssl-dev ``` -------------------------------- ### 72-bit Addition Example Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Demonstrates 72-bit addition using AC1 and AC2 to AC3 and AC4. Requires hardware support for addition. ```assembly ;; add AC1 and AC2 to AC3 and AC4 jfcl 17,.+1 add 2,4 jcry0 [aoja 1,.+1] add 1,3 ; result in AC1 and AC2 ``` -------------------------------- ### Example Breakdown with Strategies Source: https://github.com/github-linguist/linguist/blob/main/README.md This output shows the percentage breakdown of languages and the specific files contributing to each language, along with the detection strategy. ```console 66.84% 264519 Ruby 24.68% 97685 C 6.57% 25999 Go 1.29% 5098 Lex 0.32% 1257 Shell 0.31% 1212 Dockerfile Ruby: Gemfile [Filename] Rakefile [Filename] bin/git-linguist [Extension] bin/github-linguist [Extension] lib/linguist.rb [Extension] … ``` -------------------------------- ### Create Release Branch Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Start by creating a new branch for the release. Replace 'xx.xx.xx' with the desired version number. ```bash git checkout -b release-vxx.xx.xx ``` -------------------------------- ### 72-bit Negation Example Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Performs 72-bit negation. This example shows a method using setcm and movn instructions. ```assembly ;; to self setca 1, jumpe 2,[aoja 1,.+2] movn 2,2 ``` ```assembly ;; conditional negation jumpge 1,.+4 setca 1, jumpe 2,[aoja 1,.+2] movn 2,2 ``` -------------------------------- ### Run SciPy Tests Source: https://github.com/github-linguist/linguist/blob/main/samples/reStructuredText/HACKING.rst.txt Verify the SciPy development setup by running the test suite. This is done by importing SciPy in a Python interpreter and calling the `test()` function. ```python import scipy as sp sp.test() ``` -------------------------------- ### Run Linguist from Repository Source: https://github.com/github-linguist/linguist/blob/main/AGENTS.md Execute Linguist from the repository to get a language breakdown of files. ```bash bundle exec bin/github-linguist --breakdown ``` -------------------------------- ### PowerShell Example Usage Source: https://github.com/github-linguist/linguist/blob/main/test/fixtures/Text/ISO-2022-KR.txt Example of how to use the Out-AnsiGraph function with PowerShell's Get-Process cmdlet. It selects the first 5 processes, sorts them by VM, and then pipes them to Out-AnsiGraph to display ProcessName and VM. ```powershell ps | select -first 5 | sort -property VM | \n Out-AnsiGraph ProcessName, VM ``` -------------------------------- ### Single File Analysis with Gitattributes Confirmation Source: https://github.com/github-linguist/linguist/blob/main/README.md This example shows a single file analysis where the strategy is confirmed by `.gitattributes`, indicating no change in the detected language. ```console .devcontainer/devcontainer.json: 27 lines (27 sloc) type: Text mime type: application/json language: JSON with Comments strategy: Filename (confirmed by .gitattributes) ``` -------------------------------- ### Gitattributes Overrides Example Source: https://github.com/github-linguist/linguist/blob/main/README.md This example demonstrates how `.gitattributes` overrides affect language detection, showing the original strategy and confirmation or override status. ```gitattributes *.ts linguist-language=JavaScript *.js linguist-language=JavaScript ``` -------------------------------- ### 72-bit Subtraction Example Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Demonstrates 72-bit subtraction using AC1 and AC2 from AC3 and AC4. Requires hardware support for subtraction. ```assembly ;; add AC1 and AC2 to AC3 and AC4 jfcl 17,.+1 sub 2,4 jcry0 .+2 subi 1,1 sub 1,3 ; result in AC1 and AC2 ``` -------------------------------- ### Initialize Pixi.js Stage and Renderer Source: https://github.com/github-linguist/linguist/blob/main/samples/Literate CoffeeScript/pixi.coffee.md Sets up the Pixi.js stage with a background color and initializes the auto-detect renderer to match the application's dimensions. This is the foundational setup for any Pixi.js application. ```javascript stage = new PIXI.Stage(0x66FF99) renderer = PIXI.autoDetectRenderer(width, height) ``` -------------------------------- ### Install Dependencies on Ubuntu Source: https://github.com/github-linguist/linguist/blob/main/README.md Install required dependencies for Linguist on Ubuntu using apt-get. This includes build tools, cmake, ICU, zlib, libcurl, and OpenSSL development packages. ```bash sudo apt-get install build-essential cmake pkg-config libicu-dev zlib1g-dev libcurl4-openssl-dev libssl-dev ruby-dev ``` -------------------------------- ### Svelte Store Assignment Example Source: https://github.com/github-linguist/linguist/blob/main/samples/mdsvex/Stores.svx Demonstrates how assigning a value to a '$' prefixed store variable triggers the store's 'set' method. ```javascript $my_store = 'Hello'; ``` ```javascript $my_store = 'Hello'; my_store.set($my_store); ``` -------------------------------- ### Bootstrap Linguist Development Environment Source: https://github.com/github-linguist/linguist/blob/main/CONTRIBUTING.md Clones the Linguist repository and installs its Ruby gem dependencies using Bundler. This is a prerequisite for contributing. ```bash git clone https://github.com/github/linguist.git cd linguist/ script/bootstrap ``` -------------------------------- ### Install GitHub Linguist Gem Source: https://github.com/github-linguist/linguist/blob/main/README.md Install the Linguist gem using the RubyGems package manager. Ensure you have a compatible Ruby version installed. ```bash gem install github-linguist ``` -------------------------------- ### Install pkgdown from CRAN Source: https://github.com/github-linguist/linguist/blob/main/samples/HTML/pkgdown.html Install the release version of pkgdown from the Comprehensive R Archive Network (CRAN). ```r install.packages("pkgdown") ``` -------------------------------- ### Example of Signed Multiplication Results Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Shows example results of signed multiplication operations with various inputs, including negative numbers. ```assembly ;; ;; 377777,,777777 ^ 2 = 177777,,777777 000000,,000001 ;; -400000,,000000 * 377777,,777777 = -177777,,777777 400000,,000000 ;; (= 600000,,000000 400000,,000000) ;; -400000,,000000 ^ 2 = 200000,,000000 000000,,000000 ;; -400000,,000000 * -1 = 000000,,000000 400000,,000000 ;; -000000,,000001 ^ 2 = 000000,,000000 000000,,000001 ;; -000000,,000001 * 000000,,000001 = -000000,,000000 000000,,000001 ;; (= 777777,,777777 777777,,777777) ;; -000000,,000001 * 000001,,000001 = -000000,,000000 000001,,000001 ;; (= 777777,,777777 777776,,777777) ;; ``` -------------------------------- ### Install Dependencies on macOS Source: https://github.com/github-linguist/linguist/blob/main/README.md Install necessary dependencies for Linguist on macOS using Homebrew. This includes cmake, pkg-config, and icu4c. ```bash brew install cmake pkg-config icu4c ``` -------------------------------- ### Single File Analysis with Gitattributes Override Source: https://github.com/github-linguist/linguist/blob/main/README.md This example demonstrates a single file analysis where `.gitattributes` overrides the default detection strategy, changing the detected language. ```console test.rb: 13 lines (11 sloc) type: Text mime type: application/x-ruby language: Java strategy: Extension (overridden by .gitattributes) ``` -------------------------------- ### New Keycode Entry and Confirmation Source: https://github.com/github-linguist/linguist/blob/main/samples/TI Program/srcfunc.8xp.txt Guides the user through entering and confirming a new keycode. It uses graphical display and input validation. ```TI-BASIC Lbl NEW ClrDraw sub(D1,0,0) RectI(0,11,96,1) Text(1,12,"Installation") Text(1,20,"Enter your new keycode:") Text(1,26," - - - - ") DispGraph GetCalc(Str1,16)->[r1] Fill([r1],16,1) 0->{[r1]} Repeat getKey->[r2] End [r2]->{[r1]+1} Text(1,26,"*") DispGraph Repeat getKey->[r2] End [r2]->{[r1]+2} Text(7,26,"*") DispGraph Repeat getKey->[r2] End [r2]->{[r1]+3} Text(13,26,"*") DispGraph Repeat getKey->[r2] End [r2]->{[r1]+4} Text(19,26,"*") DispGraph Fill(L1,50,0) Text(1,34,"Confirm keycode:") Text(1,40," - - - - ") DispGraph Repeat getKey->[r2] End [r2]->{L1+1} Text(1,40,"*") DispGraph Repeat getKey->[r2] End [r2]->{L1+2} Text(7,40,"*") DispGraph Repeat getKey->[r2] End [r2]->{L1+3} Text(13,40,"*") DispGraph Repeat getKey->[r2] End [r2]->{L1+4} Text(19,40,"*") DispGraph If ({[r1]+1}={L1+1}) and ({[r1]+2}={L1+2}) and ({[r1]+3}={L1+3}) and ({[r1]+4}={L1+4}) sub(D3) DispGraph GetCalc(Str2,10) Archive Str1 GetCalc(Str1,[Y1]) ClrDraw Return Else Text(1,48,"ERROR keycodes do not") Text(1,54,"match.") DispGraph UnArchive Str1 DelVar Str1 Repeat getKey End Goto END End Return ``` -------------------------------- ### Webby Page with Markdown Content Source: https://github.com/github-linguist/linguist/blob/main/samples/Org/org.org Example of a Webby page using ERB and Maruku filters for Markdown content. Demonstrates front matter for metadata. ```yaml --- title: Special Directories created_at: 2009-12-17 status: Complete filter: - erb - maruku tags: - powershell --- <%= @page.title %> ================== Special Directories are a set of directories, each of which has a function that will navigate you to the appropriate directory using the push-location cmdlet. For example, the function `home` might navigate to `c:\users\bdewey.` Install ------- Copy the module to somewhere in `ENV:PSModulePath`. Then, InstallModule SpecialDirectories ``` -------------------------------- ### Temperature Converter with Synced Stores Source: https://github.com/github-linguist/linguist/blob/main/samples/mdsvex/Stores.svx An example of using the `synced` store to create a bidirectional temperature converter between Celsius and Fahrenheit within a Svelte component. It handles initial values and binds inputs to the stores. ```html ºC = ºF ``` -------------------------------- ### Analyze Git Repository with github-linguist Source: https://github.com/github-linguist/linguist/blob/main/README.md Run the github-linguist command-line tool on a Git repository to get a language breakdown by percentage and file size. Navigate to the repository's root directory first. ```bash cd /path-to-repository github-linguist ``` -------------------------------- ### Webby Page with Org-mode Content Source: https://github.com/github-linguist/linguist/blob/main/samples/Org/org.org Example of a Webby page using the 'org' filter to render org-mode content. Includes front matter for metadata and ERB for dynamic content. ```yaml --- title: Orgmode Parser created_at: 2009-12-21 status: Under development filter: - erb - org tags: - orgmode - ruby --- <%= @page.title %> Status: <%= @page.status %> * Description Helpful Ruby routines for parsing orgmode files. The most significant thing this library does today is convert orgmode files to textile. Currently, you cannot do much to customize the conversion. The supplied textile conversion is optimized for extracting "content" from the orgfile as opposed to "metadata." * History ** 2009-12-29: Version 0.4 - The first thing output in HTML gets the class "title" - HTML output is now indented - Proper support for multi-paragraph list items. See? This paragraph is part of the last bullet. - Fixed bugs: - "rake spec" wouldn't work on Linux. Needed "require 'rubygems'". ``` -------------------------------- ### Accessing Store Value in Svelte Component Source: https://github.com/github-linguist/linguist/blob/main/samples/mdsvex/Stores.svx This example shows how Svelte automatically handles the subscription to a store and assigns its value to a component-scoped variable prefixed with '$'. It also demonstrates how Svelte manages unsubscribing when the component is destroyed. ```javascript import { my_store } from './store.js'; console.log($my_store); ``` ```javascript import { my_store } from './store.js'; let $my_store; const unsubscribe = my_store.subscribe((value) => ($my_store = value)); onDestroy(unsubscribe); console.log($my_store); ``` -------------------------------- ### PUSHJ and POPJ for Function Calls Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Demonstrates using PUSHJ and POPJ instructions for function calls and returns, particularly for implementing fastcall-like behavior. ```assembly ;; In case anyone would like to play strange games, this could be ;; optimized to use a PUSHJ instruction: ;; static ;; foo (void **p, void *f) FOO: ;; { PUSHJ 1,(2) ;; *++p = &&label; POPJ 17, ;; goto *f; ;; label: ;; return; ;; } ;; And POPJ: ;; static void ;; bar (void **p) BAR: ;; { POPJ 1, ;; goto *p--; ;; } ;; ``` -------------------------------- ### Use Synced Stores with Initial Values Source: https://github.com/github-linguist/linguist/blob/main/samples/mdsvex/Stores.svx Demonstrates how to use the `synced` store creator in a Svelte component, including setting initial values and handling potential conflicts. Ensure only one initial temperature is set. ```javascript import { synced } from './synced.js'; const [a, a_plus_five] = synced( (a) => a + 5, (b) => a - 5 ); $a = 0; // set an initial value ``` -------------------------------- ### Program Navigation Source: https://github.com/github-linguist/linguist/blob/main/samples/TI Program/srcgui.8xp.txt Uses Goto to navigate between different program labels (DPRGM1, DSET1, DSET2, KSET, END, DLIST). ```TI-BASIC Goto DPRGM1 ``` ```TI-BASIC Goto DSET2 ``` ```TI-BASIC Goto END ``` ```TI-BASIC Goto DLIST ``` -------------------------------- ### Basic Writable Store Implementation Source: https://github.com/github-linguist/linguist/blob/main/samples/mdsvex/Stores.svx A fundamental implementation of a Svelte writable store, demonstrating the core `subscribe`, `set`, and `update` methods. This serves as a building block for more complex custom stores. ```javascript function writable(init) { let _val = init; const subs = []; const subscribe = (cb) => { subs.push(cb); cb(_val); return () => { const index = subs.findIndex((fn) => fn === cb); subs.splice(index, 1); }; }; const set = (v) => { _val = v; subs.forEach((fn) => fn(_val)); }; const update = (fn) => set(fn(_val)); return { subscribe, set, update }; } ``` -------------------------------- ### Update Samples Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Ensure that the project's samples are up to date. ```bash bundle exec rake samples ``` -------------------------------- ### Build Linguist Docker Image Source: https://github.com/github-linguist/linguist/blob/main/README.md Builds the Docker image for Linguist. Use this command in the root of the Linguist project. ```console $ docker build -t linguist . ``` -------------------------------- ### Run Tests Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Execute all tests to ensure the project is in a stable state. ```bash bundle exec rake test ``` -------------------------------- ### Generate Documentation with RDoc Command Source: https://github.com/github-linguist/linguist/blob/main/samples/RDoc/rdoc.rdoc Use the `rdoc` command to generate documentation for Ruby projects. Specify options and file/directory names as arguments. Type `rdoc --help` for a full list of options. ```bash $ rdoc [options] [names...] ``` ```bash $ rdoc --help ``` ```bash $ rdoc ``` ```bash % rdoc --main README.rdoc ``` -------------------------------- ### Build Gem Locally Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Build the gem locally for distribution. ```bash bundle exec rake build_gem ``` -------------------------------- ### Single File Analysis Source: https://github.com/github-linguist/linguist/blob/main/README.md Analyze a single file to get its stats, including lines, sloc, type, mime type, and language. This mode does not support the `--breakdown` flag. ```console $ github-linguist grammars.yml grammars.yml: 884 lines (884 sloc) type: Text mime type: text/x-yaml language: YAML ``` -------------------------------- ### Build Grammars Tarball Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Create a tarball of the grammars for release. ```bash ./script/build-grammars-tarball ``` -------------------------------- ### JSON Output of Language Detection Source: https://github.com/github-linguist/linguist/blob/main/README.md Use the `--json` or `-j` flag to get language detection data in JSON format. This provides a structured output suitable for programmatic use. ```console $ github-linguist --json {"Dockerfile":{"size":1212,"percentage":"0.31"},"Ruby":{"size":264519,"percentage":"66.84"},"C":{"size":97685,"percentage":"24.68"},"Lex":{"size":5098,"percentage":"1.29"},"Shell":{"size":1257,"percentage":"0.32"},"Go":{"size":25999,"percentage":"6.57"}} ``` -------------------------------- ### Import and Export ES Modules Source: https://github.com/github-linguist/linguist/blob/main/samples/MDX/sample.mdx Demonstrates importing and exporting modules in JavaScript using ESM syntax. Ensure your environment supports ES modules. ```javascript import {Chart} from './chart.js' import population from './population.js' import {External} from './some/place.js' export const year = 2018 export const pi = 3.14 export function SomeComponent(props) { const name = (props || {}).name || 'world' return

Hi, {name}

and some more things

} export function Local(props) { return } ``` -------------------------------- ### Run Linguist with Breakdown Analysis Source: https://github.com/github-linguist/linguist/blob/main/README.md Runs the Linguist Docker container with the --breakdown flag to show a detailed file-by-file analysis. ```console $ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist github-linguist --breakdown 66.84% 264519 Ruby 24.68% 97685 C 6.57% 25999 Go 1.29% 5098 Lex 0.32% 1257 Shell 0.31% 1212 Dockerfile Ruby: Gemfile Rakefile bin/git-linguist bin/github-linguist ext/linguist/extconf.rb github-linguist.gemspec lib/linguist.rb … ``` -------------------------------- ### Interpolate Variables and Call Partials Source: https://github.com/github-linguist/linguist/blob/main/samples/Antlers/kitchensink.antlers.html Demonstrates basic variable interpolation and calling partials with arguments. Use this for rendering dynamic content and reusable components. ```Antlers --- foo: bar baz: qux --- {{ seo_title ?? title }} {{ partial:layouts/navigation foo="bar" :baz="qux" }} ``` -------------------------------- ### Clone SciPy Repository and Perform In-Place Build Source: https://github.com/github-linguist/linguist/blob/main/samples/reStructuredText/HACKING.rst.txt Clone the SciPy repository and set up an in-place build for development. This allows immediate testing and use of changes by restarting the Python interpreter. ```bash git clone https://github.com/scipy/scipy.git scipy cd scipy python setup.py build_ext -i ``` -------------------------------- ### Tag and Push Release Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Tag the release with the specified version and push the tag to the remote repository. ```bash git tag vx.xx.xx; git push --tags ``` -------------------------------- ### Build Test Gem Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Build a test version of the gem. The version is dynamically determined from git tags. ```bash GEM_VERSION=$(git describe --tags 2>/dev/null | sed 's/-/./g' | sed 's/v//') bundle exec rake build_gem ``` -------------------------------- ### Push to GitHub Packages Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Push the built gem to the GitHub Packages registry. ```bash gem push --key github --host https://rubygems.pkg.github.com/github github-linguist-3.0.0.gem ``` -------------------------------- ### Instruction Wish-List: Min/Max Functions Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Lists desired instructions for finding the minimum and maximum of signed and unsigned values. ```assembly ;; MIN, MAX, UMIN, UMAX - min/max (minsi3, maxsi3, uminsi3, umaxsi3). ;; ``` -------------------------------- ### Update Local Dependencies Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Ensure your local dependencies are up to date by removing the lock file and bootstrapping. ```bash rm Gemfile.lock && script/bootstrap ``` -------------------------------- ### Define Executable and Test Targets Source: https://github.com/github-linguist/linguist/blob/main/test/fixtures/CMake/CMakeLists.txt Defines the main executable target 'toDo' by linking source files and adds a test target named 'toDoTest' that runs the 'toDo' executable. This sets up the build and testing infrastructure for the project. ```cmake add_executable(toDo main.cpp ToDo.cpp) add_test(toDoTest toDo) ``` -------------------------------- ### Build pkgdown Site Source: https://github.com/github-linguist/linguist/blob/main/samples/HTML/pkgdown.html Build the pkgdown website for an R package. This command should be run from the package's root directory. It generates a 'docs/' directory containing the website files. ```r pkgdown::build_site() ``` -------------------------------- ### GFM Task List Items Source: https://github.com/github-linguist/linguist/blob/main/samples/MDX/sample.mdx Demonstrates GitHub Flavored Markdown (GFM) task list syntax for tracking to-do items. ```markdown * [ ] not done ``` ```markdown 1. [x] done ``` -------------------------------- ### Add Grammar Script Source: https://github.com/github-linguist/linguist/blob/main/CONTRIBUTING.md Use this script to add a syntax-highlighting grammar for a new language. It analyzes the grammar and adds it to the repository if no issues are found. Ensure the grammar has a compatible license. ```bash script/add-grammar https://github.com/JaneSmith/MyGrammar ``` -------------------------------- ### Push to RubyGems.org Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Push the built gem to the public RubyGems.org registry. ```bash gem push github-linguist-3.0.0.gem ``` -------------------------------- ### JSON Output with Breakdown Source: https://github.com/github-linguist/linguist/blob/main/README.md Combine `--breakdown` and `--json` flags for a detailed JSON output including file lists, sizes, and percentages for each language. ```console $ github-linguist --breakdown --json {"Dockerfile":{"size":1212,"percentage":"0.31","files":["Dockerfile","tools/grammars/Dockerfile"]},"Ruby":{"size":264519,"percentage":"66.84","files":["Gemfile","Rakefile","bin/git-linguist","bin/github-linguist","ext/linguist/extconf.rb","github-linguist.gemspec","lib/linguist.rb",...]}} ``` -------------------------------- ### RDoc Documentation Coverage Report Source: https://github.com/github-linguist/linguist/blob/main/samples/RDoc/rdoc.rdoc Generate a documentation coverage report using `rdoc -C`. Use `rdoc -C1` to include parameter names in the report. This helps assess the completeness of your project's documentation. ```bash rdoc -C lib ``` ```bash rdoc -C1 lib ``` -------------------------------- ### Analyze Git Repository with Breakdown Source: https://github.com/github-linguist/linguist/blob/main/README.md Use the --breakdown flag with github-linguist to show the language breakdown along with a list of files for each language. ```bash github-linguist --breakdown ``` -------------------------------- ### Revisit casesi Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md A note to revisit the 'casesi' instruction or pattern. ```assembly ;; Revisit `casesi'. ;; ``` -------------------------------- ### Iterate Through Collections Source: https://github.com/github-linguist/linguist/blob/main/samples/Antlers/kitchensink.antlers.html Shows how to loop through a collection of blog posts and display their titles. Ensure the 'blog' collection exists and has entries. ```Antlers {{ collection:blog limit="10" :foo:bar="baz" }} * {{ title }} {{ /collection:blog }} ``` -------------------------------- ### Run Linguist for Code Analysis Source: https://github.com/github-linguist/linguist/blob/main/README.md Runs the Linguist Docker container to analyze the current directory. Mounts the current working directory into the container. ```console $ docker run --rm -v $(pwd):$(pwd):Z -w $(pwd) -t linguist 66.84% 264519 Ruby 24.68% 97685 C 6.57% 25999 Go 1.29% 5098 Lex 0.32% 1257 Shell 0.31% 1212 Dockerfile ``` -------------------------------- ### Define Peephole2 for SOS m -> SOSx a,m Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Optimizes 'SOS m' followed by 'SKIPx a,m' to 'SOSx a,m'. This uses peephole2 and requires the destination register not to be zero. ```c (define_peephole2 [(set (match_operand:SI 0 "reg_or_mem_operand" "") (plus:SI (match_dup 0) (const_int -1))) (parallel [(set (pc) (if_then_else (match_operator 3 "pdp10_comparison_operator" [(match_dup 0) (const_int 0)]) (label_ref (match_operand 1 "" "")) (pc))) (set (match_operand:SI 2 "register_operand" "") (match_dup 0))])] "REGNO (operands[2]) != 0" [(parallel [(set (pc) (if_then_else (match_op_dup 3 [(plus:SI (match_dup 0) (const_int -1)) (const_int 0)]) (label_ref (match_dup 1)) (pc))) (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1))) (set (match_dup 2) (plus:SI (match_dup 0) (const_int -1))) ])]) ``` -------------------------------- ### Interactive Menu Navigation Source: https://github.com/github-linguist/linguist/blob/main/samples/TI Program/srcgui.8xp.txt Handles user input via getKey to navigate through menu options and toggle settings. ```TI-BASIC Repeat getKey End If (getKey(54)) or (getKey(9)) If B=21 If X 0->X Else 1->X End Goto DSET2 End If B=28 If Y 0->Y Else 1->Y End Goto DSET2 End If B=35 If Z 0->Z Else 1->Z End Goto DSET2 End If B=42 If sub(CODE) DelVar Str1 Goto END Else Goto DSET2 End End End ``` ```TI-BASIC If (getKey(4)) and (B!=21) For(7) RectI(0,B,96,7) DispGraph RectI(0,B,96,7) B-- Normal Pause 3 Full End End If (getKey(1)) and (B!=42) For(7) RectI(0,B,96,7) DispGraph RectI(0,B,96,7) B++ Normal Pause 3 Full End End ``` ```TI-BASIC If getKey(15) If ({[Y1]+5}!=X) or ({[Y1]}!=Y) or ({[Y1]+6}!=Z) UnArchive Str1 GetCalc(Str1)->S X->{S+5} Y->{S} Z->{S+6} sub(D3) DispGraph Archive Str1 GetCalc(Str1,[Y1]) End Repeat getKey=0 End Goto DLIST End Goto KSET ``` -------------------------------- ### Single File Analysis with Strategy Source: https://github.com/github-linguist/linguist/blob/main/README.md When analyzing a single file with the `--strategies` flag, you can see the specific detection method used for that file. ```console $ github-linguist --strategies lib/linguist.rb lib/linguist.rb: 105 lines (96 sloc) type: Text mime type: application/x-ruby language: Ruby strategy: Extension ``` -------------------------------- ### Floating-Point Conversions Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Details instructions for converting floating-point numbers to integers and vice versa, supporting various precisions and target architectures. ```APIDOC ## fix_truncsfsi2 ### Description Converts a single-precision floating-point number to a signed integer, truncating the fractional part. This is an expander instruction. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## *fix_truncsfsi2 ### Description Defines the machine instruction for converting a single-precision floating-point number to a signed integer for TARGET_KI10up. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## fix_truncdfsi2 ### Description Expander instruction for converting a double-precision floating-point number to a signed integer, truncating the fractional part. Applicable to specific target architectures. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## *DFIX ### Description Defines the machine instruction for converting a double-precision floating-point number to a signed integer for TARGET_XKL2 and not TARGET_GFLOAT. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## *GFIX ### Description Defines the machine instruction for converting a double-precision floating-point number to a signed integer for TARGET_KL10up and TARGET_GFLOAT. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## fix_truncdfdi2 ### Description Expander instruction for converting a double-precision floating-point number to a signed double integer, truncating the fractional part. Applicable to specific target architectures. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## *DDFIX ### Description Defines the machine instruction for converting a double-precision floating-point number to a signed double integer for TARGET_XKL2 and not TARGET_GFLOAT. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## *GDFIX ### Description Defines the machine instruction for converting a double-precision floating-point number to a signed double integer for TARGET_KL10up and TARGET_GFLOAT. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## floatunsqisf2 ### Description Converts an unsigned single-precision floating-point number from a QI operand to a single-precision floating-point number. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## floatunshisf2 ### Description Converts an unsigned single-precision floating-point number from a HI operand to a single-precision floating-point number. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## floatsisf2 ### Description Converts a signed integer to a single-precision floating-point number for TARGET_KI10up. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` ```APIDOC ## floatunssisf2 ### Description Converts an unsigned signed integer to a single-precision floating-point number. Includes specific logic for TARGET_XKL2 and a general sequence for other targets. ### Method N/A (Instruction Definition) ### Endpoint N/A (Instruction Definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Show Language Detection Strategy Source: https://github.com/github-linguist/linguist/blob/main/README.md Use the `--strategies` or `-s` flag to see the language detection strategy for each file. This flag implicitly sets `--breakdown` unless `--json` is specified. ```console $ github-linguist --breakdown --strategies ``` -------------------------------- ### Use JSP for Fastcall Functions Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Suggests using the JSP instruction for calling functions that are intended to be fastcall or have similar optimizations. ```assembly ;; Use JSP to call functions with __attribute__ ((fastcall)) or similar. ;; ``` -------------------------------- ### Instruction Wish-List: Other Math Functions Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Lists a comprehensive set of desired mathematical functions (TAN, ASIN, etc.) for various floating-point precisions. ```assembly ;; Any other mathematical function: TAN, ASIN, ACOS, ATAN, SINH, COSH, ;; TANH, ASINH, ACOSH, ATANH, EXP, LN, LOG2, LOG10, POW, ... All ;; potentially in single, double, and giant versions. ;; ``` -------------------------------- ### Instruction Wish-List: Trigonometric Functions Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Lists desired instructions for sine and cosine functions, with potential for single, double, and giant precision. ```assembly ;; SIN, DSIN, GSIN - sine function (__builtin_sin). ;; COS, DCOS, GCOS - cosine function (__builtin_cos). ;; ``` -------------------------------- ### Define Peephole2 for ADDI a,1 -> AOJA a,m Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Optimizes 'ADDI a,1' followed by 'JRST m' to 'AOJA a,m'. This uses peephole2 and is important after basic block reordering. ```c (define_peephole2 [(set (match_operand:SI 0 "register_operand" "") (plus:SI (match_dup 0) (const_int 1))) (set (pc) (label_ref (match_operand 1 "" "")))] "" [(parallel [(set (pc) (label_ref (match_dup 1))) (set (match_dup 0) (plus:SI (match_dup 0) (const_int 1))) ])]) ``` -------------------------------- ### Create a Virtual Environment for SciPy Development Source: https://github.com/github-linguist/linguist/blob/main/samples/reStructuredText/HACKING.rst.txt Utilize `virtualenv` and `virtualenvwrapper` to create isolated Python environments for SciPy development. This helps manage dependencies and different Python versions. ```bash mkvirtualenv scipy-dev ``` -------------------------------- ### Historical KA10 Software Double Precision Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md References historical software for double-precision floating-point operations on the KA10 processor. ```assembly ;; Historical: KA10 software double precision floating-point. ``` -------------------------------- ### Check License Status Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Verify the status of licenses to ensure no problems have been introduced. ```bash bundle exec licensed status -c vendor/licenses/config.yml ``` -------------------------------- ### Load and Map Textures Source: https://github.com/github-linguist/linguist/blob/main/samples/Literate CoffeeScript/pixi.coffee.md Loads textures from a data file and maps them into Pixi.js texture objects using `PIXI.Texture.fromImage`. Ensure the image paths are correctly formatted. ```javascript textures = require "./textures" Object.keys(textures).forEach (name) -> value = textures[name] textures[name] = PIXI.Texture.fromImage("http://a0.pixiecdn.com/#{value}", true) ``` -------------------------------- ### Define Peephole2 for SOS m -> SOSx m Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Optimizes the sequence 'SOS m' followed by 'SKIPx m' to 'SOSx m'. This uses peephole2 for optimization. ```c (define_peephole2 [(set (match_operand:SI 0 "reg_or_mem_operand" "") (plus:SI (match_dup 0) (const_int -1))) (set (pc) (if_then_else (match_operator 2 "pdp10_comparison_operator" [(match_dup 0) (const_int 0)]) (label_ref (match_operand 1 "" "")) (pc)))] "" [(parallel [(set (pc) (if_then_else (match_op_dup 2 [(plus:SI (match_dup 0) (const_int -1)) (const_int 0)]) (label_ref (match_dup 1)) (pc))) (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1))) (set (match_dup 0) (plus:SI (match_dup 0) (const_int -1))) ])]) ``` -------------------------------- ### Load Unsigned Byte Immediate (LDBIzqi) Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Defines an instruction to load an unsigned byte from memory into a register, specifically for immediate addressing modes. Requires TARGET_XKL2 to be enabled. ```gcc-internal (define_insn "*LDBIzqi" [(set (match_operand:SI 0 "register_operand" "=r") (zero_extend:SI (match_operand:QI 1 "memory_operand" "<")))] "TARGET_XKL2" "*return pdp10_output_load_unsigned_byte (insn, operands);") ``` -------------------------------- ### Main Animation and Rendering Loop Source: https://github.com/github-linguist/linguist/blob/main/samples/Literate CoffeeScript/pixi.coffee.md Implements the main application loop using `requestAnimationFrame`. It updates each object and renders the stage at a fixed time step of 1/60th of a second. ```javascript dt = 1/60 animate = -> requestAnimationFrame(animate) objects.forEach (object) -> update(object, dt) renderer.render(stage) requestAnimationFrame(animate) ``` -------------------------------- ### Instruction Wish-List: Unsigned Division and Modulo Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Lists desired instructions for unsigned division and modulo operations, including single and double word variants. ```assembly ;; UIDIV, UDIV, UDDIV - unsigned division (udivsi3, udivdi3). ;; UIMOD, UMOD, UDMOD - unsigned modulo (umodsi3, umoddi3). ;; ``` -------------------------------- ### Update License Cache Source: https://github.com/github-linguist/linguist/blob/main/docs/releasing.md Update the license cache using the provided configuration file. ```bash bundle exec licensed cache -c vendor/licenses/config.yml ``` -------------------------------- ### Apply Filters and Access Array Items Source: https://github.com/github-linguist/linguist/blob/main/samples/Antlers/kitchensink.antlers.html Demonstrates chaining multiple filters to a variable and accessing array items using bracket notation. Useful for data transformation and manipulation. ```Antlers {{ alfa | bravo | charlie(delta, 'echo', "foxtrot", $golf, 42) }} ``` ```Antlers {{ alfa[bravo] }} ``` ```Antlers {{ alfa['bravo'] }} ``` -------------------------------- ### GitHub Reference Source: https://github.com/github-linguist/linguist/blob/main/samples/MDX/sample.mdx Demonstrates GitHub Flavored Markdown (GFM) syntax for referencing issues, pull requests, and security advisories. ```markdown GH-123, #123, GHSA-123asdzxc, cve-123asdzxc, user#123, user/project#123. ``` -------------------------------- ### Add a new grammar to the repository Source: https://github.com/github-linguist/linguist/blob/main/CONTRIBUTING.md Use this script to add a new TextMate-compatible grammar to Linguist. It analyzes the grammar for problems before adding it. Ensure the grammar has a compatible license. ```bash script/add-grammar --replace MyGrammar https://github.com/PeterPan/MyGrammar ``` -------------------------------- ### AOBJP, AOBJN Instructions Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Queries the availability or implementation of AOBJP and AOBJN instructions. ```assembly ;; AOBJP, AOBJN? ;; ``` -------------------------------- ### Add or Replace TextMate Grammar Source: https://github.com/github-linguist/linguist/blob/main/AGENTS.md Use this script to add a new TextMate grammar or replace an existing one. Provide the grammar name and its URL. ```bash script/add-grammar ``` ```bash script/add-grammar --replace ``` -------------------------------- ### Window Drawing Source: https://github.com/github-linguist/linguist/blob/main/samples/TI Program/srcfunc.8xp.txt Defines and draws window boundaries using Rect and RectI commands. Also sets pixel states. ```TI-BASIC Lbl D2 .windows Rect([r1]+1,[r2],[r3]-2,[r4]) Rect([r1],[r2]+1,[r3],[r4]-2) RectI([r1]+1,[r2]+1,[r3]-2,[r4]-2) Text([r1]+2,[r2]+2,[r5]) RectI([r1]+1,[r2]+1,[r3]-2,8) Pt-Off([r1]+[r3]-9,[r2]+1,[C1BEAAB6AABEC1FF]) Pxl-On([r1]+1,[r2]+[r4]-2) Pxl-On([r1]+[r3]-2,[r2]+[r4]-2) Return ``` -------------------------------- ### move_and_skipsi/f Clobbers Accumulator 0 Source: https://github.com/github-linguist/linguist/blob/main/samples/GCC Machine Description/pdp10.md Highlights that '*move_and_skipsi' and '*move_and_skipsf' clobber accumulator 0 and questions the possibility of allocating a scratch register. ```assembly ;; *move_and_skipsi and *move_and_skipsf clobbers accumulator 0. Is ;; it possible to allocate a scratch register? ;; ```