From 38e667adeab6710808858981f919144f32673432 Mon Sep 17 00:00:00 2001 From: Michael Welford Date: Sat, 18 Aug 2018 22:22:46 +0930 Subject: [PATCH] Add in corpus items. --- .gitignore | 1 - corpus/bash.sh | 35 ++++++++++++++++++++++++++++ corpus/cpp.cpp | 34 +++++++++++++++++++++++++++ corpus/css.css | 58 ++++++++++++++++++++++++++++++++++++++++++++++ corpus/html.html | 35 ++++++++++++++++++++++++++++ corpus/js.js | 45 +++++++++++++++++++++++++++++++++++ corpus/php.php | 48 ++++++++++++++++++++++++++++++++++++++ corpus/php_old.php | 34 +++++++++++++++++++++++++++ corpus/python.py | 32 +++++++++++++++++++++++++ 9 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 corpus/bash.sh create mode 100644 corpus/cpp.cpp create mode 100644 corpus/css.css create mode 100644 corpus/html.html create mode 100644 corpus/js.js create mode 100644 corpus/php.php create mode 100644 corpus/php_old.php create mode 100644 corpus/python.py diff --git a/.gitignore b/.gitignore index 1ab5c7f..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -corpus/ diff --git a/corpus/bash.sh b/corpus/bash.sh new file mode 100644 index 0000000..cd73db1 --- /dev/null +++ b/corpus/bash.sh @@ -0,0 +1,35 @@ +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi +# +# aliases +alias grpe=grep +alias grep='grep --color --line-number' +alias vim="vim -p" +alias rebash="source ~/.bashrc" + +alias install='sudo apt-get -y install' +alias search='apt-cache search' +alias purge='sudo apt-get purge' + +export EDITOR=vim + +# set up the prompt to the hostname +shopt -s checkwinsize +PS1="\e[1;35m[\w] --- \@ \d \n$>\[\e[0m\]" +PS2="\e[1;35m->\[\e[0m\]" + +#-------------------------------------------------- +# grabs some definitions from google +#-------------------------------------------------- +define () { + lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}" | grep -m 25 -w "*" | sed 's/;/ -/g' | cut -d- -f5 > /tmp/templookup.txt + if [[ -s /tmp/templookup.txt ]] ;then + until ! read response + do + echo "${response}" + done < /tmp/templookup.txt + else + echo "Sorry $USER, I can't find the term \"${1} \"" + fi diff --git a/corpus/cpp.cpp b/corpus/cpp.cpp new file mode 100644 index 0000000..e38dd9b --- /dev/null +++ b/corpus/cpp.cpp @@ -0,0 +1,34 @@ +#include "algostuff.hpp" +using namespace std; + +bool bothEvenOrOdd (int elem1, int elem2) +{ + return elem1 % 2 == elem2 % 2; +} + +int main() +{ + vector coll1; + list coll2; + + float m = 40.0f; + + INSERT_ELEMENTS(coll1,1,7); + INSERT_ELEMENTS(coll2,3,9); + + PRINT_ELEMENTS(coll1,"coll1: \n"); + PRINT_ELEMENTS(coll2,"coll2: \n"); + + // check whether both collections are equal + if (equal (coll1.begin(), coll1.end(), // first range + coll2.begin())) { // second range + cout << "coll1 == coll2" << endl; + } /* TODO Shouldn't there be an 'else' case? */ + + // check for corresponding even and odd elements + if (equal (coll1.begin(), coll1.end(), // first range + coll2.begin(), // second range + bothEvenOrOdd)) { // comparison criterion + cout << "even and odd elements correspond" << endl; + } +} diff --git a/corpus/css.css b/corpus/css.css new file mode 100644 index 0000000..633fe7c --- /dev/null +++ b/corpus/css.css @@ -0,0 +1,58 @@ +/* A comment. */ +@font-face { + font-family: 'Fira Code'; + src: url('eot/FiraCode-Bold.eot'); + src: url('eot/FiraCode-Bold.eot') format('embedded-opentype'), + url('woff2/FiraCode-Bold.woff2') format('woff2'), + url('woff/FiraCode-Bold.woff') format('woff'), + url('ttf/FiraCode-Bold.ttf') format('truetype'); + font-weight: 700; + font-style: normal; +} + +html, body { + padding: 0; + margin: 0; +} + +html { + font-size: 14px; +} + +@media screen and (min-width: 320px) { + html { + font-size: calc(11px + 9 * ((100vw - 320px) / 680)); + } +} + +@media screen and (min-width: 1000px) { + html { + font-size: 21px; + } +} + +body { + font-family: "Fira Code", monospace; + background: #000002; + color: #d4d4d9; + font-feature-settings: "calt" 1; /* Enable ligatures for IE 10+, Edge */ + text-rendering: optimizeLegibility; /* Force ligatures for Webkit, Blink, Gecko */ + -webkit-font-smoothing: subpixel-antialiased; +} + +#canvas { + display: block; + z-index: -1; + position: fixed; + top: 0; + left: 0; +} + +code, pre { + font-family: "Fira Code", monospace; + background: transparent; +} + +.blah #thing:nth-child(1) { + display: inline; +} diff --git a/corpus/html.html b/corpus/html.html new file mode 100644 index 0000000..1b89aa9 --- /dev/null +++ b/corpus/html.html @@ -0,0 +1,35 @@ + + + Name Submission + + + + + + +

