Compare commits

...

447 Commits

Author SHA1 Message Date
Ted Nyman
8c9ba2214a Bump to 2.10.5 2013-12-15 12:21:40 -08:00
Ted Nyman
8ba773127c Drop incorrect interpeter
Fixes 1.8.7 issues. cc @arfon
2013-12-15 12:20:10 -08:00
Ted Nyman
c598c9717d Add ace mode 2013-12-15 00:09:54 -08:00
Ted Nyman
ef41a1ac67 Merge pull request #831 from ethanwhite/master
Added RMarkdown to the list of languages
2013-12-15 00:07:35 -08:00
Ted Nyman
f6c4e39dbc Merge pull request #835 from hkdobrev/jshintrc
Add `.jshintrc` to JSON filenames
2013-12-14 18:28:21 -08:00
Ted Nyman
7c636c4f65 Merge pull request #836 from github/debug
Nicer debug factoring
2013-12-14 15:25:33 -08:00
Ted Nyman
6a8de63d2d Nicer debug factoring 2013-12-14 15:24:26 -08:00
Haralan Dobrev
107fee8859 Add .jshintrc to JSON filenames
JSHint tool for linting JavaScript uses `.jshintrc` configuration file.
It is in JSON format.

Example: https://github.com/jquery/jquery/blob/master/.jshintrc
2013-12-14 16:23:22 +02:00
Ethan White
1cb1705f8e Added RMarkdown to the list of languages 2013-12-12 14:55:52 -05:00
Ted Nyman
e0c1a84821 2.10.4 2013-12-12 00:56:12 -08:00
Ted Nyman
b7249b671f Update samples 2013-12-12 00:55:49 -08:00
Ted Nyman
f5e86bc691 Add a .pod sample 2013-12-12 00:55:03 -08:00
Ted Nyman
109841ceb1 2.10.3 2013-12-11 23:30:28 -08:00
Ted Nyman
1b96f87888 Update samples 2013-12-11 15:13:27 -08:00
Ted Nyman
4d40cab954 Ad .sc sample 2013-12-11 15:06:14 -08:00
Ted Nyman
4533b9baaa Merge pull request #822 from akre54/stylus-support
Add stylus support
2013-12-11 15:03:42 -08:00
Adam Krebs
5b35f92bfe remove accidental sinatra sample. copypasta.... 2013-12-11 18:01:40 -05:00
Ted Nyman
17d54d61b4 Add .sc extension for Scala 2013-12-11 14:57:47 -08:00
Ted Nyman
2a867c9c7f Merge pull request #823 from github/pod
Add separate entry for Pod format
2013-12-10 07:54:25 -08:00
Ted Nyman
5a4bbf42c1 Keep .pod extension for now 2013-12-10 07:53:51 -08:00
Ted Nyman
087ce10f12 Merge pull request #824 from github/wrap-tex
Wrap .tex
2013-12-10 07:47:49 -08:00
Brandon Keepers
27092191a8 Wrap .tex 2013-12-10 10:35:28 -05:00
Brandon Keepers
bc93a99864 update test by type 2013-12-10 10:29:40 -05:00
Brandon Keepers
2e4fbe3430 Create separate entry for .pod 2013-12-10 10:26:55 -05:00
Adam Krebs
64f77293e8 set stylus lexer to be text only for now 2013-12-10 09:40:06 -05:00
Adam Krebs
9a42628577 add more demos 2013-12-09 22:56:04 -05:00
Adam Krebs
fc9bc8b9e1 Add stylus support 2013-12-09 22:42:57 -05:00
Ted Nyman
2180c11dc6 Bump to 2.10.2 2013-12-08 18:40:14 -08:00
Ted Nyman
11207283c8 Merge pull request #819 from github/tell-me-a-story-of-prose
Explicitly mention prose types as `prose`
2013-12-08 18:36:18 -08:00
Garen Torikian
8552ec35b3 Cleanup languages file to fix tests 2013-12-08 16:41:56 -08:00
Garen Torikian
5fdc2e12bf Alphabetize RST correctly 2013-12-08 16:33:59 -08:00
Garen Torikian
37c8a94369 Include RST in the languages list 2013-12-08 16:19:19 -08:00
Garen Torikian
7d17d69c1b Set Textile as a prose language 2013-12-08 16:19:08 -08:00
Garen Torikian
ee519aeb4b Add helper method to retrieve languages by type 2013-12-08 16:12:03 -08:00
Garen Torikian
a825a013d6 Explicitly mention prose types within languages.yml 2013-12-08 16:11:47 -08:00
Ted Nyman
b4906fc3b8 Bit of docs 2013-12-08 15:24:53 -08:00
Ted Nyman
fafeead5dc Merge pull request #818 from Flyingmana/patch-1
recognize composer.lock as generated file
2013-12-08 15:23:19 -08:00
Garen Torikian
5c602d0a4e Revert "Revert "Merge pull request #695 from github/detect-prose"" 2013-12-08 13:51:27 -08:00
Daniel Fahlke
96084fa59a recognize composer.lock as generated file 2013-12-08 21:31:29 +01:00
Daniel Fahlke
c8eeda6c8a add generated test and sample for composer.lock 2013-12-08 21:22:50 +01:00
Ted Nyman
2315cdb993 Merge pull request #816 from sgallagher/master
Add .lmi to Python extensions
2013-12-06 22:28:05 -08:00
Ted Nyman
2245174d28 2.10.1 2013-12-06 22:10:03 -08:00
Ted Nyman
c089b3f28f Update samples 2013-12-06 22:09:29 -08:00
Ted Nyman
7e178cc416 Place guards, checks for multiline shell hacks 2013-12-06 22:04:40 -08:00
Ted Nyman
8603760ebe Merge branch 'master' into more-687 2013-12-06 20:32:22 -08:00
Stephen Gallagher
5bbffb00f5 Add .lmi to Python extensions
The OpenLMI project provides a scripting environment based on
Python (wrapping the Python interpreter with the 'lmishell'
command). Python scripts intended to be executed via lmishell are
conventionally given the suffix .lmi to identify them. Since the
syntax is identical to that of Python, it would be best to
identify it that way.
2013-12-06 09:40:10 -05:00
Ted Nyman
4476a23f5a Merge pull request #813 from computmaxer/brightscript_support
Adding support for the Brightscript language
2013-12-05 12:01:58 -08:00
Max Peterson
834f37810b Merge branch 'master' into brightscript_support
Conflicts:
	lib/linguist/samples.json
2013-12-05 13:02:00 -06:00
Ted Nyman
7e9bc26796 Merge pull request #740 from danluu/vhdl_extensions
Add common VHDL file extensions
2013-12-04 15:49:16 -08:00
Ted Nyman
f83f226edc Merge pull request #812 from Giacom/patch-1
Updated the DM language to use the C++ lexer.
2013-12-04 13:45:40 -08:00
Giacom
a04b9dd7cd Updated the DM language to use the C++ lexer. 2013-12-04 12:07:46 +00:00
Ted Nyman
de636f1c0b Colors for agda and tex 2013-12-04 02:08:58 -08:00
Ted Nyman
283cc3a975 2.10.0 2013-12-03 21:12:12 -08:00
Ted Nyman
23af754194 Merge pull request #810 from github/bump-pygments
Bump pygments
2013-12-03 21:10:51 -08:00
Charlie Somerville
50f4050444 Merge pull request #809 from github/languages.json
Prefer to load from languages.json if it exists
2013-12-03 21:07:44 -08:00
Charlie Somerville
bf11900bc9 prefer to load from languages.json if it exists 2013-12-04 15:58:34 +11:00
Ted Nyman
61b8a8969f 2.9.9 2013-12-03 19:21:32 -08:00
Ted Nyman
0fb7017add Bump pygments.rb to 0.5.4 2013-12-03 19:17:32 -08:00
Charlie Somerville
4a5165ad7f Merge pull request #807 from github/update-escape_utils-dep
Require escape_utils >= 0.3.1
2013-12-02 21:47:17 -08:00
Charlie Somerville
017c6fd3f2 force escape_utils 0.3.2 on ruby < 1.9.3 2013-12-03 16:42:18 +11:00
Charlie Somerville
3887acd915 require escape_utils >= 0.3.1 2013-12-03 16:15:06 +11:00
Charlie Somerville
a80bf9e024 Merge pull request #806 from github/use-json-for-loading-samples
Use JSON instead of YAML for loading samples.json
2013-12-02 21:00:14 -08:00
Charlie Somerville
27c9774d1b prefer JSON, but fall back to YAML if JSON isn't available 2013-12-03 15:55:25 +11:00
Charlie Somerville
10cadb8725 use JSON instead of YAML for loading samples.json 2013-12-03 15:51:24 +11:00
Ted Nyman
9a5d52e460 Update samples 2013-11-24 10:59:52 -08:00
Ted Nyman
a8ae3d3ae5 Just the extensions for now 2013-11-24 10:58:47 -08:00
Ted Nyman
9bf1b5867a Merge pull request #794 from natcl/patch-1
Changed primary extension for Max
2013-11-24 10:56:30 -08:00
Nathanaël Lécaudé
f64a589e98 Moved the Max examples to the Max folder 2013-11-24 13:54:10 -05:00
Nathanaël Lécaudé
72026d3a3d Changed primary extension for Max
Changed primary extension for Max to .maxpat 
.mxt is a legacy file format.
2013-11-24 13:36:26 -05:00
Ted Nyman
3a8651e31f Merge pull request #790 from hkdobrev/composer-lock
Add composer.lock to JSON filenames
2013-11-23 16:39:52 -08:00
Ted Nyman
953768641c Merge pull request #791 from mikepurvis/patch-1
Add five new extensions to XML, YAML in support of ROS usage.
2013-11-23 16:36:57 -08:00
Mike Purvis
b59d80b00c Add five new extensions to XML, YAML in support of ROS usage.
These extensions are in common use in packages part of ROS, the Robot Operating System.

