Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h2>C#</h2>
<pre class="hl csharp">
<code>
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

using Spreads.Collections.Concurrent;
using System;
using System.Data;
using Spreads.SQLite.Utilities;
using static Spreads.SQLite.Interop.NativeMethods.Sqlite3_spreads_sqlite3;

namespace Spreads.SQLite.Fast
{
    public class ConnectionPool : IDisposable
    {
        private ConnectionState _state;
        private readonly LockedObjectPool<SqliteConnection> _pool;

        public ConnectionPool(string connectionString)
        {
            ConnectionString = connectionString;
            _pool = new LockedObjectPool<SqliteConnection>(Environment.ProcessorCount * 2, OpenConnection);
            // construct first object for exception on construction if any
            _pool.Return(_pool.Rent());
            _state = ConnectionState.Open;
        }

        public string ConnectionString { get; }

        private SqliteConnection OpenConnection()
        {
            var connection = new SqliteConnection(ConnectionString);
            connection.Open();
            sqlite3_extended_result_codes(connection.DbHandle, 1);
            InitConnection(connection);
            return connection;
        }

        public virtual void InitConnection(SqliteConnection connection)
        {
            connection.ExecuteNonQuery("PRAGMA main.page_size = 4096; ");
            connection.ExecuteNonQuery("PRAGMA main.cache_size = 25000;");
            connection.ExecuteNonQuery("PRAGMA synchronous = NORMAL;");
            connection.ExecuteNonQuery("PRAGMA journal_mode = WAL;");
        }

        public void Release(SqliteConnection handle)
        {
            lock (_pool)
            {
                if (_state == ConnectionState.Closed)
                {
                    ThrowHelper.ThrowInvalidOperationException("_state == ConnectionState.Closed");
                }

                var pooled = _pool.Return(handle);
                if (!pooled)
                {
                    handle.Dispose();
                }
            }
        }

        public SqliteConnection Rent()
        {
            lock (_pool)
            {
                if (_state == ConnectionState.Closed)
                {
                    ThrowHelper.ThrowInvalidOperationException("_state == ConnectionState.Closed");
                }
                return _pool.Rent();
            }
        }

        public void Dispose()
        {
            lock (_pool)
            {
                _pool.Dispose();
                _state = ConnectionState.Closed;
            }
        }
    }
}
</code>
</pre>

<h2>Javascript</h2>
<pre class="hl js"><code>
/**
 * Iterates over properties of `object`, returning an array of all elements
 * `predicate` returns truthy for. The predicate is invoked with three
 * arguments: (value, key, object).
 *
 * If you want an object in return, consider `pickBy`.
 *
 * @since 5.0.0
 * @category Object
 * @param {Object} object The object to iterate over.
 * @param {Function} predicate The function invoked per iteration.
 * @returns {Array} Returns the new filtered array.
 * @see pickBy, pull, pullAll, pullAllBy, pullAllWith, pullAt, remove, reject
 * @example
 *
 * const object = { 'a': 5, 'b': 8, 'c': 10 }
 *
 * filterObject(object, (n) => !(n % 5))
 * // => [5, 10]
 */
function filterObject(object, predicate) {
  object = Object(object)
  const result = []

  Object.keys(object).forEach((key) => {
    const value = object[key]
    if (predicate(value, key, object)) {
      result.push(value)
    }
  })
  return result
}

export default 
</code></pre>\

<h2>Ruby</h2>
<pre class="hl ruby">
<code>
# frozen_string_literal: true

require "abstract_controller/collector"
require "active_support/core_ext/hash/reverse_merge"
require "active_support/core_ext/array/extract_options"

module ActionMailer
  class Collector
    include AbstractController::Collector
    attr_reader :responses

    def initialize(context, &block)
      @context = context
      @responses = []
      @default_render = block
    end

    def any(*args, &block)
      options = args.extract_options!
      raise ArgumentError, "You have to supply at least one format" if args.empty?
      args.each { |type| send(type, options.dup, &block) }
    end
    alias :all :any

    def custom(mime, options = {})
      options.reverse_merge!(content_type: mime.to_s)
      @context.formats = [mime.to_sym]
      options[:body] = block_given? ? yield : @default_render.call
      @responses << options
    end
  end
end
</code>
</pre>

<h2>Rust</h2>
<pre class="hl rust"><code>
// This powerful wrapper provides the ability to store a positive integer value.
// Rewrite it using generics so that it supports wrapping ANY type.

// I AM NOT DONE
struct Wrapper<u32> {
    value: u32
}

impl<u32> Wrapper<u32> {
    pub fn new(value: u32) -> Self {
        Wrapper { value }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn store_u32_in_wrapper() {
        assert_eq!(Wrapper::new(42).value,  42);
    }

    #[test]
    fn store_str_in_wrapper() {
        // TODO: Delete this assert and uncomment the one  below once you have  finished the exercise.
        assert!(false);
        // assert_eq!(Wrapper::new("Foo").value, "Foo");
    }
}
</code></pre>
              
            
!

CSS

              
                body {
 margin: 3rem;
}

h2 {
 font-family: sans-serif;
 margin: 0 auto;
 width: 700px;
}

pre {
 width: 700px;
 white-space: pre-wrap;
 word-break: break-word;
 padding: 1em;
 font-family: "Fira Mono", monospace;
 line-height: 1.15em;

 margin: 1em auto 2em auto;
 code {
 }
}

@media (prefers-color-scheme: dark) {
 $bg: darken(#fafafa, 80);
 $txt: lighten(#fafafa, 80);

 body {
  background-color: $bg;
  color: $txt;
 }

 pre {
  outline: 1px solid $txt;
 }
}

@media (prefers-color-scheme: light) {
 $bg: lighten(#fafafa, 80);
 $txt: darken(#fafafa, 80);

 body {
  background-color: $bg;
  color: $txt;
 }

 pre {
  outline: 1px solid $txt;
 }
}

              
            
!

JS

              
                var hl = function () {
 var elements = document.querySelectorAll("pre.hl");

 // regex is stolen from: https://github.com/asvd/microlight/blob/b210d51ae78c396edefbace2714e7da62f965089/microlight.js#L153

 var rgx = /\s+(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(icrolight|odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing)|v(ar|irtual|oid|olatile)|w(char_t|hen|here|hile|ith)|xor|yield)/g;

 for (let element of elements) {
  var code = element.textContent;
  element.innerHTML = code.replace(rgx, function (x) {
   return x.bold();
  });
 }
}; // h
hl();

              
            
!
999px

Console