Submit your Name here!

+

We'll get more information on the following pages..

+
+ First name >
+ Last name: >
+ +
+

Click "Submit" to continue..

+ +

A nested List:

+ Google +
    +
  • Coffee & Tea
  • +
  • Tea +
      +
    • Black tea
    • +
    • Green tea +
        +
      • China
      • +
      • Africa
      • +
      +
    • +
    +
  • +
  • Milk
  • +
diff --git a/corpus/js.js b/corpus/js.js new file mode 100644 index 0000000..fe9c7e8 --- /dev/null +++ b/corpus/js.js @@ -0,0 +1,45 @@ +/** + * @file + * + * Watch changes to *.es6.js files and compile them to ES5 during development. + * + * @internal This file is part of the core javascript build process and is only + * meant to be used in that context. + */ + +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const chokidar = require('chokidar'); + +const changeOrAdded = require('./changeOrAdded'); +const log = require('./log'); + +// Match only on .es6.js files. +const fileMatch = './**/*.es6.js'; +// Ignore everything in node_modules +const watcher = chokidar.watch(fileMatch, { + ignoreInitial: true, + ignored: './node_modules/**' +}); + +const unlinkHandler = (err) => { + if (err) { + log(err); + } +}; + +console.log('Check.'); + +// Watch for filesystem changes. +watcher + .on('add', changeOrAdded) + .on('change', changeOrAdded) + .on('unlink', (filePath) => { + const fileName = filePath.slice(0, -7); + fs.stat(`${fileName}.js`, () => { + fs.unlink(`${fileName}.js`, unlinkHandler); + }); + }) + .on('ready', () => log(`Watching '${fileMatch}' for changes.`)); diff --git a/corpus/php.php b/corpus/php.php new file mode 100644 index 0000000..d2af06a --- /dev/null +++ b/corpus/php.php @@ -0,0 +1,48 @@ +loadUserByName($reviewer_id); + if (!empty($reviewer)) { + return reset($reviewer); + } + + $user_storage = $this->entityTypeManager->getStorage('user'); + $reviewer = $user_storage->create(); + $reviewer->setUsername($reviewer_id) + ->enforceIsNew() + ->activate() + ->set('roles', ['reviewer']) + ->set(CcspUserService::FIELD_FULL_NAME, $reviewer_name) + ->setEmail($email) + ->save(); + + // @TODO fix this up, plaz. + return $reviewer; + } + +} diff --git a/corpus/php_old.php b/corpus/php_old.php new file mode 100644 index 0000000..fc96c9a --- /dev/null +++ b/corpus/php_old.php @@ -0,0 +1,34 @@ +prepare($sql); + } +} diff --git a/corpus/python.py b/corpus/python.py new file mode 100644 index 0000000..a1c027d --- /dev/null +++ b/corpus/python.py @@ -0,0 +1,32 @@ +def dump_args(func): + "This decorator dumps out the arguments passed to a function before calling it" + argnames = func.func_code.co_varnames[:func.func_code.co_argcount] + fname = func.func_name + def echo_func(*args,**kwargs): + print fname, ":", ', '.join( + '%s=%r' % entry + for entry in zip(argnames,args) + kwargs.items()) + return func(*args, **kwargs) + return echo_func + +@dump_args +def f1(a,b,c): + print a + b + c + +f1(1, 2, 3) + +def precondition(precondition, use_conditions=DEFAULT_ON): + return conditions(precondition, None, use_conditions) + +def postcondition(postcondition, use_conditions=DEFAULT_ON): + return conditions(None, postcondition, use_conditions) + +class conditions(object): + __slots__ = ('__precondition', '__postcondition') + + def __init__(self, pre, post, use_conditions=DEFAULT_ON): + if not use_conditions: + pre, post = None, None + + self.__precondition = pre + self.__postcondition = post