[urdf](http://wiki.ros.org/urdf), [srdf](http://wiki.ros.org/srdf): These are Robot Description Files, XML documents which describe the physical realities of a robotics platform, for the purposes of consumption by common libraries.

[xacro](http://wiki.ros.org/xacro) is for input files to the XML macro processor xacro, which is used in ROS to output URDF and SRDF files.

[launch](http://wiki.ros.org/roslaunch/XML): Documents which describe sets of ROS nodes to launch together.

[rviz](https://github.com/ros-visualization/rviz/blob/hydro-devel/default.rviz): YAML configuration files belonging to the [rviz](http://wiki.ros.org/rviz#Overview) utility.

Each one has been in use for several years in various ROS-related applications; lots of examples should be apparent in orgs like ros, ros-drivers, ros-visualization, pr2, turtlebot, husky, etc.

Thanks for your consideration!
2013-11-23 19:31:05 -05:00
Haralan Dobrev
56dec42c70 Add composer.lock to JSON filenames
[Composer](http://getcomposer.org] uses one configuration file (composer.json) and
one lock file (composer.lock). They both use valid JSON.

Example: https://github.com/OpenBuildings/jam/blob/master/composer.lock
2013-11-23 13:03:22 +02:00
Max Peterson
c88585cffb Adding support for the Brightscript language, with samples. 2013-11-21 19:26:44 -06:00
Ted Nyman
46779da3b5 Check line length for minified for now 2013-11-20 09:33:25 -08:00
Ted Nyman
654050a459 Minor gemspec edits 2013-11-19 17:44:47 -08:00
Ted Nyman
fe9f186b13 Merge pull request #782 from liluo/dev
fix typo
2013-11-17 13:41:16 -08:00
liluo
01616ef54e fix typo 2013-11-17 20:08:42 +08:00
Ted Nyman
9fd802a208 Regenerate samples 2013-11-16 12:33:51 -08:00
Ted Nyman
86e0b94700 Merge master 2013-11-16 12:33:18 -08:00
Ted Nyman
6e4e5e78ad Regenerate samples.json 2013-11-16 12:29:25 -08:00
Ted Nyman
183c280263 Better lexer 2013-11-16 12:28:42 -08:00
Ted Nyman
cb0b3a688f Merge pull request #771 from GreatEmerald/master
Add initial UnrealScript support
2013-11-16 12:24:29 -08:00
Ted Nyman
4f656c200b Minor docs/naming 2013-11-15 18:42:53 -08:00
Ted Nyman
791d9eed41 Merge pull request #779 from jvanegmond/patch-1
Added AutoIt
2013-11-15 18:38:18 -08:00
Jos van Egmond
74775b2e0a Added AutoIt
Language website: http://autoitscript.com
Example project on GitHub: https://github.com/jvanegmond/au3-minecraft-monitor
2013-11-14 11:15:38 +01:00
Ted Nyman
04c78c8c33 Bit more README 2013-11-10 17:57:43 -08:00
Ted Nyman
762b389721 Minor README updates 2013-11-10 17:55:17 -08:00
Ted Nyman
32e10d2c37 Merge pull request #775 from wjk/fix-doc-typo
Confusing Typo Fix
2013-11-10 09:25:52 -08:00
William Kent
d7baf4ed7b Fixed typo in a documentation comment. 2013-11-10 10:48:03 -05:00
Ted Nyman
5bef198e6d More lenient regex for LICENSE 2013-11-09 19:13:08 -08:00
Ted Nyman
c03e310422 Merge pull request #770 from hkdobrev/phpunit.xml.dist
Add phpunit.xml.dist to XML filenames
2013-11-09 19:11:18 -08:00
Ted Nyman
43723ba5ef Simpler samples 2013-11-09 16:43:45 -08:00
Ted Nyman
25954c8992 Merge pull request #773 from afischer15/master
Added Initial NetLogo support
2013-11-09 16:42:22 -08:00
Ted Nyman
12f01e9e94 Color for dart 2013-11-09 16:39:55 -08:00
Eric Schulte
41f7589d4e unit test for find_by_shebang 2013-11-09 11:44:17 -07:00
Eric Schulte
d93edf0897 adding interpreter arrays to some languages 2013-11-09 11:44:17 -07:00
Eric Schulte
7a6202a8c3 language interpreters and shebang lines
Add an interpreter array to each language, and match interpreters found
in the shebang lines of scripts to this array to identify the language
of scripts.

With suggestions from tnm. https://github.com/github/linguist/pull/687
2013-11-09 11:44:17 -07:00
Andrew Fischer
240f6a63f4 removed error causing readme... oops. 2013-11-09 12:44:09 -05:00
Andrew Fischer
f0558769f2 added initial NetLogo support 2013-11-09 12:31:29 -05:00
GreatEmerald
12086b69ac Add initial UnrealScript support
The two samples are for two different UnrealScript generations:
MutU2Weapons is UnrealScript 2, US3HelloWorld is UnrealScript 3.

Signed-off-by: GreatEmerald <pastas4@gmail.com>
2013-11-09 15:29:59 +02:00
Haralan Dobrev
e47b312866 Add phpunit.xml.dist to XML filenames
PHPUnit (a popular unit testing tool for PHP) uses `phpunit.xml`
for its configuration.

However it would use `phpunit.xml.dist` as well if `phpunit.xml`
is not available.

The reason is to track `phpunit.xml.dist` in your repo.
And to ignore `phpunit.xml`.
By default everyone (including a CI) would use `phpunit.xml.dist`
except you add `phpunit.xml` locally.

`phpunit.xml.dist` has the same XML structure as `phpunit.xml`.
So it should be detected as XML by linguist.

Example: https://github.com/erusev/parsedown/blob/master/phpunit.xml.dist

I don't know why linguist is not detecting this file as XML since
it starts with `<?xml`. Perhaps it is another issue.
2013-11-09 12:53:15 +02:00
Ted Nyman
eb5f1468d2 .pluginspec for XML 2013-11-08 14:13:45 -08:00
Ted Nyman
77c7ee6d2e Update samples 2013-11-07 17:26:20 -08:00
Ted Nyman
4f547d79a9 2.0.0 Ruby builds 2013-11-07 17:25:05 -08:00
Ted Nyman
8a5b26536e Merge pull request #755 from frunns/node-modules-generated
Added node_modules/ to generated files.
2013-11-07 17:01:53 -08:00
Ted Nyman
355ac3d81a Merge pull request #500 from Leushenko/master
Added BlitzBasic
2013-11-06 20:45:30 -08:00
Ted Nyman
8b8123a3c1 Add TeX as detectable markup 2013-11-06 20:17:47 -08:00
Ted Nyman
fc44af9343 Merge pull request #764 from bricker/add-appraisals
Add Appraisals to Ruby filenames
2013-11-06 20:15:12 -08:00
Ted Nyman
4654553d07 Merge pull request #765 from GordonSmith/UpperCaseECL
Uppercase ECL
2013-11-06 17:45:23 -08:00
Gordon Smith
940df300e8 Uppercase "ECL" Sample folder
Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
2013-11-06 09:19:29 +00:00
Gordon Smith
72b8e1c76f Uppercase "Ecl" language to "ECL"
Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
2013-11-06 09:17:03 +00:00
Bryan Ricker
92282e3677 Add Appraisals to Ruby filenames 2013-11-05 18:28:01 -08:00
Ted Nyman
9e9cbb144e Merge pull request #763 from lukaselmer/patch-2
Describe how to update samples.json
2013-11-05 17:46:53 -08:00
Lukas Elmer
8c5f1e201e Describe how to update samples.json
Describe how to update samples.json after adding new samples.
2013-11-06 02:44:07 +01:00
Lukas Elmer
ab20c033fe update samples.yml 2013-11-06 02:36:36 +01:00
Lukas Elmer
fd9c657ed4 Merge branch 'master' of https://github.com/github/linguist into patch-1 2013-11-06 02:26:50 +01:00
Ted Nyman
fea07d025d Bump to 2.9.8 2013-11-05 17:14:23 -08:00
Ted Nyman
41a570818d Just .veo for now 2013-11-05 15:24:05 -08:00
Ted Nyman
c1e38425d0 Merge pull request #741 from danluu/verilog_extensions
Add common Verilog extensions
2013-11-05 15:23:38 -08:00
Ted Nyman
6fb4e6836c Just primary extension for now 2013-11-05 15:21:27 -08:00
Ted Nyman
a2f9150f50 Merge pull request #760 from vszakats/patch-4
recognize xBase sources
2013-11-05 15:20:55 -08:00
Ted Nyman
2dcee1e43c Update samples 2013-11-05 15:18:10 -08:00
Ted Nyman
867a4d96fe Unique primary extension 2013-11-05 15:16:36 -08:00
Ted Nyman
b8c7b71ca5 Text only for now 2013-11-05 15:15:40 -08:00
Ted Nyman
70396ab636 Merge pull request #460 from remobjects/master
Oxygene language detection
2013-11-05 15:14:34 -08:00
Ted Nyman
67b5b51c47 Merge pull request #499 from ppannuto/nesc
Add support for nesC
2013-11-05 15:13:32 -08:00
Ted Nyman
7b443fcdde Merge pull request #758 from kashif/nvidia-cuda
added cuda lexer and removed example from c++ samples
2013-11-05 13:57:49 -08:00
Kashif Rasul
d86f8ba12f merged from master and updated samples.json 2013-11-05 22:07:39 +01:00
Kashif Rasul
856ee4724c Merge remote-tracking branch 'upstream/master' into nvidia-cuda
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2013-11-05 22:06:20 +01:00
Kashif Rasul
e635af4ef9 Revert 94b3ea3..b301634
This rolls back to commit 94b3ea3df5.
2013-11-05 22:05:12 +01:00
Kashif Rasul
b30163444f checked in updated samples.json 2013-11-05 22:02:41 +01:00
Ted Nyman
051bedefab Include .emacs filenames 2013-11-05 12:26:17 -08:00
Ted Nyman
1d7f63e38b Remove extra ace modes 2013-11-05 12:15:14 -08:00
Ted Nyman
d96657a48b Alphabetize 2013-11-05 11:57:40 -08:00
Ted Nyman
8bdd6ea510 Merge pull request #578 from timm/patch-1
Update languages.yml
2013-11-05 11:57:11 -08:00
Ted Nyman
9f65e702fc Remove dupe extension 2013-11-05 11:42:09 -08:00
Ted Nyman
a500dee94e Update samples file 2013-11-05 11:36:56 -08:00
Ted Nyman
1a11a6ab48 Merge pull request #555 from timjb/master
Support Agda and Literate Agda
2013-11-05 11:36:20 -08:00
Ted Nyman
c5f1317b47 Update samples file 2013-11-05 11:34:48 -08:00
Tim Baumann
5e03ff961b Merge branch 'master' of https://github.com/github/linguist
Conflicts:
	lib/linguist/languages.yml
2013-11-05 16:55:48 +01:00
Viktor Szakáts
a0c06eb6b9 recognize xBase sources
[xBase: https://en.wikipedia.org/wiki/xBase]

Reopened PR 593 with the two language additions split off.
2013-11-05 11:30:04 +01:00
Kashif Rasul
94b3ea3df5 added cuda lexer and removed example from c++ samples 2013-11-05 10:57:12 +01:00
Ted Nyman
6d7eae5011 Merge pull request #757 from chlorinejs/clojure-samples
add Clojure and its dialects to /samples
2013-11-05 00:39:27 -08:00
Hoàng Minh Thắng
3bbeea3682 add Clojure and its dialects to /samples 2013-11-05 15:33:05 +07:00
Frans Krojegård
562ec13696 Added node_modules/ to generated files. 2013-11-05 09:31:46 +01:00
Ted Nyman
a5c3bd7c13 Remove this until heuristic improves 2013-11-05 00:20:28 -08:00
Ted Nyman
6ae6882e1a Merge pull request #657 from mndrix/prolog
Add misclassified Prolog file
2013-11-04 22:43:19 -08:00
Ted Nyman
c4ad830931 Add .vimrc 2013-11-04 22:29:24 -08:00
Ted Nyman
5d417b4669 Fix syntax 2013-11-04 22:19:38 -08:00
Ted Nyman
02a264fad8 Merge pull request #612 from adityam/master
Add extensions for ConTeXt
2013-11-04 22:19:05 -08:00
Ted Nyman
31c3c43f64 Merge pull request #550 from rschiang/master
Include Qt QML markup detection
2013-11-04 22:11:03 -08:00
Ted Nyman
5197ea2488 Merge pull request #731 from zhuzhuor/master
Add support for RobotFramework .robot files
2013-11-04 22:00:17 -08:00
Ted Nyman
66167de1f9 Merge pull request #754 from myguidingstar/master
add more Clojure extensions and/or dialects'
2013-11-04 21:58:37 -08:00
Hoàng Minh Thắng
9482c2b822 add more Clojure extensions and/or dialects' 2013-11-05 12:52:14 +07:00
Ted Nyman
012a9c0e05 Merge pull request #495 from andygrunwald/decimal-places-in-output
Add decimal places to statistic output
2013-11-04 21:46:32 -08:00
Ted Nyman
881201a2c6 Merge pull request #682 from Jaxan/patch-1
Added Clean language
2013-11-04 21:10:34 -08:00
Ted Nyman
d656988258 Merge pull request #589 from kynetx/adding_krl
added KRL config and sample
2013-11-04 21:09:36 -08:00
Ted Nyman
89f7f8a00b Merge pull request #595 from j-jorge/patch-1
Add common file extensions to the c++ language
2013-11-04 21:08:20 -08:00
Ted Nyman
e4ec48fe8d Merge pull request #751 from CodeBlock/master
Add Idris.
2013-11-04 21:07:25 -08:00
Ted Nyman
1a4f890d04 Merge pull request #620 from Bartvds/master
Added Vagrantfile and Chef /cookbooks to vendors.yml
2013-11-04 21:05:08 -08:00
Ted Nyman
71633871f3 Merge pull request #561 from assassini/master
Added an exclusion pattern for a "dependencies" folder in the root directory
2013-11-04 21:00:50 -08:00
Ted Nyman
f523561e66 Ignore .osx files 2013-11-04 20:57:40 -08:00
Bartvds
f3007215b1 Added Vagrantfile to vendors.yml
Closes #619
2013-11-05 05:53:09 +01:00
Ted Nyman
1847b237c9 Remove alias 2013-11-04 20:46:11 -08:00
Ted Nyman
07169db217 Merge pull request #531 from chriskuehl/master
Add vendor exception for PhoneGap/Cordova device-specific JavaScript libraries.
2013-11-04 20:43:46 -08:00
Ted Nyman
4b4b368356 Add .R extension 2013-11-04 20:41:30 -08:00
Ted Nyman
09ef0cd3e1 Add cproject extension 2013-11-04 20:39:48 -08:00
Ted Nyman
0f6bca7a3d Merge pull request #596 from HQ063/patch-1
Update languages.yml
2013-11-04 20:37:05 -08:00
Chris Kuehl
5e3d811902 Merge github.com:github/linguist
Conflicts:
	lib/linguist/vendor.yml
2013-11-04 20:32:52 -08:00
Ted Nyman
12c655a48a Merge pull request #508 from AdamFerguson/master
Add Jade and Scaml
2013-11-04 20:30:20 -08:00
Ted Nyman
fdddffe041 Just .g4 for now 2013-11-04 20:27:46 -08:00
Ted Nyman
c3aab69b11 Merge pull request #697 from robstoll/master
Added ANTLR to the list, Pygments should have a lexer for ANTLR
2013-11-04 20:27:20 -08:00
Ted Nyman
3f1161d713 Merge pull request #643 from zulus/extjs_exclude
Exclude ExtJS library
2013-11-04 20:10:03 -08:00
Ted Nyman
cf14c5fa4f Merge pull request #450 from Giacom/master
Added DM (Dream Maker) language.
2013-11-04 19:53:25 -08:00
Ted Nyman
8aac009b00 Add more xquery extensions 2013-11-04 19:49:54 -08:00
Ted Nyman
05bb8b10fd Merge pull request #562 from hkdobrev/sublime-text
Added JSON extensions for Sublime Text
2013-11-04 19:40:48 -08:00
Ted Nyman
ecacbc937b Remove ace mode 2013-11-04 19:34:30 -08:00
Ted Nyman
86d0f0a84a Merge pull request #392 from qqshfox/protocol_buffers
Add Protocol Buffers
2013-11-04 19:33:43 -08:00
Ted Nyman
34218d9a5c Merge pull request #475 from pointwise/glyph
Added Glyph scripting language
2013-11-04 19:28:18 -08:00
Ted Nyman
de7ca0d954 Ignore files under thirdparty/ 2013-11-04 19:24:32 -08:00
Ted Nyman
81176f8dfa Add generated JNI detection, update samples 2013-11-04 19:14:34 -08:00
Ted Nyman
6ee999617e Add syscalldefs.h sample 2013-11-04 19:05:56 -08:00
Ted Nyman
88442094f9 Merge pull request #590 from jsocol/master
Add .adp for Tcl files to languages.yml
2013-11-01 11:04:07 -07:00
Ricky Elrod
5037dd5add Add Idris.
This adds Idris into the mix and uses the text-only parser for now, pending
upstream merging this patch in:
https://bitbucket.org/birkenfeld/pygments-main/pull-request/210/idris-lexer-added-lexer-for-idris/diff

Once that gets merged in, the lexer should change to idris.
2013-11-01 04:52:35 -04:00
Ted Nyman
aa41c87158 Merge pull request #739 from danluu/bluespec
Add Bluespec language
2013-10-30 23:50:52 -07:00
Ted Nyman
569eac2222 Whitespace 2013-10-30 23:46:42 -07:00
Ted Nyman
2de23046cc Merge pull request #572 from Aaron1011/add_realbasic
Added REALbasic
2013-10-30 23:46:09 -07:00
Ted Nyman
ca8b27ff15 Merge pull request #614 from robin850/patch-1
Lex .mspec files like Ruby
2013-10-30 23:45:36 -07:00
Ted Nyman
0f17ba0fcf Merge pull request #715 from Jaykul/master
Update PowerShell File Extensions
2013-10-30 23:44:18 -07:00
Ted Nyman
d5002ef06a Start vendor work for bootstrap by ignoring minimized bootstrap js and css 2013-10-30 19:12:52 -07:00
Ted Nyman
ce443e73f1 Merge pull request #707 from larsbrinkhoff/lisp
Common Lisp misidentified as OpenCL
2013-10-30 00:34:03 -07:00
Lars Brinkhoff
89b5e9f5e6 Rebuild samples.json to make Travis happy. 2013-10-30 07:28:09 +01:00
Lars Brinkhoff
c6c5e79ccf Add .cl as a Common Lisp file extension. 2013-10-30 07:28:08 +01:00
Ted Nyman
2bac3af299 Fix typo 2013-10-29 11:59:58 -07:00
Ted Nyman
5411c5457d Need to wait on pygments update 2013-10-29 11:59:27 -07:00
Ted Nyman
92595cffa3 Merge pull request #749 from hoelzro/master
Use the Haxe lexer for Haxe
2013-10-29 11:54:42 -07:00
Ted Nyman
ad77279bbf Text only lexer for Inno Setup 2013-10-29 11:54:25 -07:00
Rob Hoelz
e7d8b99ca2 Use the Haxe lexer for Haxe
The lexer for Haxe is no longer named haXe, so linguist is currently
unable to find it.  This fixes that.
2013-10-29 08:56:37 +01:00
Ted Nyman
971d848eec Merge pull request #737 from jeabakker/patch-1
Update vendor.yml
2013-10-28 12:27:54 -07:00
Ted Nyman
f353fa3890 Merge pull request #691 from le717/master
Detect Inno Setup installer scripts
2013-10-28 11:36:51 -07:00
Ted Nyman
64ce62a804 2.9.7 2013-10-28 11:24:58 -07:00
Ted Nyman
bb9537c5b4 Merge pull request #746 from tnm/no-prose
Revert "Merge pull request #695 from github/detect-prose"
2013-10-28 11:23:12 -07:00
Ted Nyman
9f00b5478d Revert "Merge pull request #695 from github/detect-prose"
This reverts commit 80321272b1, reversing
changes made to 02500d3830.
2013-10-28 11:21:56 -07:00
Lukas Elmer
086b565488 Added another matlab example 2013-10-28 18:06:17 +01:00
Lukas Elmer
27566d93e2 Added another matlab example 2013-10-28 18:02:15 +01:00
Dan Luu
7b1c78b848 Add common Verilog extensions 2013-10-26 14:15:20 -05:00
Dan Luu
4ec9145700 Add common VHDL file extensions 2013-10-26 14:10:46 -05:00
Dan Luu
922fe46f56 Add Bluespec examples 2013-10-26 14:02:04 -05:00
Dan Luu
d4628cf5db Add bluespec to language list 2013-10-25 20:58:17 -05:00
Jerome Bakker
cb9c3732f2 Update vendor.yml
extend the vendor/ exclusion to handle vendors/

Some projects use this folder to store external libaries (eg https://github.com/Elgg/Elgg)
2013-10-25 17:02:04 +02:00
Ted Nyman
ce6a8aa671 Merge pull request #733 from Sheeo/patch-1
Ungroup Elm from Haskell
2013-10-23 00:02:16 -07:00
Ted Nyman
bda61ec3d2 Merge pull request #732 from sstephenson/master
Highlight Bats test files as Shell
2013-10-23 00:00:13 -07:00
Ted Nyman
3ea0d479fc Merge pull request #730 from WestleyArgentum/patch-1
Color for Julia!
2013-10-22 20:01:23 -07:00
Michael
9ff1a9a54c Ungroup Elm from Haskell
Elm is its own language and should be counted as such
2013-10-22 14:32:12 +02:00
Sam Stephenson
024005d912 Highlight Bats test files as Shell 2013-10-21 19:44:09 -05:00
Bo Zhu
4d7cd834be add support for RobotFramework .robot files 2013-10-21 13:59:22 -04:00
Hanfei Shen
281e7456d5 Add Protocol Buffers 2013-10-19 13:24:43 +08:00
Westley Argentum Hennigh
f41c79066b Color for Julia!
See https://github.com/JuliaLang/julia/issues/4569
2013-10-18 10:37:31 -07:00
Ted Nyman
063ba50952 Bump to 2.9.6 2013-10-17 13:57:00 -07:00
Ted Nyman
70bc0b3b77 Merge pull request #584 from jayphelps/patch-1
Added common alternative Handlebars extensions
2013-10-16 23:50:48 -07:00
Ted Nyman
057ea80582 Merge pull request #663 from acgetchell/patch-2
Add LaTeX and BibTeX
2013-10-16 23:44:41 -07:00
Ted Nyman
a046e1c380 Merge pull request #721 from olivergondza/patch-1
Highlight .jelly files as XML
2013-10-16 23:30:17 -07:00
Ted Nyman
e3c2a5e510 Merge pull request #701 from thorn0/patch-1
TypeScript: fixed syntax, it wasn't TypeScript at all
2013-10-16 23:27:31 -07:00
Charlie Somerville
a00967ddc4 Merge pull request #728 from github/fix-dup-primary-extension-for-mumps
Ensure no two languages have the same primary extension
2013-10-16 09:58:52 -07:00
Charlie Somerville
599e1e2a51 update samples.json 2013-10-16 12:43:20 -04:00
Charlie Somerville
44638e1c6b add .m as an alternate extension for MUMPS so it's still picked up 2013-10-16 12:43:20 -04:00
Charlie Somerville
cabd4fb4c5 change MUMPS' primary extension from .m to .mumps
.m currently clashes with Objective-C, and MUMPS is chosen before
Objective-C when creating .m files in Gist. Even if .mumps isn't a
legitimate MUMPS extension, I think we should change it anyway since
Objective-C is far more likely to be intended when a user uses .m
2013-10-16 12:43:20 -04:00
Charlie Somerville
086845f189 use @primary_extension_index in find_by_filename 2013-10-16 12:43:16 -04:00
Charlie Somerville
413c881af8 add @primary_extension_index to ensure we don't have duped primary exts 2013-10-16 11:41:19 -04:00
Jaykul
74eb60a354 Saying my ABCs
Fixing https://travis-ci.org/github/linguist/jobs/12531345
I swear: I am not normally dyslexic
2013-10-14 14:22:11 -04:00
Jaykul
85e54e9af2 Fix alphabetical order of ps1xml 2013-10-14 13:52:40 -04:00
Oliver Gondža
245521db22 Highlight .jelly files as XML
[Jelly](http://commons.apache.org/proper/commons-jelly/) is used heavily by stapler/stapler and jenkinsci/jenkins.
2013-10-14 19:38:56 +02:00
Jaykul
5b8ad31d75 Add psc1, fix order in PowerShell
I had omitted .psc1 because I wasn't confident it was xml
And I have now sorted psd1/psm1 correctly
2013-10-14 13:20:16 -04:00
Ted Nyman
80321272b1 Merge pull request #695 from github/detect-prose
Detect prose documents
2013-10-12 18:12:27 -07:00
Garen Torikian
02500d3830 Merge pull request #713 from aclements/master
Recognize jQuery >= 1.10.0
2013-10-12 17:22:09 -07:00
Jaykul
921ceaa221 Update PowerShell File Extensions
The three core PowerShell language extensions are .psd1, .ps1 and .psm1 -- plus two xml file extensions: .ps1xml and .clixml which are for formatting rules and serialization.
.psm1 modules files use exactly the same syntax as scripts, but are imported rather than executed.
.psd1 are metadata files which use a subset of the same syntax (they can be highlighted using the same highlighter, it's just some commands, variables, and types aren't allowed in data files)
2013-10-12 16:37:49 -04:00
Austin Clements
5232a45d1f Recognize jQuery >= 1.10.0
jQuery recently passed 1.10, but the vendor regexp assumed each
component of the version number would be only one digit.  Allow
multiple digits for the minor and micro versions.
2013-10-11 21:21:43 -04:00
Andy Grunwald
fdf000ec62 Add decimal places to statistic output
If you analyze a project sometimes the statistic outputs a
language with 0%. At first it seems that the language is not
part of this project, but there are only some decimal places
missing.
2013-10-02 20:40:12 +02:00
Ted Nyman
c7933537b1 Merge pull request #705 from glts/add-j-language
Added J to languages
2013-10-01 22:02:48 -07:00
glts
e194d7238e Added "Text only" lexer for J
There is no lexer for J so far, use "Text only" to make the build pass.
2013-09-30 23:28:35 +02:00
glts
33d777a6ff Added support for J to languages.yml 2013-09-30 21:20:28 +02:00
thorn0
1b90dfedf9 TypeScript: fixed syntax, it wasn't TypeScript at all 2013-09-30 13:32:41 +03:00
Robert Stoll
b0b7d75bcd ANTLR was in the wrong order. corrected this mistake 2013-09-27 18:43:11 +02:00
Robert Stoll
74ba0f9c39 Added ANTLR to the list, Pygments should have a lexer for ANTLR 2013-09-27 18:21:39 +02:00
Ted Nyman
8465961e72 Merge pull request #574 from alaingilbert/patch-1
There is a lexer for TypeScript in the pygments project
2013-09-26 02:27:19 -07:00
Ted Nyman
f5cb6e035d Merge pull request #696 from aaronpuchert/rprofile
Add .Rprofile files
2013-09-26 02:26:09 -07:00
Aaron Puchert
7946de7116 Add .Rprofile to filenames for R 2013-09-25 12:43:22 +02:00
Garen Torikian
9e65eb35e7 💄 2013-09-24 21:47:30 -07:00
Garen Torikian
76a1369932 Alphabetize detectable markup 2013-09-24 21:28:39 -07:00
Garen Torikian
12e92f127b Add samples of prose content 2013-09-24 21:28:09 -07:00
Garen Torikian
50f3b2e398 Add Mediawiki 2013-09-24 16:34:46 -07:00
Garen Torikian
a716151c83 Add Creole 2013-09-24 16:33:09 -07:00
Garen Torikian
3c70fffb67 Add Org 2013-09-24 16:32:02 -07:00
Garen Torikian
a0a879a3a3 Add RDoc 2013-09-24 16:30:02 -07:00
Garen Torikian
5d35d18634 Add AsciiDoc as an option 2013-09-24 16:28:54 -07:00
Garen Torikian
a3a6c2f8b3 Alphabetize, foo' 2013-09-24 16:23:05 -07:00
Garen Torikian
8eef1c33b8 Start adding prose content to detector 2013-09-24 16:13:04 -07:00
Joshua Moerman
6182b0fbc2 Clean has no lexer
The haskell lexer doesn't work nice, as the comments are totally different.
2013-09-21 22:55:29 +02:00
Joshua Moerman
4e4f3c6e17 Replaced tabs with spaces
Didn't see the difference in the github editor...
2013-09-21 21:27:17 +02:00
Triangle717
800f445b22 Update languages.yml
Detect Inno Setup installer scripts (http://www.jrsoftware.org/isinfo.php)
2013-09-20 16:24:13 -04:00
Ted Nyman
a9db25cc5b Fix grammar 2013-09-19 17:33:26 -07:00
Tim Baumann
b5e1bda3e4 Merge branch 'master' of https://github.com/github/linguist 2013-09-19 15:47:18 +02:00
Ted Nyman
f06167eaca Bump to 2.9.5 2013-09-18 19:02:12 -07:00
Ted Nyman
687e82307e .cfg is used by too many non INI files 2013-09-18 19:00:15 -07:00
Joshua Moerman
d9358d8af3 Added Clean language
With the blue color from: http://wiki.clean.cs.ru.nl/Clean
2013-09-13 16:41:38 +02:00
Ted Nyman
b3fbd42786 Merge pull request #536 from zzet/patch-1
Added .podsl extension for Common Lisp language
2013-09-09 09:33:20 -07:00
Andrew Kumanyaev
590ed26f7b Alphabetized list for Common Lisp
Via comment https://github.com/github/linguist/pull/536#issuecomment-24046315
2013-09-09 11:58:24 +04:00
Ted Nyman
12093ee1f0 Merge pull request #672 from Bulwersator/master
Add squirrel
2013-09-09 00:54:31 -07:00
Ted Nyman
ee840321d1 Add test_data 2013-09-09 00:39:34 -07:00
Ted Nyman
0cbc44677c Merge pull request #606 from kethomassen/patch-1
Change YAML type to data
2013-09-09 00:38:04 -07:00
kethomassen
a9b944ac36 Make markup tests pass
Yaml ain't Markup Language!
2013-09-09 16:44:00 +10:00
Ted Nyman
759860d866 Merge pull request #549 from oubiwann/add-lfe-support
Added support for LFE (Lisp Flavored Erlang).
2013-09-08 23:27:32 -07:00
Ted Nyman
c4b21f51e4 Merge pull request #677 from github/rename-delphi-to-pascal
Rename Delphi to Pascal
2013-09-08 23:13:43 -07:00
Charlie Somerville
fdccffddfc rename Delphi to Pascal 2013-09-07 03:17:25 +10:00
Charlie Somerville
e610789d38 rake samples 2013-09-07 03:10:56 +10:00
Ted Nyman
3bd8ed45e4 Merge pull request #676 from faithanne/master
Adding .x3d to the list of .xml extensions.
2013-09-05 19:13:27 -07:00
Faith-Anne L. Kocadag
42311e1bf3 Adding .x3d to the list of .xml extensions.
Adding .x3d to the list of .xml extensions: [x3d specifications] (http://www.web3d.org/x3d/specifications/x3d_specification.html)
2013-09-05 22:05:21 -04:00
Bulwersator
9e9aae1d83 really fix sorting 2013-09-05 22:10:49 +02:00
Bulwersator
229ab3a268 fix sorting 2013-09-05 22:02:09 +02:00
Bulwersator
85840aadc2 Create Squirrel.nut 2013-09-05 20:54:59 +02:00
Bulwersator
32b7b3e1b1 Update languages.yml 2013-09-05 20:50:08 +02:00
Ted Nyman
5e7eeae98e Merge pull request #669 from r0man/cljx
Add the ".cljx" file extension to the list of Clojure languages.
2013-09-04 10:23:39 -07:00
Roman Scherer
de8c4daa45 Add the ".cljx" file extension to the list of Clojure languages.
Some people start writing portable Clojure/Clojurescript code and use
the ".cljx" file extension for that. This is driven by this project:

https://github.com/lynaghk/cljx
2013-09-03 21:34:06 +02:00
Ted Nyman
64990a00b8 Merge pull request #656 from liluo/dev
Remove unused else
2013-09-03 09:26:47 -07:00
Ted Nyman
33434f08f4 Documentation 2013-09-02 00:02:15 -07:00
Ted Nyman
d5730f6fd1 Merge pull request #664 from Mouq/master
Add .nqp to the list of Perl file extensions
2013-09-02 00:01:05 -07:00
Mouq
2305496f94 Fix order of extensions 2013-09-01 22:06:08 -04:00
Mouq
d031392507 Add .nqp to the list of Perl file extensions 2013-09-01 10:14:14 -04:00
Adam Getchell
7e251d7345 Add definitions to TeX 2013-08-31 18:21:14 -07:00
Adam Getchell
e33e76a1a7 Update languages.yml 2013-08-31 18:12:16 -07:00
Adam Getchell
9064369517 Update languages.yml 2013-08-31 18:08:39 -07:00
Adam Getchell
a9c86d5453 Add LaTeX and BibTeX 2013-08-31 17:11:11 -07:00
Michael Hendricks
4b0c975426 Add misclassified Prolog file
This file was incorrectly identified as Perl.
2013-08-30 08:31:02 -06:00
liluo
6ec22a1674 remove unused else 2013-08-30 11:04:46 +08:00
Aditya Mahajan
71b48eaf55 Also add .mkvi file extension 2013-08-29 19:41:48 -04:00
Ted Nyman
694f51d09e Merge pull request #642 from Dav1dde/volt
Added Volt language
2013-08-27 22:36:15 -07:00
Ted Nyman
79040d00c7 Merge pull request #519 from mmullis/master
Add COBOL language support
2013-08-27 02:37:47 -07:00
Ted Nyman
7dfc1644ce Merge pull request #628 from pmoura/master
Add alternative Logtalk source file extension
2013-08-26 14:14:03 -07:00
zulus
777f1d27d1 Exclude ExtJS library 2013-08-23 02:53:26 +02:00
David
c4a90bbbcd Added Volt language 2013-08-22 13:48:26 +02:00
Ted Nyman
ac0920a11b Merge pull request #599 from larsbrinkhoff/glsl
Add OpenGL Shading Language.
2013-08-19 22:11:41 -07:00
Paulo Moura
a4bdca6d6b Add alternative Logtalk source file extension 2013-08-19 02:31:33 +01:00
Ted Nyman
f9bfcceba9 Merge pull request #512 from mark-otaris/patch-1
Add the .rbxs extension for Lua files
2013-08-18 17:10:09 -07:00
Ted Nyman
e0ceccc0c6 Merge pull request #626 from dzidzitop/patch-1
COPYING is added to excludes as a file that contains copyright informati...
2013-08-18 04:06:39 -07:00
dzidzitop
cd3e88fe8b COPYING is added to excludes as a file that contains copyright information. 2013-08-18 14:03:16 +03:00
Lars Brinkhoff
254b6de1d3 Add OpenGL Shading Language. 2013-08-17 14:31:28 +02:00
Julik Tarkhanov
a93e9493e2 Add OpenGL shading language (GLSL)
This is the language used for writing OpenGL shaders, which are becoming much more mainstream lately.
2013-08-17 14:31:28 +02:00
Ted Nyman
53b356deee Only looking at root dir 2013-08-16 15:02:01 -07:00
Ted Nyman
9dca6fa9cc Vendor READMEs 2013-08-16 15:00:34 -07:00
Ted Nyman
7226aa18de Merge pull request #559 from sethvargo/add_berksfile
Add Berksfile to the list of Ruby types
2013-08-15 12:36:24 -07:00
Seth Vargo
ce97865bd2 Add 'Berksfile' to the list of Ruby files 2013-08-15 10:29:39 -04:00
Ted Nyman
424fa0f56b Merge pull request #621 from abahgat/xmi-as-xml
Recognize Umbrello .xmi files as XML
2013-08-14 14:47:37 -07:00
Alessandro Bahgat
007fc9ebd0 Added .xmi to the extensions for XML 2013-08-14 17:33:23 -04:00
Ted Nyman
e0104c8d12 2.9.4 2013-08-14 08:57:07 -07:00
Ted Nyman
1a98a1f938 Add an F# alias 2013-08-14 08:55:58 -07:00
Ted Nyman
e005893d4c Syntax 2013-08-14 08:37:03 -07:00
Ted Nyman
6c74d854ec 2.9.3, update samples, update test 2013-08-14 08:35:53 -07:00
Ted Nyman
06b185f725 Fix F# search term 2013-08-14 08:32:50 -07:00
Robin Dupret
64ec42cf4a Lex .mspec files like Ruby 2013-08-09 21:47:47 +02:00
Aditya Mahajan
c4b24d9ae1 Add extensions for ConTeXt
[ConTeXt] is a macro language build on TeX (just as LaTeX is build on
TeX). It tends to use `.mkii` and `.mkiv` extensions to represent files used in
Mark II (MkII) version and Mark IV (MkIV) version of ConTeXt.

[ConTeXt]: http://wiki.contextgarden.net/
2013-08-07 20:37:40 -04:00
Ted Nyman
e6f38cbf45 2.9.2 2013-08-05 23:17:33 -07:00
Ted Nyman
1764674a13 Remove old test 2013-08-05 23:02:19 -07:00
Ted Nyman
4741a47d21 Bring in @upsuper's css generated check 2013-08-05 23:00:04 -07:00
kethomassen
432bffe3ec Change YAML type to data 2013-08-05 16:13:18 +10:00
Gonzalo HQ063
090216df2a Update languages.yml
Alphabetize the recently added .frm extension
2013-08-04 12:40:45 -03:00
Ted Nyman
7b2fec88d1 Update samples 2013-08-03 13:25:47 -07:00
Ted Nyman
76128ccb37 Add make samples and shebang for make 2013-08-03 13:21:58 -07:00
Ted Nyman
f5ede0d0f9 Update samples 2013-08-03 13:13:49 -07:00
Siraaj Khandkar
70d1649b45 Added an R script sample. 2013-08-02 17:17:00 -04:00
Ted Nyman
de706a2eb9 Merge pull request #588 from techy1157/patch-1
Vendored .DS_Store (for mac users)
2013-08-01 21:48:20 -07:00
Ted Nyman
33ebee0f6a Merge pull request #598 from github/let-css-soar
css detection
2013-07-30 16:23:06 -07:00
Ted Nyman
51a989d5f1 Update CSS color 2013-07-30 15:30:47 -07:00
Ted Nyman
3fc208b4ce Bump to 2.9.0 2013-07-30 14:43:30 -07:00
Ted Nyman
0fa54a85d8 Include .scss file samples 2013-07-30 14:21:04 -07:00
Ted Nyman
96e8a5d2cc Start detecting CSS 2013-07-30 13:30:39 -07:00
Ted Nyman
838fbc5626 Drop less from vendor.yml 2013-07-30 03:14:51 -07:00
Gonzalo HQ063
486af800b5 Update languages.yml
- Add .frm extension as VB file
2013-07-30 00:11:40 -03:00
j-jorge
f0b9b3a35a Add common file extensions to the c++ language
.hpp and .tpp extensions are of common use respectively for headers files and separate implementation of template classes/methods.
2013-07-29 17:27:25 +02:00
Ted Nyman
80780ab042 2.8.12 2013-07-26 16:11:56 -07:00
David Calavera
bd19f6ed17 Merge pull request #594 from github/docker_syntax
Docker syntax
2013-07-26 16:10:30 -07:00
Ted Nyman
2ae76842a0 0.8.11 2013-07-26 16:08:24 -07:00
Ted Nyman
750804876e Docs for the linguist script 2013-07-26 16:08:24 -07:00
Ted Nyman
1d8da964e2 More color tweaks 2013-07-26 16:08:24 -07:00
David Calavera
d21d0f281a Put the Dockerfile sample into the right directory. 2013-07-26 15:47:45 -07:00
David Calavera
a8e337e0eb Add Dockerfile sample. 2013-07-26 15:35:00 -07:00
David Calavera
37429d91a0 Add Docker files to the list of shell formatted files. 2013-07-26 15:33:23 -07:00
Ted Nyman
4b9c6fdf62 Merge pull request #592 from vszakats/patch-1
ignore more Git local config files to avoid them being misidentified as ...
2013-07-25 19:46:26 -07:00
Viktor Szakáts
4130825a43 ignore more Git local config files to avoid them being misidentified as Racket, Ruby or else 2013-07-24 11:46:01 +02:00
James Socol
8c42e61271 Update languages.yml
Add .adp for AOL Server Tcl files.
2013-07-22 14:54:37 -04:00
Ted Nyman
6d95590861 2.8.10 2013-07-20 23:15:13 -07:00
Ted Nyman
dbc36a5e63 More color tweaking 2013-07-20 23:14:53 -07:00
Ted Nyman
32a106cedd 2.8.9 2013-07-20 23:02:54 -07:00
Ted Nyman
78ed103f90 Fix casing 2013-07-20 23:02:12 -07:00
Ted Nyman
3e26b2a0a7 Update samples file 2013-07-20 15:10:46 -07:00
Ted Nyman
4fb910533f Add another php script sample 2013-07-20 15:05:49 -07:00
Ted Nyman
b71cab6add Give go language a color closer to its website 2013-07-19 22:51:59 -07:00
Phil Windley
394fb528cc getting pendantic about ASCII sorting order 2013-07-19 16:32:54 -06:00
Phil Windley
d2f4eec397 added lexer for KRL 2013-07-19 16:29:51 -06:00
Phil Windley
5f29bf3bb4 added KRL config and sample 2013-07-19 13:46:42 -06:00
Lazersmoke
5a9d35917f Vendored .DS_Store
In case a Mac user uploads lots of folders with .DS_Stores and changes their project language as such.
2013-07-19 00:02:39 -05:00
Jay Phelps
0029183078 Needed handlebars extensions in alpha-numeric order. 2013-07-18 02:00:32 -07:00
Jay Phelps
0978258f57 Added common alternative Handlebars extensions 2013-07-18 01:47:14 -07:00
Ted Nyman
772a9a582c 2.8.8 2013-07-17 03:01:53 -07:00
Ted Nyman
e633d565a9 Update samples 2013-07-17 02:59:28 -07:00
Ted Nyman
7d6ee108c4 2.8.7 2013-07-17 02:51:07 -07:00
Ted Nyman
dd64c3b545 Merge pull request #583 from github/add-slash
Add Slash
2013-07-17 02:49:50 -07:00
Charlie Somerville
b462e29e1d update pygments 2013-07-17 02:35:38 -07:00
Charlie Somerville
43f4f5bd32 add Slash to linguist 2013-07-17 01:51:34 -07:00
Ted Nyman
904e86d901 2.8.6 2013-07-15 12:07:33 -07:00
Ted Nyman
374164a299 Merge pull request #582 from github/gitignore
Don't bother with .gitignore files
2013-07-15 12:07:00 -07:00
Ted Nyman
f73f309595 Don't bother with .gitignore files 2013-07-15 12:06:07 -07:00
Ted Nyman
f23110a98d Bump to 2.8.5 2013-07-13 23:23:41 -07:00
Ted Nyman
3193fc90f9 Merge pull request #579 from github/fix-escript
Add another escript script
2013-07-13 23:21:49 -07:00
Ted Nyman
cc04519520 Add another escript script 2013-07-13 23:16:36 -07:00
Ted Nyman
f51c5e3159 Update documentation related to Pygments 2013-07-12 14:10:55 -07:00
Tim Menzies
a75d918b93 Update languages.yml 2013-07-12 14:33:23 -04:00
Ted Nyman
c439ca5f97 Merge pull request #575 from github/suppress-generated-cs
Hide .designer.cs files
2013-07-11 18:53:39 -07:00
Paul Betts
4d45f13783 Hide .designer.cs files
VS creates a bunch of files that, while important to version, are often also
huge and boring. We should suppress them.
2013-07-11 15:54:54 -07:00
Alain Gilbert
2a56719378 There is a lexer for TypeScript in the pygments project 2013-07-11 11:59:44 -04:00
Aaron Hill
23289d8901 Added REALbasic 2013-07-10 18:56:41 -04:00
Ted Nyman
7d594b55e4 2.8.4 2013-07-07 23:38:11 -07:00
Ted Nyman
5268a93fa4 Merge pull request #443 from stuartpb/patch-1
Add Erlang rebar escript bundles to vendor.yml
2013-07-07 23:32:58 -07:00
Ted Nyman
ae44530a66 Regenerate samples 2013-07-07 21:26:33 -07:00
Ted Nyman
285216a258 Merge pull request #568 from cono/master
add .fcgi file with proper shebang as Perl sample
2013-07-07 21:26:07 -07:00
cono
4d3720745e Add Perl's index.fcgi to samples 2013-07-08 04:01:50 +03:00
Ted Nyman
a681a252d4 Merge pull request #548 from talentdeficit/master
change erlang css color to something less horrendous
2013-07-07 15:42:53 -07:00
Ted Nyman
22de40f5f6 2.8.3 2013-07-07 15:27:59 -07:00
Ted Nyman
7fbfe0a4b4 Silence this warning 2013-07-07 15:26:29 -07:00
Ted Nyman
29f5ea591f 2.8.2 2013-07-07 15:18:09 -07:00
Ted Nyman
438c0a4ec1 Remove unncessary xc extension 2013-07-07 15:17:32 -07:00
Ted Nyman
887933c86a Bump to 2.8.1 2013-07-07 14:54:24 -07:00
Ted Nyman
53340ddd4c Even more Python script support 2013-07-07 14:53:15 -07:00
Ted Nyman
72b70a11bc Bump to 2.8.0 2013-07-07 14:37:01 -07:00
Ted Nyman
d853864edb Merge pull request #567 from github/workspace
Better Python script support; update samples.json
2013-07-07 14:35:57 -07:00
Ted Nyman
62ad763933 Better Python script support; update samples.json 2013-07-07 14:33:18 -07:00
Ted Nyman
6a15ae47ee Some space here 2013-07-07 14:07:03 -07:00
Ted Nyman
1bebb50482 Exclude LICENSE files 2013-07-07 13:54:22 -07:00
Haralan Dobrev
d351d6091d added JSON extensions for Sublime Text
Signed-off-by: Haralan Dobrev <hkdobrev@gmail.com>
2013-07-02 00:10:42 +03:00
assassini
fae8f83f64 Added a test case for the "dependencies" folder exclusion pattern 2013-07-01 21:46:54 +03:00
assassini
d3d62726ae Added an exclusion pattern for a "dependencies" folder in the root directory 2013-07-01 21:38:22 +03:00
Tim Baumann
cf15832504 add agda and literate agda support 2013-06-29 12:28:43 +02:00
Ted Nyman
fdc81d8818 Update LICENSE 2013-06-24 14:32:07 -06:00
Poren Chiang
764df07450 Include Qt/QML lanuage 2013-06-23 03:20:07 +08:00
Duncan McGreggor
68dfff60b5 Fixed typo (removed capitalization). 2013-06-21 14:39:04 -07:00
Duncan McGreggor
479871f019 Added support for LFE (Lisp Flavored Erlang). 2013-06-21 14:23:31 -07:00
alisdair sullivan
10ec56e667 change css color representing erlang to slightly less horrendous
color
2013-06-20 14:48:51 -07:00
Ted Nyman
1e958a18f8 Merge pull request #541 from hkdobrev/patch-1
Added .tmTheme as XML extension
2013-06-19 13:31:26 -07:00
Ted Nyman
9fa0f6cd6f Merge pull request #543 from jasonbot/master
Treat `.pyt` files as Python source
2013-06-19 13:31:08 -07:00
Ted Nyman
4e339db911 Merge pull request #377 from rlsosborne/detect-xc-language
Add detection for the XC programming language.
2013-06-19 13:30:45 -07:00
Haralan Dobrev
c1469b25a1 Added .tmTheme as XML extension
Files with the `.tmTheme` extension similar to `.tmCommand`, `.tmLanguage`, `.tmPreferences` and `.tmSnippet` are configuration XML files for TextMate or SublimeText.

The `.tmTheme` extension was missing from this list.
2013-06-18 17:02:34 +03:00
Jason Scheirer
ef6abed81a Languages.yml entries must be in alphabetical order 2013-06-17 22:11:16 -06:00
"Jason Scheirer"
96473849e0 Add .pyt as an extension for Python 2013-06-17 17:30:10 -07:00
Paul Betts
b14e09af6b Merge pull request #215 from oxan/master
Add jQuery UI and more ASP.NET MVC files to vendor.yml
2013-06-17 11:01:04 -07:00
Andrew Kumanyaev
42050c4d12 Update languages.yml
Added .podsl extension for Common Lisp language
2013-06-17 21:48:39 +04:00
Chris Kuehl
1af71c8945 Add tests for PhoneGap/Cordova vendor exceptions. 2013-06-10 01:09:23 -04:00
Chris Kuehl
acc1a56da4 Add Cordova's/PhoneGap's JS device library as vendor exclusion. 2013-06-10 01:05:20 -04:00
Michael Mullis
f2b80a239f COBOL: move up in the sort order 2013-05-30 01:33:04 +00:00
Michael Mullis
c6d38ab647 COBOL comes before Clojure and extensions must be sorted 2013-05-30 01:29:36 +00:00
Michael Mullis
420594874a add COBOL language support 2013-05-30 01:17:07 +00:00
Mark Otaris
407c40f7d3 Add '.rbxs' extension for Lua files 2013-05-23 19:34:04 -03:00
Adam Ferguson
89bc82d9df Add samples for Jade and Scaml 2013-05-16 13:21:58 -04:00
Adam Ferguson
30aa3fd5d6 Add Jade and Scaml 2013-05-16 10:26:01 -04:00
Leushenko
22cdb9ee90 Added BlitzBasic 2013-05-09 14:58:41 +01:00
Pat Pannuto
df448c0761 Add support for nesC
nesC is an embedded systems language. It it is a stable product (~10
years old) primarily used for TinyOS, an embedded operating system.
Development has recently moved to github (https://github.com/tinyos/nesc).

Pygments has now pulled the nesC lexer as of 2013/5/6:
  https://bitbucket.org/birkenfeld/pygments-main/pull-request/166/

Please let me know if I need to do anything else / add more information.
2013-05-06 18:06:43 -04:00
marc hoffman
1e93e98d30 Merge branch 'master' of git://github.com/github/linguist 2013-04-27 22:57:33 +02:00
marc hoffman
d0034b4fb9 Oxygene language detection — drop lexer setting, as we now have a proper Oxygene lexer in pigments.rb 2013-04-27 22:55:57 +02:00
Pointwise, Inc.
3b79cf3cf2 Add lexer 2013-04-24 11:30:00 -05:00
Pointwise, Inc.
5b06a46451 Added Glyph scripting language 2013-04-18 16:11:50 -05:00
marc hoffman
15a746650c Merge branch 'master' of https://github.com/github/linguist 2013-04-03 13:20:50 +02:00
Giacomand
e408b5fbaa * Trying this. 2013-03-25 16:26:14 +00:00
Giacomand
e26bf5a0d2 - Moving diff to after DM. 2013-03-25 16:14:06 +00:00
Giacomand
465d60ba86 * Missed setting the lexer to Text Only. 2013-03-25 16:07:19 +00:00
Giacomand
d5c3978a6e * Fixed a mis-formating. 2013-03-25 10:13:38 +00:00
Giacomand
d4312c05bf - Updated sample file. 2013-03-25 09:54:23 +00:00
Giacomand
7efad57176 Added:
* DM (Dream Maker) language.
 * Sample DM file.

The DM language is used in an engine known as BYOND which allows users to easily create their own games in a language that is designed to be accessible for newcomers. I do not know how much a language has to be used on the site to be considered but searching for "BYOND" does show a lot of people using the language. I am also still learning git so if I have missed something then please let me know.
2013-03-25 09:49:00 +00:00
Stuart P. Bentley
ec786b73bc Add Erlang rebar escript bundles to vendor.yml
Fixes #236
2013-03-16 13:51:08 -07:00
marc hoffman
14d363b942 Oxygene language detection — trying if making .pas not the primary extension (which Delphi also has) fixes the build fail 2013-03-08 12:48:39 +01:00
marc hoffman
f8c6277946 Oxygene language detection — now with "text only" lexer for now (why do we need this, other languages don't specify one) 2013-03-08 12:21:51 +01:00
marc hoffman
8254bcc3ac Oxygene language detection 2013-03-08 12:13:56 +01:00
Xidorn Quan
fc8d2f641c Add samples and tests for minified CSS detection. 2013-03-02 14:27:51 +08:00
Xidorn Quan
9a5f9a5e9b Use space rate to distinguish minified files.
Minified JS files usually contain less than 2% spaces, while minified
CSS files may contain about 4% spaces. However, an unminified CSS file
may also have as low as 6% spaces, especially when it includes some
resources inline. Consequently, the division might not be appreciate
for CSS files. Even though, it will only mis-recognize a normal file
as minified for a few special cases.
2013-03-02 13:15:42 +08:00
Xidorn Quan
806369ce7f Merge minified files detecting methods. 2013-03-01 20:50:49 +08:00
Xidorn Quan
4398cda9a5 Detect minified CSS files 2013-03-01 16:15:56 +08:00
Richard Osborne
0479f72a93 Add detection for the XC programming language. 2013-02-09 13:13:21 +00:00
Oxan van Leeuwen
0f006af583 Improve detection for ASP.NET validation jQuery plugins 2012-08-10 01:09:54 +02:00
Oxan van Leeuwen
2bbf92d5f8 Update vendor.yml to include jQuery UI 2012-08-10 01:04:29 +02:00
102 changed files with 20769 additions and 780 deletions

View File

@@ -3,6 +3,7 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- ree
notifications:
disabled: true

View File

@@ -1,2 +1,7 @@
source 'https://rubygems.org'
gemspec
if RUBY_VERSION < "1.9.3"
# escape_utils 1.0.0 requires 1.9.3 and above
gem "escape_utils", "0.3.2"
end

View File

@@ -1,4 +1,4 @@
Copyright (c) 2011 GitHub, Inc.
Copyright (c) 2011-2013 GitHub, Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation

View File

@@ -31,9 +31,10 @@ We typically run on a pre-release version of Pygments, [pygments.rb](https://git
### Stats
The Language Graph you see on every repository is built by aggregating the languages of all repo's blobs. The top language in the graph determines the project's primary language. Collectively, these stats make up the [Top Languages](https://github.com/languages) page.
The Language Graph you see on every repository is built by aggregating the languages of each file in that repository.
The top language in the graph determines the project's primary language. Collectively, these stats make up the [Top Languages](https://github.com/languages) page.
The repository stats API can be used on a directory:
The repository stats API, accessed through `#languages`, can be used on a directory:
```ruby
project = Linguist::Repository.from_directory(".")
@@ -41,7 +42,7 @@ project.language.name #=> "Ruby"
project.languages #=> { "Ruby" => 0.98, "Shell" => 0.02 }
```
These stats are also printed out by the binary. Try running `linguist` on itself:
These stats are also printed out by the `linguist` binary. Try running `linguist` on itself:
$ bundle exec linguist lib/
100% Ruby
@@ -82,14 +83,18 @@ To run the tests:
## Contributing
The majority of patches won't need to touch any Ruby code at all. The [master language list](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) is just a configuration file.
The majority of contributions won't need to touch any Ruby code at all. The [master language list](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) is just a YAML configuration file.
We try to only add languages once they have a some usage on GitHub, so please note in-the-wild usage examples in your pull request.
We try to only add languages once they have some usage on GitHub, so please note in-the-wild usage examples in your pull request.
Almost all bug fixes or new language additions should come with some additional code samples. Just drop them under [`samples/`](https://github.com/github/linguist/tree/master/samples) in the correct subdirectory and our test suite will automatically test them. In most cases you shouldn't need to add any new assertions.
To update the `samples.json` after adding new files to [`samples/`](https://github.com/github/linguist/tree/master/samples):
bundle exec rake samples
### Testing
Sometimes getting the tests running can be too much work, especially if you don't have much Ruby experience. It's okay, be lazy and let our build bot [Travis](http://travis-ci.org/#!/github/linguist) run the tests for you. Just open a pull request and the bot will start cranking away.
Sometimes getting the tests running can be too much work, especially if you don't have much Ruby experience. It's okay: be lazy and let our build bot [Travis](http://travis-ci.org/#!/github/linguist) run the tests for you. Just open a pull request and the bot will start cranking away.
Here's our current build status, which is hopefully green: [![Build Status](https://secure.travis-ci.org/github/linguist.png?branch=master)](http://travis-ci.org/github/linguist)

View File

@@ -1,5 +1,7 @@
require 'rake/clean'
require 'rake/testtask'
require 'yaml'
require 'json'
task :default => :test
@@ -13,6 +15,13 @@ task :samples do
File.open('lib/linguist/samples.json', 'w') { |io| io.write json }
end
task :build_gem do
languages = YAML.load_file("lib/linguist/languages.yml")
File.write("lib/linguist/languages.json", JSON.dump(languages))
`gem build github-linguist.gemspec`
File.delete("lib/linguist/languages.json")
end
namespace :classifier do
LIMIT = 1_000

View File

@@ -1,5 +1,9 @@
#!/usr/bin/env ruby
# linguist — detect language type for a file, or, given a directory, determine language breakdown
#
# usage: linguist <path>
require 'linguist/file_blob'
require 'linguist/repository'
@@ -8,8 +12,9 @@ path = ARGV[0] || Dir.pwd
if File.directory?(path)
repo = Linguist::Repository.from_directory(path)
repo.languages.sort_by { |_, size| size }.reverse.each do |language, size|
percentage = ((size / repo.size.to_f) * 100).round
puts "%-4s %s" % ["#{percentage}%", language]
percentage = ((size / repo.size.to_f) * 100)
percentage = sprintf '%.2f' % percentage
puts "%-7s %s" % ["#{percentage}%", language]
end
elsif File.file?(path)
blob = Linguist::FileBlob.new(path, Dir.pwd)

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'github-linguist'
s.version = '2.7.0'
s.version = '2.10.5'
s.summary = "GitHub Language detection"
s.authors = "GitHub"
@@ -10,11 +10,12 @@ Gem::Specification.new do |s|
s.executables << 'linguist'
s.add_dependency 'charlock_holmes', '~> 0.6.6'
s.add_dependency 'escape_utils', '~> 0.3.1'
s.add_dependency 'escape_utils', '>= 0.3.1'
s.add_dependency 'mime-types', '~> 1.19'
s.add_dependency 'pygments.rb', '~> 0.4.2'
s.add_development_dependency 'mocha'
s.add_dependency 'pygments.rb', '~> 0.5.4'
s.add_development_dependency 'json'
s.add_development_dependency 'mocha'
s.add_development_dependency 'rake'
s.add_development_dependency 'yajl-ruby'
end

View File

@@ -189,10 +189,9 @@ module Linguist
# Public: Is the blob safe to colorize?
#
# We use Pygments.rb for syntax highlighting blobs, which
# has some quirks and also is essentially 'un-killable' via
# normal timeout. To workaround this we try to
# carefully handling Pygments.rb anything it can't handle.
# We use Pygments for syntax highlighting blobs. Pygments
# can be too slow for very large blobs or for certain
# corner-case blobs.
#
# Return true or false
def safe_to_colorize?

View File

@@ -15,8 +15,8 @@ module Linguist
#
# Returns nothing.
#
# Set LINGUIST_DEBUG=1 or =2 to see probabilities per-token,
# per-language. See also dump_all_tokens, below.
# Set LINGUIST_DEBUG=1 or =2 to see probabilities per-token or
# per-language. See also #dump_all_tokens, below.
def self.train!(db, language, data)
tokens = Tokenizer.tokenize(data)
@@ -78,18 +78,13 @@ module Linguist
def classify(tokens, languages)
return [] if tokens.nil?
tokens = Tokenizer.tokenize(tokens) if tokens.is_a?(String)
scores = {}
if verbosity >= 2
dump_all_tokens(tokens, languages)
end
debug_dump_all_tokens(tokens, languages) if verbosity >= 2
languages.each do |language|
scores[language] = tokens_probability(tokens, language) +
language_probability(language)
if verbosity >= 1
printf "%10s = %10.3f + %7.3f = %10.3f\n",
language, tokens_probability(tokens, language), language_probability(language), scores[language]
end
debug_dump_probabilities(tokens, language) if verbosity >= 1
scores[language] = tokens_probability(tokens, language) + language_probability(language)
end
scores.sort { |a, b| b[1] <=> a[1] }.map { |score| [score[0], score[1]] }
@@ -135,6 +130,11 @@ module Linguist
@verbosity ||= (ENV['LINGUIST_DEBUG'] || 0).to_i
end
def debug_dump_probabilities
printf("%10s = %10.3f + %7.3f = %10.3f\n",
language, tokens_probability(tokens, language), language_probability(language), scores[language])
end
# Internal: show a table of probabilities for each <token,language> pair.
#
# The number in each table entry is the number of "points" that each
@@ -145,18 +145,22 @@ module Linguist
# how much more likely (log of probability ratio) that token is to
# appear in one language vs. the least-likely language. Dashes
# indicate the least-likely language (and zero points) for each token.
def dump_all_tokens(tokens, languages)
def debug_dump_all_tokens(tokens, languages)
maxlen = tokens.map { |tok| tok.size }.max
printf "%#{maxlen}s", ""
puts " #" + languages.map { |lang| sprintf("%10s", lang) }.join
tokmap = Hash.new(0)
tokens.each { |tok| tokmap[tok] += 1 }
tokmap.sort.each { |tok, count|
token_map = Hash.new(0)
tokens.each { |tok| token_map[tok] += 1 }
token_map.sort.each { |tok, count|
arr = languages.map { |lang| [lang, token_probability(tok, lang)] }
min = arr.map { |a,b| b }.min
minlog = Math.log(min)
if !arr.inject(true) { |result, n| result && n[1] == arr[0][1] }
printf "%#{maxlen}s%5d", tok, count
puts arr.map { |ent|
ent[1] == min ? " -" : sprintf("%10.3f", count * (Math.log(ent[1]) - minlog))
}.join

View File

@@ -52,12 +52,16 @@ module Linguist
# Return true or false
def generated?
name == 'Gemfile.lock' ||
minified_javascript? ||
minified_files? ||
compiled_coffeescript? ||
xcode_project_file? ||
generated_net_docfile? ||
generated_parser? ||
generated_protocol_buffer?
generated_net_docfile? ||
generated_net_designer_file? ||
generated_protocol_buffer? ||
generated_jni_header? ||
composer_lock? ||
node_modules?
end
# Internal: Is the blob an XCode project file?
@@ -70,16 +74,18 @@ module Linguist
['.xib', '.nib', '.storyboard', '.pbxproj', '.xcworkspacedata', '.xcuserstate'].include?(extname)
end
# Internal: Is the blob minified JS?
# Internal: Is the blob minified files?
#
# Consider JS minified if the average line length is
# greater then 100c.
# Consider a file minified if the average line length is
# greater then 110c.
#
# Currently, only JS and CSS files are detected by this method.
#
# Returns true or false.
def minified_javascript?
return unless extname == '.js'
def minified_files?
return unless ['.js', '.css'].include? extname
if lines.any?
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 100
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 110
else
false
end
@@ -143,6 +149,16 @@ module Linguist
lines[-2].include?("</doc>")
end
# Internal: Is this a codegen file for a .NET project?
#
# Visual Studio often uses code generation to generate partial classes, and
# these files can be quite unwieldy. Let's hide them.
#
# Returns true or false
def generated_net_designer_file?
name.downcase =~ /\.designer\.cs$/
end
# Internal: Is the blob of JS a parser generated by PEG.js?
#
# PEG.js-generated parsers are not meant to be consumed by humans.
@@ -170,5 +186,32 @@ module Linguist
return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!")
end
# Internal: Is the blob a C/C++ header generated by the Java JNI tool javah?
#
# Returns true of false.
def generated_jni_header?
return false unless extname == '.h'
return false unless lines.count > 2
return lines[0].include?("/* DO NOT EDIT THIS FILE - it is machine generated */") &&
lines[1].include?("#include <jni.h>")
end
# node_modules/ can contain large amounts of files, in general not meant
# for humans in pull requests.
#
# Returns true or false.
def node_modules?
!!name.match(/node_modules\//)
end
# the php composer tool generates a lock file to represent a specific dependency state.
# In general not meant for humans in pull requests.
#
# Returns true or false.
def composer_lock?
!!name.match(/composer.lock/)
end
end
end

View File

@@ -1,6 +1,10 @@
require 'escape_utils'
require 'pygments'
require 'yaml'
begin
require 'json'
rescue LoadError
end
require 'linguist/classifier'
require 'linguist/samples'
@@ -15,11 +19,30 @@ module Linguist
@index = {}
@name_index = {}
@alias_index = {}
@extension_index = Hash.new { |h,k| h[k] = [] }
@filename_index = Hash.new { |h,k| h[k] = [] }
@extension_index = Hash.new { |h,k| h[k] = [] }
@interpreter_index = Hash.new { |h,k| h[k] = [] }
@filename_index = Hash.new { |h,k| h[k] = [] }
@primary_extension_index = {}
# Valid Languages types
TYPES = [:data, :markup, :programming]
TYPES = [:data, :markup, :programming, :prose]
# Names of non-programming languages that we will still detect
#
# Returns an array
def self.detectable_markup
["CSS", "Less", "Sass", "Stylus", "TeX"]
end
# Detect languages by a specific type
#
# type - A symbol that exists within TYPES
#
# Returns an array
def self.by_type(type)
all.select { |h| h.type == type }
end
# Internal: Create a new Language object
#
@@ -56,6 +79,16 @@ module Linguist
@extension_index[extension] << language
end
if @primary_extension_index.key?(language.primary_extension)
raise ArgumentError, "Duplicate primary extension: #{language.primary_extension}"
end
@primary_extension_index[language.primary_extension] = language
language.interpreters.each do |interpreter|
@interpreter_index[interpreter] << language
end
language.filenames.each do |filename|
@filename_index[filename] << language
end
@@ -84,10 +117,13 @@ module Linguist
if possible_languages.length > 1
data = data.call() if data.respond_to?(:call)
if data.nil? || data == ""
nil
elsif result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
Language[result[0]]
elsif (result = find_by_shebang(data)) && !result.empty?
result.first
elsif classified = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first
Language[classified[0]]
end
else
possible_languages.first
@@ -141,7 +177,24 @@ module Linguist
# Returns all matching Languages or [] if none were found.
def self.find_by_filename(filename)
basename, extname = File.basename(filename), File.extname(filename)
@filename_index[basename] + @extension_index[extname]
langs = [@primary_extension_index[extname]] +
@filename_index[basename] +
@extension_index[extname]
langs.compact.uniq
end
# Public: Look up Languages by shebang line.
#
# data - Array of tokens or String data to analyze.
#
# Examples
#
# Language.find_by_shebang("#!/bin/bash\ndate;")
# # => [#<Language name="Bash">]
#
# Returns the matching Language
def self.find_by_shebang(data)
@interpreter_index[Linguist.interpreter_from_shebang(data)]
end
# Public: Look up Language by its name or lexer.
@@ -229,6 +282,7 @@ module Linguist
# Set extensions or default to [].
@extensions = attributes[:extensions] || []
@interpreters = attributes[:interpreters] || []
@filenames = attributes[:filenames] || []
unless @primary_extension = attributes[:primary_extension]
@@ -341,6 +395,15 @@ module Linguist
# Returns the extension String.
attr_reader :primary_extension
# Public: Get interpreters
#
# Examples
#
# # => ['awk', 'gawk', 'mawk' ...]
#
# Returns the interpreters Array
attr_reader :interpreters
# Public: Get filenames
#
# Examples
@@ -434,19 +497,40 @@ module Linguist
end
extensions = Samples::DATA['extnames']
interpreters = Samples::DATA['interpreters']
filenames = Samples::DATA['filenames']
popular = YAML.load_file(File.expand_path("../popular.yml", __FILE__))
YAML.load_file(File.expand_path("../languages.yml", __FILE__)).each do |name, options|
languages_yml = File.expand_path("../languages.yml", __FILE__)
languages_json = File.expand_path("../languages.json", __FILE__)
if File.exist?(languages_json) && defined?(JSON)
languages = JSON.load(File.read(languages_json))
else
languages = YAML.load_file(languages_yml)
end
languages.each do |name, options|
options['extensions'] ||= []
options['interpreters'] ||= []
options['filenames'] ||= []
if extnames = extensions[name]
extnames.each do |extname|
if !options['extensions'].include?(extname)
options['extensions'] << extname
else
warn "#{name} #{extname.inspect} is already defined in samples/. Remove from languages.yml."
end
end
end
if interpreters == nil
interpreters = {}
end
if interpreter_names = interpreters[name]
interpreter_names.each do |interpreter|
if !options['interpreters'].include?(interpreter)
options['interpreters'] << interpreter
end
end
end
@@ -455,8 +539,6 @@ module Linguist
fns.each do |filename|
if !options['filenames'].include?(filename)
options['filenames'] << filename
else
warn "#{name} #{filename.inspect} is already defined in samples/. Remove from languages.yml."
end
end
end
@@ -473,6 +555,7 @@ module Linguist
:searchable => options.key?('searchable') ? options['searchable'] : true,
:search_term => options['search_term'],
:extensions => options['extensions'].sort,
:interpreters => options['interpreters'].sort,
:primary_extension => options['primary_extension'],
:filenames => options['filenames'],
:popular => popular.include?(name)

View File

@@ -10,6 +10,7 @@
# ace_mode - A String name of Ace Mode (if available)
# wrap - Boolean wrap to enable line wrapping (default: false)
# extension - An Array of associated extensions
# interpreter - An Array of associated interpreters
# primary_extension - A String for the main extension associated with
# the language. Must be unique. Used when a Language is picked
# from a dropdown and we need to automatically choose an
@@ -22,13 +23,19 @@
# Any additions or modifications (even trivial) should have corresponding
# test change in `test/test_blob.rb`.
#
# Please keep this list alphabetized.
# Please keep this list alphabetized. Capitalization comes before lower case.
ABAP:
type: programming
lexer: ABAP
primary_extension: .abap
ANTLR:
type: programming
color: "#9DC3FF"
lexer: ANTLR
primary_extension: .g4
ASP:
type: programming
color: "#6a40fd"
@@ -62,6 +69,11 @@ Ada:
extensions:
- .ads
Agda:
type: programming
color: "#467C91"
primary_extension: .agda
ApacheConf:
type: markup
aliases:
@@ -91,6 +103,16 @@ Arduino:
lexer: C++
primary_extension: .ino
AsciiDoc:
type: prose
lexer: Text only
ace_mode: asciidoc
wrap: true
primary_extension: .asciidoc
extensions:
- .adoc
- .asc
Assembly:
type: programming
lexer: NASM
@@ -112,14 +134,29 @@ AutoHotkey:
- ahk
primary_extension: .ahk
AutoIt:
type: programming
color: "#36699B"
aliases:
- au3
- AutoIt3
- AutoItScript
primary_extension: .au3
Awk:
type: programming
lexer: Awk
primary_extension: .awk
extensions:
- .auk
- .gawk
- .mawk
- .nawk
interpreters:
- awk
- gawk
- mawk
- nawk
Batchfile:
type: programming
@@ -134,9 +171,23 @@ Batchfile:
Befunge:
primary_extension: .befunge
BlitzBasic:
type: programming
aliases:
- blitzplus
- blitz3d
primary_extension: .bb
extensions:
- .decls
BlitzMax:
primary_extension: .bmx
Bluespec:
type: programming
lexer: verilog
primary_extension: .bsv
Boo:
type: programming
color: "#d4bec1"
@@ -147,6 +198,11 @@ Brainfuck:
extensions:
- .bf
Brightscript:
type: programming
lexer: Text only
primary_extension: .brs
Bro:
type: programming
primary_extension: .bro
@@ -184,8 +240,10 @@ C++:
- .H
- .h++
- .hh
- .hpp
- .hxx
- .tcc
- .tpp
C-ObjDump:
type: data
@@ -212,8 +270,18 @@ CMake:
filenames:
- CMakeLists.txt
COBOL:
type: programming
primary_extension: .cob
extensions:
- .cbl
- .ccp
- .cobol
- .cpy
CSS:
ace_mode: css
color: "#1f085e"
primary_extension: .css
Ceylon:
@@ -225,13 +293,26 @@ ChucK:
lexer: Java
primary_extension: .ck
Clean:
type: programming
color: "#3a81ad"
lexer: Text only
primary_extension: .icl
extensions:
- .dcl
Clojure:
type: programming
ace_mode: clojure
color: "#db5855"
primary_extension: .clj
extensions:
- .cl2
- .cljc
- .cljs
- .cljscm
- .cljx
- .hic
filenames:
- riemann.config
@@ -270,8 +351,16 @@ Common Lisp:
primary_extension: .lisp
extensions:
- .asd
- .cl
- .lsp
- .ny
- .podsl
interpreters:
- lisp
- sbcl
- ccl
- clisp
- ecl
Coq:
type: programming
@@ -285,10 +374,22 @@ Cpp-ObjDump:
- .c++objdump
- .cxx-objdump
Creole:
type: prose
lexer: Text only
wrap: true
primary_extension: .creole
Cucumber:
lexer: Gherkin
primary_extension: .feature
Cuda:
lexer: CUDA
primary_extension: .cu
extensions:
- .cuh
Cython:
type: programming
group: Python
@@ -309,6 +410,14 @@ D-ObjDump:
lexer: d-objdump
primary_extension: .d-objdump
DM:
type: programming
color: "#075ff1"
lexer: C++
primary_extension: .dm
aliases:
- byond
DOT:
type: programming
lexer: Text only
@@ -326,16 +435,9 @@ Darcs Patch:
Dart:
type: programming
color: "#98BAD6"
primary_extension: .dart
Delphi:
type: programming
color: "#b0ce4e"
primary_extension: .pas
extensions:
- .dfm
- .lpr
DCPU-16 ASM:
type: programming
lexer: dasm16
@@ -359,7 +461,7 @@ Ecere Projects:
lexer: JSON
primary_extension: .epj
Ecl:
ECL:
type: programming
color: "#8a1267"
primary_extension: .ecl
@@ -383,7 +485,6 @@ Elixir:
Elm:
type: programming
lexer: Haskell
group: Haskell
primary_extension: .elm
Emacs Lisp:
@@ -394,12 +495,14 @@ Emacs Lisp:
- elisp
- emacs
primary_extension: .el
filenames:
- .emacs
extensions:
- .emacs
Erlang:
type: programming
color: "#949e0e"
color: "#0faf8d"
primary_extension: .erl
extensions:
- .hrl
@@ -408,7 +511,9 @@ F#:
type: programming
lexer: FSharp
color: "#b845fc"
search_term: ocaml
search_term: fsharp
aliases:
- fsharp
primary_extension: .fs
extensions:
- .fsi
@@ -473,6 +578,18 @@ GAS:
extensions:
- .S
GLSL:
group: C
type: programming
primary_extension: .glsl
extensions:
- .fp
- .frag
- .geom
- .glslv
- .shader
- .vert
Genshi:
primary_extension: .kid
@@ -495,9 +612,15 @@ Gettext Catalog:
extensions:
- .pot
Glyph:
type: programming
color: "#e4cc98"
lexer: Tcl
primary_extension: .glf
Go:
type: programming
color: "#8d04eb"
color: "#a89b4d"
primary_extension: .go
Gosu:
@@ -581,6 +704,10 @@ Handlebars:
type: markup
lexer: Text only
primary_extension: .handlebars
extensions:
- .hbs
- .html.handlebars
- .html.hbs
Haskell:
type: programming
@@ -591,7 +718,6 @@ Haskell:
Haxe:
type: programming
lexer: haXe
ace_mode: haxe
color: "#346d51"
primary_extension: .hx
@@ -601,12 +727,22 @@ Haxe:
INI:
type: data
extensions:
- .cfg
- .ini
- .prefs
- .properties
primary_extension: .ini
Idris:
type: programming
lexer: Text only
primary_extension: .idr
extensions:
- .lidr
Inno Setup:
primary_extension: .iss
lexer: Text only
IRC log:
lexer: IRC logs
search_term: irc
@@ -626,12 +762,33 @@ Ioke:
color: "#078193"
primary_extension: .ik
J:
type: programming
lexer: Text only
primary_extension: .ijs
JSON:
type: data
group: JavaScript
ace_mode: json
searchable: false
primary_extension: .json
extensions:
- .sublime-keymap
- .sublime_metrics
- .sublime-mousemap
- .sublime-project
- .sublime_session
- .sublime-settings
- .sublime-workspace
filenames:
- .jshintrc
- composer.lock
Jade:
group: HTML
type: markup
primary_extension: .jade
Java:
type: programming
@@ -672,6 +829,13 @@ JavaScript:
Julia:
type: programming
primary_extension: .jl
color: "#a270ba"
KRL:
lexer: Text only
type: programming
color: "#f5c800"
primary_extension: .krl
Kotlin:
type: programming
@@ -680,13 +844,19 @@ Kotlin:
- .ktm
- .kts
LFE:
type: programming
primary_extension: .lfe
color: "#004200"
lexer: Common Lisp
group: Erlang
LLVM:
primary_extension: .ll
Lasso:
type: programming
lexer: Lasso
ace_mode: lasso
color: "#2584c3"
primary_extension: .lasso
@@ -694,7 +864,6 @@ Less:
type: markup
group: CSS
lexer: CSS
ace_mode: less
primary_extension: .less
LilyPond:
@@ -703,6 +872,13 @@ LilyPond:
extensions:
- .ily
Literate Agda:
type: programming
group: Agda
primary_extension: .lagda
extensions:
- .lagda
Literate CoffeeScript:
type: programming
group: CoffeeScript
@@ -745,6 +921,8 @@ Logos:
Logtalk:
type: programming
primary_extension: .lgt
extensions:
- .logtalk
Lua:
type: programming
@@ -753,13 +931,16 @@ Lua:
primary_extension: .lua
extensions:
- .nse
- .rbxs
M:
type: programming
lexer: Common Lisp
aliases:
- mumps
primary_extension: .m
primary_extension: .mumps
extensions:
- .m
Makefile:
aliases:
@@ -772,6 +953,8 @@ Makefile:
- makefile
- Makefile
- GNUmakefile
interpreters:
- make
Mako:
primary_extension: .mako
@@ -779,7 +962,7 @@ Mako:
- .mao
Markdown:
type: markup
type: prose
lexer: Text only
ace_mode: markdown
wrap: true
@@ -798,15 +981,23 @@ Matlab:
Max:
type: programming
color: "#ce279c"
lexer: Text only
lexer: JSON
aliases:
- max/msp
- maxmsp
search_term: max/msp
primary_extension: .mxt
primary_extension: .maxpat
extensions:
- .maxhelp
- .maxpat
- .maxproj
- .mxt
- .pat
MediaWiki:
type: prose
lexer: Text only
wrap: true
primary_extension: .mediawiki
MiniD: # Legacy
searchable: false
@@ -847,6 +1038,12 @@ Nemerle:
color: "#0d3c6e"
primary_extension: .n
NetLogo:
type: programming
lexer: Common Lisp
color: "#ff2b2b"
primary_extension: .nlogo
Nginx:
type: markup
lexer: Nginx configuration file
@@ -937,6 +1134,18 @@ OpenEdge ABL:
- abl
primary_extension: .p
Org:
type: prose
lexer: Text only
wrap: true
primary_extension: .org
Oxygene:
type: programming
lexer: Text only
color: "#5a63a3"
primary_extension: .oxygene
PHP:
type: programming
ace_mode: php
@@ -974,6 +1183,15 @@ Parrot Assembly:
- pasm
primary_extension: .pasm
Pascal:
type: programming
lexer: Delphi
color: "#b0ce4e"
primary_extension: .pas
extensions:
- .dfm
- .lpr
Perl:
type: programming
ace_mode: perl
@@ -981,12 +1199,15 @@ Perl:
primary_extension: .pl
extensions:
- .PL
- .nqp
- .perl
- .ph
- .plx
- .pm6
- .pod
- .psgi
interpreters:
- perl
Pike:
type: programming
@@ -996,6 +1217,13 @@ Pike:
extensions:
- .pmod
Pod:
type: prose
lexer: Text only
ace_mode: perl
wrap: true
primary_extension: .pod
PogoScript:
type: programming
color: "#d80074"
@@ -1008,6 +1236,9 @@ PowerShell:
aliases:
- posh
primary_extension: .ps1
extensions:
- .psd1
- .psm1
Processing:
type: programming
@@ -1022,6 +1253,13 @@ Prolog:
extensions:
- .pro
Protocol Buffer:
type: markup
aliases:
- protobuf
- Protocol Buffers
primary_extension: .proto
Puppet:
type: programming
color: "#cc5555"
@@ -1044,11 +1282,15 @@ Python:
primary_extension: .py
extensions:
- .gyp
- .lmi
- .pyt
- .pyw
- .wsgi
- .xpy
filenames:
- wscript
interpreters:
- python
Python traceback:
type: data
@@ -1057,17 +1299,55 @@ Python traceback:
searchable: false
primary_extension: .pytb
QML:
type: markup
color: "#44a51c"
primary_extension: .qml
R:
type: programming
color: "#198ce7"
lexer: S
primary_extension: .r
extensions:
- .R
filenames:
- .Rprofile
interpreters:
- Rscript
RDoc:
type: prose
lexer: Text only
ace_mode: rdoc
wrap: true
primary_extension: .rdoc
REALbasic:
type: programming
lexer: VB.net
primary_extension: .rbbas
extensions:
- .rbfrm
- .rbmnu
- .rbres
- .rbtbar
- .rbuistate
RHTML:
type: markup
group: HTML
primary_extension: .rhtml
RMarkdown:
type: markup
lexer: Text only
wrap: true
ace_mode: markdown
primary_extension: .rmd
extensions:
- .Rmd
Racket:
type: programming
lexer: Racket
@@ -1101,6 +1381,12 @@ Rebol:
Redcode:
primary_extension: .cw
RobotFramework:
type: programming
primary_extension: .robot
# extensions:
# - .txt
Rouge:
type: programming
lexer: Clojure
@@ -1124,6 +1410,7 @@ Ruby:
- .gemspec
- .god
- .irbrc
- .mspec
- .podspec
- .rbuild
- .rbw
@@ -1131,7 +1418,11 @@ Ruby:
- .ru
- .thor
- .watchr
interpreters:
- ruby
filenames:
- Appraisals
- Berksfile
- Gemfile
- Guardfile
- Podfile
@@ -1171,6 +1462,13 @@ Scala:
ace_mode: scala
color: "#7dd3b0"
primary_extension: .scala
extensions:
- .sc
Scaml:
group: HTML
type: markup
primary_extension: .scaml
Scheme:
type: programming
@@ -1179,6 +1477,11 @@ Scheme:
extensions:
- .sls
- .ss
interpreters:
- guile
- racket
- bigloo
- chicken
Scilab:
type: programming
@@ -1201,7 +1504,19 @@ Shell:
- zsh
primary_extension: .sh
extensions:
- .bats
- .tmux
interpreters:
- bash
- sh
- zsh
filenames:
- Dockerfile
Slash:
type: programming
color: "#007eff"
primary_extension: .sl
Smalltalk:
type: programming
@@ -1211,6 +1526,11 @@ Smalltalk:
Smarty:
primary_extension: .tpl
Squirrel:
type: programming
lexer: C++
primary_extension: .nut
Standard ML:
type: programming
color: "#dc566d"
@@ -1218,11 +1538,17 @@ Standard ML:
- sml
primary_extension: .sml
Stylus:
type: markup
group: CSS
lexer: Text only
primary_extension: .styl
SuperCollider:
type: programming
color: "#46390b"
lexer: Text only
primary_extension: .sc
primary_extension: .scd
TOML:
type: data
@@ -1237,6 +1563,8 @@ Tcl:
type: programming
color: "#e4cc98"
primary_extension: .tcl
extensions:
- .adp
Tcsh:
type: programming
@@ -1247,15 +1575,21 @@ Tcsh:
TeX:
type: markup
color: "#3D6117"
ace_mode: latex
wrap: true
aliases:
- latex
primary_extension: .tex
extensions:
- .aux
- .bib
- .dtx
- .ins
- .ltx
- .mkii
- .mkiv
- .mkvi
- .sty
- .toc
@@ -1264,7 +1598,7 @@ Tea:
primary_extension: .tea
Textile:
type: markup
type: prose
lexer: Text only
ace_mode: textile
wrap: true
@@ -1287,7 +1621,6 @@ Twig:
TypeScript:
type: programming
color: "#31859c"
lexer: Text only
aliases:
- ts
primary_extension: .ts
@@ -1298,13 +1631,27 @@ Unified Parallel C:
lexer: C
ace_mode: c_cpp
color: "#755223"
primary_extension: .upc
primary_extension: .upc
UnrealScript:
type: programming
color: "#a54c4d"
lexer: Java
primary_extension: .uc
VHDL:
type: programming
lexer: vhdl
color: "#543978"
primary_extension: .vhdl
extensions:
- .vhd
- .vhf
- .vhi
- .vho
- .vhs
- .vht
- .vhw
Vala:
type: programming
@@ -1319,9 +1666,7 @@ Verilog:
color: "#848bf3"
primary_extension: .v
extensions:
- .sv
- .svh
- .vh
- .veo
VimL:
type: programming
@@ -1331,6 +1676,7 @@ VimL:
- vim
primary_extension: .vim
filenames:
- .vimrc
- vimrc
- gvimrc
@@ -1341,10 +1687,22 @@ Visual Basic:
primary_extension: .vb
extensions:
- .bas
- .frm
- .frx
- .vba
- .vbs
Volt:
type: programming
lexer: D
color: "#0098db"
primary_extension: .volt
XC:
type: programming
lexer: C
primary_extension: .xc
XML:
type: markup
ace_mode: xml
@@ -1356,39 +1714,53 @@ XML:
extensions:
- .axml
- .ccxml
- .clixml
- .cproject
- .dita
- .ditamap
- .ditaval
- .glade
- .grxml
- .jelly
- .kml
- .launch
- .mxml
- .plist
- .pluginspec
- .ps1xml
- .psc1
- .pt
- .rdf
- .rss
- .scxml
- .srdf
- .svg
- .tmCommand
- .tmLanguage
- .tmPreferences
- .tmSnippet
- .tmTheme
- .tml
- .ui
- .urdf
- .vxml
- .wsdl
- .wxi
- .wxl
- .wxs
- .x3d
- .xacro
- .xaml
- .xlf
- .xliff
- .xmi
- .xsd
- .xul
- .zcml
filenames:
- .classpath
- .project
- phpunit.xml.dist
XProc:
type: programming
@@ -1403,6 +1775,8 @@ XQuery:
primary_extension: .xquery
extensions:
- .xq
- .xql
- .xqm
- .xqy
XS:
@@ -1422,12 +1796,13 @@ Xtend:
primary_extension: .xtend
YAML:
type: markup
type: data
aliases:
- yml
primary_extension: .yml
extensions:
- .reek
- .rviz
- .yaml
eC:
@@ -1454,6 +1829,11 @@ mupad:
lexer: MuPAD
primary_extension: .mu
nesC:
type: programming
color: "#ffce3b"
primary_extension: .nc
ooc:
type: programming
lexer: Ooc
@@ -1461,7 +1841,7 @@ ooc:
primary_extension: .ooc
reStructuredText:
type: markup
type: prose
wrap: true
search_term: rst
aliases:
@@ -1476,3 +1856,9 @@ wisp:
ace_mode: clojure
color: "#7582D1"
primary_extension: .wisp
xBase:
type: programming
lexer: Text only
color: "#3a4040"
primary_extension: .prg

View File

@@ -73,8 +73,8 @@ module Linguist
# Skip vendored or generated blobs
next if blob.vendored? || blob.generated? || blob.language.nil?
# Only include programming languages
if blob.language.type == :programming
# Only include programming languages and acceptable markup languages
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
@sizes[blob.language.group] += blob.size
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,8 @@
require 'yaml'
begin
require 'json'
rescue LoadError
require 'yaml'
end
require 'linguist/md5'
require 'linguist/classifier'
@@ -14,7 +18,8 @@ module Linguist
# Hash of serialized samples object
if File.exist?(PATH)
DATA = YAML.load_file(PATH)
serializer = defined?(JSON) ? JSON : YAML
DATA = serializer.load(File.read(PATH))
end
# Public: Iterate over each sample.
@@ -52,6 +57,7 @@ module Linguist
yield({
:path => File.join(dirname, filename),
:language => category,
:interpreter => File.exist?(filename) ? Linguist.interpreter_from_shebang(File.read(filename)) : nil,
:extname => File.extname(filename)
})
end
@@ -67,6 +73,7 @@ module Linguist
def self.data
db = {}
db['extnames'] = {}
db['interpreters'] = {}
db['filenames'] = {}
each do |sample|
@@ -80,6 +87,14 @@ module Linguist
end
end
if sample[:interpreter]
db['interpreters'][language_name] ||= []
if !db['interpreters'][language_name].include?(sample[:interpreter])
db['interpreters'][language_name] << sample[:interpreter]
db['interpreters'][language_name].sort!
end
end
if sample[:filename]
db['filenames'][language_name] ||= []
db['filenames'][language_name] << sample[:filename]
@@ -95,4 +110,40 @@ module Linguist
db
end
end
# Used to retrieve the interpreter from the shebang line of a file's
# data.
def self.interpreter_from_shebang(data)
lines = data.lines.to_a
if lines.any? && (match = lines[0].match(/(.+)\n?/)) && (bang = match[0]) =~ /^#!/
bang.sub!(/^#! /, '#!')
tokens = bang.split(' ')
pieces = tokens.first.split('/')
if pieces.size > 1
script = pieces.last
else
script = pieces.first.sub('#!', '')
end
script = script == 'env' ? tokens[1] : script
# "python2.6" -> "python"
if script =~ /((?:\d+\.?)+)/
script.sub! $1, ''
end
# Check for multiline shebang hacks that call `exec`
if script == 'sh' &&
lines[0...5].any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
script = $1
end
script
else
nil
end
end
end

View File

@@ -12,6 +12,9 @@
# Caches
- cache/
# Dependencies
- ^[Dd]ependencies/
# C deps
# https://github.com/joyent/node
- ^deps/
@@ -24,8 +27,15 @@
# Node dependencies
- node_modules/
# Erlang bundles
- ^rebar$
# Bootstrap minified css and js
- (^|/)bootstrap([^.]*)(\.min)\.(js|css)$
# Vendored dependencies
- vendor/
- thirdparty/
- vendors?/
# Debian packaging
- ^debian/
@@ -34,7 +44,11 @@
# jQuery
- (^|/)jquery([^.]*)(\.min)?\.js$
- (^|/)jquery\-\d\.\d(\.\d)?(\.min)?\.js$
- (^|/)jquery\-\d\.\d+(\.\d+)?(\.min)?\.js$
# jQuery UI
- (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$
- (^|/)jquery\.(ui|effects)\.([^.]*)(\.min)?\.(js|css)$
# Prototype
- (^|/)prototype(.*)\.js$
@@ -55,10 +69,6 @@
- (^|/)yahoo-([^.]*)\.js$
- (^|/)yui([^.]*)\.js$
# LESS css
- (^|/)less([^.]*)(\.min)?\.js$
- (^|/)less\-\d+\.\d+\.\d+(\.min)?\.js$
# WYS editors
- (^|/)ckeditor\.js$
- (^|/)tiny_mce([^.]*)\.js$
@@ -83,6 +93,8 @@
# WAF
- ^waf$
# .osx
- ^.osx$
## Obj-C ##
@@ -95,7 +107,8 @@
- -vsdoc\.js$
# jQuery validation plugin (MS bundles this with asp.net mvc)
- (^|/)jquery([^.]*)\.validate(\.min)?\.js$
- (^|/)jquery([^.]*)\.validate(\.unobtrusive)?(\.min)?\.js$
- (^|/)jquery([^.]*)\.unobtrusive\-ajax(\.min)?\.js$
# Microsoft Ajax
- (^|/)[Mm]icrosoft([Mm]vc)?([Aa]jax|[Vv]alidation)(\.debug)?\.js$
@@ -104,10 +117,44 @@
- ^[Pp]ackages/
# ExtJS
- (^|/)extjs/
- (^|/)extjs/.*?\.js$
- (^|/)extjs/.*?\.xml$
- (^|/)extjs/.*?\.txt$
- (^|/)extjs/.*?\.html$
- (^|/)extjs/.*?\.properties$
- (^|/)extjs/.sencha/
- (^|/)extjs/docs/
- (^|/)extjs/builds/
- (^|/)extjs/cmd/
- (^|/)extjs/examples/
- (^|/)extjs/locale/
- (^|/)extjs/packages/
- (^|/)extjs/plugins/
- (^|/)extjs/resources/
- (^|/)extjs/src/
- (^|/)extjs/welcome/
# Samples folders
- ^[Ss]amples/
# LICENSE, README, git config files
- ^COPYING$
- LICENSE$
- gitattributes$
- gitignore$
- gitmodules$
- ^README$
- ^readme$
# Test fixtures
- ^[Tt]est/fixtures/
# PhoneGap/Cordova
- (^|/)cordova([^.]*)(\.min)?\.js$
- (^|/)cordova\-\d\.\d(\.\d)?(\.min)?\.js$
# Vagrant
- ^Vagrantfile$
# .DS_Store's
- .[Dd][Ss]_[Ss]tore$

39
samples/Agda/NatCat.agda Normal file
View File

@@ -0,0 +1,39 @@
module NatCat where
open import Relation.Binary.PropositionalEquality
-- If you can show that a relation only ever has one inhabitant
-- you get the category laws for free
module
EasyCategory
(obj : Set)
(_⟶_ : obj obj Set)
(_∘_ : {x y z} x y y z x z)
(id : x x x)
(single-inhabitant : (x y : obj) (r s : x y) r s)
where
idʳ : x y (r : x y) r id y r
idʳ x y r = single-inhabitant x y (r id y) r
idˡ : x y (r : x y) id x r r
idˡ x y r = single-inhabitant x y (id x r) r
∘-assoc : w x y z (r : w x) (s : x y) (t : y z) (r s) t r (s t)
∘-assoc w x y z r s t = single-inhabitant w z ((r s) t) (r (s t))
open import Data.Nat
same : (x y : ) (r s : x y) r s
same .0 y z≤n z≤n = refl
same .(suc m) .(suc n) (s≤s {m} {n} r) (s≤s s) = cong s≤s (same m n r s)
≤-trans : x y z x y y z x z
≤-trans .0 y z z≤n s = z≤n
≤-trans .(suc m) .(suc n) .(suc n₁) (s≤s {m} {n} r) (s≤s {.n} {n₁} s) = s≤s (≤-trans m n n₁ r s)
≤-refl : x x x
≤-refl zero = z≤n
≤-refl (suc x) = s≤s (≤-refl x)
module Nat-EasyCategory = EasyCategory _≤_ (λ {x}{y}{z} ≤-trans x y z) ≤-refl same

View File

@@ -0,0 +1,13 @@
Gregory Romé has written an AsciiDoc plugin for the Redmine project management application.
https://github.com/foo-users/foo
へと `vicmd` キーマップを足してみている試み、
アニメーションgifです。
tag::romé[]
Gregory Romé has written an AsciiDoc plugin for the Redmine project management application.
end::romé[]
== Überschrift
* Codierungen sind verrückt auf älteren Versionen von Ruby

10
samples/AsciiDoc/list.asc Normal file
View File

@@ -0,0 +1,10 @@
AsciiDoc Home Page
==================
Example Articles
~~~~~~~~~~~~~~~~
- Item 1
- Item 2
- Item 3

View File

@@ -0,0 +1,25 @@
Document Title
==============
Doc Writer <thedoc@asciidoctor.org>
:idprefix: id_
Preamble paragraph.
NOTE: This is test, only a test.
== Section A
*Section A* paragraph.
=== Section A Subsection
*Section A* 'subsection' paragraph.
== Section B
*Section B* paragraph.
.Section B list
* Item 1
* Item 2
* Item 3

View File

@@ -0,0 +1,147 @@
Local bk = CreateBank(8)
PokeFloat bk, 0, -1
Print Bin(PeekInt(bk, 0))
Print %1000000000000000
Print Bin(1 Shl 31)
Print $1f
Print $ff
Print $1f + (127 - 15)
Print Hex(%01111111100000000000000000000000)
Print Hex(~%11111111100000000000000000000000)
Print Bin(FloatToHalf(-2.5))
Print HalfToFloat(FloatToHalf(-200000000000.0))
Print Bin(FToI(-2.5))
WaitKey
End
; Half-precision (16-bit) arithmetic library
;============================================
Global Half_CBank_
Function FToI(f#)
If Half_CBank_ = 0 Then Half_CBank_ = CreateBank(4)
PokeFloat Half_CBank_, 0, f
Return PeekInt(Half_CBank_, 0)
End Function
Function HalfToFloat#(h)
Local signBit, exponent, fraction, fBits
signBit = (h And 32768) <> 0
exponent = (h And %0111110000000000) Shr 10
fraction = (h And %0000001111111111)
If exponent = $1F Then exponent = $FF : ElseIf exponent Then exponent = (exponent - 15) + 127
fBits = (signBit Shl 31) Or (exponent Shl 23) Or (fraction Shl 13)
If Half_CBank_ = 0 Then Half_CBank_ = CreateBank(4)
PokeInt Half_CBank_, 0, fBits
Return PeekFloat(Half_CBank_, 0)
End Function
Function FloatToHalf(f#)
Local signBit, exponent, fraction, fBits
If Half_CBank_ = 0 Then Half_CBank_ = CreateBank(4)
PokeFloat Half_CBank_, 0, f
fBits = PeekInt(Half_CBank_, 0)
signBit = (fBits And (1 Shl 31)) <> 0
exponent = (fBits And $7F800000) Shr 23
fraction = fBits And $007FFFFF
If exponent
exponent = exponent - 127
If Abs(exponent) > $1F
If exponent <> ($FF - 127) Then fraction = 0
exponent = $1F * Sgn(exponent)
Else
exponent = exponent + 15
EndIf
exponent = exponent And %11111
EndIf
fraction = fraction Shr 13
Return (signBit Shl 15) Or (exponent Shl 10) Or fraction
End Function
Function HalfAdd(l, r)
End Function
Function HalfSub(l, r)
End Function
Function HalfMul(l, r)
End Function
Function HalfDiv(l, r)
End Function
Function HalfLT(l, r)
End Function
Function HalfGT(l, r)
End Function
; Double-precision (64-bit) arithmetic library)
;===============================================
Global DoubleOut[1], Double_CBank_
Function DoubleToFloat#(d[1])
End Function
Function FloatToDouble(f#)
End Function
Function IntToDouble(i)
End Function
Function SefToDouble(s, e, f)
End Function
Function DoubleAdd(l, r)
End Function
Function DoubleSub(l, r)
End Function
Function DoubleMul(l, r)
End Function
Function DoubleDiv(l, r)
End Function
Function DoubleLT(l, r)
End Function
Function DoubleGT(l, r)
End Function
;~IDEal Editor Parameters:
;~F#1A#20#2F
;~C#Blitz3D

369
samples/BlitzBasic/LList.bb Normal file
View File

@@ -0,0 +1,369 @@
; Double-linked list container class
;====================================
; with thanks to MusicianKool, for concept and issue fixes
Type LList
Field head_.ListNode
Field tail_.ListNode
End Type
Type ListNode
Field pv_.ListNode
Field nx_.ListNode
Field Value
End Type
Type Iterator
Field Value
Field l_.LList
Field cn_.ListNode, cni_
End Type
;Create a new LList object
Function CreateList.LList()
Local l.LList = New LList
l\head_ = New ListNode
l\tail_ = New ListNode
l\head_\nx_ = l\tail_ ;End caps
l\head_\pv_ = l\head_ ;These make it more or less safe to iterate freely
l\head_\Value = 0
l\tail_\nx_ = l\tail_
l\tail_\pv_ = l\head_
l\tail_\Value = 0
Return l
End Function
;Free a list and all elements (not any values)
Function FreeList(l.LList)
ClearList l
Delete l\head_
Delete l\tail_
Delete l
End Function
;Remove all the elements from a list (does not free values)
Function ClearList(l.LList)
Local n.ListNode = l\head_\nx_
While n <> l\tail_
Local nx.ListNode = n\nx_
Delete n
n = nx
Wend
l\head_\nx_ = l\tail_
l\tail_\pv_ = l\head_
End Function
;Count the number of elements in a list (slow)
Function ListLength(l.LList)
Local i.Iterator = GetIterator(l), elems
While EachIn(i)
elems = elems + 1
Wend
Return elems
End Function
;Return True if a list contains a given value
Function ListContains(l.LList, Value)
Return (ListFindNode(l, Value) <> Null)
End Function
;Create a linked list from the intvalues in a bank (slow)
Function ListFromBank.LList(bank)
Local l.LList = CreateList()
Local size = BankSize(bank), p
For p = 0 To size - 4 Step 4
ListAddLast l, PeekInt(bank, p)
Next
Return l
End Function
;Create a bank containing all the values in a list (slow)
Function ListToBank(l.LList)
Local size = ListLength(l) * 4
Local bank = CreateBank(size)
Local i.Iterator = GetIterator(l), p = 0
While EachIn(i)
PokeInt bank, p, i\Value
p = p + 4
Wend
Return bank
End Function
;Swap the contents of two list objects
Function SwapLists(l1.LList, l2.LList)
Local tempH.ListNode = l1\head_, tempT.ListNode = l1\tail_
l1\head_ = l2\head_
l1\tail_ = l2\tail_
l2\head_ = tempH
l2\tail_ = tempT
End Function
;Create a new list containing the same values as the first
Function CopyList.LList(lo.LList)
Local ln.LList = CreateList()
Local i.Iterator = GetIterator(lo) : While EachIn(i)
ListAddLast ln, i\Value
Wend
Return ln
End Function
;Reverse the order of elements of a list
Function ReverseList(l.LList)
Local n1.ListNode, n2.ListNode, tmp.ListNode
n1 = l\head_
n2 = l\head_\nx_
While n1 <> l\tail_
n1\pv_ = n2
tmp = n2\nx_
n2\nx_ = n1
n1 = n2
n2 = tmp
Wend
tmp = l\head_
l\head_ = l\tail_
l\tail_ = tmp
l\head_\pv_ = l\head_
l\tail_\nx_ = l\tail_
End Function
;Search a list to retrieve the first node with the given value
Function ListFindNode.ListNode(l.LList, Value)
Local n.ListNode = l\head_\nx_
While n <> l\tail_
If n\Value = Value Then Return n
n = n\nx_
Wend
Return Null
End Function
;Append a value to the end of a list (fast) and return the node
Function ListAddLast.ListNode(l.LList, Value)
Local n.ListNode = New ListNode
n\pv_ = l\tail_\pv_
n\nx_ = l\tail_
n\Value = Value
l\tail_\pv_ = n
n\pv_\nx_ = n
Return n
End Function
;Attach a value to the start of a list (fast) and return the node
Function ListAddFirst.ListNode(l.LList, Value)
Local n.ListNode = New ListNode
n\pv_ = l\head_
n\nx_ = l\head_\nx_
n\Value = Value
l\head_\nx_ = n
n\nx_\pv_ = n
Return n
End Function
;Remove the first occurence of the given value from a list
Function ListRemove(l.LList, Value)
Local n.ListNode = ListFindNode(l, Value)
If n <> Null Then RemoveListNode n
End Function
;Remove a node from a list
Function RemoveListNode(n.ListNode)
n\pv_\nx_ = n\nx_
n\nx_\pv_ = n\pv_
Delete n
End Function
;Return the value of the element at the given position from the start of the list,
;or backwards from the end of the list for a negative index
Function ValueAtIndex(l.LList, index)
Local n.ListNode = ListNodeAtIndex(l, index)
If n <> Null Then Return n\Value : Else Return 0
End Function
;Return the ListNode at the given position from the start of the list, or backwards
;from the end of the list for a negative index, or Null if invalid
Function ListNodeAtIndex.ListNode(l.LList, index)
Local e, n.ListNode
If index >= 0
n = l\head_
For e = 0 To index
n = n\nx_
Next
If n = l\tail_ Then n = Null ;Beyond the end of the list - not valid
Else ;Negative index - count backward
n = l\tail_
For e = 0 To index Step -1
n = n\pv_
Next
If n = l\head_ Then n = Null ;Before the start of the list - not valid
EndIf
Return n
End Function
;Replace a value at the given position (added by MusicianKool)
Function ReplaceValueAtIndex(l.LList,index,value)
Local n.ListNode = ListNodeAtIndex(l,index)
If n <> Null Then n\Value = value:Else Return 0
End Function
;Remove and return a value at the given position (added by MusicianKool)
Function RemoveNodeAtIndex(l.LList,index)
Local n.ListNode = ListNodeAtIndex(l,index),tval
If n <> Null Then tval = n\Value:RemoveListNode(n):Return tval:Else Return 0
End Function
;Retrieve the first value from a list
Function ListFirst(l.LList)
If l\head_\nx_ <> l\tail_ Then Return l\head_\nx_\Value
End Function
;Retrieve the last value from a list
Function ListLast(l.LList)
If l\tail_\pv_ <> l\head_ Then Return l\tail_\pv_\Value
End Function
;Remove the first element from a list, and return its value
Function ListRemoveFirst(l.LList)
Local val
If l\head_\nx_ <> l\tail_
val = l\head_\nx_\Value
RemoveListNode l\head_\nx_
EndIf
Return val
End Function
;Remove the last element from a list, and return its value
Function ListRemoveLast(l.LList)
Local val
If l\tail_\pv_ <> l\head_
val = l\tail_\pv_\Value
RemoveListNode l\tail_\pv_
EndIf
Return val
End Function
;Insert a value into a list before the specified node, and return the new node
Function InsertBeforeNode.ListNode(Value, n.ListNode)
Local bef.ListNode = New ListNode
bef\pv_ = n\pv_
bef\nx_ = n
bef\Value = Value
n\pv_ = bef
bef\pv_\nx_ = bef
Return bef
End Function
;Insert a value into a list after the specified node, and return then new node
Function InsertAfterNode.ListNode(Value, n.ListNode)
Local aft.ListNode = New ListNode
aft\nx_ = n\nx_
aft\pv_ = n
aft\Value = Value
n\nx_ = aft
aft\nx_\pv_ = aft
Return aft
End Function
;Get an iterator object to use with a loop
;This function means that most programs won't have to think about deleting iterators manually
;(in general only a small, constant number will be created)
Function GetIterator.Iterator(l.LList)
Local i.Iterator
If l = Null Then RuntimeError "Cannot create Iterator for Null"
For i = Each Iterator ;See if there's an available iterator at the moment
If i\l_ = Null Then Exit
Next
If i = Null Then i = New Iterator ;If there wasn't, create one
i\l_ = l
i\cn_ = l\head_
i\cni_ = -1
i\Value = 0 ;No especial reason why this has to be anything, but meh
Return i
End Function
;Use as the argument to While to iterate over the members of a list
Function EachIn(i.Iterator)
i\cn_ = i\cn_\nx_
If i\cn_ <> i\l_\tail_ ;Still items in the list
i\Value = i\cn_\Value
i\cni_ = i\cni_ + 1
Return True
Else
i\l_ = Null ;Disconnect from the list, having reached the end
i\cn_ = Null
i\cni_ = -1
Return False
EndIf
End Function
;Remove from the containing list the element currently pointed to by an iterator
Function IteratorRemove(i.Iterator)
If (i\cn_ <> i\l_\head_) And (i\cn_ <> i\l_\tail_)
Local temp.ListNode = i\cn_
i\cn_ = i\cn_\pv_
i\cni_ = i\cni_ - 1
i\Value = 0
RemoveListNode temp
Return True
Else
Return False
EndIf
End Function
;Call this before breaking out of an EachIn loop, to disconnect the iterator from the list
Function IteratorBreak(i.Iterator)
i\l_ = Null
i\cn_ = Null
i\cni_ = -1
i\Value = 0
End Function
;~IDEal Editor Parameters:
;~F#5#A#10#18#2A#32#3E#47#4C#58#66#6F#78#8F#9B#A9#B7#BD#C5#CC
;~F#E3#E9#EF#F4#F9#103#10D#11B#12B#13F#152#163
;~C#Blitz3D

View File

@@ -0,0 +1,66 @@
Local i, start, result
Local s.Sum3Obj = New Sum3Obj
For i = 1 To 100000
s = New Sum3Obj
result = Handle Before s
Delete s
Next
start = MilliSecs()
For i = 1 To 1000000
result = Sum3_(MakeSum3Obj(i, i, i))
Next
start = MilliSecs() - start
Print start
start = MilliSecs()
For i = 1 To 1000000
result = Sum3(i, i, i)
Next
start = MilliSecs() - start
Print start
WaitKey
End
Function Sum3(a, b, c)
Return a + b + c
End Function
Type Sum3Obj
Field isActive
Field a, b, c
End Type
Function MakeSum3Obj(a, b, c)
Local s.Sum3Obj = Last Sum3Obj
If s\isActive Then s = New Sum3Obj
s\isActive = True
s\a = a
s\b = b
s\c = c
Restore label
Read foo
Return Handle(s)
End Function
.label
Data (10 + 2), 12, 14
:
Function Sum3_(a_)
Local a.Sum3Obj = Object.Sum3Obj a_
Local return_ = a\a + a\b + a\c
Insert a Before First Sum3Obj :: a\isActive = False
Return return_
End Function
;~IDEal Editor Parameters:
;~C#Blitz3D

167
samples/Bluespec/TL.bsv Normal file
View File

@@ -0,0 +1,167 @@
package TL;
interface TL;
method Action ped_button_push();
(* always_enabled *)
method Action set_car_state_N(Bool x);
(* always_enabled *)
method Action set_car_state_S(Bool x);
(* always_enabled *)
method Action set_car_state_E(Bool x);
(* always_enabled *)
method Action set_car_state_W(Bool x);
method Bool lampRedNS();
method Bool lampAmberNS();
method Bool lampGreenNS();
method Bool lampRedE();
method Bool lampAmberE();
method Bool lampGreenE();
method Bool lampRedW();
method Bool lampAmberW();
method Bool lampGreenW();
method Bool lampRedPed();
method Bool lampAmberPed();
method Bool lampGreenPed();
endinterface: TL
typedef enum {
AllRed,
GreenNS, AmberNS,
GreenE, AmberE,
GreenW, AmberW,
GreenPed, AmberPed} TLstates deriving (Eq, Bits);
typedef UInt#(5) Time32;
typedef UInt#(20) CtrSize;
(* synthesize *)
module sysTL(TL);
Time32 allRedDelay = 2;
Time32 amberDelay = 4;
Time32 nsGreenDelay = 20;
Time32 ewGreenDelay = 10;
Time32 pedGreenDelay = 10;
Time32 pedAmberDelay = 6;
CtrSize clocks_per_sec = 100;
Reg#(TLstates) state <- mkReg(AllRed);
Reg#(TLstates) next_green <- mkReg(GreenNS);
Reg#(Time32) secs <- mkReg(0);
Reg#(Bool) ped_button_pushed <- mkReg(False);
Reg#(Bool) car_present_N <- mkReg(True);
Reg#(Bool) car_present_S <- mkReg(True);
Reg#(Bool) car_present_E <- mkReg(True);
Reg#(Bool) car_present_W <- mkReg(True);
Bool car_present_NS = car_present_N || car_present_S;
Reg#(CtrSize) cycle_ctr <- mkReg(0);
rule dec_cycle_ctr (cycle_ctr != 0);
cycle_ctr <= cycle_ctr - 1;
endrule
Rules low_priority_rule = (rules
rule inc_sec (cycle_ctr == 0);
secs <= secs + 1;
cycle_ctr <= clocks_per_sec;
endrule endrules);
function Action next_state(TLstates ns);
action
state <= ns;
secs <= 0;
endaction
endfunction: next_state
function TLstates green_seq(TLstates x);
case (x)
GreenNS: return (GreenE);
GreenE: return (GreenW);
GreenW: return (GreenNS);
endcase
endfunction
function Bool car_present(TLstates x);
case (x)
GreenNS: return (car_present_NS);
GreenE: return (car_present_E);
GreenW: return (car_present_W);
endcase
endfunction
function Rules make_from_green_rule(TLstates green_state, Time32 delay, Bool car_is_present, TLstates ns);
return (rules
rule from_green (state == green_state && (secs >= delay || !car_is_present));
next_state(ns);
endrule endrules);
endfunction: make_from_green_rule
function Rules make_from_amber_rule(TLstates amber_state, TLstates ng);
return (rules
rule from_amber (state == amber_state && secs >= amberDelay);
next_state(AllRed);
next_green <= ng;
endrule endrules);
endfunction: make_from_amber_rule
Rules hprs[7];
hprs[1] = make_from_green_rule(GreenNS, nsGreenDelay, car_present_NS, AmberNS);
hprs[2] = make_from_amber_rule(AmberNS, GreenE);
hprs[3] = make_from_green_rule(GreenE, ewGreenDelay, car_present_E, AmberE);
hprs[4] = make_from_amber_rule(AmberE, GreenW);
hprs[5] = make_from_green_rule(GreenW, ewGreenDelay, car_present_W, AmberW);
hprs[6] = make_from_amber_rule(AmberW, GreenNS);
hprs[0] = (rules
rule fromAllRed (state == AllRed && secs >= allRedDelay);
if (ped_button_pushed) action
ped_button_pushed <= False;
next_state(GreenPed);
endaction else if (car_present(next_green))
next_state(next_green);
else if (car_present(green_seq(next_green)))
next_state(green_seq(next_green));
else if (car_present(green_seq(green_seq(next_green))))
next_state(green_seq(green_seq(next_green)));
else
noAction;
endrule: fromAllRed endrules);
Rules high_priority_rules = hprs[0];
for (Integer i = 1; i<7; i=i+1)
high_priority_rules = rJoin(hprs[i], high_priority_rules);
addRules(preempts(high_priority_rules, low_priority_rule));
method Action ped_button_push();
ped_button_pushed <= True;
endmethod: ped_button_push
method Action set_car_state_N(b) ; car_present_N <= b; endmethod
method Action set_car_state_S(b) ; car_present_S <= b; endmethod
method Action set_car_state_E(b) ; car_present_E <= b; endmethod
method Action set_car_state_W(b) ; car_present_W <= b; endmethod
method lampRedNS() = (!(state == GreenNS || state == AmberNS));
method lampAmberNS() = (state == AmberNS);
method lampGreenNS() = (state == GreenNS);
method lampRedE() = (!(state == GreenE || state == AmberE));
method lampAmberE() = (state == AmberE);
method lampGreenE() = (state == GreenE);
method lampRedW() = (!(state == GreenW || state == AmberW));
method lampAmberW() = (state == AmberW);
method lampGreenW() = (state == GreenW);
method lampRedPed() = (!(state == GreenPed || state == AmberPed));
method lampAmberPed() = (state == AmberPed);
method lampGreenPed() = (state == GreenPed);
endmodule: sysTL
endpackage: TL

109
samples/Bluespec/TbTL.bsv Normal file
View File

@@ -0,0 +1,109 @@
package TbTL;
import TL::*;
interface Lamp;
method Bool changed;
method Action show_offs;
method Action show_ons;
method Action reset;
endinterface
module mkLamp#(String name, Bool lamp)(Lamp);
Reg#(Bool) prev <- mkReg(False);
method changed = (prev != lamp);
method Action show_offs;
if (prev && !lamp)
$write (name + " off, ");
endmethod
method Action show_ons;
if (!prev && lamp)
$write (name + " on, ");
endmethod
method Action reset;
prev <= lamp;
endmethod
endmodule
(* synthesize *)
module mkTest();
let dut <- sysTL;
Reg#(Bit#(16)) ctr <- mkReg(0);
Reg#(Bool) carN <- mkReg(False);
Reg#(Bool) carS <- mkReg(False);
Reg#(Bool) carE <- mkReg(False);
Reg#(Bool) carW <- mkReg(False);
Lamp lamps[12];
lamps[0] <- mkLamp("0: NS red ", dut.lampRedNS);
lamps[1] <- mkLamp("1: NS amber", dut.lampAmberNS);
lamps[2] <- mkLamp("2: NS green", dut.lampGreenNS);
lamps[3] <- mkLamp("3: E red ", dut.lampRedE);
lamps[4] <- mkLamp("4: E amber", dut.lampAmberE);
lamps[5] <- mkLamp("5: E green", dut.lampGreenE);
lamps[6] <- mkLamp("6: W red ", dut.lampRedW);
lamps[7] <- mkLamp("7: W amber", dut.lampAmberW);
lamps[8] <- mkLamp("8: W green", dut.lampGreenW);
lamps[9] <- mkLamp("9: Ped red ", dut.lampRedPed);
lamps[10] <- mkLamp("10: Ped amber", dut.lampAmberPed);
lamps[11] <- mkLamp("11: Ped green", dut.lampGreenPed);
rule start (ctr == 0);
$dumpvars;
endrule
rule detect_cars;
dut.set_car_state_N(carN);
dut.set_car_state_S(carS);
dut.set_car_state_E(carE);
dut.set_car_state_W(carW);
endrule
rule go;
ctr <= ctr + 1;
if (ctr == 5000) carN <= True;
if (ctr == 6500) carN <= False;
if (ctr == 12_000) dut.ped_button_push;
endrule
rule stop (ctr > 32768);
$display("TESTS FINISHED");
$finish(0);
endrule
function do_offs(l) = l.show_offs;
function do_ons(l) = l.show_ons;
function do_reset(l) = l.reset;
function do_it(f);
action
for (Integer i=0; i<12; i=i+1)
f(lamps[i]);
endaction
endfunction
function any_changes();
Bool b = False;
for (Integer i=0; i<12; i=i+1)
b = b || lamps[i].changed;
return b;
endfunction
rule show (any_changes());
do_it(do_offs);
do_it(do_ons);
do_it(do_reset);
$display("(at time %d)", $time);
endrule
endmodule
endpackage

View File

@@ -0,0 +1,305 @@
' *********************************************************
' ** Simple Grid Screen Demonstration App
' ** Jun 2010
' ** Copyright (c) 2010 Roku Inc. All Rights Reserved.
' *********************************************************
'************************************************************
'** Application startup
'************************************************************
Sub Main()
'initialize theme attributes like titles, logos and overhang color
initTheme()
gridstyle = "Flat-Movie"
'set to go, time to get started
while gridstyle <> ""
print "starting grid style= ";gridstyle
screen=preShowGridScreen(gridstyle)
gridstyle = showGridScreen(screen, gridstyle)
end while
End Sub
'*************************************************************
'** Set the configurable theme attributes for the application
'**
'** Configure the custom overhang and Logo attributes
'** These attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************
Sub initTheme()
app = CreateObject("roAppManager")
app.SetTheme(CreateDefaultTheme())
End Sub
'******************************************************
'** @return The default application theme.
'** Screens can make slight adjustments to the default
'** theme by getting it from here and then overriding
'** individual theme attributes.
'******************************************************
Function CreateDefaultTheme() as Object
theme = CreateObject("roAssociativeArray")
theme.ThemeType = "generic-dark"
' All these are greyscales
theme.GridScreenBackgroundColor = "#363636"
theme.GridScreenMessageColor = "#808080"
theme.GridScreenRetrievingColor = "#CCCCCC"
theme.GridScreenListNameColor = "#FFFFFF"
' Color values work here
theme.GridScreenDescriptionTitleColor = "#001090"
theme.GridScreenDescriptionDateColor = "#FF005B"
theme.GridScreenDescriptionRuntimeColor = "#5B005B"
theme.GridScreenDescriptionSynopsisColor = "#606000"
'used in the Grid Screen
theme.CounterTextLeft = "#FF0000"
theme.CounterSeparator = "#00FF00"
theme.CounterTextRight = "#0000FF"
theme.GridScreenLogoHD = "pkg:/images/Overhang_Test_HD.png"
theme.GridScreenLogoOffsetHD_X = "0"
theme.GridScreenLogoOffsetHD_Y = "0"
theme.GridScreenOverhangHeightHD = "99"
theme.GridScreenLogoSD = "pkg:/images/Overhang_Test_SD43.png"
theme.GridScreenOverhangHeightSD = "66"
theme.GridScreenLogoOffsetSD_X = "0"
theme.GridScreenLogoOffsetSD_Y = "0"
' to use your own focus ring artwork
'theme.GridScreenFocusBorderSD = "pkg:/images/GridCenter_Border_Movies_SD43.png"
'theme.GridScreenBorderOffsetSD = "(-26,-25)"
'theme.GridScreenFocusBorderHD = "pkg:/images/GridCenter_Border_Movies_HD.png"
'theme.GridScreenBorderOffsetHD = "(-28,-20)"
' to use your own description background artwork
'theme.GridScreenDescriptionImageSD = "pkg:/images/Grid_Description_Background_SD43.png"
'theme.GridScreenDescriptionOffsetSD = "(125,170)"
'theme.GridScreenDescriptionImageHD = "pkg:/images/Grid_Description_Background_HD.png"
'theme.GridScreenDescriptionOffsetHD = "(190,255)"
return theme
End Function
'******************************************************
'** Perform any startup/initialization stuff prior to
'** initially showing the screen.
'******************************************************
Function preShowGridScreen(style as string) As Object
m.port=CreateObject("roMessagePort")
screen = CreateObject("roGridScreen")
screen.SetMessagePort(m.port)
' screen.SetDisplayMode("best-fit")
screen.SetDisplayMode("scale-to-fill")
screen.SetGridStyle(style)
return screen
End Function
'******************************************************
'** Display the gird screen and wait for events from
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the show posters
'******************************************************
Function showGridScreen(screen As Object, gridstyle as string) As string
print "enter showGridScreen"
categoryList = getCategoryList()
categoryList[0] = "GridStyle: " + gridstyle
screen.setupLists(categoryList.count())
screen.SetListNames(categoryList)
StyleButtons = getGridControlButtons()
screen.SetContentList(0, StyleButtons)
for i = 1 to categoryList.count()-1
screen.SetContentList(i, getShowsForCategoryItem(categoryList[i]))
end for
screen.Show()
while true
print "Waiting for message"
msg = wait(0, m.port)
'msg = wait(0, screen.GetMessagePort()) ' getmessageport does not work on gridscreen
print "Got Message:";type(msg)
if type(msg) = "roGridScreenEvent" then
print "msg= "; msg.GetMessage() " , index= "; msg.GetIndex(); " data= "; msg.getData()
if msg.isListItemFocused() then
print"list item focused | current show = "; msg.GetIndex()
else if msg.isListItemSelected() then
row = msg.GetIndex()
selection = msg.getData()
print "list item selected row= "; row; " selection= "; selection
' Did we get a selection from the gridstyle selection row?
if (row = 0)
' yes, return so we can come back with new style
return StyleButtons[selection].Title
endif
'm.curShow = displayShowDetailScreen(showList[msg.GetIndex()])
else if msg.isScreenClosed() then
return ""
end if
end If
end while
End Function
'**********************************************************
'** When a poster on the home screen is selected, we call
'** this function passing an roAssociativeArray with the
'** ContentMetaData for the selected show. This data should
'** be sufficient for the springboard to display
'**********************************************************
Function displayShowDetailScreen(category as Object, showIndex as Integer) As Integer
'add code to create springboard, for now we do nothing
return 1
End Function
'**************************************************************
'** Return the list of categories to display in the filter
'** banner. The result is an roArray containing the names of
'** all of the categories. All just static data for the example.
'***************************************************************
Function getCategoryList() As Object
categoryList = [ "GridStyle", "Reality", "History", "News", "Comedy", "Drama"]
return categoryList
End Function
'********************************************************************
'** Given the category from the filter banner, return an array
'** of ContentMetaData objects (roAssociativeArray's) representing
'** the shows for the category. For this example, we just cheat and
'** create and return a static array with just the minimal items
'** set, but ideally, you'd go to a feed service, fetch and parse
'** this data dynamically, so content for each category is dynamic
'********************************************************************
Function getShowsForCategoryItem(category As Object) As Object
print "getting shows for category "; category
showList = [
{
Title: category + ": Header",
releaseDate: "1976",
length: 3600-600,
Description:"This row is category " + category,
hdBranded: true,
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif",
Description:"Short Synopsis #1",
Synopsis:"Length",
StarRating:10,
}
{
Title: category + ": Beverly Hillbillies",
releaseDate: "1969",
rating: "PG",
Description:"Come and listen to a story about a man named Jed: Poor mountaineer, barely kept his family fed. Then one day he was shootin at some food, and up through the ground came a bubblin crude. Oil that is, black gold, Texas tea.",
numEpisodes:42,
contentType:"season",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/4/4e/The_Beverly_Hillbillies.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/4/4e/The_Beverly_Hillbillies.jpg",
StarRating:80,
UserStarRating:40
}
{
Title: category + ": Babylon 5",
releaseDate: "1996",
rating: "PG",
Description:"The show centers on the Babylon 5 space station: a focal point for politics, diplomacy, and conflict during the years 2257-2262.",
numEpisodes:102,
contentType:"season",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/9/9d/Smb5-s4.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/9/9d/Smb5-s4.jpg",
StarRating:80,
UserStarRating:40
}
{
Title: category + ": John F. Kennedy",
releaseDate: "1961",
rating: "PG",
Description:"My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man.",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/5/52/Jfk_happy_birthday_1.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/5/52/Jfk_happy_birthday_1.jpg",
StarRating:100
}
{
Title: category + ": Man on the Moon",
releaseDate: "1969",
rating: "PG",
Description:"That's one small step for a man, one giant leap for mankind.",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg",
StarRating:100
}
{
Title: category + ": I have a Dream",
releaseDate: "1963",
rating: "PG",
Description:"I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin, but by the content of their character.",
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_-_March_on_Washington.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_-_March_on_Washington.jpg",
StarRating:100
}
]
return showList
End Function
function getGridControlButtons() as object
buttons = [
{ Title: "Flat-Movie"
ReleaseDate: "HD:5x2 SD:5x2"
Description: "Flat-Movie (Netflix) style"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif"
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif"
}
{ Title: "Flat-Landscape"
ReleaseDate: "HD:5x3 SD:4x3"
Description: "Channel Store"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px-Dunkery_Hill.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px-Dunkery_Hill.jpg",
}
{ Title: "Flat-Portrait"
ReleaseDate: "HD:5x2 SD:5x2"
Description: "3x4 style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg",
}
{ Title: "Flat-Square"
ReleaseDate: "HD:7x3 SD:6x3"
Description: "1x1 style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png",
}
{ Title: "Flat-16x9"
ReleaseDate: "HD:5x3 SD:4x3"
Description: "HD style posters"
HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png",
SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png",
}
]
return buttons
End Function

View File

@@ -1,39 +0,0 @@
void foo()
{
cudaArray* cu_array;
texture<float, 2, cudaReadModeElementType> tex;
// Allocate array
cudaChannelFormatDesc description = cudaCreateChannelDesc<float>();
cudaMallocArray(&cu_array, &description, width, height);
// Copy image data to array
cudaMemcpyToArray(cu_array, image, width*height*sizeof(float), cudaMemcpyHostToDevice);
// Set texture parameters (default)
tex.addressMode[0] = cudaAddressModeClamp;
tex.addressMode[1] = cudaAddressModeClamp;
tex.filterMode = cudaFilterModePoint;
tex.normalized = false; // do not normalize coordinates
// Bind the array to the texture
cudaBindTextureToArray(tex, cu_array);
// Run kernel
dim3 blockDim(16, 16, 1);
dim3 gridDim((width + blockDim.x - 1)/ blockDim.x, (height + blockDim.y - 1) / blockDim.y, 1);
kernel<<< gridDim, blockDim, 0 >>>(d_data, height, width);
// Unbind the array from the texture
cudaUnbindTexture(tex);
} //end foo()
__global__ void kernel(float* odata, int height, int width)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
if (x < width && y < height) {
float c = tex2D(tex, x, y);
odata[y*width+x] = c;
}
}

61
samples/C/jni_layer.h Normal file
View File

@@ -0,0 +1,61 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class jni_JniLayer */
#ifndef _Included_jni_JniLayer
#define _Included_jni_JniLayer
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: jni_JniLayer
* Method: jni_layer_initialize
* Signature: ([II)J
*/
JNIEXPORT jlong JNICALL Java_jni_JniLayer_jni_1layer_1initialize
(JNIEnv *, jobject, jintArray, jint, jint);
/*
* Class: jni_JniLayer
* Method: jni_layer_mainloop
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1mainloop
(JNIEnv *, jobject, jlong);
/*
* Class: jni_JniLayer
* Method: jni_layer_set_button
* Signature: (JII)V
*/
JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1set_1button
(JNIEnv *, jobject, jlong, jint, jint);
/*
* Class: jni_JniLayer
* Method: jni_layer_set_analog
* Signature: (JIIF)V
*/
JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1set_1analog
(JNIEnv *, jobject, jlong, jint, jint, jfloat);
/*
* Class: jni_JniLayer
* Method: jni_layer_report_analog_chg
* Signature: (JI)V
*/
JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1report_1analog_1chg
(JNIEnv *, jobject, jlong, jint);
/*
* Class: jni_JniLayer
* Method: jni_layer_kill
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1kill
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif

5
samples/C/syscalldefs.h Normal file
View File

@@ -0,0 +1,5 @@
static const syscalldef syscalldefs[] = {
[SYSCALL_OR_NUM(0, SYS_restart_syscall)] = MAKE_UINT16(0, 1),
[SYSCALL_OR_NUM(1, SYS_exit)] = MAKE_UINT16(1, 17),
[SYSCALL_OR_NUM(2, SYS_fork)] = MAKE_UINT16(0, 22),
};

View File

@@ -0,0 +1,5 @@
program-id. hello.
procedure division.
display "Hello, World!".
stop run.

View File

@@ -0,0 +1,6 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World, yet again.".
STOP RUN.

View File

@@ -0,0 +1,6 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.

7
samples/COBOL/simple.cpy Normal file
View File

@@ -0,0 +1,7 @@
01 COBOL-TEST-RECORD.
05 COBOL-TEST-USAGES.
10 COBOL-4-COMP PIC S9(4) COMP.
10 COBOL-8-COMP PIC S9(8) COMP.
10 COBOL-9-COMP PIC S9(9) COMP.
10 COBOL-4-COMP2 PIC S9(4) COMP-2.
10 COBOL-7-COMP2 PIC 9(7) COMP-2.

6307
samples/CSS/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

873
samples/CSS/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

17
samples/Clojure/for.clj Normal file
View File

@@ -0,0 +1,17 @@
(defn prime? [n]
(not-any? zero? (map #(rem n %) (range 2 n))))
(range 3 33 2)
'(3 5 7 9 11 13 15 17 19 21 23 25 27 29 31)
;; :when continues through the collection even if some have the
;; condition evaluate to false, like filter
(for [x (range 3 33 2) :when (prime? x)]
x)
'(3 5 7 11 13 17 19 23 29 31)
;; :while stops at the first collection element that evaluates to
;; false, like take-while
(for [x (range 3 33 2) :while (prime? x)]
x)
'(3 5 7)

View File

@@ -0,0 +1,8 @@
[:html
[:head
[:meta {:charset "utf-8"}]
[:link {:rel "stylesheet" :href "css/bootstrap.min.css"}]
[:script {:src "app.js"}]]
[:body
[:div.nav
[:p "Hello world!"]]]]

View File

@@ -0,0 +1,13 @@
(defn into-array
([aseq]
(into-array nil aseq))
([type aseq]
(let [n (count aseq)
a (make-array n)]
(loop [aseq (seq aseq)
i 0]
(if (< i n)
(do
(aset a i (first aseq))
(recur (next aseq) (inc i)))
a)))))

View File

@@ -0,0 +1,15 @@
(defprotocol ISound (sound []))
(deftype Cat []
ISound
(sound [_] "Meow!"))
(deftype Dog []
ISound
(sound [_] "Woof!"))
(extend-type default
ISound
(sound [_] "... silence ..."))
(sound 1) ;; => "... silence ..."

View File

@@ -0,0 +1,5 @@
(defn rand
"Returns a random floating point number between 0 (inclusive) and
n (default 1) (exclusive)."
([] (scm* [n] (random-real)))
([n] (* (rand) n)))

20
samples/Clojure/svg.cljx Normal file
View File

@@ -0,0 +1,20 @@
^:clj (ns c2.svg
(:use [c2.core :only [unify]]
[c2.maths :only [Pi Tau radians-per-degree
sin cos mean]]))
^:cljs (ns c2.svg
(:use [c2.core :only [unify]]
[c2.maths :only [Pi Tau radians-per-degree
sin cos mean]])
(:require [c2.dom :as dom]))
;;Stub for float fn, which does not exist on cljs runtime
^:cljs (def float identity)
(defn ->xy
"Convert coordinates (potentially map of `{:x :y}`) to 2-vector."
[coordinates]
(cond
(and (vector? coordinates) (= 2 (count coordinates))) coordinates
(map? coordinates) [(:x coordinates) (:y coordinates)]))

View File

@@ -0,0 +1,20 @@
(deftest function-tests
(is (= 3
(count [1 2 3])))
(is (= false
(not true)))
(is (= true
(contains? {:foo 1 :bar 2} :foo)))
(is (= {"foo" 1, "baz" 3}
(select-keys {:foo 1 :bar 2 :baz 3} [:foo :baz])))
(is (= [1 2 3]
(vals {:foo 1 :bar 2 :baz 3})))
(is (= ["foo" "bar" "baz"]
(keys {:foo 1 :bar 2 :baz 3})))
(is (= [2 4 6]
(filter (fn [x] (=== (rem x 2) 0)) [1 2 3 4 5 6]))))

View File

@@ -0,0 +1,21 @@
;;;; -*- lisp -*-
(in-package :foo)
;;; Header comment.
(defvar *foo*)
(eval-when (:execute :compile-toplevel :load-toplevel)
(defun add (x &optional y &key z)
(declare (ignore z))
;; Inline comment.
(+ x (or y 1))))
#|
Multi-line comment.
|#
(defmacro foo (x &body b)
(if x
`(1+ ,x) ;After-line comment.
42))

View File

@@ -0,0 +1,47 @@
= Creole
Creole is a Creole-to-HTML converter for Creole, the lightweight markup
language (http://wikicreole.org/). Github uses this converter to render *.creole files.
Project page on github:
* http://github.com/minad/creole
Travis-CI:
* https://travis-ci.org/minad/creole
RDOC:
* http://rdoc.info/projects/minad/creole
== INSTALLATION
{{{
gem install creole
}}}
== SYNOPSIS
{{{
require 'creole'
html = Creole.creolize('== Creole text')
}}}
== BUGS
If you found a bug, please report it at the Creole project's tracker
on GitHub:
http://github.com/minad/creole/issues
== AUTHORS
* Lars Christensen (larsch)
* Daniel Mendler (minad)
== LICENSE
Creole is Copyright (c) 2008 - 2013 Lars Christensen, Daniel Mendler. It is free software, and
may be redistributed under the terms specified in the README file of
the Ruby distribution.

View File

@@ -0,0 +1,52 @@
__global__ void scalarProdGPU(
float *d_C,
float *d_A,
float *d_B,
int vectorN,
int elementN
)
{
//Accumulators cache
__shared__ float accumResult[ACCUM_N];
////////////////////////////////////////////////////////////////////////////
// Cycle through every pair of vectors,
// taking into account that vector counts can be different
// from total number of thread blocks
////////////////////////////////////////////////////////////////////////////
for (int vec = blockIdx.x; vec < vectorN; vec += gridDim.x)
{
int vectorBase = IMUL(elementN, vec);
int vectorEnd = vectorBase + elementN;
////////////////////////////////////////////////////////////////////////
// Each accumulator cycles through vectors with
// stride equal to number of total number of accumulators ACCUM_N
// At this stage ACCUM_N is only preferred be a multiple of warp size
// to meet memory coalescing alignment constraints.
////////////////////////////////////////////////////////////////////////
for (int iAccum = threadIdx.x; iAccum < ACCUM_N; iAccum += blockDim.x)
{
float sum = 0;
for (int pos = vectorBase + iAccum; pos < vectorEnd; pos += ACCUM_N)
sum += d_A[pos] * d_B[pos];
accumResult[iAccum] = sum;
}
////////////////////////////////////////////////////////////////////////
// Perform tree-like reduction of accumulators' results.
// ACCUM_N has to be power of two at this stage
////////////////////////////////////////////////////////////////////////
for (int stride = ACCUM_N / 2; stride > 0; stride >>= 1)
{
__syncthreads();
for (int iAccum = threadIdx.x; iAccum < stride; iAccum += blockDim.x)
accumResult[iAccum] += accumResult[stride + iAccum];
}
if (threadIdx.x == 0) d_C[vec] = accumResult[0];
}
}

46
samples/Cuda/vectorAdd.cu Normal file
View File

@@ -0,0 +1,46 @@
#include <stdio.h>
#include <cuda_runtime.h>
/**
* CUDA Kernel Device code
*
* Computes the vector addition of A and B into C. The 3 vectors have the same
* number of elements numElements.
*/
__global__ void
vectorAdd(const float *A, const float *B, float *C, int numElements)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < numElements)
{
C[i] = A[i] + B[i];
}
}
/**
* Host main routine
*/
int
main(void)
{
// Error code to check return values for CUDA calls
cudaError_t err = cudaSuccess;
// Launch the Vector Add CUDA Kernel
int threadsPerBlock = 256;
int blocksPerGrid =(numElements + threadsPerBlock - 1) / threadsPerBlock;
vectorAdd<<<blocksPerGrid, threadsPerBlock>>>(d_A, d_B, d_C, numElements);
err = cudaGetLastError();
if (err != cudaSuccess)
{
fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
// Reset the device and exit
err = cudaDeviceReset();
return 0;
}

87
samples/DM/example.dm Normal file
View File

@@ -0,0 +1,87 @@
// This is a single line comment.
/*
This is a multi-line comment
*/
// Pre-processor keywords
#define PI 3.1415
#if PI == 4
#define G 5
#elif PI == 3
#define I 6
#else
#define K 7
#endif
var/GlobalCounter = 0
var/const/CONST_VARIABLE = 2
var/list/MyList = list("anything", 1, new /datum/entity)
var/list/EmptyList[99] // creates a list of 99 null entries
var/list/NullList = null
/*
Entity Class
*/
/datum/entity
var/name = "Entity"
var/number = 0
/datum/entity/proc/myFunction()
world.log << "Entity has called myFunction"
/datum/entity/New()
number = GlobalCounter++
/*
Unit Class, Extends from Entity
*/
/datum/entity/unit
name = "Unit"
/datum/entity/unit/New()
..() // calls the parent's proc; equal to super() and base() in other languages
number = rand(1, 99)
/datum/entity/unit/myFunction()
world.log << "Unit has overriden and called myFunction"
// Global Function
/proc/ReverseList(var/list/input)
var/list/output = list()
for(var/i = input.len; i >= 1; i--) // IMPORTANT: List Arrays count from 1.
output += input[i] // "+= x" is ".Add(x)"
return output
// Bitflags
/proc/DoStuff()
var/bitflag = 0
bitflag |= 8
return bitflag
/proc/DoOtherStuff()
var/bitflag = 65535 // 16 bits is the maximum amount
bitflag &= ~8
return bitflag
// Logic
/proc/DoNothing()
var/pi = PI
if(pi == 4)
world.log << "PI is 4"
else if(pi == CONST_VARIABLE)
world.log << "PI is [CONST_VARIABLE]!"
else
world.log << "PI is approximety [pi]"
#undef PI // Undefine PI

View File

@@ -0,0 +1,122 @@
#!/usr/bin/env escript
%%!
%-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*-
% ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et:
%%%
%%%------------------------------------------------------------------------
%%% BSD LICENSE
%%%
%%% Copyright (c) 2013, Michael Truog <mjtruog at gmail dot com>
%%% 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.
%%% * All advertising materials mentioning features or use of this
%%% software must display the following acknowledgment:
%%% This product includes software developed by Michael Truog
%%% * The name of the author may not be used to endorse or promote
%%% products derived from this software without specific prior
%%% written permission
%%%
%%% 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.
%%%------------------------------------------------------------------------
-author('mjtruog [at] gmail (dot) com').
-mode(compile).
main(_) ->
{ok,
[{sys, _} = RelToolConfig,
{target_dir, TargetDir},
{overlay, OverlayConfig}]} = file:consult("reltool.config"),
{ok, Spec} = reltool:get_target_spec([RelToolConfig]),
case file:make_dir(TargetDir) of
ok ->
ok;
{error, eexist} ->
io:format("release already exists? (~p)~n", [TargetDir]),
exit_code(1)
end,
ok = reltool:eval_target_spec(Spec, code:root_dir(), TargetDir),
ok = process_overlay(RelToolConfig, TargetDir, OverlayConfig),
exit_code(0).
shell(Command, Arguments) ->
CommandSuffix = " && echo 0 || echo 1",
case lists:reverse(os:cmd(lists:flatten(
io_lib:format(Command ++ CommandSuffix, Arguments)))) of
[_, $0 | _] ->
ok;
[_, $1 | _] ->
io:format("\"~s\" failed!~n", [io_lib:format(Command, Arguments)]),
error
end.
boot_rel_vsn({sys, Config} = _RelToolConfig) ->
{rel, _Name, Ver, _} = proplists:lookup(rel, Config),
Ver.
%% minimal parsing for handling mustache syntax
mustache(Body, Context) ->
mustache(Body, "", Context).
mustache([], Result, _Context) ->
lists:reverse(Result);
mustache([${, ${ | KeyStr], Result, Context) ->
mustache_key(KeyStr, "", Result, Context);
mustache([C | Rest], Result, Context) ->
mustache(Rest, [C | Result], Context).
mustache_key([$}, $} | Rest], KeyStr, Result, Context) ->
Key = erlang:list_to_existing_atom(lists:reverse(KeyStr)),
{ok, Value} = dict:find(Key, Context),
mustache(Rest, lists:reverse(Value) ++ Result, Context);
mustache_key([C | Rest], KeyStr, Result, Context) ->
mustache_key(Rest, [C | KeyStr], Result, Context).
%% support minimal overlay based on rebar overlays
process_overlay(RelToolConfig, TargetDir, OverlayConfig) ->
BootRelVsn = boot_rel_vsn(RelToolConfig),
OverlayVars =
dict:from_list([{erts_vsn, "erts-" ++ erlang:system_info(version)},
{rel_vsn, BootRelVsn},
{target_dir, TargetDir},
{hostname, net_adm:localhost()}]),
{ok, BaseDir} = file:get_cwd(),
execute_overlay(OverlayConfig, OverlayVars, BaseDir, TargetDir).
execute_overlay([], _Vars, _BaseDir, _TargetDir) ->
ok;
execute_overlay([{mkdir, Out} | Rest], Vars, BaseDir, TargetDir) ->
OutDir = mustache(filename:join(TargetDir, Out), Vars),
ok = shell("mkdir -p ~s", [OutDir]),
execute_overlay(Rest, Vars, BaseDir, TargetDir);
execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
InFile = mustache(filename:join(BaseDir, In), Vars),
OutFile = mustache(filename:join(TargetDir, Out), Vars),
true = filelib:is_file(InFile),
ok = shell("cp -R ~s ~s", [InFile, OutFile]),
execute_overlay(Rest, Vars, BaseDir, TargetDir).
exit_code(ExitCode) ->
erlang:halt(ExitCode, [{flush, true}]).

161
samples/GLSL/SyLens.glsl Normal file
View File

@@ -0,0 +1,161 @@
#version 120
/*
Original Lens Distortion Algorithm from SSontech (Syntheyes)
http://www.ssontech.com/content/lensalg.htm
r2 is radius squared.
r2 = image_aspect*image_aspect*u*u + v*v
f = 1 + r2*(k + kcube*sqrt(r2))
u' = f*u
v' = f*v
*/
// Controls
uniform float kCoeff, kCube, uShift, vShift;
uniform float chroma_red, chroma_green, chroma_blue;
uniform bool apply_disto;
// Uniform inputs
uniform sampler2D input1;
uniform float adsk_input1_w, adsk_input1_h, adsk_input1_aspect, adsk_input1_frameratio;
uniform float adsk_result_w, adsk_result_h;
float distortion_f(float r) {
float f = 1 + (r*r)*(kCoeff + kCube * r);
return f;
}
float inverse_f(float r)
{
// Build a lookup table on the radius, as a fixed-size table.
// We will use a vec3 since we will store the multipled number in the Z coordinate.
// So to recap: x will be the radius, y will be the f(x) distortion, and Z will be x * y;
vec3[48] lut;
// Since out LUT is shader-global check if it's been computed alrite
// Flame has no overflow bbox so we can safely max out at the image edge, plus some cushion
float max_r = sqrt((adsk_input1_frameratio * adsk_input1_frameratio) + 1) + 0.1;
float incr = max_r / 48;
float lut_r = 0;
float f;
for(int i=0; i < 48; i++) {
f = distortion_f(lut_r);
lut[i] = vec3(lut_r, f, lut_r * f);
lut_r += incr;
}
float t;
// Now find the nehgbouring elements
// only iterate to 46 since we will need
// 47 as i+1
for(int i=0; i < 47; i++) {
if(lut[i].z < r && lut[i+1].z > r) {
// BAM! our value is between these two segments
// get the T interpolant and mix
t = (r - lut[i].z) / (lut[i+1].z - lut[i]).z;
return mix(lut[i].y, lut[i+1].y, t );
}
}
}
float aberrate(float f, float chroma)
{
return f + (f * chroma);
}
vec3 chromaticize_and_invert(float f)
{
vec3 rgb_f = vec3(aberrate(f, chroma_red), aberrate(f, chroma_green), aberrate(f, chroma_blue));
// We need to DIVIDE by F when we redistort, and x / y == x * (1 / y)
if(apply_disto) {
rgb_f = 1 / rgb_f;
}
return rgb_f;
}
void main(void)
{
vec2 px, uv;
float f = 1;
float r = 1;
px = gl_FragCoord.xy;
// Make sure we are still centered
px.x -= (adsk_result_w - adsk_input1_w) / 2;
px.y -= (adsk_result_h - adsk_input1_h) / 2;
// Push the destination coordinates into the [0..1] range
uv.x = px.x / adsk_input1_w;
uv.y = px.y / adsk_input1_h;
// And to Syntheyes UV which are [1..-1] on both X and Y
uv.x = (uv.x *2 ) - 1;
uv.y = (uv.y *2 ) - 1;
// Add UV shifts
uv.x += uShift;
uv.y += vShift;
// Make the X value the aspect value, so that the X coordinates go to [-aspect..aspect]
uv.x = uv.x * adsk_input1_frameratio;
// Compute the radius
r = sqrt(uv.x*uv.x + uv.y*uv.y);
// If we are redistorting, account for the oversize plate in the input, assume that
// the input aspect is the same
if(apply_disto) {
r = r / (float(adsk_input1_w) / float(adsk_result_w));
}
// Apply or remove disto, per channel honoring chromatic aberration
if(apply_disto) {
f = inverse_f(r);
} else {
f = distortion_f(r);
}
vec2[3] rgb_uvs = vec2[](uv, uv, uv);
// Compute distortions per component
vec3 rgb_f = chromaticize_and_invert(f);
// Apply the disto coefficients, per component
rgb_uvs[0] = rgb_uvs[0] * rgb_f.rr;
rgb_uvs[1] = rgb_uvs[1] * rgb_f.gg;
rgb_uvs[2] = rgb_uvs[2] * rgb_f.bb;
// Convert all the UVs back to the texture space, per color component
for(int i=0; i < 3; i++) {
uv = rgb_uvs[i];
// Back from [-aspect..aspect] to [-1..1]
uv.x = uv.x / adsk_input1_frameratio;
// Remove UV shifts
uv.x -= uShift;
uv.y -= vShift;
// Back to OGL UV
uv.x = (uv.x + 1) / 2;
uv.y = (uv.y + 1) / 2;
rgb_uvs[i] = uv;
}
// Sample the input plate, per component
vec4 sampled;
sampled.r = texture2D(input1, rgb_uvs[0]).r;
sampled.g = texture2D(input1, rgb_uvs[1]).g;
sampled.b = texture2D(input1, rgb_uvs[2]).b;
// and assign to the output
gl_FragColor.rgba = vec4(sampled.rgb, 1.0 );
}

View File

@@ -0,0 +1,630 @@
//// High quality (Some browsers may freeze or crash)
//#define HIGHQUALITY
//// Medium quality (Should be fine on all systems, works on Intel HD2000 on Win7 but quite slow)
//#define MEDIUMQUALITY
//// Defaults
//#define REFLECTIONS
#define SHADOWS
//#define GRASS
//#define SMALL_WAVES
#define RAGGED_LEAVES
//#define DETAILED_NOISE
//#define LIGHT_AA // 2 sample SSAA
//#define HEAVY_AA // 2x2 RG SSAA
//#define TONEMAP
//// Configurations
#ifdef MEDIUMQUALITY
#define SHADOWS
#define SMALL_WAVES
#define RAGGED_LEAVES
#define TONEMAP
#endif
#ifdef HIGHQUALITY
#define REFLECTIONS
#define SHADOWS
//#define GRASS
#define SMALL_WAVES
#define RAGGED_LEAVES
#define DETAILED_NOISE
#define LIGHT_AA
#define TONEMAP
#endif
// Constants
const float eps = 1e-5;
const float PI = 3.14159265359;
const vec3 sunDir = vec3(0.79057,-0.47434, 0.0);
const vec3 skyCol = vec3(0.3, 0.5, 0.8);
const vec3 sandCol = vec3(0.9, 0.8, 0.5);
const vec3 treeCol = vec3(0.8, 0.65, 0.3);
const vec3 grassCol = vec3(0.4, 0.5, 0.18);
const vec3 leavesCol = vec3(0.3, 0.6, 0.2);
const vec3 leavesPos = vec3(-5.1,13.4, 0.0);
#ifdef TONEMAP
const vec3 sunCol = vec3(1.8, 1.7, 1.6);
#else
const vec3 sunCol = vec3(0.9, 0.85, 0.8);
#endif
const float exposure = 1.1; // Only used when tonemapping
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
vec3 mod289(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
return mod289(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r) {
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise(vec3 v) {
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
// First corner
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
// Other corners
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
// x0 = x0 - 0.0 + 0.0 * C.xxx;
// x1 = x0 - i1 + 1.0 * C.xxx;
// x2 = x0 - i2 + 2.0 * C.xxx;
// x3 = x0 - 1.0 + 3.0 * C.xxx;
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
// Permutations
i = mod289(i);
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float n_ = 0.142857142857; // 1.0/7.0
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
//Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}
// Main
float fbm(vec3 p)
{
float final = snoise(p);
p *= 1.94; final += snoise(p) * 0.5;
#ifdef DETAILED_NOISE
p *= 3.75; final += snoise(p) * 0.25;
return final / 1.75;
#else
return final / 1.5;
#endif
}
float waterHeight(vec3 p)
{
float d = length(p.xz);
float h = sin(d * 1.5 + iGlobalTime * 3.0) * 12.0 / d; // Island waves
#ifdef SMALL_WAVES
h += fbm(p*0.5); // Other waves
#endif
return h;
}
vec3 bump(vec3 pos, vec3 rayDir)
{
float s = 2.0;
// Fade out waves to reduce aliasing
float dist = dot(pos, rayDir);
s *= dist < 2.0 ? 1.0 : 1.4142 / sqrt(dist);
// Calculate normal from heightmap
vec2 e = vec2(1e-2, 0.0);
vec3 p = vec3(pos.x, iGlobalTime*0.5, pos.z)*0.7;
float m = waterHeight(p)*s;
return normalize(vec3(
waterHeight(p+e.xyy)*s-m,
1.0,
waterHeight(p+e.yxy)*s-m
));
}
// Ray intersections
vec4 intersectSphere(vec3 rpos, vec3 rdir, vec3 pos, float rad)
{
vec3 op = pos - rpos;
float b = dot(op, rdir);
float det = b*b - dot(op, op) + rad*rad;
if (det > 0.0)
{
det = sqrt(det);
float t = b - det;
if (t > eps)
return vec4(-normalize(rpos+rdir*t-pos), t);
}
return vec4(0.0);
}
vec4 intersectCylinder(vec3 rpos, vec3 rdir, vec3 pos, float rad)
{
vec3 op = pos - rpos;
vec2 rdir2 = normalize(rdir.yz);
float b = dot(op.yz, rdir2);
float det = b*b - dot(op.yz, op.yz) + rad*rad;
if (det > 0.0)
{
det = sqrt(det);
float t = b - det;
if (t > eps)
return vec4(-normalize(rpos.yz+rdir2*t-pos.yz), 0.0, t);
t = b + det;
if (t > eps)
return vec4(-normalize(rpos.yz+rdir2*t-pos.yz), 0.0, t);
}
return vec4(0.0);
}
vec4 intersectPlane(vec3 rayPos, vec3 rayDir, vec3 n, float d)
{
float t = -(dot(rayPos, n) + d) / dot(rayDir, n);
return vec4(n * sign(dot(rayDir, n)), t);
}
// Helper functions
vec3 rotate(vec3 p, float theta)
{
float c = cos(theta), s = sin(theta);
return vec3(p.x * c + p.z * s, p.y,
p.z * c - p.x * s);
}
float impulse(float k, float x) // by iq
{
float h = k*x;
return h * exp(1.0 - h);
}
// Raymarched parts of scene
float grass(vec3 pos)
{
float h = length(pos - vec3(0.0, -7.0, 0.0)) - 8.0;
if (h > 2.0) return h; // Optimization (Avoid noise if too far away)
return h + snoise(pos * 3.0) * 0.1 + pos.y * 0.9;
}
float tree(vec3 pos)
{
pos.y -= 0.5;
float s = sin(pos.y*0.03);
float c = cos(pos.y*0.03);
mat2 m = mat2(c, -s, s, c);
vec3 p = vec3(m*pos.xy, pos.z);
float width = 1.0 - pos.y * 0.02 - clamp(sin(pos.y * 8.0) * 0.1, 0.05, 0.1);
return max(length(p.xz) - width, pos.y - 12.5);
}
vec2 scene(vec3 pos)
{
float vtree = tree(pos);
#ifdef GRASS
float vgrass = grass(pos);
float v = min(vtree, vgrass);
#else
float v = vtree;
#endif
return vec2(v, v == vtree ? 2.0 : 1.0);
}
vec3 normal(vec3 pos)
{
vec2 eps = vec2(1e-3, 0.0);
float h = scene(pos).x;
return normalize(vec3(
scene(pos-eps.xyy).x-h,
scene(pos-eps.yxy).x-h,
scene(pos-eps.yyx).x-h
));
}
float plantsShadow(vec3 rayPos, vec3 rayDir)
{
// Soft shadow taken from iq
float k = 6.0;
float t = 0.0;
float s = 1.0;
for (int i = 0; i < 30; i++)
{
vec3 pos = rayPos+rayDir*t;
vec2 res = scene(pos);
if (res.x < 0.001) return 0.0;
s = min(s, k*res.x/t);
t += max(res.x, 0.01);
}
return s*s*(3.0 - 2.0*s);
}
// Ray-traced parts of scene
vec4 intersectWater(vec3 rayPos, vec3 rayDir)
{
float h = sin(20.5 + iGlobalTime * 2.0) * 0.03;
float t = -(rayPos.y + 2.5 + h) / rayDir.y;
return vec4(0.0, 1.0, 0.0, t);
}
vec4 intersectSand(vec3 rayPos, vec3 rayDir)
{
return intersectSphere(rayPos, rayDir, vec3(0.0,-24.1,0.0), 24.1);
}
vec4 intersectTreasure(vec3 rayPos, vec3 rayDir)
{
return vec4(0.0);
}
vec4 intersectLeaf(vec3 rayPos, vec3 rayDir, float openAmount)
{
vec3 dir = normalize(vec3(0.0, 1.0, openAmount));
float offset = 0.0;
vec4 res = intersectPlane(rayPos, rayDir, dir, 0.0);
vec3 pos = rayPos+rayDir*res.w;
#ifdef RAGGED_LEAVES
offset = snoise(pos*0.8) * 0.3;
#endif
if (pos.y > 0.0 || length(pos * vec3(0.9, 2.0, 1.0)) > 4.0 - offset) res.w = 0.0;
vec4 res2 = intersectPlane(rayPos, rayDir, vec3(dir.xy, -dir.z), 0.0);
pos = rayPos+rayDir*res2.w;
#ifdef RAGGED_LEAVES
offset = snoise(pos*0.8) * 0.3;
#endif
if (pos.y > 0.0 || length(pos * vec3(0.9, 2.0, 1.0)) > 4.0 - offset) res2.w = 0.0;
if (res2.w > 0.0 && res2.w < res.w || res.w <= 0.0)
res = res2;
return res;
}
vec4 leaves(vec3 rayPos, vec3 rayDir)
{
float t = 1e20;
vec3 n = vec3(0.0);
rayPos -= leavesPos;
float sway = impulse(15.0, fract(iGlobalTime / PI * 0.125));
float upDownSway = sway * -sin(iGlobalTime) * 0.06;
float openAmount = sway * max(-cos(iGlobalTime) * 0.4, 0.0);
float angleOffset = -0.1;
for (float k = 0.0; k < 6.2; k += 0.75)
{
// Left-right
float alpha = k + (k - PI) * sway * 0.015;
vec3 p = rotate(rayPos, alpha);
vec3 d = rotate(rayDir, alpha);
// Up-down
angleOffset *= -1.0;
float theta = -0.4 +
angleOffset +
cos(k) * 0.35 +
upDownSway +
sin(iGlobalTime+k*10.0) * 0.03 * (sway + 0.2);
p = rotate(p.xzy, theta).xzy;
d = rotate(d.xzy, theta).xzy;
// Shift
p -= vec3(5.4, 0.0, 0.0);
// Intersect individual leaf
vec4 res = intersectLeaf(p, d, 1.0+openAmount);
if (res.w > 0.0 && res.w < t)
{
t = res.w;
n = res.xyz;
}
}
return vec4(n, t);
}
// Lighting
float shadow(vec3 rayPos, vec3 rayDir)
{
float s = 1.0;
// Intersect sand
//vec4 resSand = intersectSand(rayPos, rayDir);
//if (resSand.w > 0.0) return 0.0;
// Intersect plants
s = min(s, plantsShadow(rayPos, rayDir));
if (s < 0.0001) return 0.0;
// Intersect leaves
vec4 resLeaves = leaves(rayPos, rayDir);
if (resLeaves.w > 0.0 && resLeaves.w < 1e7) return 0.0;
return s;
}
vec3 light(vec3 p, vec3 n)
{
float s = 1.0;
#ifdef SHADOWS
s = shadow(p-sunDir*0.01, -sunDir);
#endif
vec3 col = sunCol * min(max(dot(n, sunDir), 0.0), s);
col += skyCol * (-n.y * 0.5 + 0.5) * 0.3;
return col;
}
vec3 lightLeaves(vec3 p, vec3 n)
{
float s = 1.0;
#ifdef SHADOWS
s = shadow(p-sunDir*0.01, -sunDir);
#endif
float ao = min(length(p - leavesPos) * 0.1, 1.0);
float ns = dot(n, sunDir);
float d = sqrt(max(ns, 0.0));
vec3 col = sunCol * min(d, s);
col += sunCol * max(-ns, 0.0) * vec3(0.3, 0.3, 0.1) * ao;
col += skyCol * (-n.y * 0.5 + 0.5) * 0.3 * ao;
return col;
}
vec3 sky(vec3 n)
{
return skyCol * (1.0 - n.y * 0.8);
}
// Ray-marching
vec4 plants(vec3 rayPos, vec3 rayDir)
{
float t = 0.0;
for (int i = 0; i < 40; i++)
{
vec3 pos = rayPos+rayDir*t;
vec2 res = scene(pos);
float h = res.x;
if (h < 0.001)
{
vec3 col = res.y == 2.0 ? treeCol : grassCol;
float uvFact = res.y == 2.0 ? 1.0 : 10.0;
vec3 n = normal(pos);
vec2 uv = vec2(n.x, pos.y * 0.5) * 0.2 * uvFact;
vec3 tex = texture2D(iChannel0, uv).rgb * 0.6 + 0.4;
float ao = min(length(pos - leavesPos) * 0.1, 1.0);
return vec4(col * light(pos, n) * ao * tex, t);
}
t += h;
}
return vec4(sky(rayDir), 1e8);
}
// Final combination
vec3 traceReflection(vec3 rayPos, vec3 rayDir)
{
vec3 col = vec3(0.0);
float t = 1e20;
// Intersect plants
vec4 resPlants = plants(rayPos, rayDir);
if (resPlants.w > 0.0 && resPlants.w < t)
{
t = resPlants.w;
col = resPlants.xyz;
}
// Intersect leaves
vec4 resLeaves = leaves(rayPos, rayDir);
if (resLeaves.w > 0.0 && resLeaves.w < t)
{
vec3 pos = rayPos + rayDir * resLeaves.w;
vec2 uv = (pos.xz - leavesPos.xz) * 0.3;
float tex = texture2D(iChannel0, uv).r * 0.6 + 0.5;
t = resLeaves.w;
col = leavesCol * lightLeaves(pos, resLeaves.xyz) * tex;
}
if (t > 1e7) return sky(rayDir);
return col;
}
vec3 trace(vec3 rayPos, vec3 rayDir)
{
vec3 col = vec3(0.0);
float t = 1e20;
// Intersect sand
vec4 resSand = intersectSand(rayPos, rayDir);
if (resSand.w > 0.0)
{
vec3 pos = rayPos + rayDir * resSand.w;
t = resSand.w;
col = sandCol * light(pos, resSand.xyz);
}
// Intersect treasure chest
vec4 resTreasure = intersectTreasure(rayPos, rayDir);
if (resTreasure.w > 0.0 && resTreasure.w < t)
{
vec3 pos = rayPos + rayDir * resTreasure.w;
t = resTreasure.w;
col = leavesCol * light(pos, resTreasure.xyz);
}
// Intersect leaves
vec4 resLeaves = leaves(rayPos, rayDir);
if (resLeaves.w > 0.0 && resLeaves.w < t)
{
vec3 pos = rayPos + rayDir * resLeaves.w;
vec2 uv = (pos.xz - leavesPos.xz) * 0.3;
float tex = texture2D(iChannel0, uv).r * 0.6 + 0.5;
t = resLeaves.w;
col = leavesCol * lightLeaves(pos, resLeaves.xyz) * tex;
}
// Intersect plants
vec4 resPlants = plants(rayPos, rayDir);
if (resPlants.w > 0.0 && resPlants.w < t)
{
t = resPlants.w;
col = resPlants.xyz;
}
// Intersect water
vec4 resWater = intersectWater(rayPos, rayDir);
if (resWater.w > 0.0 && resWater.w < t)
{
vec3 pos = rayPos + rayDir * resWater.w;
float dist = t - resWater.w;
vec3 n = bump(pos, rayDir);
float ct = -min(dot(n,rayDir), 0.0);
float fresnel = 0.9 - 0.9 * pow(1.0 - ct, 5.0);
vec3 trans = col * exp(-dist * vec3(1.0, 0.7, 0.4) * 3.0);
vec3 reflDir = normalize(reflect(rayDir, n));
vec3 refl = sky(reflDir);
#ifdef REFLECTIONS
if (dot(pos, rayDir) < -2.0)
refl = traceReflection(pos, reflDir).rgb;
#endif
t = resWater.t;
col = mix(refl, trans, fresnel);
}
if (t > 1e7) return sky(rayDir);
return col;
}
// Ray-generation
vec3 camera(vec2 px)
{
vec2 rd = (px / iResolution.yy - vec2(iResolution.x/iResolution.y*0.5-0.5, 0.0)) * 2.0 - 1.0;
float t = sin(iGlobalTime * 0.1) * 0.2;
vec3 rayDir = normalize(vec3(rd.x, rd.y, 1.0));
vec3 rayPos = vec3(0.0, 3.0, -18.0);
return trace(rayPos, rayDir);
}
void main(void)
{
#ifdef HEAVY_AA
vec3 col = camera(gl_FragCoord.xy+vec2(0.0,0.5))*0.25;
col += camera(gl_FragCoord.xy+vec2(0.25,0.0))*0.25;
col += camera(gl_FragCoord.xy+vec2(0.5,0.75))*0.25;
col += camera(gl_FragCoord.xy+vec2(0.75,0.25))*0.25;
#else
vec3 col = camera(gl_FragCoord.xy);
#ifdef LIGHT_AA
col = col * 0.5 + camera(gl_FragCoord.xy+vec2(0.5,0.5))*0.5;
#endif
#endif
#ifdef TONEMAP
// Optimized Haarm-Peter Duikers curve
vec3 x = max(vec3(0.0),col*exposure-0.004);
col = (x*(6.2*x+.5))/(x*(6.2*x+1.7)+0.06);
#else
col = pow(col, vec3(0.4545));
#endif
gl_FragColor = vec4(col, 1.0);
}

68
samples/GLSL/shader.fp Normal file
View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2010 Josh A. Beam
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 AUTHOR ``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 AUTHOR 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 CONTACT, 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.
*/
const int NUM_LIGHTS = 3;
const vec3 AMBIENT = vec3(0.1, 0.1, 0.1);
const float MAX_DIST = 2.5;
const float MAX_DIST_SQUARED = MAX_DIST * MAX_DIST;
uniform vec3 lightColor[NUM_LIGHTS];
varying vec3 fragmentNormal;
varying vec3 cameraVector;
varying vec3 lightVector[NUM_LIGHTS];
void
main()
{
// initialize diffuse/specular lighting
vec3 diffuse = vec3(0.0, 0.0, 0.0);
vec3 specular = vec3(0.0, 0.0, 0.0);
// normalize the fragment normal and camera direction
vec3 normal = normalize(fragmentNormal);
vec3 cameraDir = normalize(cameraVector);
// loop through each light
for(int i = 0; i < NUM_LIGHTS; ++i) {
// calculate distance between 0.0 and 1.0
float dist = min(dot(lightVector[i], lightVector[i]), MAX_DIST_SQUARED) / MAX_DIST_SQUARED;
float distFactor = 1.0 - dist;
// diffuse
vec3 lightDir = normalize(lightVector[i]);
float diffuseDot = dot(normal, lightDir);
diffuse += lightColor[i] * clamp(diffuseDot, 0.0, 1.0) * distFactor;
// specular
vec3 halfAngle = normalize(cameraDir + lightDir);
vec3 specularColor = min(lightColor[i] + 0.5, 1.0);
float specularDot = dot(normal, halfAngle);
specular += specularColor * pow(clamp(specularDot, 0.0, 1.0), 16.0) * distFactor;
}
vec4 sample = vec4(1.0, 1.0, 1.0, 1.0);
gl_FragColor = vec4(clamp(sample.rgb * (diffuse + AMBIENT) + specular, 0.0, 1.0), sample.a);
}

42
samples/Idris/Chars.idr Normal file
View File

@@ -0,0 +1,42 @@
module Prelude.Char
import Builtins
isUpper : Char -> Bool
isUpper x = x >= 'A' && x <= 'Z'
isLower : Char -> Bool
isLower x = x >= 'a' && x <= 'z'
isAlpha : Char -> Bool
isAlpha x = isUpper x || isLower x
isDigit : Char -> Bool
isDigit x = (x >= '0' && x <= '9')
isAlphaNum : Char -> Bool
isAlphaNum x = isDigit x || isAlpha x
isSpace : Char -> Bool
isSpace x = x == ' ' || x == '\t' || x == '\r' ||
x == '\n' || x == '\f' || x == '\v' ||
x == '\xa0'
isNL : Char -> Bool
isNL x = x == '\r' || x == '\n'
toUpper : Char -> Char
toUpper x = if (isLower x)
then (prim__intToChar (prim__charToInt x - 32))
else x
toLower : Char -> Char
toLower x = if (isUpper x)
then (prim__intToChar (prim__charToInt x + 32))
else x
isHexDigit : Char -> Bool
isHexDigit x = elem (toUpper x) hexChars where
hexChars : List Char
hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F']

267
samples/JSON/composer.lock generated Normal file
View File

@@ -0,0 +1,267 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "d8ff8fcb71824f5199f3499bf71862f1",
"packages": [
{
"name": "arbit/system-process",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/Arbitracker/system-process.git",
"reference": "1.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Arbitracker/system-process/zipball/1.0",
"reference": "1.0",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"SystemProcess": "src/main/php/"
}
},
"notification-url": "http://packagist.org/downloads/",
"description": "System process execution library",
"time": "2013-03-31 12:42:56"
},
{
"name": "pdepend/staticReflection",
"version": "0.1",
"source": {
"type": "git",
"url": "https://github.com/manuelpichler/staticReflection.git",
"reference": "origin/master"
},
"type": "library"
},
{
"name": "qafoo/rmf",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/Qafoo/REST-Micro-Framework.git",
"reference": "5f43983f15a8aa12be42ad6068675d4008bfb9ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Qafoo/REST-Micro-Framework/zipball/5f43983f15a8aa12be42ad6068675d4008bfb9ed",
"reference": "5f43983f15a8aa12be42ad6068675d4008bfb9ed",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"Qafoo\\RMF": "src/main/"
}
},
"description": "Very simple VC framework which makes it easy to build HTTP applications / REST webservices",
"support": {
"source": "https://github.com/Qafoo/REST-Micro-Framework/tree/master",
"issues": "https://github.com/Qafoo/REST-Micro-Framework/issues"
},
"time": "2012-12-07 13:33:01"
},
{
"name": "twig/twig",
"version": "1.6.0",
"source": {
"type": "git",
"url": "git://github.com/fabpot/Twig.git",
"reference": "v1.6.0"
},
"dist": {
"type": "zip",
"url": "https://github.com/fabpot/Twig/zipball/v1.6.0",
"reference": "v1.6.0",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"type": "library",
"autoload": {
"psr-0": {
"Twig_": "lib/"
}
},
"license": [
"BSD"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"keywords": [
"templating"
],
"time": "2012-02-03 23:34:52"
},
{
"name": "twitter/bootstrap",
"version": "0.1",
"source": {
"type": "git",
"url": "https://github.com/twitter/bootstrap/",
"reference": "origin/master"
},
"type": "library"
},
{
"name": "zetacomponents/base",
"version": "1.8",
"source": {
"type": "git",
"url": "https://github.com/zetacomponents/Base.git",
"reference": "1.8"
},
"dist": {
"type": "zip",
"url": "https://github.com/zetacomponents/Base/zipball/1.8",
"reference": "1.8",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"src"
]
},
"license": [
"apache2"
],
"authors": [
{
"name": "Sergey Alexeev"
},
{
"name": "Sebastian Bergmann"
},
{
"name": "Jan Borsodi"
},
{
"name": "Raymond Bosman"
},
{
"name": "Frederik Holljen"
},
{
"name": "Kore Nordmann"
},
{
"name": "Derick Rethans"
},
{
"name": "Vadym Savchuk"
},
{
"name": "Tobias Schlitt"
},
{
"name": "Alexandru Stanoi"
}
],
"description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.",
"homepage": "https://github.com/zetacomponents",
"time": "2009-12-21 04:14:16"
},
{
"name": "zetacomponents/graph",
"version": "1.5",
"source": {
"type": "git",
"url": "https://github.com/zetacomponents/Graph.git",
"reference": "1.5"
},
"dist": {
"type": "zip",
"url": "https://github.com/zetacomponents/Graph/zipball/1.5",
"reference": "1.5",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"src"
]
},
"license": [
"apache2"
],
"authors": [
{
"name": "Sergey Alexeev"
},
{
"name": "Sebastian Bergmann"
},
{
"name": "Jan Borsodi"
},
{
"name": "Raymond Bosman"
},
{
"name": "Frederik Holljen"
},
{
"name": "Kore Nordmann"
},
{
"name": "Derick Rethans"
},
{
"name": "Vadym Savchuk"
},
{
"name": "Tobias Schlitt"
},
{
"name": "Alexandru Stanoi"
},
{
"name": "Lars Jankowski"
},
{
"name": "Elger Thiele"
},
{
"name": "Michael Maclean"
}
],
"description": "A component for creating pie charts, line graphs and other kinds of diagrams.",
"homepage": "https://github.com/zetacomponents",
"time": "2009-12-21 04:26:17"
}
],
"packages-dev": [
],
"aliases": [
],
"minimum-stability": "stable",
"stability-flags": {
"qafoo/rmf": 20,
"arbit/system-process": 0
},
"platform": [
],
"platform-dev": [
]
}

3
samples/Jade/hello.jade Normal file
View File

@@ -0,0 +1,3 @@
p.
Hello,
World!

View File

@@ -0,0 +1,15 @@
ruleset sample {
meta {
name "Hello World"
description <<
Hello world
>>
author "Phil Windley"
}
// just one rule
rule hello {
select when web pageview
notify("Hello world!", "Just a note to say hello");
}
}

111
samples/LFE/church.lfe Normal file
View File

@@ -0,0 +1,111 @@
;; Copyright (c) 2013 Duncan McGreggor <oubiwann@cogitat.io>
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; File : church.lfe
;; Author : Duncan McGreggor
;; Purpose : Demonstrating church numerals from the lambda calculus
;; The code below was used to create the section of the user guide here:
;; http://lfe.github.io/user-guide/recursion/5.html
;;
;; Here is some example usage:
;;
;; > (slurp '"church.lfe")
;; #(ok church)
;; > (zero)
;; #Fun<lfe_eval.10.53503600>
;; > (church->int1 (zero))
;; 0
;; > (church->int1 (three))
;; 3
;; > (church->int1 (five))
;; 5
;; > (church->int2 #'five/0)
;; 5
;; > (church->int2 (lambda () (get-church 25)))
;; 25
(defmodule church
(export all))
(defun zero ()
(lambda (s)
(lambda (x) x)))
(defun one ()
(lambda (s)
(lambda (x)
(funcall s x))))
(defun two ()
(lambda (s)
(lambda (x)
(funcall s
(funcall s x)))))
(defun three ()
(lambda (s)
(lambda (x)
(funcall s
(funcall s
(funcall s x))))))
(defun four ()
(lambda (s)
(lambda (x)
(funcall s
(funcall s
(funcall s
(funcall s x)))))))
(defun five ()
(get-church 5))
(defun int-successor (n)
(+ n 1))
(defun church->int1 (church-numeral)
"
Converts a called church numeral to an integer, e.g.:
> (church->int1 (five))
"
(funcall
(funcall church-numeral #'int-successor/1) 0))
(defun church->int2 (church-numeral)
"
Converts a non-called church numeral to an integer, e.g.:
> (church->int2 #'five/0)
"
(funcall
(funcall
(funcall church-numeral) #'int-successor/1) 0))
(defun church-successor (church-numeral)
(lambda (s)
(lambda (x)
(funcall s
(funcall
(funcall church-numeral s) x)))))
(defun get-church (church-numeral count limit)
(cond ((== count limit) church-numeral)
((/= count limit)
(get-church
(church-successor church-numeral)
(+ 1 count)
limit))))
(defun get-church (integer)
(get-church (zero) 0 integer))

104
samples/LFE/gps1.lfe Normal file
View File

@@ -0,0 +1,104 @@
;;; -*- Mode: LFE; -*-
;;; Code from Paradigms of Artificial Intelligence Programming
;;; Copyright (c) 1991 Peter Norvig
;;;; File gps1.lisp: First version of GPS (General Problem Solver)
;;;; Converted to LFE by Robert Virding
;; Define macros for global variable access. This is a hack and very naughty!
(defsyntax defvar
([name val] (let ((v val)) (put 'name v) v)))
(defsyntax setvar
([name val] (let ((v val)) (put 'name v) v)))
(defsyntax getvar
([name] (get 'name)))
;; Module definition.
(defmodule gps1
(export (gps 2) (gps 3) (school-ops 0))
(import (from lists (member 2) (all 2) (any 2))
;; Rename lists functions to be more CL like.
(rename lists ((all 2) every) ((any 2) some) ((filter 2) find-all))))
;; An operation.
(defrecord op
action preconds add-list del-list)
;; General Problem Solver: achieve all goals using *ops*.
(defun gps (state goals ops)
;; Set global variables
(defvar *state* state) ;The current state: a list of conditions.
(defvar *ops* ops) ;A list of available operators.
(if (every (fun achieve 1) goals) 'solved))
(defun gps (state goals)
;; Set global variables, but use existing *ops*
(defvar *state* state) ;The current state: a list of conditions.
(if (every (fun achieve 1) goals) 'solved))
;; A goal is achieved if it already holds or if there is an
;; appropriate op for it that is applicable."
(defun achieve (goal)
(orelse (member goal (getvar *state*))
(some (fun apply-op 1)
(find-all (lambda (op) (appropriate-p goal op))
(getvar *ops*)))))
;; An op is appropriate to a goal if it is in its add list.
(defun appropriate-p (goal op)
(member goal (op-add-list op)))
;; Print a message and update *state* if op is applicable.
(defun apply-op (op)
(if (every (fun achieve 1) (op-preconds op))
(progn
(: io fwrite '"executing ~p\n" (list (op-action op)))
(setvar *state* (set-difference (getvar *state*) (op-del-list op)))
(setvar *state* (union (getvar *state*) (op-add-list op)))
'true)))
;; Define the set functions to work on list, a listsets module really.
(defun set-difference
([(cons e es) s2]
(if (member e s2)
(set-difference es s2)
(cons e (set-difference es s2))))
([() s2] ()))
(defun union
([(cons e es) s2]
(if (member e s2) (union es s2) (cons e (union es s2))))
([() s2] ()))
;;; ==============================
(defun school-ops ()
(list
(make-op action 'drive-son-to-school
preconds '(son-at-home car-works)
add-list '(son-at-school)
del-list '(son-at-home))
(make-op action 'shop-installs-battery
preconds '(car-needs-battery shop-knows-problem shop-has-money)
add-list '(car-works)
del-list ())
(make-op action 'tell-shop-problem
preconds '(in-communication-with-shop)
add-list '(shop-knows-problem)
del-list ())
(make-op action 'telephone-shop
preconds '(know-phone-number)
add-list '(in-communication-with-shop)
del-list ())
(make-op action 'look-up-number
preconds '(have-phone-book)
add-list '(know-phone-number)
del-list ())
(make-op action 'give-shop-money
preconds '(have-money)
add-list '(shop-has-money)
del-list '(have-money))))

View File

@@ -0,0 +1,83 @@
;; Copyright (c) 2008-2013 Robert Virding
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; File : mnesia_demo.lfe
;; Author : Robert Virding
;; Purpose : A simple Mnesia demo file for LFE.
;; This file contains a simple demo of using LFE to access Mnesia
;; tables. It shows how to use the emp-XXXX macro (ETS match pattern)
;; together with mnesia:match_object, match specifications with
;; mnesia:select and Query List Comprehensions.
(defmodule mnesia_demo
(export (new 0) (by_place 1) (by_place_ms 1) (by_place_qlc 1)))
(defrecord person name place job)
(defun new ()
;; Start mnesia and create a table, we will get an in memory only schema.
(: mnesia start)
(: mnesia create_table 'person '(#(attributes (name place job))))
;; Initialise the table.
(let ((people '(
;; First some people in London.
#(fred london waiter)
#(bert london waiter)
#(john london painter)
#(paul london driver)
;; Now some in Paris.
#(jean paris waiter)
#(gerard paris driver)
#(claude paris painter)
#(yves paris waiter)
;; And some in Rome.
#(roberto rome waiter)
#(guiseppe rome driver)
#(paulo rome painter)
;; And some in Berlin.
#(fritz berlin painter)
#(kurt berlin driver)
#(hans berlin waiter)
#(franz berlin waiter)
)))
(: lists foreach (match-lambda
([(tuple n p j)]
(: mnesia transaction
(lambda ()
(let ((new (make-person name n place p job j)))
(: mnesia write new))))))
people)))
;; Match records by place using match_object and the emp-XXXX macro.
(defun by_place (place)
(: mnesia transaction
(lambda () (: mnesia match_object (emp-person place place)))))
;; Use match specifications to match records
(defun by_place_ms (place)
(let ((f (lambda () (: mnesia select 'person
(match-spec ([(match-person name n place p job j)]
(when (=:= p place))
(tuple n j)))))))
(: mnesia transaction f)))
;; Use Query List Comprehensions to match records
(defun by_place_qlc (place)
(let ((f (lambda ()
(let ((q (qlc (lc ((<- person (: mnesia table 'person))
(=:= (person-place person) place))
person))))
(: qlc e q)))))
(: mnesia transaction f)))

169
samples/LFE/object.lfe Normal file
View File

@@ -0,0 +1,169 @@
;; Copyright (c) 2013 Duncan McGreggor <oubiwann@cogitat.io>
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; File : object.lfe
;; Author : Duncan McGreggor
;; Purpose : Demonstrating simple OOP with closures
;; The simple object system demonstrated below shows how to do the following:
;; * create objects
;; * call methods on those objects
;; * have methods which can call other methods
;; * update the state of an instance variable
;;
;; Note, however, that his example does not demonstrate inheritance.
;;
;; To use the code below in LFE, do the following:
;;
;; $ cd examples
;; $ ../bin/lfe -pa ../ebin
;;
;; Load the file and create a fish-class instance:
;;
;; > (slurp '"object.lfe")
;; #(ok object)
;; > (set mommy-fish (fish-class '"Carp"))
;; #Fun<lfe_eval.10.91765564>
;;
;; Execute some of the basic methods:
;;
;; > (get-species mommy-fish)
;; "Carp"
;; > (move mommy-fish 17)
;; The Carp swam 17 feet!
;; ok
;; > (get-id mommy-fish)
;; "47eebe91a648f042fc3fb278df663de5"
;;
;; Now let's look at "modifying" state data (e.g., children counts):
;;
;; > (get-children mommy-fish)
;; ()
;; > (get-children-count mommy-fish)
;; 0
;; > (set (mommy-fish baby-fish-1) (reproduce mommy-fish))
;; (#Fun<lfe_eval.10.91765564> #Fun<lfe_eval.10.91765564>)
;; > (get-id mommy-fish)
;; "47eebe91a648f042fc3fb278df663de5"
;; > (get-id baby-fish-1)
;; "fdcf35983bb496650e558a82e34c9935"
;; > (get-children-count mommy-fish)
;; 1
;; > (set (mommy-fish baby-fish-2) (reproduce mommy-fish))
;; (#Fun<lfe_eval.10.91765564> #Fun<lfe_eval.10.91765564>)
;; > (get-id mommy-fish)
;; "47eebe91a648f042fc3fb278df663de5"
;; > (get-id baby-fish-2)
;; "3e64e5c20fb742dd88dac1032749c2fd"
;; > (get-children-count mommy-fish)
;; 2
;; > (get-info mommy-fish)
;; id: "47eebe91a648f042fc3fb278df663de5"
;; species: "Carp"
;; children: ["fdcf35983bb496650e558a82e34c9935",
;; "3e64e5c20fb742dd88dac1032749c2fd"]
;; ok
(defmodule object
(export all))
(defun fish-class (species)
"
This is the constructor that will be used most often, only requiring that
one pass a 'species' string.
When the children are not defined, simply use an empty list.
"
(fish-class species ()))
(defun fish-class (species children)
"
This contructor is mostly useful as a way of abstracting out the id
generation from the larger constructor. Nothing else uses fish-class/2
besides fish-class/1, so it's not strictly necessary.
When the id isn't know, generate one."
(let* (((binary (id (size 128))) (: crypto rand_bytes 16))
(formatted-id (car
(: io_lib format
'"~32.16.0b" (list id)))))
(fish-class species children formatted-id)))
(defun fish-class (species children id)
"
This is the constructor used internally, once the children and fish id are
known.
"
(let ((move-verb '"swam"))
(lambda (method-name)
(case method-name
('id
(lambda (self) id))
('species
(lambda (self) species))
('children
(lambda (self) children))
('info
(lambda (self)
(: io format
'"id: ~p~nspecies: ~p~nchildren: ~p~n"
(list (get-id self)
(get-species self)
(get-children self)))))
('move
(lambda (self distance)
(: io format
'"The ~s ~s ~p feet!~n"
(list species move-verb distance))))
('reproduce
(lambda (self)
(let* ((child (fish-class species))
(child-id (get-id child))
(children-ids (: lists append
(list children (list child-id))))
(parent-id (get-id self))
(parent (fish-class species children-ids parent-id)))
(list parent child))))
('children-count
(lambda (self)
(: erlang length children)))))))
(defun get-method (object method-name)
"
This is a generic function, used to call into the given object (class
instance).
"
(funcall object method-name))
; define object methods
(defun get-id (object)
(funcall (get-method object 'id) object))
(defun get-species (object)
(funcall (get-method object 'species) object))
(defun get-info (object)
(funcall (get-method object 'info) object))
(defun move (object distance)
(funcall (get-method object 'move) object distance))
(defun reproduce (object)
(funcall (get-method object 'reproduce) object))
(defun get-children (object)
(funcall (get-method object 'children) object))
(defun get-children-count (object)
(funcall (get-method object 'children-count) object))

View File

@@ -0,0 +1,82 @@
\documentclass{article}
% The following packages are needed because unicode
% is translated (using the next set of packages) to
% latex commands. You may need more packages if you
% use more unicode characters:
\usepackage{amssymb}
\usepackage{bbm}
\usepackage[greek,english]{babel}
% This handles the translation of unicode to latex:
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{autofe}
% Some characters that are not automatically defined
% (you figure out by the latex compilation errors you get),
% and you need to define:
\DeclareUnicodeCharacter{8988}{\ensuremath{\ulcorner}}
\DeclareUnicodeCharacter{8989}{\ensuremath{\urcorner}}
\DeclareUnicodeCharacter{8803}{\ensuremath{\overline{\equiv}}}
% Add more as you need them (shouldnt happen often).
% Using “\newenvironment” to redefine verbatim to
% be called “code” doesnt always work properly.
% You can more reliably use:
\usepackage{fancyvrb}
\DefineVerbatimEnvironment
{code}{Verbatim}
{} % Add fancy options here if you like.
\begin{document}
\begin{code}
module NatCat where
open import Relation.Binary.PropositionalEquality
-- If you can show that a relation only ever has one inhabitant
-- you get the category laws for free
module
EasyCategory
(obj : Set)
(_⟶_ : obj → obj → Set)
(_∘_ : ∀ {x y z} → x ⟶ y → y ⟶ z → x ⟶ z)
(id : ∀ x → x ⟶ x)
(single-inhabitant : (x y : obj) (r s : x ⟶ y) → r ≡ s)
where
idʳ : ∀ x y (r : x ⟶ y) → r ∘ id y ≡ r
idʳ x y r = single-inhabitant x y (r ∘ id y) r
idˡ : ∀ x y (r : x ⟶ y) → id x ∘ r ≡ r
idˡ x y r = single-inhabitant x y (id x ∘ r) r
∘-assoc : ∀ w x y z (r : w ⟶ x) (s : x ⟶ y) (t : y ⟶ z) → (r ∘ s) ∘ t ≡ r ∘ (s ∘ t)
∘-assoc w x y z r s t = single-inhabitant w z ((r ∘ s) ∘ t) (r ∘ (s ∘ t))
open import Data.Nat
same : (x y : ) (r s : x ≤ y) → r ≡ s
same .0 y z≤n z≤n = refl
same .(suc m) .(suc n) (s≤s {m} {n} r) (s≤s s) = cong s≤s (same m n r s)
≤-trans : ∀ x y z → x ≤ y → y ≤ z → x ≤ z
≤-trans .0 y z z≤n s = z≤n
≤-trans .(suc m) .(suc n) .(suc n₁) (s≤s {m} {n} r) (s≤s {.n} {n₁} s) = s≤s (≤-trans m n n₁ r s)
≤-refl : ∀ x → x ≤ x
≤-refl zero = z≤n
≤-refl (suc x) = s≤s (≤-refl x)
module Nat-EasyCategory = EasyCategory _≤_ (λ {x}{y}{z} → ≤-trans x y z) ≤-refl same
\end{code}
\end{document}

View File

@@ -0,0 +1,16 @@
all: hello
hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello
main.o: main.cpp
g++ -c main.cpp
factorial.o: factorial.cpp
g++ -c factorial.cpp
hello.o: hello.cpp
g++ -c hello.cpp
clean:
rm -rf *o hello

View File

@@ -0,0 +1,3 @@
#!/usr/bin/make -f
%:
ls -l

View File

@@ -0,0 +1,31 @@
function [ error ] = cross_validation(x,y,hyper_parameter)
num_data = size(x,1);
K = 10;
indices = crossvalind('Kfold', num_data, K);
errors = zeros(K,1);
for i = 1:K
% get indices
test_idx = (indices == i);
train_idx = ~test_idx;
% get training data
x_train = x(train_idx,:);
y_train = y(train_idx,:);
% train
w = train(x_train, y_train, hyper_parameter);
% get test data
x_test = x(test_idx,:);
y_test = y(test_idx,:);
% calculate error
errors(i) = calc_cost(x_test, y_test, w, hyper_parameter); %calc_error
%errors(i) = calc_error(x_test, y_test, w);
end
error = mean(errors);
end

View File

@@ -0,0 +1,6 @@
function [ d, d_mean, d_std ] = normalize( d )
d_mean = mean(d);
d = d - repmat(d_mean, size(d,1), 1);
d_std = std(d);
d = d./ repmat(d_std, size(d,1), 1);
end

View File

@@ -0,0 +1,90 @@
= Overview =
The GDB Tracepoint Analysis feature is an extension to the Tracing and Monitoring Framework that allows the visualization and analysis of C/C++ tracepoint data collected by GDB and stored to a log file.
= Getting Started =
The feature can be installed from the Eclipse update site by selecting '''Linux Tools''' > '''GDB Tracepoint Analysis'''.
The feature requires GDB version 7.2 or later to be installed on the local host. The executable program 'gdb' must be found in the path.
= GDB Trace Perspective =
To open the perspective, select '''Window''' > '''Open Perspective''' > '''Other...''' > '''GDB Trace'''.
The perspective includes the following views by default:
* '''Project Explorer''': This view shows the projects in the workspace and is used to create and manage Tracing projects.
* '''Debug''': This view shows the running C/C++ Postmortem Debugger instances and displays the thread and stack trace associated with a tracepoint.
* '''Trace Control''': This view shows the status of the debugger and allows navigation of trace records.
* '''Console''': This view displays console output of the C/C++ Postmortem Debugger.
The editor area contains the '''Events''' and '''C/C++''' editors when a GDB Trace is opened.
[[Image:images/GDBTracePerspective.png]]
= Collecting Tracepoint Data =
Collecting the C/C++ tracepoint data is outside the scope of this feature. It can be done from the GDB command line or by using the CDT debug component within Eclipse. See the CDT FAQ entry in the [[#References | References]] section.
= Importing Tracepoint Data =
Some information in this section is redundant with the LTTng User Guide. For further details, see the LTTng User Guide entry in the [[#References | References]] section.
== Creating a Tracing Project ==
In the '''Project Explorer''' view, right-click and select '''New''' > '''Project...''' from the context menu. In the '''New Project''' dialog, select '''Tracing''' > '''Tracing Project''', click '''Next''', name your project and click '''Finish'''.
== Importing a GDB Trace ==
In your tracing project, right-click on the '''Traces''' folder and select '''Import...'''. Browse to, or enter, a source directory. Select the trace file in the tree. Optionally set the trace type to '''GDB : GDB Trace'''. Click '''Finish'''.
Alternatively, the trace can be drag & dropped to the '''Traces''' folder from any external file manager.
== Selecting the GDB Trace Type ==
Right-click the imported trace in the '''Traces''' folder and choose '''Select Trace Type...''' > '''GDB''' > '''GDB Trace''' from the context menu. This step can be omitted if the trace type was selected at import.
The trace will be updated with the GDB icon [[Image:images/gdb_icon16.png]].
== Selecting the Trace Executable ==
The executable file that created the tracepoint data must be identified so that the C/C++ Postmortem Debugger can be launched properly.
Right-click the GDB trace in the '''Traces''' folder and choose '''Select Trace Executable...''' from the context menu. Browse to, or enter, the path of the executable file and press '''OK'''.
The selected file must be recognized by GDB as an executable.
= Visualizing Tracepoint Data =
== Opening a GDB Trace ==
In the '''Traces''' folder, double-click the GDB trace or right-click it and select '''Open''' from the context menu.
The tracepoint data will be opened in an Events editor, and a C/C++ Postmortem Debugger instance will be launched.
If available in the workspace, the source code corresponding to the first trace record will also be opened in a C/C++ editor.
At this point it is recommended to relocate the Events editor outside of the default editor area, so that it is not hidden by the C/C++ editor.
== Viewing Trace Data ==
In the Events editor, a table is shown with one row for each trace record. The '''Trace Frame''' column shows the sequential trace record number. The '''Tracepoint''' column shows the number assigned by GDB at collection time for this tracepoint. The '''File''' column shows the file name, line number and method where the tracepoint was set. The '''Content''' column shows the data collected at run-time by the tracepoint.
Searching and filtering can be done on any column by entering a regular expression in the column header.
== Navigating the GDB Trace ==
Trace records can be selected in the Events editor using the keyboard or mouse. The C/C++ Postmortem Debugger in the '''Debug''' view will be updated to show the stack trace of the current trace record.
The trace can also be navigated from the '''Trace Control''' view by clicking the '''Next Trace Record''' or '''Previous Trace Record''' buttons. The Events editor and '''Debug''' views will be updated.
= References =
* [http://wiki.eclipse.org/index.php/Linux_Tools_Project/LTTng2/User_Guide LTTng User Guide]
* [http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_trace_my_application_using_C.2FC.2B.2B_Tracepoints.3F CDT FAQ - How can I trace my application using C/C++ Tracepoints?]
= Updating This Document =
This document is maintained in a collaborative wiki. If you wish to update or modify this document please visit [http://wiki.eclipse.org/index.php/Linux_Tools_Project/GDB_Tracepoint_Analysis/User_Guide http://wiki.eclipse.org/Linux_Tools_Project/GDB_Tracepoint_Analysis/User_Guide]

View File

@@ -0,0 +1,55 @@
patches-own [
living? ;; indicates if the cell is living
live-neighbors ;; counts how many neighboring cells are alive
]
to setup-blank
clear-all
ask patches [ cell-death ]
reset-ticks
end
to setup-random
clear-all
ask patches
[ ifelse random-float 100.0 < initial-density
[ cell-birth ]
[ cell-death ] ]
reset-ticks
end
to cell-birth
set living? true
set pcolor fgcolor
end
to cell-death
set living? false
set pcolor bgcolor
end
to go
ask patches
[ set live-neighbors count neighbors with [living?] ]
;; Starting a new "ask patches" here ensures that all the patches
;; finish executing the first ask before any of them start executing
;; the second ask. This keeps all the patches in synch with each other,
;; so the births and deaths at each generation all happen in lockstep.
ask patches
[ ifelse live-neighbors = 3
[ cell-birth ]
[ if live-neighbors != 2
[ cell-death ] ] ]
tick
end
to draw-cells
let erasing? [living?] of patch mouse-xcor mouse-ycor
while [mouse-down?]
[ ask patch mouse-xcor mouse-ycor
[ ifelse erasing?
[ cell-death ]
[ cell-birth ] ]
display ]
end

23
samples/OpenCL/sample.cl Normal file
View File

@@ -0,0 +1,23 @@
/* Old-style comment. */
// New-style comment.
typedef float foo_t;
#ifndef ZERO
#define ZERO (0.0)
#endif
#define FOO(x) ((x) + \
ZERO)
__kernel
void foo(__global const foo_t * x, __local foo_t y, const uint n)
{
barrier(CLK_LOCAL_MEM_FENCE);
if (n > 42) {
*x += y;
}
}

164
samples/Org/org.org Normal file
View File

@@ -0,0 +1,164 @@
#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
#+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
#+TAGS: Write(w) Update(u) Fix(f) Check(c)
#+TITLE: org-ruby
#+AUTHOR: Brian Dewey
#+EMAIL: bdewey@gmail.com
#+LANGUAGE: en
#+PRIORITIES: A C B
#+CATEGORY: worg
{Back to Worg's index}
* Motivation
The dominant simple plain-text markup languages for the web are
Textile and Markdown. A factor for the popularity of those markup
formats is the widespread availability of simple, free packages for
converting the formats to HTML. For example, the world of
Ruby-powered websites has settled on RedCloth for converting Textile
to HTML.
The default way to convert org-mode files to HTML is the powerful
publishing functionality provided by =emacs=. However, =emacs= does
not easiliy integrate into many existing website frameworks.
=Org-ruby= tries to make it easier to use org-mode files in both
dyanmic and static website generation tools written in
Ruby. =Org-ruby= is a simple Ruby gem to convert org-mode files to
HTML.
* Using Org-ruby
=Org-ruby= follows the same model as other Ruby markup
libraries. You install the gem:
#+BEGIN_EXAMPLE
sudo gem install org-ruby
#+END_EXAMPLE
Then, to convert an org-file to HTML in your Ruby code:
#+BEGIN_EXAMPLE
require 'rubygems'
require 'org-ruby'
data = IO.read(filename)
puts Orgmode::Parser.new(data).to_html
#+END_EXAMPLE
* Walkthrough: Using org-ruby with Webby
Here is an example of how to integrate =org-ruby= into Webby, a
static website generation tool written in Ruby.
Webby follows a similar pattern to other static site generation
tools (like nanoc, Jekyll, and webgen):
- You author website content in text with simple markup
- Each page is fed through one or more /filters/ to produce HTML
- The HTML is mixed in with layouts to produce the final pages
For a Webby site, a the source for a page may look like this:
#+BEGIN_EXAMPLE
---
title: Special Directories
created_at: 2009-12-17
status: Complete
filter:
- erb
- maruku
tags:
- powershell
---
<%= @page.title %>
==================
Special Directories are a set of directories, each of which has a
function that will navigate you to the appropriate directory using
the push-location cmdlet. For example, the function `home` might
navigate to `c:\users\bdewey.`
Install
-------
Copy the module to somewhere in `ENV:PSModulePath`. Then,
InstallModule SpecialDirectories
#+END_EXAMPLE
In the above example, the text is written in Markdown. At the top of
the file, metadata informs Webby to pass the text through two
/filters/ to produce HTML. The first filter, =erb=, handles embedded
Ruby. In this case, it will replace ~<%= @page.title %>~ with the
page title (=Special Directories=). The second filter uses Maruku to
translate Markdown into HTML.
You can use the exact same pattern to include org-mode files in a
Webby site. For this walkthrough, I assume you already have Webby
installed, and that you've already created a site.
1. Make sure you have =org-ruby= installed: =sudo gem install
org-ruby=.
2. You need to register a new Webby filter to handle org-mode
content. Webby makes this easy. In the =lib/= folder of your
site, create a file =orgmode.rb=:
#+BEGIN_EXAMPLE
require 'org-ruby'
Webby::Filters.register :org do |input|
Orgmode::Parser.new(input).to_html
end
#+END_EXAMPLE
This code creates a new filter, =org=, that will use the
=org-ruby= parser to translate org-mode input into HTML.
3. Create your content. For example:
#+BEGIN_EXAMPLE
---
title: Orgmode Parser
created_at: 2009-12-21
status: Under development
filter:
- erb
- org
tags:
- orgmode
- ruby
---
<%= @page.title %>
Status: <%= @page.status %>
* Description
Helpful Ruby routines for parsing orgmode files. The most
significant thing this library does today is convert orgmode files
to textile. Currently, you cannot do much to customize the
conversion. The supplied textile conversion is optimized for
extracting "content" from the orgfile as opposed to "metadata."
* History
** 2009-12-29: Version 0.4
- The first thing output in HTML gets the class "title"
- HTML output is now indented
- Proper support for multi-paragraph list items.
See? This paragraph is part of the last bullet.
- Fixed bugs:
- "rake spec" wouldn't work on Linux. Needed "require 'rubygems'".
#+END_EXAMPLE
This file will go through the =erb= and =org= filters; as defined
in the previous step, the =org= filter will use =org-ruby= to
generate HTML.
That's all there is to it!

View File

@@ -0,0 +1,55 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RootNamespace>Loops</RootNamespace>
<OutputType>exe</OutputType>
<AssemblyName>Loops</AssemblyName>
<AllowGlobals>False</AllowGlobals>
<AllowLegacyOutParams>False</AllowLegacyOutParams>
<AllowLegacyCreate>False</AllowLegacyCreate>
<ApplicationIcon>Properties\App.ico</ApplicationIcon>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<ProjectGuid>{916BD89C-B610-4CEE-9CAF-C515D88E2C94}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>DEBUG;TRACE;</DefineConstants>
<OutputPath>.\bin\Debug</OutputPath>
<GeneratePDB>True</GeneratePDB>
<GenerateMDB>True</GenerateMDB>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>.\bin\Release</OutputPath>
<EnableAsserts>False</EnableAsserts>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\RemObjects Software\Oxygene\RemObjects.Oxygene.targets" />
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>$(Framework)\mscorlib.dll</HintPath>
</Reference>
<Reference Include="System">
<HintPath>$(Framework)\System.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<HintPath>$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data">
<HintPath>$(Framework)\System.Data.dll</HintPath>
</Reference>
<Reference Include="System.Xml">
<HintPath>$(Framework)\System.Xml.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.pas" />
<Content Include="Properties\App.ico" />
<Compile Include="Properties\AssemblyInfo.pas" />
<EmbeddResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
</EmbeddResource>
<Compile Include="Properties\Resources.Designer.pas" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
</None>
<Compile Include="Properties\Settings.Designer.pas" />
</ItemGroup>
</Project>

125
samples/Oxygene/Program.pas Normal file
View File

@@ -0,0 +1,125 @@
namespace Loops;
interface
uses System.Linq;
type
ConsoleApp = class
public
class method Main;
method loopsTesting;
method fillData : sequence of Country;
var
Countries : sequence of Country;
end;
type
Country = public class
public
property Name : String;
property Capital : String;
constructor (setName : String; setCapital : String);
end;
implementation
class method ConsoleApp.Main;
begin
Console.WriteLine('Loops example');
Console.WriteLine();
with myConsoleApp := new ConsoleApp() do
myConsoleApp.loopsTesting;
end;
method ConsoleApp.loopsTesting;
begin
{---------------------------------}
{"for" loop, taking every 5th item}
for i : Int32 :=0 to 50 step 5 do
begin
Console.Write(i); Console.Write(' ');
end;
Console.WriteLine(); Console.WriteLine();
{---------------------------------}
{"for" loop, going from high to low value}
for i : Int32 := 10 downto 1 do
begin
Console.Write(i); Console.Write(' ');
end;
Console.WriteLine(); Console.WriteLine();
Countries := fillData;
{---------------------------------}
{loop with defined "index" variable, which will count from 0 through the number of elements looped}
Console.WriteLine('Countries: ');
for each c in Countries index num do
Console.WriteLine(Convert.ToString(num + 1) + ') ' + c.Name);
Console.WriteLine();
Console.WriteLine('Cities: ');
var ind : Integer :=0;
{---------------------------------}
{simple "loop" construct that loops endlessly, until broken out of}
loop
begin
Console.WriteLine(Countries.ElementAt(ind).Capital);
Inc(ind);
if ind = Countries.Count then break;
end;
Console.WriteLine();
{---------------------------------}
{the type of 'c' is inferred automatically}
for each c in Countries do
Console.WriteLine(c.Capital + ' is the capital of ' + c.Name);
Console.WriteLine();
ind := 0;
Console.WriteLine('Cities: ');
{"repeat ... until" loop}
repeat
Console.WriteLine(Countries.ElementAt(ind).Capital);
Inc(ind);
until ind = Countries.Count;
Console.WriteLine();
ind := 0;
Console.WriteLine('Countries: ');
{---------------------------------}
{"while ... do" loop}
while ind < Countries.Count do
begin
Console.WriteLine(Countries.ElementAt(ind).Name);
Inc(ind);
end;
Console.ReadLine();
end;
method ConsoleApp.fillData: sequence of Country;
begin
result := [new Country('UK', 'London'), new Country('USA', 'Washington'), new Country('Germany', 'Berlin'),
new Country('Ukraine', 'Kyiv'), new Country('Russia', 'Moscow'), new Country('France', 'Paris')];
end;
constructor Country (setName :String; setCapital: String);
begin
Name := setName;
Capital := setCapital;
end;
end.

22
samples/PHP/php2.script! Normal file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined('YII_DEBUG') or define('YII_DEBUG', true);
// fcgi doesn't have STDIN defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/vendor/autoload.php');
$config = require(__DIR__ . '/config/console.php');
$application = new yii\console\Application($config);
$application->run();

102
samples/Perl/index.fcgi Executable file
View File

@@ -0,0 +1,102 @@
#!/usr/bin/perl
use strict;
use warnings;
use CGI::Fast;
use XML::Hash::XS;
use File::Spec;
use FindBin qw($Bin);
#use lib File::Spec->catdir($Bin, qw(.. lib));
my $_stop = 0;
my $request;
$SIG{'PIPE'} = 'IGNORE';
$SIG{'INT'} = $SIG{'TERM'} = sub {
$_stop = 1;
exit(0) unless defined($request);
};
unless ($ENV{'SERVER_SOFTWARE'}) { # for nginx external fcgi
$CGI::Fast::Ext_Request = FCGI::Request(
\*STDIN, \*STDOUT, \*STDERR,
\%ENV, int($ARGV[0] || 0), 1
);
}
my $conv = XML::Hash::XS->new(
use_attr => 1,
indent => 2,
output => \*STDOUT,
xml_decl => 1
);
my $tmpl_path = File::Spec->catdir($Bin, qw|.. tmpl|);
my $data = {
name => {
nick => 'cono'
},
tree => {
example => [
{ name => 'Encyclopaedia', parent => 0, id => 1 },
{ name => 'Science', parent => 1, id => 2 },
{ name => 'Culture', parent => 1, id => 3 },
{ name => 'Art', parent => 3, id => 4 },
{ name => 'Craft', parent => 3, id => 5 }
],
},
third_party => {
results => [
{ artist_name => 'Madonna', venue => 'Kitchen', event => 'cooking', date => '2013-04-21' },
{ artist_name => 'cono', venue => 'Provectus-IT', event => 'presentation', date => '2013-04-20' },
]
}
};
while (1) {
eval {
$request = CGI::Fast->new();
unless ($request) {
$_stop = 1;
return;
}
my ($tmpl, $output) = ('nick');
if ($ENV{'REQUEST_URI'} =~ m|/([a-zA-Z0-9_]+)|) {
$tmpl = $1;
$output = $data->{$tmpl} if exists $data->{$tmpl};
}
die "Bad request" unless $output;
if (-e File::Spec->catfile($tmpl_path, "$tmpl.xslt")) {
print "X-Xslt-Stylesheet: /$tmpl.xslt\r\n";
}
print qq(Content-type:application/xml;charset=utf-8\r\n\r\n);
$conv->hash2xml($output);
};
if ($@) {
print qq(Content-type:text/html;charset=utf-8\r\n\r\nError: $@);
}
$request = undef;
last if $_stop;
if (-M $0 < 0) {
unless ($ENV{'SERVER_SOFTWARE'}) { # for nginx external fcgi
system("$0 ". int($ARGV[0] || 0).' &');
}
last;
}
}
exit(0);

159
samples/Pod/contents.pod Normal file
View File

@@ -0,0 +1,159 @@
$Id: contents.pod,v 1.3 2003/05/04 04:05:14 tower Exp $
=begin html
<style = "text/css">
code { font-family: sans-serif; font-weight:bold; }
</style>
=end html
=head1 Net::Z3950::AsyncZ
=head2 Intro
Net::Z3950::AsyncZ adds an additional layer of asynchronous support for the Z3950 module through the use
of multiple forked processes. I hope that users will also find that it provides a convenient
front end to C<Net::Z3950>. My initial idea was to write something that
would provide a convenient means of processing and formatting Z39.50 records--which I
did, using the C<Z3950> synchronous code. But I also wanted something that could
handle queries to large numbers of servers at one session. Working on this part of my
project, I found that I had trouble with the C<Z3950> asynchronous features
and so ended up with what I have here.
=begin html
I give a more detailed account in the <A href="AsyncZ.html#apologia"><B>DESCRIPTION</b></a>
section of <code>AsyncZ.html</code>.
=end html
=pod
I give a more detailed account in in the B<DESCRIPTION> section of C<AsyncZ.pod>.
=cut
=head2 Documentation
=pod
=over 4
=item AsyncZ.pod
This is the starting point--it gives an overview of the AsyncZ module,
describes the basic mechanics of its asynchronous workings, and details
the particulars of the objects and methods. But see
L</"Examples.pod> for detailed explanations of the sample
scripts which come with the C<Net::Z3950::AsyncZ> distribution.
=item Options.pod
This document details the various options that can be set to modify
the behavior of AsyncZ Index
=item Report.pod
Report.pod deals with how records are treated line by line
and how you can affect the apearance of a record's line by line output
=item Examples.pod
This document goes through the sample scripts that come with the
C<Net::Z3950::AsyncZ> distribution and annotates them
in a line-by-line fashion. It's a basic HOW-TO.
=back
=cut
=begin html
<UL>
<LI>
<A href="AsyncZ.html">AsyncZ.html</a>
<br>This is the starting point--it gives an overview of the AsyncZ module,
describes the basic mechanics of its asynchronous workings, and details
the particulars of the objects and methods. But see
<a href="#examples">Examples</a> for detailed explanations of the sample
scripts which come with the <code>Net::Z3950::AsyncZ</code> distribution.
<LI>
<A href="Options.html">Options.html</a>
<br> This document details the various options that can be set to modify
the behavior of <code>AsyncZ</code>
<LI>
<A href="Report.html">Report.html</a>
<br><Code>Report.html</code> deals with how records are treated line by line
and how you can affect the apearance of a record's line by line output
<LI><A name = "examples"></a>
<A href="Examples.html">Examples.html</a>
This document goes through the sample scripts that come with the
<code>Net::Z3950::AsyncZ</code> distribution and annotates them
in a line-by-line fashion. It's a basic HOW-TO.
</UL>
=end html
=head2 The Modules
=pod
There are more modules than there is documentation. The reason for this
is that the only module you have full and complete access to is
C<Net::Z3950::AsyncZ>. The other modules are either internal to C<Net::AsyncZ>
or accessed indirectly or in part indirectly.
=cut
=for html
There are more modules than there is documentation. The reason for this
is that the only module you have full and complete access to is
<code>Net::Z3950::AsyncZ</code>. The other modules are either internal to <code>Net::AsyncZ</code>
or accessed indirectly or in part indirectly.
=head3 Here are the modules:
=over 4
=item Net::Z3950::AsyncZ
The main module: direct access --documented in
C<AsyncZ> and C<Options> documentation
=item Net::Z3950::AsyncZ::ErrMsg
User error message handling: indirect access -- documented in
C<AsyncZ> documentation
=item Net::Z3950::AsyncZ::Errors
Error handling for debugging: limited access -- documented in
C<AsyncZ> documentation
=item Net::Z3950::AsyncZ::Report
Module reponsible for fetching and formatting records: limited access -- documented
=item Net::Z3950::AsyncZ::ZLoop
Event loop for child processes: no access -- not documented
=item Net::Z3950::AsyncZ::ZSend
Connection details for child processes: no access -- not documented
=item Net::Z3950::AsyncZ::Options::_params
Options for child processes: direct and indirect access -- documented
in C<Options> and C<AsyncZ> documentation
=back
=head1 INDEX

View File

@@ -0,0 +1,27 @@
package tutorial;
option java_package = "com.example.tutorial";
option java_outer_classname = "AddressBookProtos";
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phone = 4;
}
message AddressBook {
repeated Person person = 1;
}

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env python
import os
import sys
def main():
# usage string
usage = 'usage: gitall command'
# command check
if len(sys.argv) < 2:
sys.exit(usage)
command = 'git ' + ' '.join(sys.argv[1:])
printDelimiter()
print 'Running command:', command
# get a list of git directories in the specified parent
gitDirectories = getSubdirectories('.', isGitDirectory)
for gitDirectory in gitDirectories:
os.chdir(gitDirectory)
printDelimiter()
print 'Current respository location:', os.getcwd()
os.system(command)
printDelimiter()
def getSubdirectories(directory, filter = None):
directory = os.path.abspath(directory)
subdirectories = os.walk(directory).next()[1]
if filter is None:
return [directory + '/' + i for i in subdirectories]
else:
return [directory + '/' + i for i in subdirectories if filter(directory + '/' + i)]
def isGitDirectory(directory):
return os.path.isdir(directory + '/.git/')
def printDelimiter():
print '\033[91m'
print ('#' * 80)
print '\033[0m'
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,324 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright © 2013 Martin Ueding <dev@martin-ueding.de>
import argparse
import matplotlib.pyplot as pl
import numpy as np
import scipy.optimize as op
from prettytable import PrettyTable
__docformat__ = "restructuredtext en"
# Sensitivität der Thermosäule
S = 30e-6
def phif(U):
return U / S
def main():
options = _parse_args()
V = 1000
data = np.genfromtxt("a-leer.csv", delimiter="\t")
t = data[:,0]
U = data[:,1] / V / 1000
U_err = 0.7e-3 / V
offset = np.mean(U[-3:])
x = np.linspace(min(t), max(t))
y = np.ones(x.size) * offset
pl.plot(x, y * 10**6, label="Offset")
print "Offset: {:.3g} V".format(offset)
pl.errorbar(t, U * 10**6, yerr=U_err * 10**6, linestyle="none", marker="+",
label="Messdaten")
pl.grid(True)
pl.legend(loc="best")
pl.title(u"Bestimmung des Offsets")
pl.xlabel(ur"Zeit $t / \mathrm{s}$")
pl.ylabel(ur"Thermospannung $U / \mathrm{\mu V}$")
pl.savefig("Plot_a-leer.pdf")
pl.clf()
V = 100
data = np.genfromtxt("a-Lampe.csv", delimiter="\t")
t = data[:,0]
U = data[:,1] / V / 1000 - offset
U_err = 0.7e-3 / V
x = np.linspace(min(t), max(t))
y = np.ones(x.size) * max(U) * 0.9
pl.plot(x, y * 10**6, label=ur"$90\%$")
pl.errorbar(t, U * 10**6, yerr=U_err * 10**6, linestyle="none", marker="+",
label="Messdaten")
pl.grid(True)
pl.legend(loc="best")
pl.title(u"Bestimmung der Ansprechzeit")
pl.xlabel(ur"Zeit $t / \mathrm{s}$")
pl.ylabel(ur"Thermospannung $U / \mathrm{\mu V}$")
pl.savefig("Plot_a-Lampe.pdf")
pl.clf()
# Lesliewürfel
print """
Lesliewürfel
============
"""
glanz = np.genfromtxt("b-glanz.csv", delimiter="\t")
matt = np.genfromtxt("b-matt.csv", delimiter="\t")
schwarz = np.genfromtxt("b-schwarz.csv", delimiter="\t")
weiss = np.genfromtxt("b-weiss.csv", delimiter="\t")
T0 = 19.0 + 273.15
T0_err = 1.0
glanz[:,0] += 273.15
matt[:,0] += 273.15
schwarz[:,0] += 273.15
weiss[:,0] += 273.15
glanz[:,1] /= 1000 * V
matt[:,1] /= 1000 * V
schwarz[:,1] /= 1000 * V
weiss[:,1] /= 1000 * V
glanz[:,1] -= offset
matt[:,1] -= offset
schwarz[:,1] -= offset
weiss[:,1] -= offset
glanz_phi = phif(glanz[:,1])
matt_phi = phif(matt[:,1])
schwarz_phi = phif(schwarz[:,1])
weiss_phi = phif(weiss[:,1])
T_err = 0.3
sigma = 5.670373e-8
def boltzmann(T, epsilon, offset):
return epsilon * sigma * T**4 + offset
glanz_popt, glanz_pconv = op.curve_fit(boltzmann, glanz[:,0], glanz_phi)
matt_popt, matt_pconv = op.curve_fit(boltzmann, matt[:,0], matt_phi)
schwarz_popt, schwarz_pconv = op.curve_fit(boltzmann, schwarz[:,0], schwarz_phi)
weiss_popt, weiss_pconv = op.curve_fit(boltzmann, weiss[:,0], weiss_phi)
glanz_x = np.linspace(min(glanz[:,0]), max(glanz[:,0]))
glanz_y = boltzmann(glanz_x, *glanz_popt)
pl.plot(glanz_x, glanz_y, label="Fit glanz", color="gold")
matt_x = np.linspace(min(matt[:,0]), max(matt[:,0]))
matt_y = boltzmann(matt_x, *matt_popt)
pl.plot(matt_x, matt_y, label="Fit matt", color="yellow")
schwarz_x = np.linspace(min(schwarz[:,0]), max(schwarz[:,0]))
schwarz_y = boltzmann(schwarz_x, *schwarz_popt)
pl.plot(schwarz_x, schwarz_y, label="Fit schwarz", color="black")
weiss_x = np.linspace(min(weiss[:,0]), max(weiss[:,0]))
weiss_y = boltzmann(weiss_x, *weiss_popt)
pl.plot(weiss_x, weiss_y, label="Fit weiss", color="gray")
print "glanz ε = {:.3g} ± {:.3g}".format(glanz_popt[0], np.sqrt(glanz_pconv.diagonal()[0]))
print "glanz offset = {:.3g} ± {:.3g}".format(glanz_popt[1], np.sqrt(glanz_pconv.diagonal()[1]))
print "matt ε = {:.3g} ± {:.3g}".format(matt_popt[0], np.sqrt(matt_pconv.diagonal()[0]))
print "matt offset = {:.3g} ± {:.3g}".format(matt_popt[1], np.sqrt(matt_pconv.diagonal()[1]))
print "schwarz ε = {:.3g} ± {:.3g}".format(schwarz_popt[0], np.sqrt(schwarz_pconv.diagonal()[0]))
print "schwarz offset = {:.3g} ± {:.3g}".format(schwarz_popt[1], np.sqrt(schwarz_pconv.diagonal()[1]))
print "weiss ε = {:.3g} ± {:.3g}".format(weiss_popt[0], np.sqrt(weiss_pconv.diagonal()[0]))
print "weiss offset = {:.3g} ± {:.3g}".format(weiss_popt[1], np.sqrt(weiss_pconv.diagonal()[1]))
pl.errorbar(glanz[:,0], glanz_phi, xerr=T_err, yerr=U_err/S,
label="glanz", color="gold", linestyle="none")
pl.errorbar(matt[:,0], matt_phi, xerr=T_err, yerr=U_err/S,
label="matt", color="yellow", linestyle="none")
pl.errorbar(schwarz[:,0], schwarz_phi, xerr=T_err, yerr=U_err/S,
label="schwarz", color="black", linestyle="none")
pl.errorbar(weiss[:,0], weiss_phi, xerr=T_err, yerr=U_err/S,
label="weiss", color="gray", linestyle="none")
header = ["T / K", "Phi/F in W/m^2", "Fehler T", "Fehler Phi/F"]
print """
Tabellen für den Lesliewürfel-Plot
----------------------------------
"""
print "Glanz"
glanz_table = PrettyTable(header)
for row in zip(glanz[:,0], glanz_phi, np.ones(glanz[:,0].size)*T_err, np.ones(glanz_phi.size)*U_err/S):
glanz_table.add_row(row)
print glanz_table
print
print "Matt"
matt_table = PrettyTable(header)
for row in zip(matt[:,0], matt_phi, np.ones(matt[:,0].size)*T_err, np.ones(matt_phi.size)*U_err/S):
matt_table.add_row(row)
print matt_table
print
print "Schwarz"
schwarz_table = PrettyTable(header)
for row in zip(schwarz[:,0], schwarz_phi, np.ones(schwarz[:,0].size)*T_err, np.ones(schwarz_phi.size)*U_err/S):
schwarz_table.add_row(row)
print schwarz_table
print
print "Weiß"
weiss_table = PrettyTable(header)
for row in zip(weiss[:,0], weiss_phi, np.ones(weiss[:,0].size)*T_err, np.ones(weiss_phi.size)*U_err/S):
weiss_table.add_row(row)
print weiss_table
print
epsilon = 0.1
x = np.linspace(min([min(x) for x in [glanz[:,0], matt[:,0], schwarz[:,0],
weiss[:,0]]]),
max([max(x) for x in [glanz[:,0], matt[:,0], schwarz[:,0],
weiss[:,0]]]),
100)
offset = - epsilon * sigma * T0**4
print "ideal offset = {:.3g}".format(offset)
y = boltzmann(x, epsilon, offset)
pl.plot(x, y, label=ur"$\epsilon = 0.1$")
pl.grid(True)
pl.title(u"Lesliewürfel")
pl.xlabel(ur"Temperatur $T / \mathrm{K}$")
pl.ylabel(ur"Strahlungsfluss $\frac{\Phi}{F} / \mathrm{\frac{W}{m^2}}$")
pl.legend(loc="best", prop={"size": 12})
pl.savefig("Plot_b.pdf")
pl.clf()
# Aufgabe c
print """
Aufgabe c
=========
"""
data = np.genfromtxt("c-erste.csv", delimiter="\t")
d = data[:,0] / 100
U = data[:,1] / V
phi = phif(U)
def c(x, a, b):
return a*x + b
dx = d**(-2)
dy = phi
dx_err = np.abs(-2 * d**(-3)) * 0.001
dy_err = 0.001 / S
popt, pconv = op.curve_fit(c, dx, dy)
x = np.linspace(min(dx), max(dx))
y = c(x, *popt)
pl.plot(x, y, label="Fit")
print "Fitparameter"
print "a", popt[0], "±", np.sqrt(pconv.diagonal()[0])
print "b", popt[1], "±", np.sqrt(pconv.diagonal()[1])
pl.errorbar(dx, dy, xerr=dx_err, yerr=dy_err, linestyle="none",
marker="+", label="Messdaten")
pl.grid(True)
pl.title(u"Halogenlampe bei verschiedenen Abständen")
pl.xlabel(ur"Abstand $d^{-2} / \mathrm{m^{-2}}$")
pl.ylabel(ur"Strahlungsfluss $\frac{\Phi}{F} / \mathrm{\frac{W}{m^2}}$")
pl.legend(loc="best")
pl.savefig("Plot_c-erste.pdf")
pl.clf()
print
print "Tabelle für Aufgabe c"
fields = ["d^-2 in m^-2", "Phi/F in W/m^2", "Fehler d^-2", "Fehler Phi/F"]
table = PrettyTable(fields)
table.align = "l"
for row in zip(dx, dy, dx_err, np.ones(dy.size)*dy_err):
table.add_row(row)
print table
print
data = np.genfromtxt("c-zweite.csv", delimiter="\t")
U1 = data[:,0]
I1 = data[:,1]
U2 = data[:,2] / V
U_err = 0.001
I_err = 0.01
p = U1 * I1
R = U1 / I1
R_err = np.sqrt(
(1/I1 * U_err)**2
+ (U1/I1**2 * I_err)**2
)
phi = phif(U2)
phi_err = U_err / S
alpha = 4.82e-3
beta = 6.76e-7
R0 = 0.35
R0_err = 0.05
T = (-alpha*R0 + np.sqrt(R0)*np.sqrt(4*beta*R + alpha**2*R0 - 4*beta*R0) +
2*beta*R0*T0)/(2*beta*R0)
popt, pconv = op.curve_fit(boltzmann, T, phi, sigma=phi_err)
x = np.linspace(min(T), max(T))
y = boltzmann(x, *popt)
pl.plot(x, y, label="Fit")
epsilon = popt[0]
epsilon_err = np.sqrt(pconv.diagonal()[0])
print "ε = {:.3g} ± {:.3g}".format(epsilon, epsilon_err)
f1 = (1/(np.sqrt(R0)*np.sqrt(4*beta*R + alpha**2*R0 - 4*beta*R0))) * R_err
f2 = T0_err
f3 = ((-alpha + ((alpha**2 - 4*beta)*np.sqrt(R0))/( 2*np.sqrt(4*beta*R + alpha**2*R0 - 4*beta*R0)) + np.sqrt( 4*beta*R + alpha**2*R0 - 4*beta*R0)/(2*np.sqrt(R0)) + 2*beta*T0)/( 2*beta*R0) - (-alpha*R0 + np.sqrt(R0)*np.sqrt(4*beta*R + alpha**2*R0 - 4*beta*R0) + 2*beta*R0*T0)/( 2*beta*R0**2)) * R0_err
T_err = np.sqrt(f1**2 + f2**2 + f3**2)
pl.errorbar(T, phi, xerr=T_err, yerr=phi_err, label="Messdaten",
linestyle="none", marker="+")
pl.grid(True)
pl.legend(loc="best")
pl.title(u"Halogenlampe bei verschiedenen Leistungen")
pl.xlabel(u"Temperatur $T / \mathrm{K}$")
pl.ylabel(ur"Strahlungsfluss $\frac{\Phi}{F} / \mathrm{\frac{W}{m^2}}$")
pl.savefig("Plot_c-zweite.pdf")
pl.clf()
def _parse_args():
"""
Parses the command line arguments.
:return: Namespace with arguments.
:rtype: Namespace
"""
parser = argparse.ArgumentParser(description="")
#parser.add_argument("args", metavar="N", type=str, nargs="*", help="Positional arguments.")
#parser.add_argument("", dest="", type="", default=, help=)
#parser.add_argument("--version", action="version", version="<the version>")
return parser.parse_args()
if __name__ == "__main__":
main()

31
samples/R/git-punchcard.script! Executable file
View File

@@ -0,0 +1,31 @@
#! /usr/bin/env Rscript
# vim: filetype=r:
ParseDates <- function(lines) {
dates <- matrix(unlist(strsplit(lines, " +")), ncol=6, byrow=TRUE)
days <- dates[,1]
times <- dates[,4]
hours <- matrix(unlist(strsplit(times, ":")), ncol=3, byrow=TRUE)[,1]
all.days <- c("Sun", "Sat", "Fri", "Thu", "Wed", "Tue", "Mon")
all.hours <- 0:23
data.frame( Day = factor(days , levels=all.days)
, Hour = factor(hours, levels=all.hours)
)
}
Main <- function() {
lines <- system("git log --format=%ad", intern=TRUE)
punchcard <- as.data.frame(table(ParseDates(lines)))
punchcard <-
( ggplot2::ggplot(punchcard, ggplot2::aes(y=Day, x=Hour))
+ ggplot2::geom_point(ggplot2::aes(size=Freq))
+ ggplot2::scale_size(range=c(0, 15))
)
ggplot2::ggsave( filename = "punchcard.png"
, plot = punchcard
, width = 10
, height = 5
)
}
Main()

129
samples/RDoc/rdoc.rdoc Normal file
View File

@@ -0,0 +1,129 @@
= \RDoc - Ruby Documentation System
home :: https://github.com/rdoc/rdoc
rdoc :: http://docs.seattlerb.org/rdoc
bugs :: https://github.com/rdoc/rdoc/issues
code quality :: {<img src="https://codeclimate.com/badge.png" alt="code climate">}[https://codeclimate.com/github/rdoc/rdoc]
== Description
RDoc produces HTML and command-line documentation for Ruby projects. RDoc
includes the +rdoc+ and +ri+ tools for generating and displaying documentation
from the command-line.
== Generating Documentation
Once installed, you can create documentation using the +rdoc+ command
$ rdoc [options] [names...]
For an up-to-date option summary, type
$ rdoc --help
A typical use might be to generate documentation for a package of Ruby
source (such as RDoc itself).
$ rdoc
This command generates documentation for all the Ruby and C source
files in and below the current directory. These will be stored in a
documentation tree starting in the subdirectory +doc+.
You can make this slightly more useful for your readers by having the
index page contain the documentation for the primary file. In our
case, we could type
% rdoc --main README.rdoc
You'll find information on the various formatting tricks you can use
in comment blocks in the documentation this generates.
RDoc uses file extensions to determine how to process each file. File names
ending +.rb+ and +.rbw+ are assumed to be Ruby source. Files
ending +.c+ are parsed as C files. All other files are assumed to
contain just Markup-style markup (with or without leading '#' comment
markers). If directory names are passed to RDoc, they are scanned
recursively for C and Ruby source files only.
To generate documentation using +rake+ see RDoc::Task.
To generate documentation programmatically:
gem 'rdoc'
require 'rdoc/rdoc'
options = RDoc::Options.new
# see RDoc::Options
rdoc = RDoc::RDoc.new
rdoc.document options
# see RDoc::RDoc
== Writing Documentation
To write documentation for RDoc place a comment above the class, module,
method, constant, or attribute you want documented:
##
# This class represents an arbitrary shape by a series of points.
class Shape
##
# Creates a new shape described by a +polyline+.
#
# If the +polyline+ does not end at the same point it started at the
# first pointed is copied and placed at the end of the line.
#
# An ArgumentError is raised if the line crosses itself, but shapes may
# be concave.
def initialize polyline
# ...
end
end
The default comment markup format is the RDoc::Markup format.
TomDoc[rdoc-ref:RDoc::TomDoc], Markdown[rdoc-ref:RDoc::Markdown] and
RD[rdoc-ref:RDoc::RD] format comments are also supported. You can set the
default comment format for your entire project by creating a
<tt>.rdoc_options</tt> file. See RDoc::Options@Saved+Options for instructions
on creating one. You can also set the comment format for a single file
through the +:markup:+ directive, but this is only recommended if you wish to
switch markup formats. See RDoc::Markup@Other+directives.
Comments can contain directives that tell RDoc information that it cannot
otherwise discover through parsing. See RDoc::Markup@Directives to control
what is or is not documented, to define method arguments or to break up
methods in a class by topic. See RDoc::Parser::Ruby for directives used to
teach RDoc about metaprogrammed methods.
See RDoc::Parser::C for documenting C extensions with RDoc.
To determine how well your project is documented run <tt>rdoc -C lib</tt> to
get a documentation coverage report. <tt>rdoc -C1 lib</tt> includes parameter
names in the documentation coverage report.
== Bugs
See CONTRIBUTING@Bugs for information on filing a bug report. It's OK to file
a bug report for anything you're having a problem with. If you can't figure
out how to make RDoc produce the output you like that is probably a
documentation bug.
== License
RDoc is Copyright (c) 2001-2003 Dave Thomas, The Pragmatic Programmers.
Portions (c) 2007-2011 Eric Hodel. Portions copyright others, see individual
files and LEGAL.rdoc for details.
RDoc is free software, and may be redistributed under the terms specified in
LICENSE.rdoc.
== Warranty
This software is provided "as is" and without any express or implied
warranties, including, without limitation, the implied warranties of
merchantability and fitness for a particular purpose.

View File

@@ -1,7 +0,0 @@
#!/bin/sh
#| -*- scheme -*-
exec racket -um "$0" "$@"
|#
(require racket/file racket/path racket/list racket/string
(for-syntax racket/base))

View File

@@ -0,0 +1,45 @@
*** Settings ***
Documentation Example test cases using the data-driven testing approach.
...
... Tests use `Calculate` keyword created in this file, that in
... turn uses keywords in `CalculatorLibrary`. An exception is
... the last test that has a custom _template keyword_.
...
... The data-driven style works well when you need to repeat
... the same workflow multiple times.
...
... Notice that one of these tests fails on purpose to show how
... failures look like.
Test Template Calculate
Library CalculatorLibrary
*** Test Cases *** Expression Expected
Addition 12 + 2 + 2 16
2 + -3 -1
Subtraction 12 - 2 - 2 8
2 - -3 5
Multiplication 12 * 2 * 2 48
2 * -3 -6
Division 12 / 2 / 2 3
2 / -3 -1
Failing 1 + 1 3
Calculation error [Template] Calculation should fail
kekkonen Invalid button 'k'.
${EMPTY} Invalid expression.
1 / 0 Division by zero.
*** Keywords ***
Calculate
[Arguments] ${expression} ${expected}
Push buttons C${expression}=
Result should be ${expected}
Calculation should fail
[Arguments] ${expression} ${expected}
${error} = Should cause error C${expression}=
Should be equal ${expected} ${error} # Using `BuiltIn` keyword

View File

@@ -0,0 +1,33 @@
*** Settings ***
Documentation Example test case using the gherkin syntax.
...
... This test has a workflow similar to the keyword-driven
... examples. The difference is that the keywords use higher
... abstraction level and their arguments are embedded into
... the keyword names.
...
... This kind of _gherkin_ syntax has been made popular by
... [http://cukes.info|Cucumber]. It works well especially when
... tests act as examples that need to be easily understood also
... by the business people.
Library CalculatorLibrary
*** Test Cases ***
Addition
Given calculator has been cleared
When user types "1 + 1"
and user pushes equals
Then result is "2"
*** Keywords ***
Calculator has been cleared
Push button C
User types "${expression}"
Push buttons ${expression}
User pushes equals
Push button =
Result is "${result}"
Result should be ${result}

View File

@@ -0,0 +1,37 @@
*** Settings ***
Documentation Example test cases using the keyword-driven testing approach.
...
... All tests contain a workflow constructed from keywords in
... `CalculatorLibrary`. Creating new tests or editing existing
... is easy even for people without programming skills.
...
... This kind of style works well for normal test automation.
... If also business people need to understand tests, using
... _gherkin_ style may work better.
Library CalculatorLibrary
*** Test Cases ***
Push button
Push button 1
Result should be 1
Push multiple buttons
Push button 1
Push button 2
Result should be 12
Simple calculation
Push button 1
Push button +
Push button 2
Push button =
Result should be 3
Longer calculation
Push buttons 5 + 4 - 3 * 2 / 1 =
Result should be 3
Clear
Push button 1
Push button C
Result should be ${EMPTY} # ${EMPTY} is a built-in variable

View File

@@ -0,0 +1,7 @@
appraise "rails32" do
gem 'rails', '~> 3.2.0'
end
appraise "rails40" do
gem 'rails', '~> 4.0.0'
end

12
samples/Sass/demo.scss Normal file
View File

@@ -0,0 +1,12 @@
$blue: #3bbfce;
$margin: 16px;
.content_navigation {
color: $blue;
}
.border {
padding: $margin / 2;
margin: $margin / 2;
border: 2px $blue solid;
}

75
samples/Scala/node11.sc Normal file
View File

@@ -0,0 +1,75 @@
import math.random
import scala.language.postfixOps
import scala.util._
import scala.util.{Try, Success, Failure}
import scala.concurrent._
import duration._
import ExecutionContext.Implicits.global
import scala.concurrent.{ ExecutionContext, CanAwait, OnCompleteRunnable, TimeoutException, ExecutionException, blocking }
/* This worksheet demonstrates some of the code snippets from
* Week3, Lecture 4, "Composing Futures".
*/
object node11 {
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet
/**
* Retry successfully completing block at most noTimes
* and give up after that
*/
def retry[T](n: Int)(block: =>Future[T]): Future[T] = {
val ns: Iterator[Int] = (1 to n).iterator
val attempts: Iterator[()=>Future[T]] = ns.map(_ => ()=>block)
val failed: Future[T] = Future.failed(new Exception)
attempts.foldLeft(failed)((a, block) => a fallbackTo { block() })
} //> retry: [T](n: Int)(block: => scala.concurrent.Future[T])scala.concurrent.Fut
//| ure[T]
def rb(i: Int) = {
blocking{Thread.sleep(100*random.toInt)}
println("Hi " ++ i.toString)
i + 10
} //> rb: (i: Int)Int
def block(i: Int) = {
println("Iteration: " + i.toString)
val ri = retry(i)( Future {rb(i)} )
ri onComplete {
case Success(s) => println(s.toString ++ " = 10 + " ++ i.toString)
case Failure(t:Exception) => println(t.toString ++ " " ++ i.toString)
case r => println(r.toString ++ " " ++ i.toString)
}
} //> block: (i: Int)Unit
/* Multiple executions of a block of commands where
* each block contains one collectCoins and
* one buyTreasure. If either call fails, the whole iteration does not fail,
* because we are catching exceptions (with flatMap) in this implementation.
* Note that these blocks execute synchrounsly.
*/
(0 to 4 toList).foreach(i =>block(i)) //> Iteration: 0
//| Iteration: 1
//| java.lang.Exception 0
//| Hi 1
//| Iteration: 2
//| 11 = 10 + 1
//| Hi 2
//| Iteration: 3
//| Hi 3
//| Hi 2
//| Iteration: 4
//| 12 = 10 + 2
blocking{Thread.sleep(3000)} //> Hi 4
//| Hi 3
//| 13 = 10 + 3
//| Hi 3
//| 14 = 10 + 4
//| Hi 4
//| Hi 4
//| Hi 4-
}

View File

@@ -0,0 +1,3 @@
%p
Hello,
World!

View File

@@ -0,0 +1,30 @@
# This file describes the standard way to build Docker, using docker
docker-version 0.4.2
from ubuntu:12.04
maintainer Solomon Hykes <solomon@dotcloud.com>
# Build dependencies
run apt-get install -y -q curl
run apt-get install -y -q git
# Install Go
run curl -s https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz | tar -v -C /usr/local -xz
env PATH /usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
env GOPATH /go
env CGO_ENABLED 0
run cd /tmp && echo 'package main' > t.go && go test -a -i -v
# Download dependencies
run PKG=github.com/kr/pty REV=27435c699; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
run PKG=github.com/gorilla/context/ REV=708054d61e5; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
run PKG=github.com/gorilla/mux/ REV=9b36453141c; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
# Run dependencies
run apt-get install -y iptables
# lxc requires updating ubuntu sources
run echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > /etc/apt/sources.list
run apt-get update
run apt-get install -y lxc
run apt-get install -y aufs-tools
# Upload docker source
add . /go/src/github.com/dotcloud/docker
# Build the binary
run cd /go/src/github.com/dotcloud/docker/docker && go install -ldflags "-X main.GITCOMMIT '??' -d -w"
env PATH /usr/local/go/bin:/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
cmd ["docker"]

127
samples/Slash/brainfuck.sl Normal file
View File

@@ -0,0 +1,127 @@
<%
class Env {
def init {
@memory = [];
@ptr = 0;
}
def ptr { @ptr }
def ptr=(ptr) { @ptr = ptr }
def current_value { @memory[@ptr] || 0 }
def current_value=(value) { @memory[@ptr] = value }
}
class AST {
class Next {
def eval(env) {
env.ptr++;
}
}
class Prev {
def eval(env) {
env.ptr--;
}
}
class Inc {
def eval(env) {
env.current_value++;
}
}
class Dec {
def eval(env) {
env.current_value--;
}
}
class Output {
def eval(env) {
print(env.current_value.char);
}
}
class Input {
def eval(env) {
...
}
}
class Sequence {
def init(nodes) {
@nodes = nodes;
}
def eval(env) {
for node in @nodes {
node.eval(env);
}
}
}
class Loop {
def init(seq) {
@seq = seq;
}
def eval(env) {
while env.current_value != 0 {
@seq.eval(env);
}
}
}
}
class Parser {
def init(str) {
@chars = str.split("");
}
def parse {
@stack = [[]];
for char in @chars {
_parse_char(char);
}
if @stack.length != 1 {
throw SyntaxError.new("unexpected end of input");
}
AST::Sequence.new(@stack.last);
}
def _parse_char(char) {
switch char {
">" { _add(AST::Next.new); }
"<" { _add(AST::Prev.new); }
"+" { _add(AST::Inc.new); }
"-" { _add(AST::Dec.new); }
"." { _add(AST::Output.new); }
"," { _add(AST::Input.new); }
"[" { _open_loop(); }
"]" { _close_loop(); }
}
}
def _add(node) {
@stack.last.push(node);
}
def _open_loop {
@stack.push([]);
}
def _close_loop {
if @stack.length == 1 {
throw SyntaxError.new("unexpected ']'");
}
nodes = @stack.pop;
_add(AST::Loop.new(AST::Sequence.new(nodes)));
}
}
src = File.read(ARGV.first);
ast = Parser.new(src).parse;
ast.eval(Env.new);

View File

@@ -0,0 +1,56 @@
//example from http://www.squirrel-lang.org/#documentation
local table = {
a = "10"
subtable = {
array = [1,2,3]
},
[10 + 123] = "expression index"
}
local array=[ 1, 2, 3, { a = 10, b = "string" } ];
foreach (i,val in array)
{
::print("the type of val is"+typeof val);
}
/////////////////////////////////////////////
class Entity
{
constructor(etype,entityname)
{
name = entityname;
type = etype;
}
x = 0;
y = 0;
z = 0;
name = null;
type = null;
}
function Entity::MoveTo(newx,newy,newz)
{
x = newx;
y = newy;
z = newz;
}
class Player extends Entity {
constructor(entityname)
{
base.constructor("Player",entityname)
}
function DoDomething()
{
::print("something");
}
}
local newplayer = Player("da playar");
newplayer.MoveTo(100,200,300);

31
samples/Stylus/demo.styl Normal file
View File

@@ -0,0 +1,31 @@
border-radius()
-webkit-border-radius arguments
-moz-border-radius arguments
border-radius arguments
a.button
border-radius 5px
fonts = helvetica, arial, sans-serif
body {
padding: 50px;
font: 14px/1.4 fonts;
}
form
input[type=text]
padding: 5px
border: 1px solid #eee
color: #ddd
textarea
@extends form input[type=text]
padding: 10px
$foo
color: #FFF
.bar
background: #000
@extends $foo

View File

@@ -1,114 +0,0 @@
BCR2000 {
var controls,
controlBuses,
rangedControlBuses,
responders
;
*new {
^super.new.init;
}
init {
controls = Dictionary.new(108);
controlBuses = Dictionary.new(108);
rangedControlBuses = Dictionary.new(108);
this.createCCResponders;
}
createCCResponders {
responders = Array.fill(108, {|i|
CCResponder({|src, chan, num, val|
[src, chan, num, val].postln;
// Write to controls
controls.put(i + 1, val);
// Write to bus (converted to scalar 0..1)
controlBuses.put(i + 1, Bus.control(Server.default));
controlBuses.at(i + 1).value = val / 127;
},
// Adjust values as/if needed
nil, // src
nil, // chan
nil, // num
nil // value
)
});
}
// Value from BCR
at {arg controlNum;
^controls.at(controlNum)
}
// Convert to 0..1
scalarAt {arg controlNum;
^controls.at(controlNum) / 127
}
// Get a bus
busAt {arg controlNum;
^controlBuses.at(controlNum)
}
/*
busRangeAt(arg controlNum, lo, hi;
if (rangedControlBuses.at(controlNum).isNil, {
rangedControlBuses.put(controlNum, Bus.control(Server.default))
});
// Left to right order of operations
//rangedControlBuses.put(
bus.value = hi - lo * controls.at(controlNum) + lo;
^bus
}
*/
}
/* Scratch
Dictionary
b = BCR2000();
b.at(4);
b.scalarAt(4);
b.controls[5].get;
throw
z = Dictionary.new(2);
z.at(\1);
Array.fill(10, {|i| i.postln;})
(2 + 3).asSymbol;
SynthDef(\x, {
arg amp = 0.01,
freq = 1200,
modDepth = 0.7,
modFreq = 2
;
var
carrier,
modulator
;
modulator = SinOsc.ar(modFreq, mul: modDepth);
carrier = Saw.ar(freq, add: modulator, mul: amp);
Out.ar([0,1], carrier)
}).store;
x = Synth(\x);
x.set(\modDepth, 1);
x.set(\modFreq, 64);
x.map(\modFreq, b.busAt(
ControlSpec
*/

View File

@@ -1 +1 @@
console.log "Hello, World!"
console.log("Hello, World!");

View File

@@ -0,0 +1,644 @@
/*
* Copyright (c) 2008, 2013 Dainius "GreatEmerald" Masiliūnas
*
* 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.
*/
//-----------------------------------------------------------------------------
// MutU2Weapons.uc
// Mutator class for replacing weapons
// GreatEmerald, 2008
//-----------------------------------------------------------------------------
class MutU2Weapons extends Mutator
config(U2Weapons);
var() config string ReplacedWeaponClassNames0;
var() config string ReplacedWeaponClassNames1, ReplacedWeaponClassNames2, ReplacedWeaponClassNames3;
var() config string ReplacedWeaponClassNames4, ReplacedWeaponClassNames5, ReplacedWeaponClassNames6;
var() config string ReplacedWeaponClassNames7, ReplacedWeaponClassNames8, ReplacedWeaponClassNames9;
var() config string ReplacedWeaponClassNames10, ReplacedWeaponClassNames11, ReplacedWeaponClassNames12;
var() config bool bConfigUseU2Weapon0, bConfigUseU2Weapon1, bConfigUseU2Weapon2, bConfigUseU2Weapon3;
var() config bool bConfigUseU2Weapon4, bConfigUseU2Weapon5, bConfigUseU2Weapon6, bConfigUseU2Weapon7;
var() config bool bConfigUseU2Weapon8, bConfigUseU2Weapon9, bConfigUseU2Weapon10, bConfigUseU2Weapon11;
var() config bool bConfigUseU2Weapon12;
//var byte bUseU2Weapon[13];
//var class<Weapon> ReplacedWeaponClasses[13];
//var class<WeaponPickup> ReplacedWeaponPickupClasses[13];
//var class<Ammo> ReplacedAmmoPickupClasses[13];
var class<Weapon> U2WeaponClasses[13]; //GE: For default properties ONLY!
//var string U2WeaponPickupClassNames[13];
var string U2AmmoPickupClassNames[13]; //GE: For default properties ONLY!
var byte bIsVehicle[13], bNotVehicle[13]; //GE: For default properties ONLY!
var localized string U2WeaponDisplayText[33], U2WeaponDescText[33];
//var localized string GUISelectOptions[4];
//var config int FirePowerMode;
var config bool bExperimental;
var config bool bUseFieldGenerator;
var config bool bUseProximitySensor;
var config bool bIntegrateShieldReward;
var int IterationNum; //GE: Weapons.Length
const DamageMultiplier=1.818182;
var config int DamagePercentage;
var config bool bUseXMPFeel;
var config string FlashbangModeString;
struct WeaponInfo
{
var class<Weapon> ReplacedWeaponClass; //GE: Generated from ReplacedWeaponClassName. This is what we replace.
//var class<WeaponPickup> ReplacedWeaponPickupClass; //GE: UNUSED?!
var class<Ammo> ReplacedAmmoPickupClass; //GE: Generated from ReplacedWeaponClassName.
var class<Weapon> WeaponClass; //GE: This is the weapon we are going to put inside the world.
var string WeaponPickupClassName; //GE: Generated from WeponClass.
var string AmmoPickupClassName; //GE: Generated from WeaponClass.
var bool bEnabled; //GE: Structs can't be defaultproperty'd, thus we still require bConfigUseU2WeaponX
var bool bIsVehicle; //GE: This indicates that the weapon spawns a vehicle (deployable turrets). These only work in vehicle gametypes, duh.
var bool bNotVehicle; //GE: Opposite of bIsVehicle, that is, only works in non-vehicle gametypes. Think shotgun.
};
var WeaponInfo Weapons[13];
/*
* GE: Here we initialise the mutator. First of all, structs can't use defaultproperties (until UE3) and thus config, so here we need to initialise the structs.
*/
function PostBeginPlay()
{
local int FireMode, x;
//local string ReplacedWeaponPickupClassName;
//IterationNum = ArrayCount(ReplacedWeaponClasses) - int(Level.Game.bAllowVehicles); //GE: He he, neat way to get the required number.
IterationNum = ArrayCount(Weapons);
for (x = 0; x < IterationNum; x++)
{
Weapons[x].bEnabled = bool(GetPropertyText("bConfigUseU2Weapon"$x)); //GE: GetPropertyText() is needed to use variables in an array-like fashion.
//bUseU2Weapon[x] = byte(bool(GetPropertyText("bConfigUseU2Weapon"$x)));
Weapons[x].ReplacedWeaponClass = class<Weapon>(DynamicLoadObject(GetPropertyText("ReplacedWeaponClassNames"$x),class'Class'));
//ReplacedWeaponClasses[x] = class<Weapon>(DynamicLoadObject(GetPropertyText("ReplacedWeaponClassNames"$x),class'Class'));
//ReplacedWeaponPickupClassName = string(ReplacedWeaponClasses[x].default.PickupClass);
for(FireMode = 0; FireMode<2; FireMode++)
{
if( (Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode] != None)
&& (Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode].default.AmmoClass != None)
&& (Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode].default.AmmoClass.default.PickupClass != None) )
{
Weapons[x].ReplacedAmmoPickupClass = class<Ammo>(Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode].default.AmmoClass.default.PickupClass);
break;
}
}
Weapons[x].WeaponClass = U2WeaponClasses[x];
Weapons[x].WeaponPickupClassName = string(Weapons[x].WeaponClass.default.PickupClass);
Weapons[x].AmmoPickupClassName = U2AmmoPickupClassNames[x];
Weapons[x].bIsVehicle = bool(bIsVehicle[x]);
Weapons[x].bNotVehicle = bool(bNotVehicle[x]);
}
Super.PostBeginPlay();
}
/*
* GE: Utility function for checking if we can replace the item with the weapon/ammo of choice.
*/
function bool ValidReplacement(int x)
{
if (Level.Game.bAllowVehicles)
return (Weapons[x].bEnabled && !Weapons[x].bNotVehicle );
return (Weapons[x].bEnabled && !Weapons[x].bIsVehicle);
}
/*
* GE: Here we replace things.
*/
function bool CheckReplacement( Actor Other, out byte bSuperRelevant )
{
local int x, i;
local WeaponLocker L;
bSuperRelevant = 0;
if (xWeaponBase(Other) != None)
{
for (x = 0; x < IterationNum; x++)
{
if (ValidReplacement(x) && xWeaponBase(Other).WeaponType == Weapons[x].ReplacedWeaponClass)
{
xWeaponBase(Other).WeaponType = Weapons[x].WeaponClass;
return false;
}
}
return true;
}
if (Weapon(Other) != None)
{
if ( Other.IsA('BallLauncher') )
return true;
for (x = 0; x < IterationNum; x++)
if (ValidReplacement(x) && Other.Class == Weapons[x].ReplacedWeaponClass)
return false;
return true;
}
/*if (WeaponPickup(Other) != None) //GE: This should never happen.
{
for (x = 0; x < IterationNum; x++)
{
if (Weapons[x].bEnabled && Other.Class == Weapons[x].ReplacedWeaponPickupClass)
{
ReplaceWith(Other, U2WeaponPickupClassNames[x]);
return false;
}
}
} */
if (Ammo(Other) != None)
{
for (x = 0; x < IterationNum; x++)
{
if (ValidReplacement(x) && Other.Class == Weapons[x].ReplacedAmmoPickupClass)
{
ReplaceWith(Other, Weapons[x].AmmoPickupClassName);
return false;
}
}
return true;
}
if (WeaponLocker(Other) != None)
{
L = WeaponLocker(Other);
for (x = 0; x < IterationNum; x++)
if (ValidReplacement(x))
for (i = 0; i < L.Weapons.Length; i++)
if (L.Weapons[i].WeaponClass == Weapons[x].ReplacedWeaponClass)
L.Weapons[i].WeaponClass = Weapons[x].WeaponClass;
return true;
}
//STARTING WEAPON
if( xPawn(Other) != None )
xPawn(Other).RequiredEquipment[0] = string(Weapons[1].WeaponClass);
if( xPawn(Other) != None && bUseFieldGenerator == True && Level.Game.bAllowVehicles)
xPawn(Other).RequiredEquipment[2] = "U2Weapons.U2WeaponFieldGenerator";
if( xPawn(Other) != None && bUseProximitySensor == True && Level.Game.bAllowVehicles)
xPawn(Other).RequiredEquipment[3] = "U2Weapons.U2ProximitySensorDeploy";
//GE: Special handling - Shield Reward integration
if (bIntegrateShieldReward && Other.IsA('ShieldReward'))
{
ShieldPack(Other).SetStaticMesh(StaticMesh'XMPWorldItemsM.items.Pickup_TD_001');
ShieldPack(Other).Skins[0] = Shader'U2343T.Pickups.Energy_Pickup_B_FX_01';
ShieldPack(Other).RepSkin = Shader'U2343T.Pickups.Energy_Pickup_B_FX_01';
ShieldPack(Other).SetDrawScale(0.35);
ShieldPack(Other).SetCollisionSize(27.0, 4.0);
ShieldPack(Other).PickupMessage = "You got an Energy Pickup.";
ShieldPack(Other).PickupSound = Sound'U2A.Powerups.EnergyPowerUp';
}
return Super.CheckReplacement(Other,bSuperRelevant);
}
/*
* GE: This is for further replacement, I think...
*/
function string GetInventoryClassOverride(string InventoryClassName)
{
local int x;
for (x = 0; x < IterationNum; x++)
{
if (InventoryClassName ~= string(Weapons[x].ReplacedWeaponClass) && ValidReplacement(x))
return string(Weapons[x].WeaponClass);
}
return Super.GetInventoryClassOverride(InventoryClassName);
}
/*
* GE: Configuration options.
*/
static function FillPlayInfo(PlayInfo PlayInfo)
{
local array<CacheManager.WeaponRecord> Recs;
local string WeaponOptions;
local int i;
Super.FillPlayInfo(PlayInfo);
class'CacheManager'.static.GetWeaponList(Recs);
for (i = 0; i < Recs.Length; i++)
{
if (WeaponOptions != "")
WeaponOptions $= ";";
WeaponOptions $= Recs[i].ClassName $ ";" $ Recs[i].FriendlyName;
}
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon0", default.U2WeaponDisplayText[0], 0, 3, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames0", default.U2WeaponDisplayText[1], 0, 4, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon1", default.U2WeaponDisplayText[2], 0, 5, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames1", default.U2WeaponDisplayText[3], 0, 6, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon2", default.U2WeaponDisplayText[6], 0, 7, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames2", default.U2WeaponDisplayText[7], 0, 8, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon3", default.U2WeaponDisplayText[8], 0, 9, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames3", default.U2WeaponDisplayText[9], 0, 10, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon4", default.U2WeaponDisplayText[10], 0, 11, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames4", default.U2WeaponDisplayText[11], 0, 12, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon5", default.U2WeaponDisplayText[12], 0, 13, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames5", default.U2WeaponDisplayText[13], 0, 14, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon6", default.U2WeaponDisplayText[14], 0, 15, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames6", default.U2WeaponDisplayText[15], 0, 16, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon7", default.U2WeaponDisplayText[16], 0, 17, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames7", default.U2WeaponDisplayText[17], 0, 18, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon8", default.U2WeaponDisplayText[18], 0, 19, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames8", default.U2WeaponDisplayText[19], 0, 20, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon9", default.U2WeaponDisplayText[20], 0, 21, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames9", default.U2WeaponDisplayText[21], 0, 22, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon10", default.U2WeaponDisplayText[22], 0, 23, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames10", default.U2WeaponDisplayText[23], 0, 24, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon11", default.U2WeaponDisplayText[24], 0, 25, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames11", default.U2WeaponDisplayText[25], 0, 26, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon12", default.U2WeaponDisplayText[26], 0, 27, "Check");
PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames12", default.U2WeaponDisplayText[27], 0, 28, "Select", WeaponOptions);
PlayInfo.AddSetting(default.RulesGroup, "bUseXMPFeel", default.U2WeaponDisplayText[4], 0, 29, "Check");
PlayInfo.AddSetting(default.RulesGroup, "DamagePercentage", default.U2WeaponDisplayText[30], 0, 30, "Text", "3;0:100");
PlayInfo.AddSetting(default.RulesGroup, "bExperimental", default.U2WeaponDisplayText[5], 0, 31, "Check");
PlayInfo.AddSetting(default.RulesGroup, "bUseFieldGenerator", default.U2WeaponDisplayText[28], 0, 32, "Check");
PlayInfo.AddSetting(default.RulesGroup, "bUseProximitySensor", default.U2WeaponDisplayText[29], 0, 33, "Check");
PlayInfo.AddSetting(default.RulesGroup, "bIntegrateShieldReward", default.U2WeaponDisplayText[31], 0, 34, "Check");
PlayInfo.AddSetting(default.RulesGroup, "FlashbangModeString", default.U2WeaponDisplayText[32], 0, 35, "Select", "FM_None;None;FM_Directional;Direction-based;FM_DistanceBased;Distance-based");
}
/*
* GE: Configuration tooltips.
*/
static event string GetDescriptionText(string PropName)
{
if (PropName == "bConfigUseU2Weapon0")
return default.U2WeaponDescText[0];
if (PropName == "ReplacedWeaponClassNames0")
return default.U2WeaponDescText[1];
if (PropName == "bConfigUseU2Weapon1")
return default.U2WeaponDescText[2];
if (PropName == "ReplacedWeaponClassNames1")
return default.U2WeaponDescText[3];
if (PropName == "bConfigUseU2Weapon2")
return default.U2WeaponDescText[6];
if (PropName == "ReplacedWeaponClassNames2")
return default.U2WeaponDescText[7];
if (PropName == "bConfigUseU2Weapon3")
return default.U2WeaponDescText[8];
if (PropName == "ReplacedWeaponClassNames3")
return default.U2WeaponDescText[9];
if (PropName == "bConfigUseU2Weapon4")
return default.U2WeaponDescText[10];
if (PropName == "ReplacedWeaponClassNames4")
return default.U2WeaponDescText[11];
if (PropName == "bConfigUseU2Weapon5")
return default.U2WeaponDescText[12];
if (PropName == "ReplacedWeaponClassNames5")
return default.U2WeaponDescText[13];
if (PropName == "bConfigUseU2Weapon6")
return default.U2WeaponDescText[14];
if (PropName == "ReplacedWeaponClassNames6")
return default.U2WeaponDescText[15];
if (PropName == "bConfigUseU2Weapon7")
return default.U2WeaponDescText[16];
if (PropName == "ReplacedWeaponClassNames7")
return default.U2WeaponDescText[17];
if (PropName == "bConfigUseU2Weapon8")
return default.U2WeaponDescText[18];
if (PropName == "ReplacedWeaponClassNames8")
return default.U2WeaponDescText[19];
if (PropName == "bConfigUseU2Weapon9")
return default.U2WeaponDescText[20];
if (PropName == "ReplacedWeaponClassNames9")
return default.U2WeaponDescText[21];
if (PropName == "bConfigUseU2Weapon10")
return default.U2WeaponDescText[22];
if (PropName == "ReplacedWeaponClassNames10")
return default.U2WeaponDescText[23];
if (PropName == "bConfigUseU2Weapon11")
return default.U2WeaponDescText[24];
if (PropName == "ReplacedWeaponClassNames11")
return default.U2WeaponDescText[25];
if (PropName == "bConfigUseU2Weapon12")
return default.U2WeaponDescText[26];
if (PropName == "ReplacedWeaponClassNames12")
return default.U2WeaponDescText[27];
if (PropName == "bUseXMPFeel")
return default.U2WeaponDescText[4];
if (PropName == "bExperimental")
return default.U2WeaponDescText[5];
if (PropName == "bUseFieldGenerator")
return default.U2WeaponDescText[28];
if (PropName == "bUseProximitySensor")
return default.U2WeaponDescText[29];
if (PropName == "DamagePercentage")
return default.U2WeaponDescText[30];
if (PropName == "bIntegrateShieldReward")
return default.U2WeaponDescText[31];
if (PropName == "FlashbangModeString")
return default.U2WeaponDescText[32];
return Super.GetDescriptionText(PropName);
}
/*
* GE: Here we set all the properties for different play styles.
*/
event PreBeginPlay()
{
//local int x;
//local class<Weapon> Weapons;
local float k; //GE: Multiplier.
Super.PreBeginPlay();
k=float(DamagePercentage)/100.0;
//log("MutU2Weapons: k is"@k);
//Sets various settings that match different games
/*if (FirePowerMode == 1) { //Original XMP - use the UTXMP original values
k=1;
}
else */if (!bUseXMPFeel && DamagePercentage != class'MutU2Weapons'.default.DamagePercentage) { //Original U2; compensate for float division errors
Class'U2Weapons.U2AssaultRifleFire'.default.DamageMin *= DamageMultiplier * k;
Class'U2Weapons.U2AssaultRifleFire'.default.DamageMax *= DamageMultiplier * k;
Class'U2Weapons.U2AssaultRifleProjAlt'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileASExplAlt'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2FireFlameThrower'.default.DamageMin *= DamageMultiplier * k;
Class'U2Weapons.U2FireFlameThrower'.default.DamageMax *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileFragGrenade'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileConcussionGrenade'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileRocketDrunken'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileRocketSeeking'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileRocket'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileAltShotgun'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2FireShotgun'.default.DamageMin *= DamageMultiplier * k;
Class'U2Weapons.U2FireShotgun'.default.DamageMax *= DamageMultiplier * k;
Class'U2Weapons.U2FireSniper'.default.DamageMin *= DamageMultiplier * k;
Class'U2Weapons.U2FireSniper'.default.DamageMax *= DamageMultiplier * k;
Class'U2Weapons.U2FirePistol'.default.DamageMin *= DamageMultiplier * k;
Class'U2Weapons.U2FirePistol'.default.DamageMax *= DamageMultiplier * k;
Class'U2Weapons.U2FireAltPistol'.default.DamageMin *= DamageMultiplier * k;
Class'U2Weapons.U2FireAltPistol'.default.DamageMax *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileEMPGrenade'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2ProjectileToxicGrenade'.default.Damage *= DamageMultiplier * k;
Class'U2Weapons.U2HurterProxy_Gas'.default.myDamage *= DamageMultiplier * k;
Class'U2Weapons.U2HurterProxy_Fire'.default.myDamage *= DamageMultiplier * k;
}
//Dampened U2 is already the default - no need for a rewrite?
else if (bUseXMPFeel) { //General XMP
Class'U2Weapons.U2AssaultRifleFire'.default.Spread = 6.0;
Class'U2Weapons.U2AssaultRifleAmmoInv'.default.MaxAmmo = 300;
Class'U2Weapons.U2AssaultRifleProjAlt'.default.Speed = 5000;
Class'U2Weapons.U2AssaultRifleProjAlt'.default.MomentumTransfer = 8000;
Class'U2Weapons.U2WeaponEnergyRifle'.default.ClipSize = 30;
Class'U2Weapons.U2FireAltEnergyRifle'.default.FireLastReloadTime = 2.265000;
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Speed = 1400.000000;
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.DamageRadius = 290.000000;
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.LifeSpan = 6.0;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.ShakeRadius = 1024.0;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.ShakeMagnitude = 1.0;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.Speed = 2500.0;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.MaxSpeed = 5000.0;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.LifeSpan = 6.0;
Class'U2Weapons.U2AmmoEnergyRifle'.default.MaxAmmo = 150;
Class'U2Weapons.U2FireAltFlameThrower'.default.FireRate = 0.25;
Class'U2Weapons.U2ProjectileAltFlameThrower'.default.MaxSpeed = 500.0;
Class'U2Weapons.U2ProjectileAltFlameThrower'.default.LifeSpan = 22.0;
Class'U2Weapons.U2ProjectileAltFlameThrower'.default.MomentumTransfer = 500.0;
Class'U2Weapons.U2WeaponFlameThrower'.default.ClipSize = 80;
Class'U2Weapons.U2WeaponFlameThrower'.default.ReloadTime = 2.0;
Class'U2Weapons.U2AmmoFlameThrower'.default.MaxAmmo = 480;
Class'U2Weapons.U2ProjectileFragGrenade'.default.MomentumTransfer = 9000;
Class'U2Weapons.U2ProjectileFragGrenade'.default.MaxSpeed = 2600.0;
Class'U2Weapons.U2ProjectileFragGrenade'.default.Speed = 2600.0;
Class'U2Weapons.U2ProjectileSmokeGrenade'.default.MaxSpeed = 2600.0;
Class'U2Weapons.U2ProjectileSmokeGrenade'.default.Speed = 2600.0;
Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.DamageRadius = 256.0;
Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.MomentumTransfer = 9000.0;
Class'U2Weapons.U2ProjectileConcussionGrenade'.default.DamageRadius = 180.0;
Class'U2Weapons.U2FireGrenade'.default.FireRate = 1.33;
Class'U2Weapons.U2WeaponRocketLauncher'.default.ReloadTime = 2.0;
Class'U2Weapons.U2AmmoRocketLauncher'.default.MaxAmmo = 25;
Class'U2Weapons.U2ProjectileRocketDrunken'.default.Speed = 1200.0;
Class'U2Weapons.U2ProjectileRocketSeeking'.default.Speed = 1200.0;
Class'U2Weapons.U2ProjectileRocket'.default.Speed = 2133.0;//3200 is too much
Class'U2Weapons.U2ProjectileRocket'.default.MaxSpeed = 2133.0;
Class'U2Weapons.U2ProjectileRocket'.default.DamageRadius = 384.0;
Class'U2Weapons.U2WeaponShotgun'.default.ReloadTime = 2.21;
Class'U2Weapons.U2WeaponShotgun'.default.ClipSize = 6;
Class'U2Weapons.U2AmmoShotgun'.default.MaxAmmo = 42;
Class'U2Weapons.U2WeaponSniper'.default.ClipSize = 3;
Class'U2Weapons.U2FireSniper'.default.FireRate = 1.0;
Class'U2Weapons.U2AmmoSniper'.default.MaxAmmo = 18;
Class'U2Weapons.U2FirePistol'.default.FireLastReloadTime = 2.4;
Class'U2Weapons.U2FireAltPistol'.default.FireLastReloadTime = 2.4;
Class'U2Weapons.U2AmmoPistol'.default.MaxAmmo = 45;
Class'U2Weapons.U2DamTypePistol'.default.VehicleDamageScaling = 0.30;
Class'U2Weapons.U2DamTypeAltPistol'.default.VehicleDamageScaling = 0.30;
Class'U2Weapons.U2AssaultRifleFire'.default.DamageMin = 20*k;
Class'U2Weapons.U2AssaultRifleFire'.default.DamageMax = 20*k;
Class'U2Weapons.U2AssaultRifleProjAlt'.default.Damage = 175*k;
Class'U2Weapons.U2ProjectileASExplAlt'.default.Damage = 64.0*k;
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Damage = 120.0*k;
Class'U2Weapons.U2ProjectileEnergyRifle'.default.Damage = 13.0*k;
Class'U2Weapons.U2FireFlameThrower'.default.DamageMin = 15*k;
Class'U2Weapons.U2FireFlameThrower'.default.DamageMax = 15*k;
Class'U2Weapons.U2ProjectileFragGrenade'.default.Damage = 200.0*k;
Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.Damage = 50.0*k;
Class'U2Weapons.U2ProjectileConcussionGrenade'.default.Damage = 15.0*k;
Class'U2Weapons.U2ProjectileRocketDrunken'.default.Damage = 70.0*k;
Class'U2Weapons.U2ProjectileRocketSeeking'.default.Damage = 70.0*k;
Class'U2Weapons.U2ProjectileRocket'.default.Damage = 190.0*k;
Class'U2Weapons.U2ProjectileAltShotgun'.default.Damage = 22.0*k;
Class'U2Weapons.U2FireShotgun'.default.DamageMin = 16*k;
Class'U2Weapons.U2FireShotgun'.default.DamageMax = 16*k;
Class'U2Weapons.U2FireSniper'.default.DamageMin = 75*k;
Class'U2Weapons.U2FireSniper'.default.DamageMax = 75*k;
Class'U2Weapons.U2FirePistol'.default.DamageMin = 40*k;
Class'U2Weapons.U2FirePistol'.default.DamageMax = 40*k;
Class'U2Weapons.U2FireAltPistol'.default.DamageMin = 65*k;
Class'U2Weapons.U2FireAltPistol'.default.DamageMax = 65*k;
Class'U2Weapons.U2ProjectileEMPGrenade'.default.Damage = 140.0*k;
Class'U2Weapons.U2ProjectileToxicGrenade'.default.Damage = 100.0*k;
Class'U2Weapons.U2HurterProxy_Gas'.default.myDamage = 30.0*k;
Class'U2Weapons.U2HurterProxy_Fire'.default.myDamage = 80.0*k;
}
//
//-----------------------------------------------------------
//
//Experimental options - lets you Unuse EMPimp projectile and fire from two CAR barrels
if ((bExperimental) && (!bUseXMPFeel)) { //General U2
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.LifeSpan = 2.0;
Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Damage = 210.0*k;
}
if (bExperimental) { //CAR - nothing's setting it, FireMode independent
Class'U2Weapons.U2AssaultRifleFire'.default.bModeExclusive = false;
Class'U2Weapons.U2AssaultRifleAltFire'.default.bModeExclusive = false;
}
class'U2ProjectileConcussionGrenade'.static.SetFlashbangMode(FlashbangModeString);
}
defaultproperties
{
ReplacedWeaponClassNames0="XWeapons.Minigun"
ReplacedWeaponClassNames1="XWeapons.AssaultRifle"
ReplacedWeaponClassNames2="XWeapons.BioRifle"
ReplacedWeaponClassNames3="XWeapons.ShockRifle"
ReplacedWeaponClassNames4="Onslaught.ONSGrenadeLauncher"
ReplacedWeaponClassNames5="XWeapons.RocketLauncher"
ReplacedWeaponClassNames6="XWeapons.FlakCannon"
ReplacedWeaponClassNames7="XWeapons.SniperRifle"
ReplacedWeaponClassNames8="UTClassic.ClassicSniperRifle"
ReplacedWeaponClassNames9="Onslaught.ONSMineLayer"
ReplacedWeaponClassNames10="XWeapons.Redeemer"
ReplacedWeaponClassNames11="XWeapons.Painter"
ReplacedWeaponClassNames12="XWeapons.LinkGun"
bConfigUseU2Weapon0=True
bConfigUseU2Weapon1=True
bConfigUseU2Weapon2=True
bConfigUseU2Weapon3=True
bConfigUseU2Weapon4=True
bConfigUseU2Weapon5=True
bConfigUseU2Weapon6=True
bConfigUseU2Weapon7=True
bConfigUseU2Weapon8=True
bConfigUseU2Weapon9=True
bConfigUseU2Weapon10=True
bConfigUseU2Weapon11=True
bConfigUseU2Weapon12=True
bUseFieldGenerator=True
bUseProximitySensor=True
U2WeaponClasses(0)=Class'U2Weapons.U2AssaultRifleInv'
U2WeaponClasses(1)=Class'U2Weapons.U2WeaponEnergyRifle'
U2WeaponClasses(2)=Class'U2Weapons.U2WeaponFlameThrower'
U2WeaponClasses(3)=Class'U2Weapons.U2WeaponPistol'
U2WeaponClasses(4)=Class'U2Weapons.U2AutoTurretDeploy'
U2WeaponClasses(5)=Class'U2Weapons.U2WeaponRocketLauncher'
U2WeaponClasses(6)=Class'U2Weapons.U2WeaponGrenadeLauncher'
U2WeaponClasses(7)=Class'U2Weapons.U2WeaponSniper'
U2WeaponClasses(8)=Class'U2Weapons.U2WeaponSniper'
U2WeaponClasses(9)=Class'U2Weapons.U2WeaponRocketTurret'
U2WeaponClasses(10)=Class'U2Weapons.U2WeaponLandMine'
U2WeaponClasses(11)=Class'U2Weapons.U2WeaponLaserTripMine'
U2WeaponClasses(12)=Class'U2Weapons.U2WeaponShotgun' //GE: Has to be in !Level.Game.bAllowVehicles
bIsVehicle(0)=0
bIsVehicle(1)=0
bIsVehicle(2)=0
bIsVehicle(3)=0
bIsVehicle(4)=1
bIsVehicle(5)=0
bIsVehicle(6)=0
bIsVehicle(7)=0
bIsVehicle(8)=0
bIsVehicle(9)=1
bIsVehicle(10)=1
bIsVehicle(11)=1
bIsVehicle(12)=0
bNotVehicle(12)=1
U2AmmoPickupClassNames(0)="U2Weapons.U2AssaultRifleAmmoPickup"
U2AmmoPickupClassNames(1)="U2Weapons.U2PickupAmmoEnergyRifle"
U2AmmoPickupClassNames(2)="U2Weapons.U2PickupAmmoFlameThrower"
U2AmmoPickupClassNames(3)="U2Weapons.U2PickupAmmoPistol"
U2AmmoPickupClassNames(4)="U2Weapons.U2PickupAutoTurret"
U2AmmoPickupClassNames(5)="U2Weapons.U2PickupAmmoRocket"
U2AmmoPickupClassNames(6)="U2Weapons.U2PickupAmmoGrenade"
U2AmmoPickupClassNames(7)="U2Weapons.U2PickupAmmoSniper"
U2AmmoPickupClassNames(8)="U2Weapons.U2PickupAmmoSniper"
U2AmmoPickupClassNames(9)="U2Weapons.U2PickupRocketTurret"
U2AmmoPickupClassNames(10)="U2Weapons.U2PickupLandMine"
U2AmmoPickupClassNames(11)="U2Weapons.U2PickupLaserTripMine"
U2AmmoPickupClassNames(12)="U2Weapons.U2PickupAmmoShotgun"
U2WeaponDisplayText(0)="Include the Combat Assault Rifle"
U2WeaponDisplayText(1)="Replace this with the M32 Duster CAR"
U2WeaponDisplayText(2)="Include the Shock Lance"
U2WeaponDisplayText(3)="Replace this with the Shock Lance"
U2WeaponDisplayText(4)="Use XMP-style fire power?"
U2WeaponDisplayText(5)="Use alternative options?"
U2WeaponDisplayText(6)="Include the Flamethrower"
U2WeaponDisplayText(7)="Replace this with the Vulcan"
U2WeaponDisplayText(8)="Include the Magnum Pistol"
U2WeaponDisplayText(9)="Replace this with the Magnum Pistol"
U2WeaponDisplayText(10)="Include the Auto Turret"
U2WeaponDisplayText(11)="Replace this with the Auto Turret"
U2WeaponDisplayText(12)="Include the Shark Rocket Launcher"
U2WeaponDisplayText(13)="Replace this with the Shark"
U2WeaponDisplayText(14)="Include the Grenade Launcher"
U2WeaponDisplayText(15)="Replace this with the Hydra"
U2WeaponDisplayText(16)="Include the Widowmaker Sniper (1)"
U2WeaponDisplayText(17)="Replace this with the Widowmaker Rifle"
U2WeaponDisplayText(18)="Include the Widowmaker Sniper (2)"
U2WeaponDisplayText(19)="Replace this with the Widowmaker Rifle too"
U2WeaponDisplayText(20)="Include the Rocket Turret"
U2WeaponDisplayText(21)="Replace this with the Rocket Turret"
U2WeaponDisplayText(22)="Include the Land Mine"
U2WeaponDisplayText(23)="Replace this with the Land Mine"
U2WeaponDisplayText(24)="Include the Laser Trip Mine"
U2WeaponDisplayText(25)="Replace this with the Laser Trip Mine"
U2WeaponDisplayText(26)="Include the Crowd Pleaser Shotgun"
U2WeaponDisplayText(27)="Replace this with the Crowd Pleaser"
U2WeaponDisplayText(28)="Include the Field Generator"
U2WeaponDisplayText(29)="Include the Proximity Sensor"
U2WeaponDisplayText(30)="Firepower damping percentage"
U2WeaponDisplayText(31)="Integrate with Shield Reward"
U2WeaponDisplayText(32)="Concussion grenade behaviour"
U2WeaponDescText(0)="Include the M32 Duster Combat Assault Rifle in the game, i.e. enable it?"
U2WeaponDescText(1)="What weapon should be replaced with the CAR. By default it's the Minigun."
U2WeaponDescText(2)="Enable the Shock Lance Energy Rifle?"
U2WeaponDescText(3)="What weapon should be replaced with the Energy Rifle. By default it's the Assault Rifle. NOTE: Changing this value is not recommended."
U2WeaponDescText(4)="If enabled, this option will make all weapon firepower the same as in Unreal II XMP; if not, the firepower is consistent with Unreal II SP."
U2WeaponDescText(5)="If enabled, will make the Shock Lance use another, limited, secondary fire mode and allow Combat Assault Rifle use Unreal: Return to Na Pali fire style (shooting out of 2 barrels)."
U2WeaponDescText(6)="Enable the Vulcan Flamethrower?"
U2WeaponDescText(7)="What weapon should be replaced with the Flamethrower. By default it's the Bio Rifle."
U2WeaponDescText(8)="Enable the Magnum Pistol?"
U2WeaponDescText(9)="What weapon should be replaced with the Magnum Pistol. By default it's the Shock Rifle."
U2WeaponDescText(10)="Enable the Automatic Turret?"
U2WeaponDescText(11)="What weapon should be replaced with the Auto Turret. By default it's the Onslaught Grenade Launcher."
U2WeaponDescText(12)="Enable the Shark Rocket Launcher?"
U2WeaponDescText(13)="What weapon should be replaced with the Shark Rocket Launcher. By default it's the Rocket Launcher."
U2WeaponDescText(14)="Enable the Hydra Grenade Launcher?"
U2WeaponDescText(15)="What weapon should be replaced with the Hydra Grenade Launcher. By default it's the Flak Cannon."
U2WeaponDescText(16)="Should the Lightning Gun be replaced with the Widowmaker Sniper Rifle?"
U2WeaponDescText(17)="What weapon should be replaced with the Widowmaker Sniper Rifle. By default it's the Lightning Gun here."
U2WeaponDescText(18)="Should the Classic Sniper Rifle be replaced with the Widowmaker Sniper Rifle?"
U2WeaponDescText(19)="What weapon should be replaced with the Widowmaker Sniper Rifle. By default it's the Classic Sniper Rifle here."
U2WeaponDescText(20)="Enable the Rocket Turret delpoyable?"
U2WeaponDescText(21)="What weapon should be replaced with the Rocket Turret deployable. By default it's the Mine Layer."
U2WeaponDescText(22)="Enable the Land Mine?"
U2WeaponDescText(23)="What weapon should be replaced with the Land Mine. By default it's the Redeemer."
U2WeaponDescText(24)="Enable the Laser Trip Mine?"
U2WeaponDescText(25)="What weapon should be replaced with the Laser Trip Mine. By default it's the Ion Painter."
U2WeaponDescText(26)="Enable the Crowd Pleaser Shotgun? It won't replace the Link Gun in matches with vehicles."
U2WeaponDescText(27)="What weapon should be replaced with the Crowd Pleaser Shotgun. By default it's the Link Gun. It does not replace it in vehicle matches."
U2WeaponDescText(28)="Enable the Field Generator? If enabled, you start with one."
U2WeaponDescText(29)="Enable the Proximity Sensor? If enabled, you start with one."
U2WeaponDescText(30)="This number controls how powerful all weapons are. By deafult the firepower is set to 55% of the original in order to compensate for the fact that players in UT2004 don't have shields or damage filtering."
U2WeaponDescText(31)="If checked, the Shield Reward mutator produces Unreal II shield pickups."
U2WeaponDescText(32)="Choose between no white overlay, overlay depending on the player's view (XMP style) and overlay depending on the distance from the player (default, foolproof)."
//FirePowerMode=4
DamagePercentage=55
bUseXMPFeel=False
bIntegrateShieldReward=True
FlashbangModeString="FM_DistanceBased"
GroupName="Arena"
FriendlyName="Unreal II or XMP Weapons"
Description="Add the Unreal II weapons to other gametypes. Fully customisable, you can choose between Unreal II and XMP weapon behaviour."
}

View File

@@ -0,0 +1,10 @@
class US3HelloWorld extends GameInfo;
event InitGame( string Options, out string Error )
{
`log( "Hello, world!" );
}
defaultproperties
{
}

93
samples/Volt/tesla.volt Normal file
View File

@@ -0,0 +1,93 @@
// Copyright © 2012-2013, Jakob Bornecrantz. All rights reserved.
// See copyright notice in src/volt/license.d (BOOST ver. 1.0).
module main;
import core.stdc.stdio;
import core.stdc.stdlib;
import watt.process;
import watt.path;
import results;
import list;
import cmd;
int main()
{
auto cmdGroup = new CmdGroup();
bool printOk = true;
bool printImprovments = true;
bool printFailing = true;
bool printRegressions = true;
string compiler = getEnv("VOLT");
if (compiler is null) {
printf("compiler envar not set\n".ptr);
return -1;
}
/// @todo Scan for files
auto tests = testList;
int total;
int passed;
int failed;
int improved;
int regressed;
auto rets = new Result[] (tests.length);
for (size_t i; i < tests.length; i++) {
rets[i] = new Result();
rets[i].runTest(cmdGroup, tests[i], compiler);
}
cmdGroup.waitAll();
for (size_t i; i < tests.length; i++) {
auto ret = rets[i];
total++;
if (ret.ok) {
passed++;
improved += cast(int)!ret.hasPassed;
if (!ret.hasPassed && printImprovments) {
printf("%s: %s, improved!\n".ptr, ret.test.ptr, ret.msg.ptr);
} else if (printOk) {
printf("%s: %s\n".ptr, ret.test.ptr, ret.msg.ptr);
}
} else {
failed++;
regressed += cast(int)ret.hasPassed;
if (ret.hasPassed && printRegressions) {
printf("%s: %s, regressed!\n".ptr, ret.test.ptr, ret.msg.ptr);
} else if (printFailing) {
printf("%s: %s\n".ptr, ret.test.ptr, ret.msg.ptr);
}
}
fflush(stdout);
}
auto xml = fopen("results.xml".ptr, "w+".ptr);
if (xml !is null) {
fprintf(xml, "<testsuites errors=\"%u\" failures=\"%u\" tests=\"%u\">\n".ptr,
regressed, failed - regressed, total);
for (size_t i; i < rets.length; i++) {
rets[i].xmlLog(xml);
}
fprintf(xml, "</testsuites>\n".ptr);
fflush(xml);
fclose(xml);
xml = null;
}
auto rate = cast(float)passed / cast(float)total * 100.f;
printf("Summary: %i tests, %i pass%s, %i failure%s, %.2f%% pass rate, %i regressions, %i improvements.\n".ptr,
total,
passed, (passed == 1 ? "".ptr : "es".ptr),
failed, (failed == 1 ? "".ptr : "s".ptr),
cast(double)rate, regressed, improved);
return regressed ? -1 : 0;
}

10
samples/XC/main.xc Normal file
View File

@@ -0,0 +1,10 @@
int main()
{
int x;
chan c;
par {
c <: 0;
c :> x;
}
return x;
}

Some files were not shown because too many files have changed in this diff Show More