This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gemspec
|
||||
|
||||
gem 'rake'
|
||||
|
||||
gem 'minitest', '>= 5.0'
|
||||
gem 'minitest-power_assert'
|
||||
gem 'power_assert', '~> 2.0'
|
||||
|
||||
# don't try to install redcarpet under jruby
|
||||
gem 'redcarpet', platforms: :ruby
|
||||
|
||||
# Profiling
|
||||
gem 'memory_profiler', require: false
|
||||
|
||||
group :development do
|
||||
gem 'pry'
|
||||
|
||||
# Needed for a Rake task
|
||||
gem 'git'
|
||||
gem 'yard'
|
||||
|
||||
gem 'rubocop', '~> 1.0', '<= 1.11'
|
||||
gem 'rubocop-performance'
|
||||
|
||||
# docs
|
||||
gem 'github-markup'
|
||||
|
||||
# for visual tests
|
||||
gem 'sinatra'
|
||||
|
||||
# Ruby 3 no longer ships with a web server
|
||||
gem 'puma' if RUBY_VERSION >= '3'
|
||||
gem 'shotgun'
|
||||
|
||||
gem "mutex_m" if RUBY_VERSION >= '3.4'
|
||||
gem "base64" if RUBY_VERSION >= '3.4'
|
||||
end
|
||||
@@ -0,0 +1,187 @@
|
||||
# MIT license. See http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
Copyright (c) 2012 Jeanine Adkisson.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
# SPECIAL NOTE:
|
||||
|
||||
Many of the lexers in this project are adaptations of those in Pygments
|
||||
(pygments.org). The license for Pygments is as follows:
|
||||
|
||||
# BEGIN pygments/LICENSE #
|
||||
|
||||
Copyright (c) 2006-2012 by the respective authors (see AUTHORS file).
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# END pygments/LICENSE #
|
||||
|
||||
The contents of the AUTHORS file at the time of porting was:
|
||||
|
||||
# BEGIN pygments/AUTHORS #
|
||||
|
||||
Pygments is written and maintained by Georg Brandl <georg@python.org>.
|
||||
|
||||
Major developers are Tim Hatch <tim@timhatch.com> and Armin Ronacher
|
||||
<armin.ronacher@active-4.com>.
|
||||
|
||||
Other contributors, listed alphabetically, are:
|
||||
|
||||
* Sam Aaron -- Ioke lexer
|
||||
* Kumar Appaiah -- Debian control lexer
|
||||
* Ali Afshar -- image formatter
|
||||
* Andreas Amann -- AppleScript lexer
|
||||
* Jeffrey Arnold -- R/S lexer, BUGS lexers
|
||||
* Jeremy Ashkenas -- CoffeeScript lexer
|
||||
* Stefan Matthias Aust -- Smalltalk lexer
|
||||
* Ben Bangert -- Mako lexers
|
||||
* Max Battcher -- Darcs patch lexer
|
||||
* Paul Baumgart, 280 North, Inc. -- Objective-J lexer
|
||||
* Michael Bayer -- Myghty lexers
|
||||
* John Benediktsson -- Factor lexer
|
||||
* Christopher Bertels -- Fancy lexer
|
||||
* Jarrett Billingsley -- MiniD lexer
|
||||
* Adam Blinkinsop -- Haskell, Redcode lexers
|
||||
* Frits van Bommel -- assembler lexers
|
||||
* Pierre Bourdon -- bugfixes
|
||||
* Hiram Chirino -- Scaml and Jade lexers
|
||||
* Leaf Corcoran -- MoonScript lexer
|
||||
* Christopher Creutzig -- MuPAD lexer
|
||||
* Pete Curry -- bugfixes
|
||||
* Owen Durni -- haXe lexer
|
||||
* Nick Efford -- Python 3 lexer
|
||||
* Sven Efftinge -- Xtend lexer
|
||||
* Artem Egorkine -- terminal256 formatter
|
||||
* James H. Fisher -- PostScript lexer
|
||||
* Carlos Galdino -- Elixir and Elixir Console lexers
|
||||
* Naveen Garg -- Autohotkey lexer
|
||||
* Laurent Gautier -- R/S lexer
|
||||
* Alex Gaynor -- PyPy log lexer
|
||||
* Bertrand Goetzmann -- Groovy lexer
|
||||
* Krzysiek Goj -- Scala lexer
|
||||
* Matt Good -- Genshi, Cheetah lexers
|
||||
* Patrick Gotthardt -- PHP namespaces support
|
||||
* Olivier Guibe -- Asymptote lexer
|
||||
* Martin Harriman -- SNOBOL lexer
|
||||
* Matthew Harrison -- SVG formatter
|
||||
* Steven Hazel -- Tcl lexer
|
||||
* Aslak Hellesøy -- Gherkin lexer
|
||||
* Greg Hendershott -- Racket lexer
|
||||
* Jordi Gutiérrez Hermoso -- Octave lexer
|
||||
* David Hess, Fish Software, Inc. -- Objective-J lexer
|
||||
* Varun Hiremath -- Debian control lexer
|
||||
* Doug Hogan -- Mscgen lexer
|
||||
* Ben Hollis -- Mason lexer
|
||||
* Tim Howard -- BlitzMax lexer
|
||||
* Ivan Inozemtsev -- Fantom lexer
|
||||
* Brian R. Jackson -- Tea lexer
|
||||
* Dennis Kaarsemaker -- sources.list lexer
|
||||
* Igor Kalnitsky -- vhdl lexer
|
||||
* Eric Knibbe -- Lasso lexer
|
||||
* Adam Koprowski -- Opa lexer
|
||||
* Benjamin Kowarsch -- Modula-2 lexer
|
||||
* Alexander Kriegisch -- Kconfig and AspectJ lexers
|
||||
* Marek Kubica -- Scheme lexer
|
||||
* Jochen Kupperschmidt -- Markdown processor
|
||||
* Gerd Kurzbach -- Modelica lexer
|
||||
* Olov Lassus -- Dart lexer
|
||||
* Sylvestre Ledru -- Scilab lexer
|
||||
* Mark Lee -- Vala lexer
|
||||
* Ben Mabey -- Gherkin lexer
|
||||
* Simone Margaritelli -- Hybris lexer
|
||||
* Kirk McDonald -- D lexer
|
||||
* Gordon McGregor -- SystemVerilog lexer
|
||||
* Stephen McKamey -- Duel/JBST lexer
|
||||
* Brian McKenna -- F# lexer
|
||||
* Lukas Meuser -- BBCode formatter, Lua lexer
|
||||
* Paul Miller -- LiveScript lexer
|
||||
* Hong Minhee -- HTTP lexer
|
||||
* Michael Mior -- Awk lexer
|
||||
* Jon Morton -- Rust lexer
|
||||
* Paulo Moura -- Logtalk lexer
|
||||
* Mher Movsisyan -- DTD lexer
|
||||
* Ana Nelson -- Ragel, ANTLR, R console lexers
|
||||
* Nam T. Nguyen -- Monokai style
|
||||
* Jesper Noehr -- HTML formatter "anchorlinenos"
|
||||
* Mike Nolta -- Julia lexer
|
||||
* Jonas Obrist -- BBCode lexer
|
||||
* David Oliva -- Rebol lexer
|
||||
* Jon Parise -- Protocol buffers lexer
|
||||
* Ronny Pfannschmidt -- BBCode lexer
|
||||
* Benjamin Peterson -- Test suite refactoring
|
||||
* Dominik Picheta -- Nimrod lexer
|
||||
* Clément Prévost -- UrbiScript lexer
|
||||
* Kashif Rasul -- CUDA lexer
|
||||
* Justin Reidy -- MXML lexer
|
||||
* Norman Richards -- JSON lexer
|
||||
* Lubomir Rintel -- GoodData MAQL and CL lexers
|
||||
* Andre Roberge -- Tango style
|
||||
* Konrad Rudolph -- LaTeX formatter enhancements
|
||||
* Mario Ruggier -- Evoque lexers
|
||||
* Stou Sandalski -- NumPy, FORTRAN, tcsh and XSLT lexers
|
||||
* Matteo Sasso -- Common Lisp lexer
|
||||
* Joe Schafer -- Ada lexer
|
||||
* Ken Schutte -- Matlab lexers
|
||||
* Tassilo Schweyer -- Io, MOOCode lexers
|
||||
* Joerg Sieker -- ABAP lexer
|
||||
* Robert Simmons -- Standard ML lexer
|
||||
* Kirill Simonov -- YAML lexer
|
||||
* Steve Spigarelli -- XQuery lexer
|
||||
* Jerome St-Louis -- eC lexer
|
||||
* James Strachan -- Kotlin lexer
|
||||
* Tiberius Teng -- default style overhaul
|
||||
* Jeremy Thurgood -- Erlang, Squid config lexers
|
||||
* Erick Tryzelaar -- Felix lexer
|
||||
* Daniele Varrazzo -- PostgreSQL lexers
|
||||
* Abe Voelker -- OpenEdge ABL lexer
|
||||
* Whitney Young -- ObjectiveC lexer
|
||||
* Matthias Vallentin -- Bro lexer
|
||||
* Nathan Weizenbaum -- Haml and Sass lexers
|
||||
* Dietmar Winkler -- Modelica lexer
|
||||
* Nils Winter -- Smalltalk lexer
|
||||
* Davy Wybiral -- Clojure lexer
|
||||
* Diego Zamboni -- CFengine3 lexer
|
||||
* Alex Zimin -- Nemerle lexer
|
||||
|
||||
Many thanks for all contributions!
|
||||
|
||||
# END pygments/AUTHORS #
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'pathname'
|
||||
ROOT_DIR = Pathname.new(__FILE__).dirname.parent
|
||||
Kernel::load ROOT_DIR.join('lib/rouge.rb')
|
||||
Kernel::load ROOT_DIR.join('lib/rouge/cli.rb')
|
||||
Signal.trap('PIPE', 'SYSTEM_DEFAULT') if Signal.list.include? 'PIPE'
|
||||
|
||||
begin
|
||||
Rouge::CLI.parse(ARGV).run
|
||||
rescue Rouge::CLI::Error => e
|
||||
puts e.message
|
||||
exit e.status
|
||||
rescue Interrupt
|
||||
$stderr.puts "\nrouge: interrupted"
|
||||
exit 2
|
||||
end
|
||||
@@ -0,0 +1,106 @@
|
||||
# -*- coding: utf-8 -*- #
|
||||
# frozen_string_literal: true
|
||||
|
||||
# stdlib
|
||||
require 'pathname'
|
||||
|
||||
# The containing module for Rouge
|
||||
module Rouge
|
||||
# cache value in a constant since `__dir__` allocates a new string
|
||||
# on every call.
|
||||
LIB_DIR = __dir__.freeze
|
||||
|
||||
class << self
|
||||
def reload!
|
||||
Object::send :remove_const, :Rouge
|
||||
Kernel::load __FILE__
|
||||
end
|
||||
|
||||
# Highlight some text with a given lexer and formatter.
|
||||
#
|
||||
# @example
|
||||
# Rouge.highlight('@foo = 1', 'ruby', 'html')
|
||||
# Rouge.highlight('var foo = 1;', 'js', 'terminal256')
|
||||
#
|
||||
# # streaming - chunks become available as they are lexed
|
||||
# Rouge.highlight(large_string, 'ruby', 'html') do |chunk|
|
||||
# $stdout.print chunk
|
||||
# end
|
||||
def highlight(text, lexer, formatter, &b)
|
||||
lexer = Lexer.find(lexer) unless lexer.respond_to? :lex
|
||||
raise "unknown lexer #{lexer}" unless lexer
|
||||
|
||||
formatter = Formatter.find(formatter) unless formatter.respond_to? :format
|
||||
raise "unknown formatter #{formatter}" unless formatter
|
||||
|
||||
formatter.format(lexer.lex(text), &b)
|
||||
end
|
||||
|
||||
# Load a file relative to the `lib/rouge` path.
|
||||
#
|
||||
# @api private
|
||||
def load_file(path)
|
||||
Kernel::load File.join(LIB_DIR, "rouge/#{path}.rb")
|
||||
end
|
||||
|
||||
# Load the lexers in the `lib/rouge/lexers` directory.
|
||||
#
|
||||
# @api private
|
||||
def load_lexers
|
||||
lexer_dir = Pathname.new(LIB_DIR) / "rouge/lexers"
|
||||
Pathname.glob(lexer_dir / '*.rb').each do |f|
|
||||
Lexers.load_lexer(f.relative_path_from(lexer_dir))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Rouge.load_file 'version'
|
||||
Rouge.load_file 'util'
|
||||
Rouge.load_file 'text_analyzer'
|
||||
Rouge.load_file 'token'
|
||||
|
||||
Rouge.load_file 'lexer'
|
||||
Rouge.load_file 'regex_lexer'
|
||||
Rouge.load_file 'template_lexer'
|
||||
|
||||
Rouge.load_lexers
|
||||
|
||||
Rouge.load_file 'guesser'
|
||||
Rouge.load_file 'guessers/util'
|
||||
Rouge.load_file 'guessers/glob_mapping'
|
||||
Rouge.load_file 'guessers/modeline'
|
||||
Rouge.load_file 'guessers/filename'
|
||||
Rouge.load_file 'guessers/mimetype'
|
||||
Rouge.load_file 'guessers/source'
|
||||
Rouge.load_file 'guessers/disambiguation'
|
||||
|
||||
Rouge.load_file 'formatter'
|
||||
Rouge.load_file 'formatters/html'
|
||||
Rouge.load_file 'formatters/html_table'
|
||||
Rouge.load_file 'formatters/html_pygments'
|
||||
Rouge.load_file 'formatters/html_legacy'
|
||||
Rouge.load_file 'formatters/html_linewise'
|
||||
Rouge.load_file 'formatters/html_line_highlighter'
|
||||
Rouge.load_file 'formatters/html_line_table'
|
||||
Rouge.load_file 'formatters/html_inline'
|
||||
Rouge.load_file 'formatters/terminal256'
|
||||
Rouge.load_file 'formatters/terminal_truecolor'
|
||||
Rouge.load_file 'formatters/tex'
|
||||
Rouge.load_file 'formatters/null'
|
||||
|
||||
Rouge.load_file 'theme'
|
||||
Rouge.load_file 'tex_theme_renderer'
|
||||
Rouge.load_file 'themes/thankful_eyes'
|
||||
Rouge.load_file 'themes/colorful'
|
||||
Rouge.load_file 'themes/base16'
|
||||
Rouge.load_file 'themes/github'
|
||||
Rouge.load_file 'themes/igor_pro'
|
||||
Rouge.load_file 'themes/monokai'
|
||||
Rouge.load_file 'themes/molokai'
|
||||
Rouge.load_file 'themes/monokai_sublime'
|
||||
Rouge.load_file 'themes/gruvbox'
|
||||
Rouge.load_file 'themes/tulip'
|
||||
Rouge.load_file 'themes/pastie'
|
||||
Rouge.load_file 'themes/bw'
|
||||
Rouge.load_file 'themes/magritte'
|
||||
@@ -0,0 +1,530 @@
|
||||
# -*- coding: utf-8 -*- #
|
||||
# frozen_string_literal: true
|
||||
|
||||
# not required by the main lib.
|
||||
# to use this module, require 'rouge/cli'.
|
||||
|
||||
require 'rbconfig'
|
||||
require 'uri'
|
||||
|
||||
module Rouge
|
||||
class FileReader
|
||||
attr_reader :input
|
||||
def initialize(input)
|
||||
@input = input
|
||||
end
|
||||
|
||||
def file
|
||||
case input
|
||||
when '-'
|
||||
IO.new($stdin.fileno, 'rt:bom|utf-8')
|
||||
when String
|
||||
File.new(input, 'rt:bom|utf-8')
|
||||
when ->(i){ i.respond_to? :read }
|
||||
input
|
||||
end
|
||||
end
|
||||
|
||||
def read
|
||||
@read ||= begin
|
||||
file.read
|
||||
rescue => e
|
||||
$stderr.puts "unable to open #{input}: #{e.message}"
|
||||
exit 1
|
||||
ensure
|
||||
file.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class CLI
|
||||
def self.doc
|
||||
return enum_for(:doc) unless block_given?
|
||||
|
||||
yield %|usage: rougify {global options} [command] [args...]|
|
||||
yield %||
|
||||
yield %|where <command> is one of:|
|
||||
yield %| highlight #{Highlight.desc}|
|
||||
yield %| debug #{Debug.desc}|
|
||||
yield %| help #{Help.desc}|
|
||||
yield %| style #{Style.desc}|
|
||||
yield %| list #{List.desc}|
|
||||
yield %| guess #{Guess.desc}|
|
||||
yield %| version #{Version.desc}|
|
||||
yield %||
|
||||
yield %|global options:|
|
||||
yield %[ --require|-r <fname> require <fname> after loading rouge]
|
||||
yield %||
|
||||
yield %|See `rougify help <command>` for more info.|
|
||||
end
|
||||
|
||||
class Error < StandardError
|
||||
attr_reader :message, :status
|
||||
def initialize(message, status=1)
|
||||
@message = message
|
||||
@status = status
|
||||
end
|
||||
end
|
||||
|
||||
def self.parse(argv=ARGV)
|
||||
argv = normalize_syntax(argv)
|
||||
|
||||
while (head = argv.shift)
|
||||
case head
|
||||
when '-h', '--help', 'help', '-help'
|
||||
return Help.parse(argv)
|
||||
when '--require', '-r'
|
||||
require argv.shift
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
klass = class_from_arg(head)
|
||||
return klass.parse(argv) if klass
|
||||
|
||||
argv.unshift(head) if head
|
||||
Highlight.parse(argv)
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
end
|
||||
|
||||
def self.error!(msg, status=1)
|
||||
raise Error.new(msg, status)
|
||||
end
|
||||
|
||||
def error!(*a)
|
||||
self.class.error!(*a)
|
||||
end
|
||||
|
||||
def self.class_from_arg(arg)
|
||||
case arg
|
||||
when 'version', '--version', '-v'
|
||||
Version
|
||||
when 'help', nil
|
||||
Help
|
||||
when 'highlight', 'hi'
|
||||
Highlight
|
||||
when 'debug'
|
||||
Debug
|
||||
when 'style'
|
||||
Style
|
||||
when 'list'
|
||||
List
|
||||
when 'guess'
|
||||
Guess
|
||||
end
|
||||
end
|
||||
|
||||
class Version < CLI
|
||||
def self.desc
|
||||
"print the rouge version number"
|
||||
end
|
||||
|
||||
def self.parse(*); new; end
|
||||
|
||||
def run
|
||||
puts Rouge.version
|
||||
end
|
||||
end
|
||||
|
||||
class Help < CLI
|
||||
def self.desc
|
||||
"print help info"
|
||||
end
|
||||
|
||||
def self.doc
|
||||
return enum_for(:doc) unless block_given?
|
||||
|
||||
yield %|usage: rougify help <command>|
|
||||
yield %||
|
||||
yield %|print help info for <command>.|
|
||||
end
|
||||
|
||||
def self.parse(argv)
|
||||
opts = { :mode => CLI }
|
||||
until argv.empty?
|
||||
arg = argv.shift
|
||||
klass = class_from_arg(arg)
|
||||
if klass
|
||||
opts[:mode] = klass
|
||||
next
|
||||
end
|
||||
end
|
||||
new(opts)
|
||||
end
|
||||
|
||||
def initialize(opts={})
|
||||
@mode = opts[:mode]
|
||||
end
|
||||
|
||||
def run
|
||||
@mode.doc.each(&method(:puts))
|
||||
end
|
||||
end
|
||||
|
||||
class Highlight < CLI
|
||||
def self.desc
|
||||
"highlight code"
|
||||
end
|
||||
|
||||
def self.doc
|
||||
return enum_for(:doc) unless block_given?
|
||||
|
||||
yield %[usage: rougify highlight <filename> [options...]]
|
||||
yield %[ rougify highlight [options...]]
|
||||
yield %[]
|
||||
yield %[--input-file|-i <filename> specify a file to read, or - to use stdin]
|
||||
yield %[]
|
||||
yield %[--lexer|-l <lexer> specify the lexer to use.]
|
||||
yield %[ If not provided, rougify will try to guess]
|
||||
yield %[ based on --mimetype, the filename, and the]
|
||||
yield %[ file contents.]
|
||||
yield %[]
|
||||
yield %[--formatter-preset|-f <opts> specify the output formatter to use.]
|
||||
yield %[ If not provided, rougify will default to]
|
||||
yield %[ terminal256. options are: terminal256,]
|
||||
yield %[ terminal-truecolor, html, html-pygments,]
|
||||
yield %[ html-inline, html-line-table, html-table,]
|
||||
yield %[ null/raw/tokens, or tex.]
|
||||
yield %[]
|
||||
yield %[--theme|-t <theme> specify the theme to use for highlighting]
|
||||
yield %[ the file. (only applies to some formatters)]
|
||||
yield %[]
|
||||
yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
|
||||
yield %[]
|
||||
yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
|
||||
yield %[ (opt1=val1&opt2=val2)]
|
||||
yield %[]
|
||||
yield %[--formatter-opts|-F <opts> specify formatter options in CGI format]
|
||||
yield %[ (opt1=val1&opt2=val2)]
|
||||
yield %[]
|
||||
yield %[--require|-r <filename> require a filename or library before]
|
||||
yield %[ highlighting]
|
||||
yield %[]
|
||||
yield %[--escape allow the use of escapes between <! and !>]
|
||||
yield %[]
|
||||
yield %[--escape-with <l> <r> allow the use of escapes between custom]
|
||||
yield %[ delimiters. implies --escape]
|
||||
end
|
||||
|
||||
# There is no consistent way to do this, but this is used elsewhere,
|
||||
# and we provide explicit opt-in and opt-out with $COLORTERM
|
||||
def self.supports_truecolor?
|
||||
return true if %w(24bit truecolor).include?(ENV['COLORTERM'])
|
||||
return false if ENV['COLORTERM'] && ENV['COLORTERM'] =~ /256/
|
||||
|
||||
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
||||
ENV['ConEmuANSI'] == 'ON' && !ENV['ANSICON']
|
||||
else
|
||||
ENV['TERM'] !~ /(^rxvt)|(-color$)/
|
||||
end
|
||||
end
|
||||
|
||||
def self.parse_opts(argv)
|
||||
opts = {
|
||||
:formatter => supports_truecolor? ? 'terminal-truecolor' : 'terminal256',
|
||||
:theme => 'thankful_eyes',
|
||||
:css_class => 'codehilite',
|
||||
:input_file => '-',
|
||||
:lexer_opts => {},
|
||||
:formatter_opts => {},
|
||||
:requires => [],
|
||||
}
|
||||
|
||||
until argv.empty?
|
||||
arg = argv.shift
|
||||
case arg
|
||||
when '-r', '--require'
|
||||
opts[:requires] << argv.shift
|
||||
when '--input-file', '-i'
|
||||
opts[:input_file] = argv.shift
|
||||
when '--mimetype', '-m'
|
||||
opts[:mimetype] = argv.shift
|
||||
when '--lexer', '-l'
|
||||
opts[:lexer] = argv.shift
|
||||
when '--formatter-preset', '-f'
|
||||
opts[:formatter] = argv.shift
|
||||
when '--theme', '-t'
|
||||
opts[:theme] = argv.shift
|
||||
when '--css-class', '-c'
|
||||
opts[:css_class] = argv.shift
|
||||
when '--lexer-opts', '-L'
|
||||
opts[:lexer_opts] = parse_cgi(argv.shift)
|
||||
when '--escape'
|
||||
opts[:escape] = ['<!', '!>']
|
||||
when '--escape-with'
|
||||
opts[:escape] = [argv.shift, argv.shift]
|
||||
when /^--/
|
||||
error! "unknown option #{arg.inspect}"
|
||||
else
|
||||
opts[:input_file] = arg
|
||||
end
|
||||
end
|
||||
|
||||
opts
|
||||
end
|
||||
|
||||
def self.parse(argv)
|
||||
new(parse_opts(argv))
|
||||
end
|
||||
|
||||
def input_stream
|
||||
@input_stream ||= FileReader.new(@input_file)
|
||||
end
|
||||
|
||||
def input
|
||||
@input ||= input_stream.read
|
||||
end
|
||||
|
||||
def lexer_class
|
||||
@lexer_class ||= Lexer.guess(
|
||||
:filename => @input_file,
|
||||
:mimetype => @mimetype,
|
||||
:source => input_stream,
|
||||
)
|
||||
end
|
||||
|
||||
def raw_lexer
|
||||
lexer_class.new(@lexer_opts)
|
||||
end
|
||||
|
||||
def escape_lexer
|
||||
Rouge::Lexers::Escape.new(
|
||||
start: @escape[0],
|
||||
end: @escape[1],
|
||||
lang: raw_lexer,
|
||||
)
|
||||
end
|
||||
|
||||
def lexer
|
||||
@lexer ||= @escape ? escape_lexer : raw_lexer
|
||||
end
|
||||
|
||||
attr_reader :input_file, :lexer_name, :mimetype, :formatter, :escape
|
||||
|
||||
def initialize(opts={})
|
||||
Rouge::Lexer.enable_debug!
|
||||
|
||||
opts[:requires].each do |r|
|
||||
require r
|
||||
end
|
||||
|
||||
@input_file = opts[:input_file]
|
||||
|
||||
if opts[:lexer]
|
||||
@lexer_class = Lexer.find(opts[:lexer]) \
|
||||
or error! "unknown lexer #{opts[:lexer].inspect}"
|
||||
else
|
||||
@lexer_name = opts[:lexer]
|
||||
@mimetype = opts[:mimetype]
|
||||
end
|
||||
|
||||
@lexer_opts = opts[:lexer_opts]
|
||||
|
||||
theme = Theme.find(opts[:theme]).new or error! "unknown theme #{opts[:theme]}"
|
||||
|
||||
# TODO: document this in --help
|
||||
@formatter = case opts[:formatter]
|
||||
when 'terminal256' then Formatters::Terminal256.new(theme)
|
||||
when 'terminal-truecolor' then Formatters::TerminalTruecolor.new(theme)
|
||||
when 'html' then Formatters::HTML.new
|
||||
when 'html-pygments' then Formatters::HTMLPygments.new(Formatters::HTML.new, opts[:css_class])
|
||||
when 'html-inline' then Formatters::HTMLInline.new(theme)
|
||||
when 'html-line-table' then Formatters::HTMLLineTable.new(Formatters::HTML.new)
|
||||
when 'html-table' then Formatters::HTMLTable.new(Formatters::HTML.new)
|
||||
when 'null', 'raw', 'tokens' then Formatters::Null.new
|
||||
when 'tex' then Formatters::Tex.new
|
||||
else
|
||||
error! "unknown formatter preset #{opts[:formatter]}"
|
||||
end
|
||||
|
||||
@escape = opts[:escape]
|
||||
end
|
||||
|
||||
def run
|
||||
Formatter.enable_escape! if @escape
|
||||
formatter.format(lexer.lex(input), &method(:print))
|
||||
end
|
||||
|
||||
private_class_method def self.parse_cgi(str)
|
||||
pairs = URI.decode_www_form(str).map { |k, v| [k.to_sym, v] }
|
||||
Hash[pairs]
|
||||
end
|
||||
end
|
||||
|
||||
class Debug < Highlight
|
||||
def self.desc
|
||||
end
|
||||
|
||||
def self.doc
|
||||
return enum_for(:doc) unless block_given?
|
||||
|
||||
yield %|usage: rougify debug [<options>]|
|
||||
yield %||
|
||||
yield %|Debug a lexer. Similar options to `rougify highlight`, but|
|
||||
yield %|defaults to the `null` formatter, and ensures the `debug`|
|
||||
yield %|option is enabled, to print debugging information to stdout.|
|
||||
end
|
||||
|
||||
def self.parse_opts(argv)
|
||||
out = super(argv)
|
||||
out[:lexer_opts]['debug'] = '1'
|
||||
out[:formatter] = 'null'
|
||||
|
||||
out
|
||||
end
|
||||
end
|
||||
|
||||
class Style < CLI
|
||||
def self.desc
|
||||
"print CSS styles"
|
||||
end
|
||||
|
||||
def self.doc
|
||||
return enum_for(:doc) unless block_given?
|
||||
|
||||
yield %|usage: rougify style [<theme-name>] [<options>]|
|
||||
yield %||
|
||||
yield %|Print CSS styles for the given theme. Extra options are|
|
||||
yield %|passed to the theme. To select a mode (light/dark) for the|
|
||||
yield %|theme, append '.light' or '.dark' to the <theme-name>|
|
||||
yield %|respectively. Theme defaults to thankful_eyes.|
|
||||
yield %||
|
||||
yield %|options:|
|
||||
yield %| --scope (default: .highlight) a css selector to scope by|
|
||||
yield %| --tex (default: false) render as TeX|
|
||||
yield %| --tex-prefix (default: RG) a command prefix for TeX|
|
||||
yield %| implies --tex if specified|
|
||||
yield %||
|
||||
yield %|available themes:|
|
||||
yield %| #{Theme.registry.keys.sort.join(', ')}|
|
||||
end
|
||||
|
||||
def self.parse(argv)
|
||||
opts = {
|
||||
:theme_name => 'thankful_eyes',
|
||||
:tex => false,
|
||||
:tex_prefix => 'RG'
|
||||
}
|
||||
|
||||
until argv.empty?
|
||||
arg = argv.shift
|
||||
case arg
|
||||
when '--tex'
|
||||
opts[:tex] = true
|
||||
when '--tex-prefix'
|
||||
opts[:tex] = true
|
||||
opts[:tex_prefix] = argv.shift
|
||||
when /--(\w+)/
|
||||
opts[$1.tr('-', '_').to_sym] = argv.shift
|
||||
else
|
||||
opts[:theme_name] = arg
|
||||
end
|
||||
end
|
||||
|
||||
new(opts)
|
||||
end
|
||||
|
||||
def initialize(opts)
|
||||
theme_name = opts.delete(:theme_name)
|
||||
theme_class = Theme.find(theme_name) \
|
||||
or error! "unknown theme: #{theme_name}"
|
||||
|
||||
@theme = theme_class.new(opts)
|
||||
if opts[:tex]
|
||||
tex_prefix = opts[:tex_prefix]
|
||||
@theme = TexThemeRenderer.new(@theme, prefix: tex_prefix)
|
||||
end
|
||||
end
|
||||
|
||||
def run
|
||||
@theme.render(&method(:puts))
|
||||
end
|
||||
end
|
||||
|
||||
class List < CLI
|
||||
def self.desc
|
||||
"list available lexers"
|
||||
end
|
||||
|
||||
def self.doc
|
||||
return enum_for(:doc) unless block_given?
|
||||
|
||||
yield %|usage: rouge list|
|
||||
yield %||
|
||||
yield %|print a list of all available lexers with their descriptions.|
|
||||
end
|
||||
|
||||
def self.parse(argv)
|
||||
new
|
||||
end
|
||||
|
||||
def run
|
||||
puts "== Available Lexers =="
|
||||
|
||||
Lexer.all.sort_by(&:tag).each do |lexer|
|
||||
desc = String.new("#{lexer.desc}")
|
||||
if lexer.aliases.any?
|
||||
desc << " [aliases: #{lexer.aliases.join(',')}]"
|
||||
end
|
||||
puts "%s: %s" % [lexer.tag, desc]
|
||||
|
||||
lexer.option_docs.keys.sort.each do |option|
|
||||
puts " ?#{option}= #{lexer.option_docs[option]}"
|
||||
end
|
||||
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Guess < CLI
|
||||
def self.desc
|
||||
"guess the languages of file"
|
||||
end
|
||||
|
||||
def self.parse(args)
|
||||
new(input_file: args.shift)
|
||||
end
|
||||
|
||||
attr_reader :input_file, :input_source
|
||||
|
||||
def initialize(opts)
|
||||
@input_file = opts[:input_file] || '-'
|
||||
@input_source = FileReader.new(@input_file).read
|
||||
end
|
||||
|
||||
def lexers
|
||||
Lexer.guesses(
|
||||
filename: input_file,
|
||||
source: input_source,
|
||||
)
|
||||
end
|
||||
|
||||
def run
|
||||
lexers.each do |l|
|
||||
puts "{ tag: #{l.tag.inspect}, title: #{l.title.inspect}, desc: #{l.desc.inspect} }"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private_class_method def self.normalize_syntax(argv)
|
||||
out = []
|
||||
argv.each do |arg|
|
||||
case arg
|
||||
when /^(--\w+)=(.*)$/
|
||||
out << $1 << $2
|
||||
when /^(-\w)(.+)$/
|
||||
out << $1 << $2
|
||||
else
|
||||
out << arg
|
||||
end
|
||||
end
|
||||
|
||||
out
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
lo_obj ?= lo_obj->do_nothing( 'Char' && ` String` ).
|
||||
|
||||
SELECT SINGLE * FROM mara INTO ls_mara WHERE matkl EQ '1324'.
|
||||
LOOP AT lt_mara ASSIGNING <mara>.
|
||||
CHECK <mara>-mtart EQ '0001'.
|
||||
ENDLOOP.
|
||||
@@ -0,0 +1,4 @@
|
||||
function hello(name:String):void
|
||||
{
|
||||
trace("hello " + name);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
with Ada.Directories;
|
||||
with Ada.Direct_IO;
|
||||
with Ada.Text_IO;
|
||||
|
||||
procedure Extra_IO.Read_File (Name : String) is
|
||||
|
||||
package Dirs renames Ada.Directories;
|
||||
package Text_IO renames Ada.Text_IO;
|
||||
|
||||
-- Get the size of the file for a new string.
|
||||
Size : Natural := Natural (Dirs.Size (Name));
|
||||
subtype File_String is String (1 .. Size);
|
||||
|
||||
-- Instantiate Direct_IO for our file type.
|
||||
package FIO is new Ada.Direct_IO (File_String);
|
||||
|
||||
File : FIO.File_Type;
|
||||
Contents : File_String;
|
||||
|
||||
begin
|
||||
FIO.Open (File, FIO.In_File, Name);
|
||||
FIO.Read (File, Contents);
|
||||
FIO.Close (File);
|
||||
|
||||
Text_IO.Put (Contents);
|
||||
end Extra_IO.Read_File;
|
||||
@@ -0,0 +1,21 @@
|
||||
AddDefaultCharset UTF-8
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Serve gzipped version if available and accepted
|
||||
AddEncoding x-gzip .gz
|
||||
RewriteCond %{HTTP:Accept-Encoding} gzip
|
||||
RewriteCond %{REQUEST_FILENAME}.gz -f
|
||||
RewriteRule ^(.*)$ $1.gz [QSA,L]
|
||||
<FilesMatch \.css\.gz$>
|
||||
ForceType text/css
|
||||
Header append Vary Accept-Encoding
|
||||
</FilesMatch>
|
||||
<FilesMatch \.js\.gz$>
|
||||
ForceType application/javascript
|
||||
Header append Vary Accept-Encoding
|
||||
</FilesMatch>
|
||||
<FilesMatch \.html\.gz$>
|
||||
ForceType text/html
|
||||
Header append Vary Accept-Encoding
|
||||
</FilesMatch>
|
||||
@@ -0,0 +1,9 @@
|
||||
public class with sharing Trigger {
|
||||
@Deprecated
|
||||
public void resolveSum(int x, int y) {
|
||||
System.debug('x is ' + x);
|
||||
System.debug('y is ' + y);
|
||||
|
||||
System.debug('x + y = ' + (x+y));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
FORMAT: 1A
|
||||
HOST: http://polls.apiblueprint.org/
|
||||
|
||||
# Polls
|
||||
|
||||
Polls is a simple API allowing consumers to view polls and vote in them.
|
||||
|
||||
# Polls API Root [/]
|
||||
|
||||
## Group Question
|
||||
|
||||
Resources related to questions in the API.
|
||||
|
||||
## Question [/questions/{question_id}]
|
||||
|
||||
+ Parameters
|
||||
+ question_id: 1 (number, required) - ID of the Question in form of an integer
|
||||
|
||||
+ Attributes
|
||||
+ question: `Favourite programming language?` (required)
|
||||
+ published_at: `2014-11-11T08:40:51.620Z` - An ISO8601 date when the question was published
|
||||
+ choices (array[Choice], required) - An array of Choice objects
|
||||
+ url: /questions/1
|
||||
|
||||
### View a Questions Detail [GET]
|
||||
|
||||
+ Response 200 (application/json)
|
||||
+ Attributes (Question)
|
||||
|
||||
### Delete a Question [DELETE]
|
||||
|
||||
+ Relation: delete
|
||||
+ Response 204
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AppleScript playing with iTunes
|
||||
tell application "iTunes" to get current selection
|
||||
@@ -0,0 +1,12 @@
|
||||
GET common.s
|
||||
|
||||
RetVal * 0x123 :SHL: 4
|
||||
|
||||
AREA |Area$$Name|, CODE, READONLY
|
||||
|
||||
MyFunction ROUT ; This is a comment
|
||||
ASSERT RetVal <> 0
|
||||
1 MOVW r0, #RetVal
|
||||
BX lr
|
||||
|
||||
END
|
||||
@@ -0,0 +1,16 @@
|
||||
(*
|
||||
This is a comment
|
||||
*)
|
||||
module Foo =
|
||||
autoload xfm
|
||||
|
||||
let a = b | c . d
|
||||
|
||||
let lns = a*
|
||||
|
||||
let filter = incl "/path/to/file"
|
||||
. incl "/path/to/other_file"
|
||||
. Util.stdexcl
|
||||
|
||||
(* xmf is the transform *)
|
||||
let xmf = transform lns filter
|
||||
@@ -0,0 +1,4 @@
|
||||
BEGIN { # Simulate echo(1)
|
||||
for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i]
|
||||
printf "\n"
|
||||
exit }
|
||||
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
setlocal enableextensions enabledelayedexpansion
|
||||
for /f "tokens=*" %%a in ("hello !username! hi") do echo %%~a
|
||||
@@ -0,0 +1,6 @@
|
||||
REM > DefaultFilename
|
||||
REM Ordinary comment
|
||||
FOR n=1 TO 10
|
||||
PRINTTAB(n)"Hello there ";FNnumber(n)DIV3+1
|
||||
NEXT:END
|
||||
DEFFNnumber(x%)=ABS(x%-4)
|
||||
@@ -0,0 +1,12 @@
|
||||
@article{Witten:1988hf,
|
||||
author = "Witten, Edward",
|
||||
title = "{Quantum Field Theory and the Jones Polynomial}",
|
||||
journal = "Commun. Math. Phys.",
|
||||
volume = "121",
|
||||
year = "1989",
|
||||
pages = "351-399",
|
||||
doi = "10.1007/BF01217730",
|
||||
note = "[,233(1988)]",
|
||||
reportNumber = "IASSNS-HEP-88-33",
|
||||
SLACcitation = "%%CITATION = CMPHA,121,351;%%"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
targetScope = 'subscription' // To create a resource group
|
||||
|
||||
@description('The Azure region to create the resources in.')
|
||||
param location string
|
||||
|
||||
// Create a resource group
|
||||
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
|
||||
name: 'rg-sample'
|
||||
location: location
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<#@ template language="C#" #>
|
||||
<#@ import namespace="System.Data" #>
|
||||
<Biml xmlns="http://schemas.varigence.com/biml.xsd">
|
||||
<Connections>
|
||||
<!-- Creates a connection to the Adventure Works database -->
|
||||
<Connection
|
||||
Name="AdventureWorks"
|
||||
ConnectionString="Provider=SQLNCLI10.1;Data Source=Localhost;Persist Security Info=False;Integrated Security=SSPI;Initial Catalog=AdventureWorksDW"
|
||||
/>
|
||||
</Connections>
|
||||
<!-- Packages Collection -->
|
||||
<Packages>
|
||||
<!-- A Package -->
|
||||
<Package
|
||||
Name="MyFirstPackage"
|
||||
ConstraintMode="Linear"
|
||||
>
|
||||
<!-- A Package's Tasks -->
|
||||
<Tasks>
|
||||
<ExecuteSQL Name="ExecuteStoredProc" ConnectionName="AdventureWorks">
|
||||
<DirectInput>EXEC usp_StoredProc</DirectInput>
|
||||
</ExecuteSQL>
|
||||
<# foreach (var table in RootNode.Tables) { #>
|
||||
<Dataflow Name="Duplicate <#=table.Name#> Data">
|
||||
<Transformations>
|
||||
<OleDbSource Name="Retrieve Data" ConnectionName="AdventureWorks">
|
||||
<DirectInput>SELECT * FROM <#=table.Name#></DirectInput>
|
||||
</OleDbSource>
|
||||
<OleDbDestination Name="Insert Data" ConnectionName="AdventureWorks">
|
||||
<ExternalTableOutput Table="<#=table.Name#>" />
|
||||
</OleDbDestination>
|
||||
</Transformations>
|
||||
</Dataflow>
|
||||
<# } #>
|
||||
</Tasks>
|
||||
</Package>
|
||||
</Packages>
|
||||
</Biml>
|
||||
@@ -0,0 +1,7 @@
|
||||
r0 = *(u8 *)skb[23]
|
||||
*(u32 *)(r10 - 4) = r0
|
||||
r1 = *(u32 *)(r6 + 4)
|
||||
r1 = 0 ll
|
||||
call 1 /* lookup */
|
||||
if r0 == 0 goto +2 <LBB0_3>
|
||||
lock *(u64 *)(r0 + 0) += r1
|
||||
@@ -0,0 +1,5 @@
|
||||
[
|
||||
This is a sample
|
||||
comment.
|
||||
]
|
||||
.[>+<-]>,
|
||||
@@ -0,0 +1,6 @@
|
||||
function main(args as dynamic) as void
|
||||
screen = CreateObject("roSGScreen")
|
||||
'Create a scene and load /components/helloworld.xml'
|
||||
scene = screen.CreateScene("HelloWorld")
|
||||
screen.show()
|
||||
end function
|
||||
@@ -0,0 +1,7 @@
|
||||
#Область ПрограммныйИнтерфейс
|
||||
|
||||
Процедура ПриветМир() Экспорт
|
||||
Сообщить("Привет мир");
|
||||
КонецПроцедуры
|
||||
|
||||
#КонецОбласти
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "ruby/ruby.h"
|
||||
|
||||
static int
|
||||
clone_method_i(st_data_t key, st_data_t value, st_data_t data)
|
||||
{
|
||||
clone_method((VALUE)data, (ID)key, (const rb_method_entry_t *)value);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
shared class CeylonClass<Parameter>()
|
||||
given Parameter satisfies Object {
|
||||
|
||||
shared String name => "CeylonClass";
|
||||
}
|
||||
|
||||
shared void run() => CeylonClass();
|
||||
@@ -0,0 +1,18 @@
|
||||
component accessors="true" {
|
||||
|
||||
property type="string" name="firstName" default="";
|
||||
property string username;
|
||||
|
||||
function init(){
|
||||
return this;
|
||||
}
|
||||
|
||||
public any function submitOrder( required product, coupon="", boolean results=true ){
|
||||
|
||||
var foo = function( required string baz, x=true, y=false ){
|
||||
return "bar!";
|
||||
};
|
||||
|
||||
return foo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
interface FastEthernet0.20
|
||||
encapsulation dot1Q 20
|
||||
no ip route-cache
|
||||
bridge-group 1
|
||||
no bridge-group 1 source-learning
|
||||
bridge-group 1 spanning-disabled
|
||||
|
||||
! Supports shortened versions of config words, too
|
||||
inter gi0.10
|
||||
encap dot1q 10 native
|
||||
inter gi0
|
||||
|
||||
banner login # Authenticate yourself! #
|
||||
|
||||
! Supports #, $ and % to delimit banners, and multiline
|
||||
banner motd $
|
||||
Attention!
|
||||
We will be having scheduled system maintenance on this device.
|
||||
$
|
||||
@@ -0,0 +1,6 @@
|
||||
delete :: !a !.(Set a) -> Set a | < a
|
||||
delete x Tip = Tip
|
||||
delete x (Bin _ y l r)
|
||||
| x < y = balanceR y (delete x l) r
|
||||
| x > y = balanceL y l (delete x r)
|
||||
| otherwise = glue l r
|
||||
@@ -0,0 +1,5 @@
|
||||
(defn make-adder [x]
|
||||
(let [y x]
|
||||
(fn [z] (+ y z))))
|
||||
(def add2 (make-adder 2))
|
||||
(add2 4)
|
||||
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
|
||||
project(foo C)
|
||||
|
||||
# some note
|
||||
add_executable(foo utils.c "foo.c")
|
||||
target_link_libraries(foo ${LIBRARIES})
|
||||
@@ -0,0 +1,8 @@
|
||||
; Header comments
|
||||
|
||||
#include "definitions.h"
|
||||
|
||||
command-keyword-table: command_handler
|
||||
foo(min-args:0, max-args:0,; comment
|
||||
international:,
|
||||
invalid-syntax: "syntaxtoken" help-text: "helptoken")
|
||||
@@ -0,0 +1,103 @@
|
||||
*-----------------------
|
||||
* This file was sourced from https://github.com/openmainframeproject/cobol-programming-course
|
||||
* Credits:
|
||||
* The course materials were made available through a joint collaboration between IBM, its clients, and
|
||||
* American River College and proposed as a new project by IBM.
|
||||
*-----------------------
|
||||
* Copyright Contributors to the COBOL Programming Course
|
||||
* SPDX-License-Identifier: CC-BY-4.0
|
||||
*-----------------------
|
||||
IDENTIFICATION DIVISION.
|
||||
*-----------------------
|
||||
PROGRAM-ID. CBL0001
|
||||
AUTHOR. Otto B. Fun.
|
||||
*--------------------
|
||||
ENVIRONMENT DIVISION.
|
||||
*--------------------
|
||||
INPUT-OUTPUT SECTION.
|
||||
FILE-CONTROL.
|
||||
SELECT PRINT-LINE ASSIGN TO PRTLINE.
|
||||
SELECT ACCT-REC ASSIGN TO ACCTREC.
|
||||
*SELECT clause creates an internal file name
|
||||
*ASSIGN clause creates a name for an external data source,
|
||||
*which is associated with the JCL DDNAME used by the z/OS
|
||||
*e.g. ACCTREC is linked in JCL file CBL0001J to &SYSUID..DATA
|
||||
*where &SYSUID. stands for Your z/OS user id
|
||||
*e.g. if Your user id is Z54321,
|
||||
*the data set used for ACCTREC is Z54321.DATA
|
||||
*-------------
|
||||
DATA DIVISION.
|
||||
*-------------
|
||||
FILE SECTION.
|
||||
FD PRINT-LINE RECORDING MODE F.
|
||||
01 PRINT-REC.
|
||||
05 ACCT-NO-O PIC X(8).
|
||||
05 ACCT-LIMIT-O PIC $$,$$$,$$9.99.
|
||||
05 ACCT-BALANCE-O PIC $$,$$$,$$9.99.
|
||||
* PIC $$,$$$,$$9.99 -- Alternative for PIC on chapter 7.2.3,
|
||||
* using $ to allow values of different amounts of digits
|
||||
* and .99 instead of v99 to allow period display on output
|
||||
05 LAST-NAME-O PIC X(20).
|
||||
05 FIRST-NAME-O PIC X(15).
|
||||
05 COMMENTS-O PIC X(50).
|
||||
* since the level 05 is higher than level 01,
|
||||
* all variables belong to PRINT-REC (see chapter 7.3.3)
|
||||
*
|
||||
FD ACCT-REC RECORDING MODE F.
|
||||
01 ACCT-FIELDS.
|
||||
05 ACCT-NO PIC X(8).
|
||||
05 ACCT-LIMIT PIC S9(7)V99 COMP-3.
|
||||
05 ACCT-BALANCE PIC S9(7)V99 COMP-3.
|
||||
* PIC S9(7)v99 -- seven-digit plus a sign digit value
|
||||
* COMP-3 -- packed BCD (binary coded decimal) representation
|
||||
05 LAST-NAME PIC X(20).
|
||||
05 FIRST-NAME PIC X(15).
|
||||
05 CLIENT-ADDR.
|
||||
10 STREET-ADDR PIC X(25).
|
||||
10 CITY-COUNTY PIC X(20).
|
||||
10 USA-STATE PIC X(15).
|
||||
05 RESERVED PIC X(7).
|
||||
05 COMMENTS PIC X(50).
|
||||
*
|
||||
WORKING-STORAGE SECTION.
|
||||
01 FLAGS.
|
||||
05 LASTREC PIC X VALUE SPACE.
|
||||
*------------------
|
||||
PROCEDURE DIVISION.
|
||||
*------------------
|
||||
OPEN-FILES.
|
||||
OPEN INPUT ACCT-REC.
|
||||
OPEN OUTPUT PRINT-LINE.
|
||||
*
|
||||
READ-NEXT-RECORD.
|
||||
PERFORM READ-RECORD
|
||||
* The previous statement is needed before entering the loop.
|
||||
* Both the loop condition LASTREC = 'Y'
|
||||
* and the call to WRITE-RECORD depend on READ-RECORD having
|
||||
* been executed before.
|
||||
* The loop starts at the next line with PERFORM UNTIL
|
||||
PERFORM UNTIL LASTREC = 'Y'
|
||||
PERFORM WRITE-RECORD
|
||||
PERFORM READ-RECORD
|
||||
END-PERFORM
|
||||
.
|
||||
*
|
||||
CLOSE-STOP.
|
||||
CLOSE ACCT-REC.
|
||||
CLOSE PRINT-LINE.
|
||||
GOBACK.
|
||||
*
|
||||
READ-RECORD.
|
||||
READ ACCT-REC
|
||||
AT END MOVE 'Y' TO LASTREC
|
||||
END-READ.
|
||||
*
|
||||
WRITE-RECORD.
|
||||
MOVE ACCT-NO TO ACCT-NO-O.
|
||||
MOVE ACCT-LIMIT TO ACCT-LIMIT-O.
|
||||
MOVE ACCT-BALANCE TO ACCT-BALANCE-O.
|
||||
MOVE LAST-NAME TO LAST-NAME-O.
|
||||
MOVE FIRST-NAME TO FIRST-NAME-O.
|
||||
MOVE COMMENTS TO COMMENTS-O.
|
||||
WRITE PRINT-REC.
|
||||
*
|
||||
@@ -0,0 +1,6 @@
|
||||
# Specify a default Code Owner by using a wildcard:
|
||||
* @default-codeowner
|
||||
|
||||
/docs/ @all-docs
|
||||
|
||||
[Development] @dev-team
|
||||
@@ -0,0 +1,5 @@
|
||||
# Objects:
|
||||
math =
|
||||
root: Math.sqrt
|
||||
square: square
|
||||
cube: (x) -> x * square x
|
||||
@@ -0,0 +1 @@
|
||||
(defun square (x) (* x x))
|
||||
@@ -0,0 +1,4 @@
|
||||
# A generic configuration file
|
||||
option1 "val1"
|
||||
option2 23
|
||||
option3 'val3'
|
||||
@@ -0,0 +1,6 @@
|
||||
# prints "hello, world" to the screen
|
||||
~# echo Hello, World
|
||||
Hello, World
|
||||
|
||||
# don't run this
|
||||
~# rm -rf --no-preserve-root /
|
||||
@@ -0,0 +1,16 @@
|
||||
Require Import Coq.Lists.List.
|
||||
|
||||
Section with_T.
|
||||
Context {T : Type}.
|
||||
|
||||
Fixpoint length (ls : list T) : nat :=
|
||||
match ls with
|
||||
| nil => 0
|
||||
| _ :: ls => S (length ls)
|
||||
end.
|
||||
End with_T.
|
||||
|
||||
Definition a_string := "hello
|
||||
world".
|
||||
Definition escape_string := "0123".
|
||||
Definition zero_string := "0".
|
||||
@@ -0,0 +1,8 @@
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "Hello World" << endl;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
lib LibC
|
||||
WNOHANG = 0x00000001
|
||||
|
||||
@[ReturnsTwice]
|
||||
fun fork : PidT
|
||||
fun getpgid(pid : PidT) : PidT
|
||||
fun kill(pid : PidT, signal : Int) : Int
|
||||
fun getpid : PidT
|
||||
fun getppid : PidT
|
||||
fun exit(status : Int) : NoReturn
|
||||
|
||||
ifdef x86_64
|
||||
alias ClockT = UInt64
|
||||
else
|
||||
alias ClockT = UInt32
|
||||
end
|
||||
|
||||
SC_CLK_TCK = 3
|
||||
|
||||
struct Tms
|
||||
utime : ClockT
|
||||
stime : ClockT
|
||||
cutime : ClockT
|
||||
cstime : ClockT
|
||||
end
|
||||
|
||||
fun times(buffer : Tms*) : ClockT
|
||||
fun sysconf(name : Int) : Long
|
||||
end
|
||||
|
||||
class Process
|
||||
def self.exit(status = 0)
|
||||
LibC.exit(status)
|
||||
end
|
||||
|
||||
def self.pid
|
||||
LibC.getpid
|
||||
end
|
||||
|
||||
def self.getpgid(pid : Int32)
|
||||
ret = LibC.getpgid(pid)
|
||||
raise Errno.new(ret) if ret < 0
|
||||
ret
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
// reverse byte order (16-bit)
|
||||
public static UInt16 ReverseBytes(UInt16 value)
|
||||
{
|
||||
return (UInt16)((value & 0xFFU) << 8 | (value & 0xFF00U) >> 8);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
body {
|
||||
font-size: 12pt;
|
||||
background: #fff url(temp.png) top left no-repeat;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
version 1.1
|
||||
@totalColumns 5
|
||||
@separator ','
|
||||
Transaction_Date: xDate
|
||||
Transaction_ID: notEmpty
|
||||
Originator_Name: notEmpty
|
||||
Originator_Address: any("yes","no")
|
||||
Originator_Country: notEmpty
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <cstdio>
|
||||
|
||||
__global__ void helloFromGPU() {
|
||||
std::printf("Hello World\n");
|
||||
__syncthreads();
|
||||
}
|
||||
|
||||
int main() {
|
||||
dim3 block(1, 10);
|
||||
helloFromGPU<<<1, block>>>();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Cypher Mode for Rouge
|
||||
CREATE (john:Person {name: 'John'})
|
||||
MATCH (user)-[:friend]->(follower)
|
||||
WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ 'S.*'
|
||||
RETURN user.name, follower.name
|
||||
@@ -0,0 +1,6 @@
|
||||
cdef extern from 'foo.h':
|
||||
int foo_int
|
||||
struct foo_struct:
|
||||
pass
|
||||
|
||||
ctypedef int word
|
||||
@@ -0,0 +1,16 @@
|
||||
import std.algorithm, std.conv, std.functional,
|
||||
std.math, std.regex, std.stdio;
|
||||
|
||||
alias round = pipe!(to!real, std.math.round, to!string);
|
||||
static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Replace anything that looks like a real
|
||||
// number with the rounded equivalent.
|
||||
stdin
|
||||
.byLine
|
||||
.map!(l => l.replaceAll!(c => c.hit.round)
|
||||
(reFloatingPoint))
|
||||
.each!writeln;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
module A {
|
||||
const i: int := 56_78
|
||||
}
|
||||
|
||||
method m(b: bool, s: string) {
|
||||
var x: string;
|
||||
var i: int;
|
||||
if b then i := 1; else i := 2;
|
||||
i := if b 1 else 2;
|
||||
assert b;
|
||||
assume b;
|
||||
print s;
|
||||
expect b;
|
||||
}
|
||||
|
||||
function f(i: int): int { i + 1 }
|
||||
@@ -0,0 +1,6 @@
|
||||
void main() {
|
||||
var collection=[1,2,3,4,5];
|
||||
for(var a in collection){
|
||||
print(a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
Get_Variable("EUSER","ENV","USERNAME");
|
||||
|
||||
Message("Le Login Windows est : %EUSER%");
|
||||
|
||||
Get_Variable("st","JOB","FOLDER1.date_err.SYSTEM.STATUS");
|
||||
|
||||
|
||||
AFFECT("filter1", '%%/"t"');
|
||||
AFFECT("filter2", '%%/"pi"');
|
||||
JSONTOSQL("%{jsonpath}%/file.json", "",
|
||||
" JSONPATH like '%filter1%' ", "a = JSONVALUE",
|
||||
" JSONPATH like '%filter2%' ", "b = JSONVALUE; output(json_data, a, b)");
|
||||
|
||||
|
||||
Affect(VAR1,'%TEST%'); //Créer et affecter la variable VAR1 avec une chaîne
|
||||
select * from TABLE1 where COL1 like %VAR1%; //utiliser la variable VAR1 dans une requête
|
||||
|
||||
select * from TEST_TABLE; //exécution d'une requête Select pour ramener des valeurs
|
||||
Affect_LastColumns("TEST1"); //création du paramètre TEST1
|
||||
@@ -0,0 +1,7 @@
|
||||
--- file1 2012-10-16 15:07:58.086886874 +0100
|
||||
+++ file2 2012-10-16 15:08:07.642887236 +0100
|
||||
@@ -1,3 +1,3 @@
|
||||
a b c
|
||||
-d e f
|
||||
+D E F
|
||||
g h i
|
||||
@@ -0,0 +1,19 @@
|
||||
# this is digdag task definitions
|
||||
timezone: UTC
|
||||
|
||||
+setup:
|
||||
echo>: start ${session_time}
|
||||
|
||||
+disp_current_date:
|
||||
echo>: ${moment(session_time).utc().format('YYYY-MM-DD HH:mm:ss Z')}
|
||||
|
||||
+repeat:
|
||||
for_each>:
|
||||
order: [first, second, third]
|
||||
animal: [dog, cat]
|
||||
_do:
|
||||
echo>: ${order} ${animal}
|
||||
_parallel: true
|
||||
|
||||
+teardown:
|
||||
echo>: finish ${session_time}
|
||||
@@ -0,0 +1,9 @@
|
||||
maintainer First O'Last
|
||||
|
||||
run echo \
|
||||
123 $bar
|
||||
# comment
|
||||
onbuild add . /app/src
|
||||
onbuild run echo \
|
||||
123 $bar
|
||||
CMD /bin/bash
|
||||
@@ -0,0 +1,5 @@
|
||||
// The graph name and the semicolons are optional
|
||||
graph G {
|
||||
a -- b -- c;
|
||||
b -- d;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Example code - use without restriction.
|
||||
*/
|
||||
Layout_Person := RECORD
|
||||
UNSIGNED1 PersonID;
|
||||
STRING15 FirstName;
|
||||
STRING25 LastName;
|
||||
END;
|
||||
|
||||
allPeople := DATASET([ {1,'Fred','Smith'},
|
||||
{2,'Joe','Blow'},
|
||||
{3,'Jane','Smith'}],Layout_Person);
|
||||
|
||||
somePeople := allPeople(LastName = 'Smith');
|
||||
|
||||
// Outputs ---
|
||||
somePeople;
|
||||
@@ -0,0 +1 @@
|
||||
<title><%= @title %></title>
|
||||
@@ -0,0 +1,30 @@
|
||||
note
|
||||
description: "Represents a person."
|
||||
|
||||
class
|
||||
PERSON
|
||||
|
||||
create
|
||||
make, make_unknown
|
||||
|
||||
feature {NONE} -- Creation
|
||||
|
||||
make (a_name: like name)
|
||||
-- Create a person with `a_name' as `name'.
|
||||
do
|
||||
name := a_name
|
||||
ensure
|
||||
name = a_name
|
||||
end
|
||||
|
||||
make_unknown
|
||||
do ensure
|
||||
name = Void
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: detachable STRING
|
||||
-- Full name or Void if unknown.
|
||||
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
Enum.map([1,2,3], fn(x) -> x * 2 end)
|
||||
@@ -0,0 +1,4 @@
|
||||
import Html exposing (text)
|
||||
|
||||
main =
|
||||
text "Hello, World!"
|
||||
@@ -0,0 +1,11 @@
|
||||
From: Me <me@example.com>
|
||||
To: You <you@example.com>
|
||||
Date: Tue, 21 Jul 2020 15:14:03 +0000
|
||||
Subject: A very important message
|
||||
|
||||
> Please investigate. Thank you.
|
||||
|
||||
I have investigated.
|
||||
|
||||
--
|
||||
This message is highly confidential and will self-destruct.
|
||||
@@ -0,0 +1,4 @@
|
||||
<%- |
|
||||
Optional[String] $title,
|
||||
| -%>
|
||||
<title><%= $title %></title>
|
||||
@@ -0,0 +1 @@
|
||||
<title><%= @title %></title>
|
||||
@@ -0,0 +1,7 @@
|
||||
%%% Geometry module.
|
||||
-module(geometry).
|
||||
-export([area/1]).
|
||||
|
||||
%% Compute rectangle and circle area.
|
||||
area({rectangle, Width, Ht}) -> Width * Ht;
|
||||
area({circle, R}) -> 3.14159 * R * R.
|
||||
@@ -0,0 +1,3 @@
|
||||
If Formatter.enable_escape! is called, this allows escaping into html
|
||||
or the parent format with a special delimiter. For example:
|
||||
<!<span style="text-decoration: underline">!>underlined text!<!</span>!>
|
||||
@@ -0,0 +1,5 @@
|
||||
USING: io kernel sequences ;
|
||||
|
||||
4 iota [
|
||||
"Happy Birthday " write 2 = "dear NAME" "to You" ? print
|
||||
] each
|
||||
@@ -0,0 +1,13 @@
|
||||
# Simple things are simple.
|
||||
hello-user = Hello, {$userName}!
|
||||
|
||||
# Complex things are possible.
|
||||
shared-photos =
|
||||
{$userName} {$photoCount ->
|
||||
[one] added a new photo
|
||||
*[other] added {$photoCount} new photos
|
||||
} to {$userGender ->
|
||||
[male] his stream
|
||||
[female] her stream
|
||||
*[other] their stream
|
||||
}.
|
||||
@@ -0,0 +1,22 @@
|
||||
program bottles
|
||||
|
||||
implicit none
|
||||
integer :: nbottles
|
||||
|
||||
do nbottles = 99, 1, -1
|
||||
call print_bottles(nbottles)
|
||||
end do
|
||||
|
||||
contains
|
||||
|
||||
subroutine print_bottles(n)
|
||||
implicit none
|
||||
integer, intent(in) :: n
|
||||
|
||||
write(*, "(I0, 1X, 'bottles of beer on the wall,')") n
|
||||
write(*, "(I0, 1X, 'bottles of beer.')") n
|
||||
write(*, "('Take one down, pass it around,')")
|
||||
write(*, "(I0, 1X, 'bottles of beer on the wall.', /)") n - 1
|
||||
end subroutine print_bottles
|
||||
|
||||
end program bottles
|
||||
@@ -0,0 +1,16 @@
|
||||
include "MUMPS"
|
||||
|
||||
// Parameters
|
||||
func f = 1.;
|
||||
|
||||
// Mesh
|
||||
int nn = 25; //Mesh quality
|
||||
mesh Th = square(nn, nn);
|
||||
|
||||
// Fespace
|
||||
func Pk = P2;
|
||||
fespace Uh(Th, Pk);
|
||||
Uh u;
|
||||
|
||||
// Plot
|
||||
plot(u, nbiso=30, fill=true, value=true, cmm="A");
|
||||
@@ -0,0 +1,12 @@
|
||||
(* Binary tree with leaves carrying an integer. *)
|
||||
type Tree = Leaf of int | Node of Tree * Tree
|
||||
|
||||
let rec existsLeaf test tree =
|
||||
match tree with
|
||||
| Leaf v -> test v
|
||||
| Node (left, right) ->
|
||||
existsLeaf test left
|
||||
|| existsLeaf test right
|
||||
|
||||
let hasEvenLeaf tree =
|
||||
existsLeaf (fun n -> n % 2 = 0) tree
|
||||
@@ -0,0 +1,18 @@
|
||||
extends Node
|
||||
|
||||
# Variables & Built-in Types
|
||||
|
||||
var a = 5
|
||||
var b = true
|
||||
var s = "Hello"
|
||||
var arr = [1, 2, 3]
|
||||
|
||||
# Constants & Enums
|
||||
|
||||
const ANSWER = 42
|
||||
enum { UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY }
|
||||
|
||||
# Functions
|
||||
|
||||
func _ready():
|
||||
print("Hello, World")
|
||||
@@ -0,0 +1,23 @@
|
||||
[lvl_s4t3_entry() // [R1]
|
||||
{ info_tbls: [(c4uB,
|
||||
label: lvl_s4t3_info
|
||||
rep: HeapRep 1 ptrs { Thunk }
|
||||
srt: Nothing)]
|
||||
stack_info: arg_space: 8 updfr_space: Just 8
|
||||
}
|
||||
{offset
|
||||
c4uB: // global
|
||||
if ((Sp + -32) < SpLim) (likely: False) goto c4uC; else goto c4uD;
|
||||
c4uC: // global
|
||||
R1 = R1;
|
||||
call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;
|
||||
c4uD: // global
|
||||
I64[Sp - 16] = stg_upd_frame_info;
|
||||
P64[Sp - 8] = R1;
|
||||
R2 = P64[R1 + 16];
|
||||
I64[Sp - 32] = stg_ap_p_info;
|
||||
P64[Sp - 24] = Main.fib3_closure+1;
|
||||
Sp = Sp - 32;
|
||||
call GHC.Num.fromInteger_info(R2) args: 40, res: 0, upd: 24;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Rec {
|
||||
-- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0}
|
||||
Main.fib_fib [Occ=LoopBreaker] :: Integer -> Integer
|
||||
[GblId, Arity=1, Str=<S,U>, Unf=OtherCon []]
|
||||
Main.fib_fib
|
||||
= \ (ds_d2OU :: Integer) ->
|
||||
case integer-gmp-1.0.2.0:GHC.Integer.Type.eqInteger#
|
||||
ds_d2OU Main.fib1
|
||||
of {
|
||||
__DEFAULT ->
|
||||
case integer-gmp-1.0.2.0:GHC.Integer.Type.eqInteger#
|
||||
ds_d2OU Main.fib3
|
||||
of {
|
||||
__DEFAULT ->
|
||||
integer-gmp-1.0.2.0:GHC.Integer.Type.plusInteger
|
||||
(Main.fib_fib
|
||||
(integer-gmp-1.0.2.0:GHC.Integer.Type.minusInteger
|
||||
ds_d2OU Main.fib3))
|
||||
(Main.fib_fib
|
||||
(integer-gmp-1.0.2.0:GHC.Integer.Type.minusInteger
|
||||
ds_d2OU Main.fib2));
|
||||
1# -> Main.fib3
|
||||
};
|
||||
1# -> Main.fib1
|
||||
}
|
||||
end Rec }
|
||||
@@ -0,0 +1,17 @@
|
||||
# language: en
|
||||
Feature: Addition
|
||||
In order to avoid silly mistakes
|
||||
As someone who has trouble with mental math
|
||||
I want to be told the sum of two numbers
|
||||
|
||||
Scenario Outline: Add two numbers
|
||||
Given I have entered <input_1> into the calculator
|
||||
And I have entered <input_2> into the calculator
|
||||
When I press <button>
|
||||
Then the result should be <output> on the screen
|
||||
|
||||
Examples:
|
||||
| input_1 | input_2 | button | output |
|
||||
| 20 | 30 | add | 50 |
|
||||
| 2 | 5 | add | 7 |
|
||||
| 0 | 40 | add | 40 |
|
||||
@@ -0,0 +1,23 @@
|
||||
import { LinkTo } from '@ember/routing';
|
||||
import { local } from 'embroider-css-modules';
|
||||
|
||||
import styles from './navigation-menu.css';
|
||||
|
||||
const NavigationMenu = <template>
|
||||
<nav aria-label={{@name}} data-test-nav={{@name}}>
|
||||
<ul class={{styles.list}}>
|
||||
{{#each @menuItems as |menuItem|}}
|
||||
<li>
|
||||
<LinkTo
|
||||
class={{local styles "link"}}
|
||||
data-test-link={{menuItem.label}}
|
||||
>
|
||||
{{menuItem.label}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</nav>
|
||||
</template>;
|
||||
|
||||
export default NavigationMenu;
|
||||
@@ -0,0 +1,14 @@
|
||||
#version 330 core
|
||||
|
||||
uniform mat4 worldMatrix;
|
||||
|
||||
layout(location = 0) in vec2 position;
|
||||
layout(location = 1) in vec4 color;
|
||||
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vertexColor = color;
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello, 世界")
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apply plugin: 'java'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.openjdk.jmh:jmh-core:1.12'
|
||||
compile 'org.openjdk.jmh:jmh-generator-annprocess:1.12'
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
query myQuery($variable: Boolean) {
|
||||
# Queries can have comments!
|
||||
friends(ids: ["a1", "a2"]) {
|
||||
id
|
||||
name
|
||||
|
||||
...someFields
|
||||
|
||||
... @include(if: $variable) {
|
||||
foo
|
||||
}
|
||||
|
||||
... @skip(if: true) {
|
||||
bar
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Greet {
|
||||
def name
|
||||
Greet(who) { name = who[0].toUpperCase() +
|
||||
who[1..-1] }
|
||||
def salute() { println "Hello $name!" }
|
||||
}
|
||||
|
||||
g = new Greet('world') // create object
|
||||
g.salute() // output "Hello World!"
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { TOC } from '@ember/component/template-only';
|
||||
import { LinkTo } from '@ember/routing';
|
||||
import { local } from 'embroider-css-modules';
|
||||
|
||||
import styles from './navigation-menu.css';
|
||||
|
||||
type MenuItem = {
|
||||
label: string;
|
||||
route: string;
|
||||
};
|
||||
|
||||
interface NavigationMenuSignature {
|
||||
Args: {
|
||||
menuItems: MenuItem[];
|
||||
name?: string;
|
||||
};
|
||||
}
|
||||
|
||||
const NavigationMenu = <template>
|
||||
<nav aria-label={{@name}} data-test-nav={{@name}}>
|
||||
<ul class={{styles.list}}>
|
||||
{{#each @menuItems as |menuItem|}}
|
||||
<li>
|
||||
<LinkTo
|
||||
class={{local styles "link"}}
|
||||
data-test-link={{menuItem.label}}
|
||||
>
|
||||
{{menuItem.label}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</nav>
|
||||
</template> satisfies TOC<NavigationMenuSignature>;
|
||||
|
||||
export default NavigationMenu;
|
||||
@@ -0,0 +1,5 @@
|
||||
<?hh // strict
|
||||
|
||||
async function foo(): Awaitable<string> {
|
||||
return await (() ==> 'Hello, world')();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
%section.container
|
||||
%h1= post.title
|
||||
%h2= post.subtitle
|
||||
.content
|
||||
= post.content
|
||||
@@ -0,0 +1,7 @@
|
||||
<div class="entry">
|
||||
<h1>{{title}}</h1>
|
||||
{{#with story}}
|
||||
<div class="intro">{{{intro}}}</div>
|
||||
<div class="body">{{{body}}}</div>
|
||||
{{/with}}
|
||||
</div>
|
||||
@@ -0,0 +1,6 @@
|
||||
quicksort :: Ord a => [a] -> [a]
|
||||
quicksort [] = []
|
||||
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
|
||||
where
|
||||
lesser = filter (< p) xs
|
||||
greater = filter (>= p) xs
|
||||
@@ -0,0 +1,4 @@
|
||||
// hello world!
|
||||
public static function hello(arg : String) {
|
||||
return 'Hello $arg';
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
service {
|
||||
key = "value"
|
||||
}
|
||||
|
||||
variable "ami" {
|
||||
description = "the AMI to use"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
struct PSInput
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
// Vertex shader
|
||||
PSInput VSMain(float4 position : POSITION, float4 color : COLOR)
|
||||
{
|
||||
PSInput result;
|
||||
result.position = position;
|
||||
result.color = color;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Pixel shader
|
||||
float4 PSMain(PSInput input) : SV_TARGET
|
||||
{
|
||||
return input.color;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# These are our own config values defined by the app
|
||||
simple-app {
|
||||
answer = 42
|
||||
}
|
||||
|
||||
# Here we override some values used by a library
|
||||
simple-lib.foo = "This value comes from simple-app's application.conf"
|
||||
simple-lib.whatever = "This value comes from simple-app's application.conf"
|
||||
@@ -0,0 +1,5 @@
|
||||
SELECT e.first_name, e.last_name, d.department_name
|
||||
FROM employees e
|
||||
JOIN departments d ON e.department_id = d.department_id;
|
||||
|
||||
update `table` set name='abc', date=${date}, test_interpolation="${var1}.${var2}" where xyz is null;
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head><title>Title!</title></head>
|
||||
<body>
|
||||
<p id="foo">Hello, World!</p>
|
||||
<script type="text/javascript">var a = 1;</script>
|
||||
<style type="text/css">#foo { font-weight: bold; }</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,14 @@
|
||||
POST /demo/submit/ HTTP/1.1
|
||||
Host: rouge.jneen.net
|
||||
Cache-Control: max-age=0
|
||||
Origin: http://rouge.jayferd.us
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2)
|
||||
AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
|
||||
Content-Type: application/json
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
|
||||
Referer: http://pygments.org/
|
||||
Accept-Encoding: gzip,deflate,sdch
|
||||
Accept-Language: en-US,en;q=0.8
|
||||
Accept-Charset: windows-949,utf-8;q=0.7,*;q=0.3
|
||||
|
||||
{"name":"test","lang":"text","boring":true}
|
||||
@@ -0,0 +1,10 @@
|
||||
(defn simple-conversation []
|
||||
(print "Hello! I'd like to get to know you. Tell me about yourself!")
|
||||
(setv name (input "What is your name? "))
|
||||
(let [age (input "What is your age? ")]
|
||||
(if (and age
|
||||
name)
|
||||
(print (+ "Hello " name "! I see you are "
|
||||
age " years old.")))))
|
||||
|
||||
(simple-conversation)
|
||||
@@ -0,0 +1,8 @@
|
||||
for i = 99L, 0, -1 do begin
|
||||
|
||||
print, i, format="(I0, 1X, 'bottles of beer on the wall,')"
|
||||
print, i, format="(I0, 1X, 'bottles of beer.')"
|
||||
print, 'Take one down, pass it around,'
|
||||
print, i, format="(I0, 1X, 'bottles of beer on the wall.', /)"
|
||||
|
||||
endfor
|
||||
@@ -0,0 +1,13 @@
|
||||
import Data.Vect
|
||||
|
||||
insert : Ord elem =>
|
||||
(x : elem) -> (xsSorted : Vect len elem) -> Vect (S len) elem
|
||||
insert x [] = [x]
|
||||
insert x (y :: xs) = case x < y of
|
||||
True => x :: y :: xs
|
||||
False => y :: insert x xs
|
||||
|
||||
insSort : Ord elem => Vect n elem -> Vect n elem
|
||||
insSort [] = []
|
||||
insSort (x :: xs) = let xsSorted = insSort xs in
|
||||
insert x xsSorted
|
||||
@@ -0,0 +1,21 @@
|
||||
// first-order lag derivative term
|
||||
(*
|
||||
Parameter K must be set to T / (T + T1)
|
||||
*)
|
||||
FUNCTION_BLOCK DT2
|
||||
|
||||
VAR_INPUT
|
||||
IN : REAL;
|
||||
K : REAL;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
Q : REAL;
|
||||
END_VAR
|
||||
VAR
|
||||
H : REAL := 0.0;
|
||||
END_VAR
|
||||
|
||||
BEGIN
|
||||
Q := IN - H;
|
||||
H := H + K * Q;
|
||||
END_FUNCTION_BLOCK
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma TextEncoding = "UTF-8"
|
||||
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
|
||||
|
||||
Function/WAVE MakeWave(name)
|
||||
String name
|
||||
|
||||
Make/N=(8,8) root:$name/WAVE=wv = p^2 + q^2
|
||||
return wv
|
||||
End
|
||||
@@ -0,0 +1,4 @@
|
||||
; last modified 1 April 2001 by John Doe
|
||||
[owner]
|
||||
name=John Doe
|
||||
organization=Acme Widgets Inc.
|
||||
@@ -0,0 +1,11 @@
|
||||
bottle := method(i,
|
||||
if(i==0, return "no more bottles of beer")
|
||||
if(i==1, return "1 bottle of beer")
|
||||
return i asString .. " bottles of beer"
|
||||
)
|
||||
|
||||
for(i, 99, 1, -1,
|
||||
write(bottle(i), " on the wall, ", bottle(i), ",\n")
|
||||
write("take one down, pass it around,\n")
|
||||
write(bottle(i - 1), " on the wall.\n\n")
|
||||
)
|
||||
@@ -0,0 +1,4 @@
|
||||
irb(main):001:0> puts "Hello, world!"
|
||||
Hello, world!
|
||||
irb(main):002:0> Object.new
|
||||
=> #<Object:0x0056182cb182b8>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user