### C# 'Hello World' for Beef IDE Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/getting-start/_index.md This C# code snippet demonstrates a basic 'Hello, world!' console application. It is intended to be used within the Beef IDE. Ensure you have the Beef IDE installed and a new Console project set up. ```csharp using System; namespace Hello { class Program { static void Main() { Console.WriteLine("Hello, world!"); } } } ``` -------------------------------- ### Beef Build Command-line 'Hello World' Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/getting-start/_index.md This demonstrates the command-line approach to creating a 'Hello World' application using BeefBuild. It involves initializing a workspace, creating a source file, and then compiling and running the application. ```bash # Create a new directory named "Hello" directory "Hello" # Change into that directory cd "Hello" # Initialize a new workspace and project BeefBuild -new # Create a src/Program.bf text file and paste the C# code from the IDE example # (Assuming C# is the target language for this example) # Compile and execute the application BeefBuild -run ``` -------------------------------- ### Start Reveal.js Development Server Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md Command to start the reveal.js development server and monitor source files for changes. This command requires Node.js and npm to be installed and is part of the full setup. ```sh $ npm start ``` -------------------------------- ### Copy Demo Content to Website Root Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/README.md This command copies all files from the Academic theme's example site folder to your website's root directory. This is useful for initializing your site with pre-configured content and settings. ```bash cp -av themes/academic/exampleSite/* . ``` -------------------------------- ### Copy Example Site Config to Hugo Root Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/getting-start/configuration.md Copies the example configuration file from the theme to the Hugo root directory. This is a command-line operation. ```bash $ cp themes/docdock/exampleSite/config.toml . ``` -------------------------------- ### Install Hugo from Source using Go Modules Source: https://github.com/beefytech/beef_website/blob/master/bin/README.md This snippet demonstrates how to fetch and install the Hugo binaries from its GitHub repository using Go Modules, a feature built into Go 1.11 and later. It's suitable for users who want to contribute to Hugo's source code or documentation. Ensure you have Git and Go (version 1.11+) installed. ```bash mkdir $HOME/src cd $HOME/src git clone https://github.com/gohugoio/hugo.git cd hugo go install ``` -------------------------------- ### Serve Hugo Site Locally Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/getting-start/configuration.md Starts a local Hugo development server to preview the website. The site will be accessible at http://localhost:1313. ```bash $ hugo server ``` -------------------------------- ### Clone Academic Kickstart Repository with Git Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/README.md This command clones the Academic Kickstart repository to your local machine. Replace 'My_Website' with your desired directory name. This is a prerequisite for installing the theme using Git. ```bash git clone https://github.com/sourcethemes/academic-kickstart.git My_Website ``` -------------------------------- ### Panel Shortcode Theming Examples Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/panel.md Provides examples of applying various predefined themes to the panel shortcode. Each theme changes the visual appearance of the panel's border and header. ```Go Template {{% panel theme="success" header="Success theme" %}}this is a panel text{{% /panel %}} ``` ```Go Template {{% panel theme="default" header="default theme" %}}this is a panel text{{% /panel %}} ``` ```Go Template {{% panel theme="primary" header="primary theme" %}}this is a panel text{{% /panel %}} ``` ```Go Template {{% panel theme="info" header="info theme" %}}this is a panel text{{% /panel %}} ``` ```Go Template {{% panel theme="warning" header="warning theme" %}}this is a panel text{{% /panel %}} ``` ```Go Template {{% panel theme="danger" header="danger theme" %}}this is a panel text{{% /panel %}} ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md Command to install project dependencies using npm. This is a required step after cloning the reveal.js repository for the full setup, ensuring all necessary packages are downloaded. ```sh $ npm install ``` -------------------------------- ### Clone Reveal.js Repository Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md Command to clone the reveal.js repository from GitHub. This is the first step in the full setup for development and requires Git to be installed. ```sh $ git clone https://github.com/hakimel/reveal.js.git ``` -------------------------------- ### Running a BeefBuild command Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/BeefBuild/_index.md Example of executing the BeefBuild CLI to compile and run a project with arguments. This demonstrates the basic syntax for specifying the workspace and passing arguments to the compiled program. ```bash BeefBuild -workspace=samples\HelloWorld -run -args Argument1 Argument2 ``` -------------------------------- ### Reveal.js Initialization with Transitions Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/test/examples/slide-transitions.html Demonstrates the basic initialization of Reveal.js, including commented-out examples for setting global transition effects and speeds. This code configures the presentation's core settings. ```javascript Reveal.initialize({ center: true, history: true, // transition: 'slide', // transitionSpeed: 'slow', // backgroundTransition: 'slide' }); ``` -------------------------------- ### Mermaid GANTT Chart Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/mermaid.md This snippet demonstrates how to generate a GANTT chart using Mermaid syntax. It defines tasks with start dates, durations, and dependencies, suitable for project timeline visualization. ```html
gantt dateFormat YYYY-MM-DD title Adding GANTT diagram functionality to mermaid section A section Completed task :done, des1, 2014-01-06,2014-01-08 Active task :active, des2, 2014-01-09, 3d Future task : des3, after des2, 5d Future task2 : des4, after des3, 5d section Critical tasks Completed task in the critical line :crit, done, 2014-01-06,24h Implement parser and jison :crit, done, after des1, 2d Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d Add to mermaid :1d
``` ```mermaid gantt dateFormat YYYY-MM-DD title Adding GANTT diagram functionality to mermaid section A section Completed task :done, des1, 2014-01-06,2014-01-08 Active task :active, des2, 2014-01-09, 3d Future task : des3, after des2, 5d Future task2 : des4, after des3, 5d section Critical tasks Completed task in the critical line :crit, done, 2014-01-06,24h Implement parser and jison :crit, done, after des1, 2d Create tests for parser :crit, active, 3d Future task in critical line :crit, 5d Create tests for renderer :2d Add to mermaid :1d ``` -------------------------------- ### Initialize Git Submodules for Academic Theme Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/README.md After cloning the repository, this command initializes and updates the Git submodules, which includes the Academic theme. This ensures all necessary theme components are downloaded and set up correctly. ```bash cd My_Website git submodule update --init --recursive ``` -------------------------------- ### Add Custom JavaScript - jQuery Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/content-organisation/customize-style/_index.md This snippet illustrates adding custom JavaScript functionality to a page. The provided example uses jQuery (which is pre-loaded by the theme) to execute a function `tweakPage`. Place this code in a file like `static/js/custom.js` and link it in your `custom-head.html`. ```javascript function tweakPage() { // make some changes here } $(tweakPage) ``` -------------------------------- ### Hello World in C# Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/content/home/lang.md A basic "Hello, World!" program in C# that prints the string "Hello, World!" to the console. This is a fundamental example for beginners. ```csharp using System; class Program { public static void Main() { Console.WriteLine("Hello, World!"); } } ``` -------------------------------- ### Install Hugo DocDock Theme from ZIP Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/README.md Instructions for installing the DocDock theme by downloading and extracting a ZIP archive. This method places all theme files directly into the project's themes directory. ```bash https://github.com/vjeantet/hugo-theme-docdock/archive/master.zip ``` -------------------------------- ### Initialize Hugo Site and Git Repository Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/README.md Commands to create a new Hugo site and initialize it as a Git repository. This sets up the basic directory structure for your Hugo project and prepares it for version control. ```bash $ hugo new site . $ git init ``` -------------------------------- ### Initialize Reveal.js with Dependencies Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md Configures Reveal.js by loading various optional plugins as dependencies. Each dependency can have a source path, an async flag, a callback function, and a condition for loading. This setup requires head.js to be loaded beforehand. ```javascript Reveal.initialize({ dependencies: [ // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, // Interpret Markdown in
elements { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, // Syntax highlight for elements { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, // Zoom in and out with Alt+click { src: 'plugin/zoom-js/zoom.js', async: true }, // Speaker notes { src: 'plugin/notes/notes.js', async: true }, // MathJax { src: 'plugin/math/math.js', async: true } ] }); ``` -------------------------------- ### Install Hugo DocDock Theme via Git Clone Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/README.md Steps to install the DocDock theme by cloning the repository directly into the themes directory. This method is suitable for local development where the theme files are managed within the project. ```bash $ git clone https://github.com/vjeantet/hugo-theme-docdock.git themes/docdock ``` -------------------------------- ### Install Hugo DocDock Theme as Git Submodule Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/README.md Instructions for installing the DocDock theme as a Git submodule. This method is recommended for CI/CD pipelines and remote builds, as it manages the theme as a separate dependency. ```bash $ git submodule add https://github.com/vjeantet/hugo-theme-docdock.git themes/docdock $ git submodule init $ git submodule update ``` -------------------------------- ### Hugo Content Folder Structure Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/content-organisation/_index.md This example illustrates the hierarchical structure of content folders in a Hugo project. The nested structure directly translates to the website's navigation menu. The _index.md file in each directory serves as the homepage for that section. ```text content ├── level-one │ ├── level-two │ │ ├── level-three │ │ │ ├── level-four │ │ │ │ ├── _index.md │ │ │ │ ├── page-4-a.md │ │ │ │ ├── page-4-b.md │ │ │ │ └── page-4-c.md │ │ │ ├── _index.md │ │ │ ├── page-3-a.md │ │ │ ├── page-3-b.md │ │ │ └── page-3-c.md │ │ ├── _index.md │ │ ├── page-2-a.md │ │ ├── page-2-b.md │ │ └── page-2-c.md │ ├── _index.md │ ├── page-1-a.md │ ├── page-1-b.md │ └── page-1-c.md ├── _index.md └── page-top.md ``` -------------------------------- ### Mermaid Flowchart Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/mermaid.md This snippet demonstrates how to create a basic flowchart using Mermaid syntax. It defines nodes with different shapes and directional links between them, illustrating a simple decision tree. ```html
graph LR; A[Hard edge] -->|Link text| B(Round edge) B --> C{Decision} C -->|One| D[Result one] C -->|Two| E[Result two]
``` ```mermaid graph LR; A[Hard edge] -->|Link text| B(Round edge) B --> C{Decision} C -->|One| D[Result one] C -->|Two| E[Result two] ``` -------------------------------- ### Setup Speaker Notes UI - JavaScript Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/static/js/vendor/reveal.js/plugin/notes/notes.html Initializes references to DOM elements for displaying speaker notes. It selects the necessary elements using their class names. This function should be called once to set up the UI components for notes. ```javascript function setupNotes() { notes = document.querySelector( '.speaker-controls-notes' ); notesValue = document.querySelector( '.speaker-controls-notes .value' ); } ``` -------------------------------- ### Clone Hugo Repository for Documentation Source: https://github.com/beefytech/beef_website/blob/master/bin/README.md This command clones the Hugo repository to build the documentation site located in the `/docs` subfolder. This is useful for developers who need to work with or build the documentation locally. Requires Git to be installed. ```bash git clone git@github.com:gohugoio/hugo.git ``` -------------------------------- ### Reveal.js Code Syntax Highlighting Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md Demonstrates how to use Reveal.js with highlight.js for code syntax highlighting. Includes examples of the 'data-trim' attribute to remove whitespace and 'data-noescape' to prevent HTML escaping. ```html

(def lazy-fib
  (concat
   [0 1]
   ((fn rfib [a b]
        (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))
	
``` -------------------------------- ### JavaScript Speaker Layout Setup and Management Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/plugin/notes-server/notes.html Sets up the speaker layout dropdown, handles changes, and persists the selected layout using local storage. It also includes functions to retrieve the current layout and a default if none is set. ```javascript function setupLayout() { layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); layoutLabel = document.querySelector( '.speaker-layout-label' ); // Render the list of available layouts for( var id in SPEAKER_LAYOUTS ) { var option = document.createElement( 'option' ); option.setAttribute( 'value', id ); option.textContent = SPEAKER_LAYOUTS[ id ]; layoutDropdown.appendChild( option ); } // Monitor the dropdown for changes layoutDropdown.addEventListener( 'change', function( event ) { setLayout( layoutDropdown.value ); }, false ); // Restore any currently persisted layout setLayout( getLayout() ); } /** * Sets a new speaker view layout. The layout is persisted * in local storage. */ function setLayout( value ) { var title = SPEAKER_LAYOUTS[ value ]; layoutLabel.innerHTML = 'Layout' + ( title ? ( ': ' + title ) : '' ); layoutDropdown.value = value; document.body.setAttribute( 'data-speaker-layout', value ); // Persist locally if( window.localStorage ) { window.localStorage.setItem( 'reveal-speaker-layout', value ); } } /** * Returns the ID of the most recently set speaker layout * or our default layout if none has been set. */ function getLayout() { if( window.localStorage ) { var layout = window.localStorage.getItem( 'reveal-speaker-layout' ); if( layout ) { return layout; } } // Default to the first record in the layouts hash for( var id in SPEAKER_LAYOUTS ) { return id; } } ``` -------------------------------- ### Configure Speaker Notes Server (JavaScript) Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md This JavaScript configuration snippet is used to initialize Reveal.js with the speaker notes server plugin. It requires the 'socket.io.js' and 'notes-server/client.js' scripts to be loaded asynchronously. This setup allows for running speaker notes on a separate device. ```javascript Reveal.initialize({ dependencies: [ { src: 'socket.io/socket.io.js', async: true }, { src: 'plugin/notes-server/client.js', async: true } ] }); ``` -------------------------------- ### Reveal.js Shortcode Source Code Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/revealjs.md Provides the raw shortcode and content used in the revealjs demo. This snippet shows the exact structure within the Hugo template that generates the reveal.js presentation, including the shortcode parameters and slide delimiters. ```html {{}} # In the morning ___ ## Getting up - Turn off alarm - Get out of bed ___ ## Breakfast - Eat eggs - Drink coffee --- # In the evening ___ ## Dinner - Eat spaghetti - Drink wine ___ ## Going to sleep - Get in bed - Count sheep {{}} ``` -------------------------------- ### Example Usage of Excerpt Include Shortcode Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/excerpt-include.md This snippet demonstrates how to use the Excerpt Include shortcode to display content from another page. The 'filename' parameter is mandatory, specifying the source file. The 'panel' parameter is optional and adds a visual panel with a title around the included excerpt. ```shortcode {{%excerpt-include filename="shortcodes/excerpt.md" panel="From excerpt page" /%}} ``` -------------------------------- ### C# Mixin Example with Scope Targeting Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/language-guide/datatypes/members.md Illustrates mixin scope targeting in C#. The `AllocString` mixin demonstrates allocating within a specified scope using `scope:mixin` and callsite targets like `:WhileBody` and `::`. ```C# static mixin AllocString() { scope:mixin String() } void Use() { String outerStr = null; while (IsRunning()) WhileBody: { String whileStr = null; if (Check()) { // Allocs string in current scope let localStr = AllocString!(); // Allocs string in the scope of the 'while' body whileStr = AllocString!:WhileBody(); // Allocs string in method scope outerStr = AllocString!::(); } } ``` -------------------------------- ### Setup Speaker Layout Selector Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/plugin/notes/notes.html Configures the dropdown and label for selecting speaker view layouts. It populates the dropdown with available layouts from `SPEAKER_LAYOUTS` and adds an event listener to apply the selected layout. It also restores the last used layout. ```javascript function setupLayout() { layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); layoutLabel = document.querySelector( '.speaker-layout-label' ); for( var id in SPEAKER_LAYOUTS ) { var option = document.createElement( 'option' ); option.setAttribute( 'value', id ); option.textContent = SPEAKER_LAYOUTS[ id ]; layoutDropdown.appendChild( option ); } layoutDropdown.addEventListener( 'change', function( event ) { setLayout( layoutDropdown.value ); }, false ); setLayout( getLayout() ); } ``` -------------------------------- ### JavaScript WebSocket Communication and State Management Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/plugin/notes-server/notes.html This snippet manages WebSocket connections for real-time state updates. It handles initial setup, message reception, and forwarding state changes to presentation iframes. It includes logic for ignoring messages from other clients and setting up keyboard event forwarding. ```javascript (function() { var notes, notesValue, currentState, currentSlide, upcomingSlide, layoutLabel, layoutDropdown, connected = false; var socket = io.connect( window.location.origin ), socketId = '{{socketId}}'; var SPEAKER_LAYOUTS = { 'default': 'Default', 'wide': 'Wide', 'tall': 'Tall', 'notes-only': 'Notes only' }; socket.on( 'statechanged', function( data ) { // ignore data from sockets that aren't ours if( data.socketId !== socketId ) { return; } if( connected === false ) { connected = true; setupKeyboard(); setupNotes(); setupTimer(); } handleStateMessage( data ); } ); setupLayout(); // Load our presentation iframes setupIframes(); // Once the iframes have loaded, emit a signal saying there's // a new subscriber which will trigger a 'statechanged' // message to be sent back window.addEventListener( 'message', function( event ) { var data = JSON.parse( event.data ); if( data && data.namespace === 'reveal' ) { if( /ready/.test( data.eventName ) ) { socket.emit( 'new-subscriber', { socketId: socketId } ); } } // Messages sent by reveal.js inside of the current slide preview if( data && data.namespace === 'reveal' ) { if( /slidechanged|fragmentshown|fragmenthidden|overviewshown|overviewhidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { socket.emit( 'statechanged-speaker', { state: data.state } ); } } } ); /** * Called when the main window sends an updated state. */ function handleStateMessage( data ) { // Store the most recently set state to avoid circular loops // applying the same state currentState = JSON.stringify( data.state ); // No need for updating the notes in case of fragment changes if ( data.notes ) { notes.classList.remove( 'hidden' ); if( data.markdown ) { notesValue.innerHTML = marked( data.notes ); } else { notesValue.innerHTML = data.notes; } } else { notes.classList.add( 'hidden' ); } // Update the note slides currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' ); upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' ); upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'next' }), '*' ); } // Limit to max one state update per X ms handleStateMessage = debounce( handleStateMessage, 200 ); /** * Forward keyboard events to the current slide window. * This enables keyboard events to work even if focus * isn't set on the current slide iframe. */ function setupKeyboard() { document.addEventListener( 'keydown', function( event ) { currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' ); } ); } /** * Creates the preview iframes. */ function setupIframes() { var params = [ 'receiver', 'progress=false', 'history=false', 'transition=none', 'backgroundTransition=none' ].join( '&' ); var currentURL = '/?' + params + '&postMessageEvents=true'; var upcomingURL = '/?' + params + '&controls=false'; currentSlide = document.createElement( 'iframe' ); currentSlide.setAttribute( 'width', 1280 ); currentSlide.setAttribute( 'height', 1024 ); currentSlide.setAttribute( 'src', currentURL ); document.querySelector( '#current-slide' ).appendChild( currentSlide ); upcomingSlide = document.createElement( 'iframe' ); upcomingSlide.setAttribute( 'width', 640 ); upcomingSlide.setAttribute( 'height', 512 ); upcomingSlide.setAttribute( 'src', upcomingURL ); document.querySelector( '#upcoming-slide' ).appendChild( upcomingSlide ); } /** * Setup the notes UI. */ function setupNotes() { notes = document.querySelector( '.speaker-controls-notes' ); notesValue = document.querySelector( '.speaker-controls-notes .value' ); } /** * Create the timer and clock and start updating them * at an interval. */ function setupTimer() { var start = new Date(), timeEl = document.querySelector( '.speaker-controls-time' ), clockEl = timeEl.querySelector( '.clock-value' ), hoursEl = timeEl.querySelector( '.hours-value' ), minutesEl = timeEl.querySelector( '.minutes-value' ), secondsEl = timeEl.querySelector( '.seconds-value' ); function _updateTimer() { var diff, hours, minutes, seconds, now = new Date(); diff = now.getTime() - start.getTime(); hours = Math.floor( diff / ( 1000 * 60 * 60 ) ); minutes = Math.floor( ( diff / ( 1000 * 60 ) ) % 60 ); seconds = Math.floor( ( diff / 1000 ) % 60 ); clockEl.innerHTML = now.toLocaleTimeString( 'en-US', { hour12: true, hour: '2-digit', minute:'2-digit' } ); hoursEl.innerHTML = zeroPadInteger( hours ); hoursEl.className = hours > 0 ? '' : 'mute'; minutesEl.innerHTML = ':' + zeroPadInteger( minutes ); minutesEl.className = minutes > 0 ? '' : 'mute'; secondsEl.innerHTML = ':' + zeroPadInteger( seconds ); } // Update once directly _updateTimer(); // Then update every second setInterval( _updateTimer, 1000 ); timeEl.addEventListener( 'click', function() { start = new Date(); _updateTimer(); return false; } ); } /** * Sets up the speake ``` -------------------------------- ### Mermaid Sequence Diagram Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/mermaid.md This snippet illustrates the creation of a sequence diagram using Mermaid. It shows participants interacting through messages, including loops and notes, to depict a conversation flow. ```html
sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you? loop Healthcheck John->John: Fight against hypochondria end Note right of John: Rational thoughts
prevail... John-->Alice: Great! John->Bob: How about you? Bob-->John: Jolly good!
``` ```mermaid sequenceDiagram participant Alice participant Bob Alice->>John: Hello John, how are you? loop Healthcheck John->John: Fight against hypochondria end Note right of John: Rational thoughts
prevail... John-->Alice: Great! John->Bob: How about you? Bob-->John: Jolly good! ``` -------------------------------- ### Reveal.js Initialization with Dependencies Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/demo.html This JavaScript code shows the initialization of reveal.js with various plugins and configurations. It includes settings for controls, progress, history, slide centering, transition effects, and conditionally loads plugins like Markdown support, highlight.js, search, zoom, and notes. ```javascript // More info https://github.com/hakimel/reveal.js#configuration Reveal.initialize({ controls: true, progress: true, history: true, center: true, transition: 'slide', // none/fade/slide/convex/concave/zoom // More info https://github.com/hakimel/reveal.js#dependencies dependencies: [ { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: 'plugin/search/search.js', async: true }, { src: 'plugin/zoom-js/zoom.js', async: true }, { src: 'plugin/notes/notes.js', async: true } ] }); ``` -------------------------------- ### Reveal.js Initialization with Dependencies Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/plugin/markdown/example.html Initializes reveal.js with various configuration options and a list of essential dependencies. These dependencies include polyfills for classList, Markdown support, syntax highlighting, and speaker notes. The initialization ensures that reveal.js functions correctly with its extended features. ```javascript Reveal.initialize({ controls: true, progress: true, history: true, center: true, // Optional libraries used to extend on reveal.js dependencies: [ { src: '../../lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: '../highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '../notes/notes.js' } ] }); ``` -------------------------------- ### Add .gitkeep and .gitignore for Build Results Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/getting-start/configuration.md Creates an empty .gitkeep file in the public directory and adds a rule to .gitignore to manage build output files and keep the repository lean. ```bash /public/* !/public/.gitkeep ``` -------------------------------- ### Initialize Reveal.js with Plugins and Options Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/layouts/slides/baseof.html This JavaScript code dynamically loads Reveal.js CSS based on print mode and initializes the presentation framework. It defines default options and merges them with plugin configurations, including asynchronous loading for performance. ```javascript var link = document.createElement( 'link' ); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = window.location.search.match( /print-pdf/gi ) ? '{{ $cdn_url_reveal }}/css/print/pdf.css' : '{{ $cdn_url_reveal }}/css/print/paper.css'; document.getElementsByTagName( 'head' )[0].appendChild( link ); window.revealPlugins = { dependencies: [ { src: '{{ $cdn_url_reveal }}/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: '{{ $cdn_url_reveal }}/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: '{{ $cdn_url_reveal }}/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '{{ $cdn_url_reveal }}/plugin/zoom-js/zoom.js', async: true }, { src: '{{ $cdn_url_reveal }}/plugin/math/math.js', async: true }, { src: '{{ $cdn_url_reveal }}/plugin/print-pdf/print-pdf.js', async: true }, // Notes plugin must be loaded locally as CDN is missing `notes.html`. { src: '{{ "js/vendor/reveal.js/plugin/notes/notes.js" | relURL }}', async: true } ] }; let revealDefaults = { center: true, controls: true, history: true, progress: true, transition: 'slide', mouseWheel: true }; let revealOptions = Object.assign({}, revealDefaults, window.revealPlugins); Reveal.initialize(revealOptions); ``` -------------------------------- ### C# Enum with Methods and Properties Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/language-guide/datatypes/_index.md Demonstrates defining enums with associated methods and properties, similar to value types. Includes an example of a computed property. ```C# enum Direction { case North; case East; case South; case West; public Direction Opposite { get { switch (this) { case .North: return .South; case .East: return .West; case .South: return .North; case .West: return .East; } } } } ``` -------------------------------- ### Reveal.js Initialization and Configuration Options Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/README.md Demonstrates how to initialize Reveal.js with a comprehensive set of configuration options. These options control presentation behavior, appearance, and interactivity. All listed options are optional and have default values. ```javascript Reveal.initialize({ // Display presentation control arrows controls: true, // Help the user learn the controls by providing hints, for example by // bouncing the down arrow when they first encounter a vertical slide controlsTutorial: true, // Determines where controls appear, "edges" or "bottom-right" controlsLayout: 'bottom-right', // Visibility rule for backwards navigation arrows; "faded", "hidden" // or "visible" controlsBackArrows: 'faded', // Display a presentation progress bar progress: true, // Set default timing of 2 minutes per slide defaultTiming: 120, // Display the page number of the current slide slideNumber: false, // Push each slide change to the browser history history: false, // Enable keyboard shortcuts for navigation keyboard: true, // Enable the slide overview mode overview: true, // Vertical centering of slides center: true, // Enables touch navigation on devices with touch input touch: true, // Loop the presentation loop: false, // Change the presentation direction to be RTL rtl: false, // Randomizes the order of slides each time the presentation loads shuffle: false, // Turns fragments on and off globally fragments: true, // Flags if the presentation is running in an embedded mode, // i.e. contained within a limited portion of the screen embedded: false, // Flags if we should show a help overlay when the questionmark // key is pressed help: true, // Flags if speaker notes should be visible to all viewers showNotes: false, // Global override for autoplaying embedded media (video/audio/iframe) // - null: Media will only autoplay if data-autoplay is present // - true: All media will autoplay, regardless of individual setting // - false: No media will autoplay, regardless of individual setting autoPlayMedia: null, // Number of milliseconds between automatically proceeding to the // next slide, disabled when set to 0, this value can be overwritten // by using a data-autoslide attribute on your slides autoSlide: 0, // Stop auto-sliding after user input autoSlideStoppable: true, // Use this method for navigation when auto-sliding autoSlideMethod: Reveal.navigateNext, // Enable slide navigation via mouse wheel mouseWheel: false, // Hides the address bar on mobile devices hideAddressBar: true, // Opens links in an iframe preview overlay previewLinks: false, // Transition style transition: 'slide', // none/fade/slide/convex/concave/zoom // Transition speed transitionSpeed: 'default', // default/fast/slow // Transition style for full page slide backgrounds backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom // Number of slides away from the current that are visible viewDistance: 3, // Parallax background image parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" // Parallax background size parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" // Number of pixels to move the parallax background per slide // - Calculated automatically unless specified // - Set to 0 to disable movement along an axis parallaxBackgroundHorizontal: null, parallaxBackgroundVertical: null, // The display mode that will be used to show slides display: 'block' }); ``` -------------------------------- ### Basic Panel Shortcode Usage Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/panel.md Demonstrates the fundamental usage of the panel shortcode to enclose and highlight text. No specific parameters are required for basic functionality. ```Go Template {{% panel %}}this is a panel text{{% /panel %}} ``` -------------------------------- ### C# Read-Only Indexer Property Example Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/language-guide/datatypes/members.md Implements a read-only indexer property in C# for a generic `ReadOnlyList`. This allows accessing elements by index using `this[int idx]`. ```C# public ReadOnlyList { public T this[int idx] { get { return mList[idx]; } } } ``` -------------------------------- ### Initialize Reveal.js Slideshow with Options Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/layouts/shortcodes/revealjs.html Configures and initializes the Reveal.js library for creating presentations. It accepts various options such as controls, centering, history, progress, and transition effects. Dependencies include necessary Reveal.js plugins for markdown, highlighting, zoom, and notes. ```javascript function initSlides() { Reveal.initialize({ embedded: true, controls: {{with .Get "controls"}}{{.|safeHTML}}{{else}}false{{end}}, center: {{with .Get "center"}}{{.|safeHTML}}{{else}}true{{end}}, history: {{with .Get "history"}}{{.|safeHTML}}{{else}}false{{end}}, progress: {{with .Get "progress"}}{{.|safeHTML}}{{else}}false{{end}}, transition: {{with .Get "transition"}}{{.}}{{else}}"concave"{{end}}, dependencies: [ { src: '{{"revealjs/lib/js/classList.js"|relURL}}', condition: function() { return !document.body.classList; } }, { src: '{{"revealjs/plugin/markdown/marked.js"|relURL}}', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: '{{"revealjs/plugin/markdown/markdown.js"|relURL}}', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: '{{"revealjs/plugin/highlight/highlight.js"|relURL}}', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: '{{"revealjs/plugin/zoom-js/zoom.js"|relURL}}', async: true, condition: function() { return !!document.body.classList; } }, { src: '{{"revealjs/plugin/notes/notes.js"|relURL}}', async: true, condition: function() { return !!document.body.classList; } } ] }); } ``` -------------------------------- ### Hugo Children Shortcode with Card Style and Depth Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/children/_index.md This example utilizes the 'card' style to display child pages as cards, along with a specified depth and the option to show descriptions. ```gohtml {{%/* children style="card" depth="2" description="true" */%}} {{% children style="card" depth="2" description="true" %}} ``` -------------------------------- ### Activate Search Output Formats in config.toml Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/getting-start/configuration.md Configures the output formats for the home page to include HTML, RSS, and JSON, enabling search functionality. ```toml [outputs] home = [ "HTML", "RSS", "JSON"] ``` -------------------------------- ### Return Statement for Method Value Output in C# Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/language-guide/statements.md Provides an example of the 'return' statement in C#, used to exit a method and optionally return a value. This is fundamental for methods that produce output. ```C# int GetSize() { return mSize; } ``` -------------------------------- ### C# Documentation Comments Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/ide/documentation.md Demonstrates the usage of documentation comments in C# with /// and /** */ syntax. It shows how to document methods, structures, and parameters, including multiline explanations and the @brief tag for concise summaries. ```C# static { /// Must be placed directly above the method, including attributes. /// Using multiple lines like this is also fine. Both will be recognized. [Optimize] public static void DoAThing() {} /// Documentation also works for types. struct SomeStruct { /** * Multiline comment with two ** at the start works in the same way. */ void PrivateMethod() {} } /** * If you have a really long explainer here, you may not actually want to show that in autcompletion prompts. * @brief Allows you to select only this line to be shown. * * @param a This is shown when writing a call to this function and placing parameter "a". * @param b For the second argument, the documentation for b (this!) will show up instead. */ public static void DoAnotherThing(int a, int b) {} } ``` -------------------------------- ### Load Algolia InstantSearch JS (CDN) Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/layouts/partials/site_js.html Loads the Algolia InstantSearch JavaScript library from a CDN. This library facilitates the implementation of real-time search experiences using Algolia. ```html {{ if eq site.Params.search.engine 2 }} {{ if ($scr.Get "use_cdn") }} {{ printf "" $js.instantsearch.url $js.instantsearch.sri | safeHTML }} {{ end }} {{ end }} ``` -------------------------------- ### C# Nullable Type Usage Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/language-guide/datatypes/_index.md Demonstrates the use of nullable types in C#, which wrap value types to allow for null semantics. Includes examples of null coalescing and conditional assignment. ```C# int? val = null; int i = val ?? 21; if (val == null) val = 42; int? val2 = val + 123; ``` -------------------------------- ### Gitignore Configuration for Public Directory Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/README.md Configuration for the `.gitignore` file to exclude the `public/` directory, except for a `.gitkeep` file. This prevents build artifacts from being committed to the repository, keeping it cleaner. ```gitignore /public/* !/public/.gitkeep ``` -------------------------------- ### Initialize Reveal.js with Plugins (JavaScript) Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/static/revealjs/index.html This JavaScript code initializes the reveal.js presentation framework. It configures various plugins, including marked.js and markdown.js for markdown support, notes.js for speaker notes, and highlight.js for syntax highlighting. The highlight.js plugin is configured to initialize syntax highlighting automatically when the page loads. ```javascript Reveal.initialize({ dependencies: [ { src: 'plugin/markdown/marked.js' }, { src: 'plugin/markdown/markdown.js' }, { src: 'plugin/notes/notes.js', async: true }, { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } } ] }); ``` -------------------------------- ### Hugo Children Shortcode with Description Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/themes/docdock/exampleSite/content/shortcodes/children/_index.md This example shows how to use the children shortcode to display descriptions for child pages. If a page lacks a description, it will use the first 70 words of its content. ```gohtml {{%/* children description="true" */%}} {{%children description="true" %}} ``` -------------------------------- ### Beef Tuple Type Usage (C#) Source: https://github.com/beefytech/beef_website/blob/master/beef-lang.org/content/language-guide/datatypes/_index.md Provides examples of using tuple types in Beef for creating and accessing collections of values. Demonstrates unnamed and named members, decomposition, and explicit typing. ```C# let tup = (1, 2); // Unnamed members int sum = tup.0 + tup.1; // Access by position let (first, second) = tup; // Decompose into new variables let coords = (x: 2, y: 3); // Named members let len = Math.Sqrt(coords.x*coords.x + coords.y*coords.y); // Access by name (uint, uint) utup = (1, 2); // Explicitly typed, unnamed members (int index, Type type) entry = (first, null); // Explicitly typed, named members ``` -------------------------------- ### Initialize Code Highlighting Source: https://github.com/beefytech/beef_website/blob/master/www.beef-lang.org/themes/academic/layouts/partials/site_js.html Initializes highlight.js to automatically apply syntax highlighting to code blocks on the page. This script runs after the highlight.js library has been loaded. ```javascript hljs.initHighlightingOnLoad(); ```