text:
module('lively.ide.tools.ASTEditor').requires("lively.ide.tools.CommandLine", 'lively.ast.acorn')
.requiresLib({url: 'https://lively-web.org/core/lib/grasp.js', loadTest: function() { return typeof grasp !== 'undefined' }})
.toRun(function() {

lively.BuildSpec('lively.ide.tools.ASTEditor', {
    _Extent: lively.pt(727.0,457.0),
    className: "lively.morphic.Window",
    contentOffset: lively.pt(3.0,22.0),
    name: "ASTEditor",
    sourceModule: "lively.morphic.Widgets",
    draggingEnabled: true,
    submorphs: [{
        _BorderColor: Color.rgb(95,94,95),
        _Extent: lively.pt(721.0,432.0),
        _Fill: Color.rgb(231,231,231),
        _Position: lively.pt(3.0,22.0),
        className: "lively.morphic.Box",
        doNotSerialize: ["state"],
        droppingEnabled: false,
        isCopyMorphRef: true,
        lastFocused: {isMorphRef: true,name: "searchInput"},
        layout: { adjustForNewBounds: true, resizeHeight: true, resizeWidth: true },
        morphRefId: 1,
        name: "ASTEditorPane",
        state: { target: null },
        submorphs: [{
            _AutocompletionEnabled: true,
            _BorderColor: Color.rgb(95,94,95),
            _Extent: lively.pt(712.0,338.0),
            _FontSize: 12,
            _LineWrapping: false,
            _Position: lively.pt(4.0,65.0),
            _ShowActiveLine: false,
            _ShowErrors: true,
            _ShowGutter: false,
            _ShowIndents: true,
            _ShowInvisibles: false,
            _ShowPrintMargin: false,
            _ShowWarnings: false,
            _SoftTabs: true,
            _TextMode: "text",
            _Theme: "chrome",
            className: "lively.morphic.CodeEditor",
            droppingEnabled: false,
            grabbingEnabled: false,
            lastFocused: { isMorphRef: true, name: "CommandLine" },
            layout: { resizeHeight: true, resizeWidth: true },
            name: "output",
            sourceModule: "lively.ide.CodeEditor"
        },

        lively.BuildSpec("lively.ide.tools.CommandLine").customize({
            labelString: 'query: ',
            _Extent: lively.pt(712.0,20.0),
            _Position: lively.pt(4.0,5.0),
            layout: {
                resizeWidth: true
            },
            name: "searchInput"
        }),

        lively.BuildSpec("lively.ide.tools.CommandLine").customize({
            _Extent: lively.pt(712.0,20.0),
            _Position: lively.pt(4.0,35.0),
            layout: { resizeWidth: true },
            name: "replaceInput",
            labelString: 'replace with: '
        }),

        {
            _BorderColor: Color.rgb(189,190,192),
            _BorderRadius: 5,
            _BorderWidth: 1,
            _Extent: lively.pt(80.0,20.0),
            _Position: lively.pt(4.0,406.0),
            className: "lively.morphic.Button",
            label: "show target",
            layout: { moveVertical: true },
            name: "showTargetButton",
        },{
            _BorderColor: Color.rgb(189,190,192),
            _BorderRadius: 5,
            _BorderWidth: 1,
            _Extent: lively.pt(80.0,20.0),
            _Position: lively.pt(86.0,406.0),
            className: "lively.morphic.Button",
            droppingEnabled: false,
            grabbingEnabled: false,
            isPressed: false,
            label: "set target",
            layout: { moveVertical: true },
            name: "setTargetButton",
            toggle: false,
            value: false,
        },{
            _BorderColor: Color.rgb(189,190,192),
            _BorderRadius: 5,
            _BorderWidth: 1,
            _Extent: lively.pt(80.0,20.0),
            _Position: lively.pt(168.0,406.0),
            className: "lively.morphic.Button",
            droppingEnabled: false,
            grabbingEnabled: false,
            isPressed: false,
            label: "apply",
            layout: { moveVertical: true },
            name: "applyButton",
            sourceModule: "lively.morphic.Widgets",
            toggle: false,
            value: false,
        },{
            _Extent: lively.pt(36.7,18.0),
            _FontFamily: "Arial, sans-serif",
            _FontSize: 8,
            _HandStyle: "default",
            _InputAllowed: false,
            _Padding: lively.rect(5,5,0,0),
            _Position: lively.pt(604.0,408.0),
            allowInput: false,
            className: "lively.morphic.Text",
            droppingEnabled: false,
            fixedHeight: true,
            fixedWidth: true,
            grabbingEnabled: false,
            layout: {
                moveHorizontal: true,
                moveVertical: true,
                resizeWidth: false
            },
            name: "queryModeLabel",
            textString: "query"
        },{
            _ClipMode: "auto",
            _Extent: lively.pt(77.0,25.0),
            _Fill: Color.rgb(243,243,243),
            _Position: lively.pt(641.0,408.0),
            className: "lively.morphic.DropDownList",
            droppingEnabled: true,
            itemList: ["equery","squery"],
            layout: {
                moveHorizontal: true,
                moveVertical: true
            },
            name: "querySelectionList",
            selection: "equery"
        },{
            _ClipMode: "auto",
            _Extent: lively.pt(75.0,25.0),
            _Fill: Color.rgb(243,243,243),
            _Position: lively.pt(516.0,408.0),
            className: "lively.morphic.DropDownList",
            itemList: ["tree","ast","source","diff"],
            layout: {
                moveHorizontal: true,
                moveVertical: true
            },
            name: "outputTypeSelectionList",
            selection: "source",
        },{
            _Extent: lively.pt(36.7,18.0),
            _FontFamily: "Arial, sans-serif",
            _FontSize: 8,
            _HandStyle: "default",
            _InputAllowed: false,
            _Padding: lively.rect(5,5,0,0),
            _Position: lively.pt(476.0,408.0),
            allowInput: false,
            className: "lively.morphic.Text",
            droppingEnabled: false,
            fixedHeight: true,
            fixedWidth: true,
            grabbingEnabled: false,
            layout: {
                moveHorizontal: true,
                moveVertical: true,
                resizeWidth: false
            },
            name: "queryModeLabel1",
            textString: "output"
        },{
            _BorderColor: Color.rgb(189,190,192),
            _BorderRadius: 5,
            _BorderWidth: 1,
            _Extent: lively.pt(80.0,20.0),
            _Position: lively.pt(332.0,406.0),
            className: "lively.morphic.Button",
            droppingEnabled: false,
            grabbingEnabled: false,
            isPressed: false,
            label: "about",
            layout: {
                moveVertical: true
            },
            name: "aboutButton",
            sourceModule: "lively.morphic.Widgets",
            toggle: false,
            value: false,
            connectionRebuilder: function connectionRebuilder() {
            lively.bindings.connect(this, "fire", this.get("ASTEditorPane"), "aboutPressed", {});
        }
        },{
            _BorderColor: Color.rgb(189,190,192),
            _BorderRadius: 5,
            _BorderWidth: 1,
            _Extent: lively.pt(80.0,20.0),
            _Position: lively.pt(250.0,406.0),
            _StyleClassNames: ["Morph","Button"],
            className: "lively.morphic.Button",
            droppingEnabled: false,
            grabbingEnabled: false,
            isPressed: false,
            label: "as JS",
            layout: {
                moveVertical: true
            },
            name: "extractExpressionButton",
            sourceModule: "lively.morphic.Widgets",
            toggle: false,
            value: false,
            connectionRebuilder: function connectionRebuilder() {
            lively.bindings.connect(this, "fire", this.get("ASTEditorPane"), "extractCommand", {});
        }
        }],
        aboutPressed: function aboutPressed() {

        var t = this.world().addTextWindow({title: 'About AST Editor', extent: pt(700, 400)});

        t.applyStyle({
            fill: Color.white
        });

        var markup = [
            ["The AST editor uses the ",{}],
            ["graspjs",{ uri: "http://graspjs.com" }],
            [" library to match and transform JavaScript code. graspjs supports two different matching modes: ", {}],
            ["equery", {italics: 'italic'}],
            [" and ", {}],
            ["squery", {italics: 'italic'}],
            [".\n\nEquery (\"example query\") matches JavaScript-like expressions with wildcards. Example:\n", {}],
            ["  __.assertEquals($first, _$rest)", {fontFamily: "monospace" }],
            ["\n\nSquery uses a matching scheme similar to CSS selectors to match AST nodes. Example:\n",{}],
            ["  statement > *[callee.property=#assertEquals]", {fontFamily: "monospace" }],
            ["\n\nThose query expressions can be used to do strucural searches and replacements based on the JavaScript AST. With equery it is possible to bind AST subtrees to names to use those in the replacements. The equery example from above binds the first argument to ",{}],
            ["assertEquals", {fontFamily: "monospace" }],
            [" to ", {}],
            ["first", {fontFamily: "monospace" }],
            [" and the remaining arguments to ", {}],
            ["rest", {fontFamily: "monospace" }],
            [". Those can be reused in an replacement expression:\n", {}],
            ["  expect({{first}}).to.equal({{rest | join \", \"}})", {fontFamily: "monospace" }],
            ["\n\n\nMore information can be found here: ",{}],
            ["http://graspjs.com/docs/",{uri: "http://graspjs.com/docs/" }],
            ["\n",{}]];

        t.setRichTextMarkup(markup);
        t.getWindow().comeForward();
    },
        applyPressed: function applyPressed() {
        var t = this.state.target;
        if (!t) { show('no target'); return; }
        var patched = JsDiff.applyPatch(t.textString, this.computePatch());
        t.textString = patched;
        this.searchInputChanged();
    },
        computePatch: function computePatch() {
        var search     = this.get('searchInput').getInput();
        var replace    = this.get('replaceInput').getInput();
        var queryMode  = this.get('querySelectionList').selection || 'equery';
        var code       = this.getTargetCode();

        var replacement = grasp.replace(queryMode, search, replace, code) || '';
        if (Object.isArray(replacement)) replacement = replacement.join('\n\n\n//==============\n\n\n');
        return JsDiff.createPatch(this.getFileName(), code, replacement);
    },
        ensureLibs: function ensureLibs(thenDo) {
        // this.ensureLibs(function() { alertOK('ok'); });
        Functions.composeAsync(
            function(next) { lively.require('lively.ast.acorn').toRun(function() { next(); }); },
            function(next) { JSLoader.loadJs(lively.module("lib.jsdiff.jsdiff").uri().toString()); Functions.waitFor(2000, function() { return typeof JsDiff !== 'undefined'; }, next); },
            function(next) {
                JSLoader.loadJs(URL.codeBase.withFilename('lib/grasp.js').toString()); Functions.waitFor(2000, function() { return typeof grasp !== 'undefined'; }, next);

                }
        )(function(err) { thenDo && thenDo.call(this, err); }.bind(this))
    },
        extractCommandSource: function extractCommandSource() {

        var query = this.get("searchInput").getInput();
        var replace = this.get("replaceInput").getInput();
        var queryMode  = this.get('querySelectionList').selection || 'equery';
        var target = this.state.target
        var getCodeExpression;

        if (target) {
            if (target.name && $morph(target.name) === target) getCodeExpression = "$morph('" + target.name + "')";
            else getCodeExpression = "$world.getMorphById('" + target.id + "')";
            getCodeExpression += '.textString';
        } else getCodeExpression = '';

        if (replace) {

            var graspCode = Strings.format("grasp.replace('%s', '%s', '%s', %s)",
                queryMode, query, replace, getCodeExpression);

        } else {

            var graspCode = Strings.format("grasp.search('%s', '%s', %s)",
                queryMode, query, getCodeExpression);

        }
        return graspCode;
        },

        extractCommand: function extractCommand() {

        $world.addCodeEditor({
            title: 'grasp expression',
            content: this.extractCommandSource()
        }).getWindow().comeForward();

    },
        focusMove: function focusMove(delta, n) {
        // delta=-1, focIdx = 0

        var focusTargets = [
            this.get('searchInput'),
            this.get('replaceInput'),
            this.get('output'),
            this.get('querySelectionList'),
            this.get('outputTypeSelectionList')];

        var newIdx;

        if (delta !== undefined) {
            var focused = lively.morphic.Morph.focusedMorph(),
                focIdx = focusTargets.indexOf(focused);
            newIdx = (focIdx+delta) % focusTargets.length;
        } else if (n !== undefined) newIdx = n;
        else newIdx = 0;

        if (newIdx < 0) newIdx = focusTargets.length-1;
        var focTarget = focusTargets[newIdx];

        focTarget && focTarget.focus();
    },
        getFileName: function getFileName() {

        var t = this.state.target;
        if (!t) return 'no filename';

        if (t.getTargetFilePath()) return t.getTargetFilePath();

        return t.name ? '<' + t.name + '>' : String(t);
    },
        getTargetCode: function getTargetCode() {
        return this.state.target ? this.state.target.textString : '';
    },
        init: function init() {
        this.reset();
        this.startStepping(1000, 'update');
    },
        onFromBuildSpecCreated: function onFromBuildSpecCreated() {
        this.onLoad();
    },
        onKeyDown: function onKeyDown(evt) {
        var sig = evt.getKeyString();

        function selectNext(list) {
            var idx = list.selectedLineNo;
            list.saveSelectAt((idx+1) % (list.getList().length));
        }

        var sel = this.get('outputTypeSelectionList')
        switch(sig) {
            case 'Alt-Q': selectNext(this.get('querySelectionList')); evt.stop(); return true;
            case 'Alt-O': selectNext(this.get('outputTypeSelectionList')); evt.stop(); return true;
            case 'Alt-A': this.applyPressed(); evt.stop(); return true;
            case 'Alt-C': this.extractCommand(); evt.stop(); return true;
            case 'Alt-Up': this.focusMove(-1); evt.stop(); return true;
            case 'Alt-Down': this.focusMove(1); evt.stop(); return true;
            case 'F1': this.focusMove(undefined, 0); evt.stop(); return true;
            case 'F2': this.focusMove(undefined, 1); evt.stop(); return true;
            case 'F3': this.focusMove(undefined, 2); evt.stop(); return true;
            case 'F4': this.focusMove(undefined, 3); evt.stop(); return true;
            case 'F5': this.focusMove(undefined, 4); evt.stop(); return true;
            case 'Control-V': case 'PageDown':
                if (!this.get('output').isFocused()) {
                    this.get('output').scrollPage('down');
                    evt.stop(); return true;
                }
                break;
            case 'Alt-V': case 'PageUp':
                if (!this.get('output').isFocused()) {
                    this.get('output').scrollPage('up');
                    evt.stop(); return true;
                }
                break;

            default: return $super(evt);
        }
    },
        onLoad: function onLoad() {
        this.ensureLibs(function(err) {
            if (err) {
                show("Error loading AST Editor: " + err);
            } else {
                alertOK('graspjs loaded');
                this.init();
            }
        });
    },
        onWindowGetsFocus: function onWindowGetsFocus() {
        this.get('searchInput').focus();
    },
        openOn: function openOn(codeeditor, thenDo) {
        this.ensureLibs(function(err) {
            if (err) thenDo && thenDo(err);
            else {
                this.init();
                this.state.target = codeeditor;
                thenDo && thenDo(null, this);
            }
        })
    },
        replaceInputChanged: function replaceInputChanged() {
        this.searchInputChanged();
    },
        reset: function reset() {

        this.getWindow().setTitle('AST Editor');
        this.getWindow().name = 'ASTEditor';
        this.name = 'ASTEditorPane';

        lively.bindings.noUpdate(function() {
            this.get('searchInput').setInput("");
            this.get('replaceInput').setInput("");
            this.get('output').textString = "";

            lively.bindings.connect(this.get('searchInput'), 'textString', this, 'searchInputChanged');
            lively.bindings.connect(this.get('replaceInput'), 'textString', this, 'replaceInputChanged');
            lively.bindings.connect(this.get('showTargetButton'), 'fire', this, 'showTargetPressed');
            lively.bindings.connect(this.get('setTargetButton'), 'fire', this, 'setTargetPressed');
            lively.bindings.connect(this.get('applyButton'), 'fire', this, 'applyPressed');
            lively.bindings.connect(this.get('aboutButton'), 'fire', this, 'aboutPressed');
            lively.bindings.connect(this.get('extractExpressionButton'), 'fire', this, 'extractCommand');

            lively.bindings.connect(this.get('querySelectionList'), 'selection', this, 'searchInputChanged');

            lively.bindings.connect(this.get('outputTypeSelectionList'), 'selection', this, 'searchInputChanged');

            this.get('querySelectionList').setList(['equery', 'squery']);
            this.get('outputTypeSelectionList').setList(['tree', 'ast', 'source', 'diff']);

        }.bind(this));

        this.doNotSerialize = ['state'];
        this.resetState();

        // this.getWindow().buildSpec().createMorph().openInWorld()
    },
        resetState: function resetState() {
        this.state = {
            target: null
        }
    },
        searchInputChanged: function searchInputChanged() {

        var self       = this;
        var search     = this.get('searchInput').getInput();
        var replace    = this.get('replaceInput').getInput();
        var outputMode = this.get('outputTypeSelectionList').selection || 'source';
        var queryMode  = this.get('querySelectionList').selection || 'equery';
        var code       = this.getTargetCode();

        if (!search || !search.length) return;

        try {
            var nodes = grasp.search(queryMode, search, code);

            if (!nodes.length) throw new Error('Nothing matched');

            switch (outputMode) {
                case 'tree':   printASTTree(); break;
                case 'source': printSource(); break;
                case 'ast':    printAST(); break;
                case 'diff':   printReplacementDiff(); break;
                default:       throw new Error('unknown output mode ' + outputMode);
            }

        } catch (e) { handleError(e); }

        // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

        function printSource() {
            self.get('output').setTextMode("javascript");
            self.get('output').textString = Strings.format("// Found %s matches\n%s",
                nodes.length,
                nodes.map(function(n, i) {
                    return "// match " + i + ':\n' + code.slice(n.start, n.end);
                }).join('\n\n'));
        }

        function printAST() {
            self.get('output').setTextMode("json");
            self.get('output').textString = Strings.format("%s",
                nodes.map(function(n, i) {
                    return "// match " + i + ':\n' + Objects.inspect(n, {maxDepth: 3});
                }).join('\n\n\n'));
        }

        function printASTTree() {
            self.get('output').setTextMode("text");

            self.get('output').textString = Strings.format("// Found %s matches\n%s",
                nodes.length,
                nodes.map(function(n, i) {
                    acorn.walk.addSource(n, code.slice(n.start, n.end), false, true);
                    return "// match " + i + ':\n' + lively.ast.acorn.printAst(n, {printSource: true, printPositions: true});
                }).join('\n\n'));
        }

        function printReplacementDiff() {
            var p = self.computePatch();
            self.get('output').setTextMode("diff");
            self.get('output').textString = p
        }

        function handleError(e) {
            self.get('output').setTextMode("text");
            self.get('output').textString = String(e);
        }

    },
        setTargetPressed: function setTargetPressed() {

        var world = this.world(),
            self = this;

        alertOK('Click on the text to select');

        // ----

        function select() {
            var morph = world.hands[0].morphUnderMe();
            if (!morph || !morph.isCodeEditor) {
                show('invalid selection');
                return;
            }
            morph.show();
            alertOK((morph.name || morph) + " selected");
            self.state.target = morph;
            self.searchInputChanged();
        };

        (function() {
            lively.bindings.connect(world, 'onMouseUp', select, 'call', {
                removeAfterUpdate: true});
        }).delay(0.2);

    },
        showTargetPressed: function showTargetPressed() {
        show(this.state.target || 'no target');
    },
        update: function update() {
        var t = this.state.target;
        if (!t) return;
        if (this.state._lastLength !== t.textString.length) this.searchInputChanged();
        this.state._lastLength = t.textString.length;
    }
    }],
    targetMorph: {
        isMorphRef: true,
        name: "ASTEditorPane"
    },
    titleBar: "AST Editor"
});

Object.extend(lively.ide.tools.ASTEditor, {

    openOn: function(codeEditor, thenDo) {
        var win = lively.BuildSpec('lively.ide.tools.ASTEditor').createMorph()
        var ed = win.targetMorph;
        ed.openOn(codeEditor, thenDo);
        return win.openInWorldCenter().comeForward();
    }

});

}) // end of module


text:
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
    Created on : 24/01/2016, 11:51:06
    Author     : eibertek
*/
/* latin */
@font-face {
  font-family: Share-Regular;
  src: local('Share-Regular'), url(Share-Regular.ttf);
 // unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}

html,body {
    height: 100%;
    background-color: grey;
}

.parallax {
  position:absolute;
  left: 0;
  top: 0;
}

.information.welcome {
    padding-top: 30px;
    text-shadow: 1px 0px 4px rgba(0,0,0, 0.5);
    width: 100%;
}

.modulos {
    display: block;
    margin: 40px auto;
    width: 50%;
}

.finanzas {
    font-size: 60px;
}

.usuarios {
    font-size: 60px;
}
.image1 {
    background-image: url("../images/opl-parallax-universe.jpg");
    background-position: center;
    background-size: contain;
    background-attachment: fixed;
    background-repeat: repeat;
}
.image2 {
    background-image: url("../images/informatic2.jpg");
}

.image3 {
    background-image: url("../images/universe1.jpg");
    height: 900px;
}

a.btnEnter{
    background-image: url("../images/enter_btn.png");
    background-size: 100px;
    background-repeat: no-repeat;
    height: 100px;
    width: 100px;
}

a.btnEnter:active{
    background-image: url("../images/enter_btn.png");
    -webkit-filter:invert(100%);
    filter:progid:DXImageTransform.Microsoft.BasicImage(invert='1');
}
#container {
        color: white;
	font: 20px/1 'Share-Regular', cursive;
	text-shadow: 0px 0px 4px rgba(255,255,255, 0.5);
}
.photo {
  background-attachment: fixed;
  background-position: 50% 0%;
  background-repeat: no-repeat;
  background-color: grey;
  position: relative;
}

redpajama_set_name: RedPajamaGithub


text:
<?php
/**
 *
 *  PSR-3 compatible logger.
 *
 */
namespace CssCrush;

class Logger
{
    /**
     * System is unusable.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function emergency($message, array $context = [])
    {
        $this->error($message, $context);
    }

    /**
     * Action must be taken immediately.
     *
     * Example: Entire website down, database unavailable, etc. This should
     * trigger the SMS alerts and wake you up.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function alert($message, array $context = [])
    {
        $this->error($message, $context);
    }

    /**
     * Critical conditions.
     *
     * Example: Application component unavailable, unexpected exception.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function critical($message, array $context = [])
    {
        $this->error($message, $context);
    }

    /**
     * Runtime errors that do not require immediate action but should typically
     * be logged and monitored.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function error($message, array $context = [])
    {
        trigger_error($message, E_USER_ERROR);
    }

    /**
     * Exceptional occurrences that are not errors.
     *
     * Example: Use of deprecated APIs, poor use of an API, undesirable things
     * that are not necessarily wrong.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function warning($message, array $context = [])
    {
        trigger_error($message, E_USER_WARNING);
    }

    /**
     * Normal but significant events.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function notice($message, array $context = [])
    {
        trigger_error($message, E_USER_NOTICE);
    }

    /**
     * Interesting events.
     *
     * Example: User logs in, SQL logs.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function info($message, array $context = [])
    {
        $this->debug($message, $context);
    }

    /**
     * Detailed debug information.
     *
     * @param string $message
     * @param array $context
     * @return null
     */
    public function debug($message, array $context = [])
    {
        if (! empty($context['label'])) {
            $label = PHP_EOL . "$label" . PHP_EOL . str_repeat('=', strlen($label)) . PHP_EOL;
        }
        else {
            $label = '';
        }

        if (is_string($message)) {
            Crush::$process->debugLog[] = "$label$message";
        }
        else {
            ob_start();
            ! empty($context['var_dump']) ? var_dump($message) : print_r($message);
            Crush::$process->debugLog[] = $label . ob_get_clean();
        }
    }

    /**
     * Logs with an arbitrary level.
     *
     * @param mixed $level
     * @param string $message
     * @param array $context
     * @return null
     */
    public function log($level, $message, array $context = [])
    {
        $log_levels = array_flip(get_class_methods(__CLASS__));
        unset($log_levels['log']);

        if (isset($log_levels[$level])) {
            return $this->$level($message, $context);
        }
    }
}


text:
Space Warps
-----------

Crowd-sourced discovery of gravitational lenses. We are a Zooniverse project,
which launched in Spring 2013 at [http://spacewarps.org](http://spacewarps.org). This repository contains code and documentation
being developed by the science team.

Two papers on the first dataset we searched for lenses, the CFHTLS, are:

* [Marshall et al 2015: *"Space Warps I: Crowd-sourcing the Discovery of Gravitational Lenses"*](https://github.com/drphilmarshall/SpaceWarps/raw/master/doc/sw-system.pdf)
* [More et al 2015: *"Space Warps II: New Gravitational Lens Candidates from the CFHTLS Discovered through Citizen Science"*](https://github.com/drphilmarshall/SpaceWarps/raw/master/doc/sw-cfhtls.pdf)

The web app itself is being developed [here](https://github.com/zooniverse/Lens-Zoo) as part of the [Zooniverse](http://zooniverse.org) project. The simulated lenses used in the training sample are created with [SIMCT](https://github.com/anupreeta27/SIMCT). If you are interested in building a site like Space Warps using Zooniverse techology, keep an eye on their website or drop them a line.

See also, for fun:
* [LensToy](http://github.com/slowe/LensToy/)
* [LensWrangler](http://github.com/drphilmarshall/LensWrangler/).

### Contact

* Phil Marshall (KIPAC, SLAC National Accelerator Laboratory)
* Aprajita Verma (Physics Department, University of Oxford)
* Anupreeta More (Kavli IPMU, University of Tokyo)

You can email us at [spacewarpspi@googlegroups.com](mailto:spacewarpspi@googlegroups.com), or just [send us an issue!](https://github.com/drphilmarshall/SpaceWarps/issues)

### License

All our code is free to re-use under the MIT license. If you make use of any of it in your research, please cite us at this website, and (for now) as *"(Marshall et al 2015, More et al 2015)"*. Please do get in touch though - it would be great to collaborate on improving the SWAP analysis, for example!


text:
namespace nt2
{

  namespace tag
  {
    struct outer_fold_step_outcache_;
    struct outer_fold_step_incache_;
    struct fold_;
  }

  // Outer Fold worker
  template<class BackEnd, class Site, class Out, class In, class Neutral,class Bop,class Uop>
  struct worker<tag::outer_fold_,BackEnd,Site,Out,In,Neutral,Bop,Uop>
  {
      typedef typename boost::remove_reference<In>::type::extent_type           extent_type;
      typedef typename Out::value_type                                          value_type;
      typedef typename details::target_type_from_site<Site,value_type>::type    target_type;

      worker(Out& out, In& in, Neutral const& n, Bop const& bop, Uop const& uop)
      : out_(out), in_(in), neutral_(n), bop_(bop), uop_(uop)
      {}

      void operator()(std::size_t begin, std::size_t size) const
      {
        extent_type ext = in_.extent();
        static const std::size_t N = boost::simd::meta::cardinal_of<target_type>::value;
        std::size_t ibound = boost::fusion::at_c<0>(ext);
        std::size_t mbound = boost::fusion::at_c<1>(ext);
        std::size_t obound = boost::fusion::at_c<2>(ext);
        std::size_t iboundxmbound =  ibound * mbound;

        std::size_t cache_line_size = nt2::config::top_cache_line_size(2) / sizeof(value_type);
        std::size_t grain  = cache_line_size;

        // Compute the lower multiple of cache_line of ibound
        std::size_t cache_bound = (cache_line_size / (sizeof(value_type)*N))*N;
        std::size_t iibound =  boost::simd::align_under(ibound, cache_bound);

        // Compute the lower multiple of grain of mbound
        std::size_t mmbound =  (mbound/grain)*grain;

        if( iibound < grain )
        {
          // Instanciate the spawner/worker associated to the mbound dimension
          nt2::spawner<tag::fold_, BackEnd, target_type> s_simd;
          nt2::spawner<tag::fold_, BackEnd, value_type> s_scalar;

          nt2::worker<tag::outer_fold_step_outcache_,BackEnd,Site,In,Neutral,Bop>
          w(in_,neutral_,bop_);

          for(std::size_t o = begin, oout_ = begin*ibound, oin_ = begin * iboundxmbound;
              o < begin + size;
              ++o, oout_+=ibound, oin_+= iboundxmbound)
          {
            // parallelized part
            for (std::size_t i = 0, kout_ = oout_, kin_ = oin_;
                 i < iibound;
                 i+=N, kout_+=N, kin_+=N)
            {
              w.update(kin_);

              target_type result = neutral_(nt2::meta::as_<target_type>());

              if( (size == obound) && (grain < mmbound) )
                  result = s_simd( w, 0, mmbound, grain);
              else if(mmbound != 0)
                  result = w(result, 0, mmbound);

              result = w(result, mmbound, mbound-mmbound);

              nt2::run(out_, kout_, result);
            }

            // scalar part
            for(std::size_t i = iibound, kout_ = oout_ + iibound, kin_ = oin_ + iibound;
                i < ibound;
                ++i, ++kout_, ++kin_)
            {
              w.update(kin_);

              value_type result = neutral_(nt2::meta::as_<value_type>());

              if( (size == obound) && (grain < mmbound) )
                  result = s_scalar(w, 0, mmbound, grain);
              else if(mmbound != 0)
                  result = w(result, 0, mmbound);

              result = w(result, mmbound, mbound-mmbound);

              nt2::run(out_, kout_, result);
            }
          }
        }

        else
        {
          // Instanciate the spawner/worker associated to the ibound dimension
          nt2::spawner<tag::transform_, BackEnd> s;

          // vectorized worker
          nt2::worker<tag::outer_fold_step_incache_,BackEnd,Site,Out,In,Neutral,Bop>
          w1(out_,in_,neutral_,bop_);

          // scalar worker
          nt2::worker<tag::outer_fold_step_incache_,BackEnd,tag::cpu_,Out,In,Neutral,Bop>
          w2(out_,in_,neutral_,bop_);

          for(std::size_t o = 0, oout_ = begin*ibound, oin_ = begin * iboundxmbound;
              o < size;
              ++o, oout_+=ibound, oin_+= iboundxmbound)
          {
            w1.update(oout_, oin_);
            w2.update(oout_, oin_);

            // parallelized part
            if((size == obound) && (grain < iibound))
              s(w1,0,iibound,grain);

            else if(iibound != 0)
              w1(0,iibound);

            // scalar part
            w2(iibound,ibound-iibound);
          }
        }
      }

      Out&                     out_;
      In&                      in_;
      Neutral const &          neutral_;
      Bop const &              bop_;
      Uop const &              uop_;

      private:
      worker& operator=(worker const&);
   };

}
#endif


text:
class OneClickEditsController < ApplicationController

  skip_before_filter :signed_in_user
  before_filter :authenticate

  def show
    redirect_to submission_path(@submission)
  end

  private

    def authenticate
      @submission = Submission.find_by_auth_token(params[:id])

      if @submission

        if @submission.area_editor
          sign_in @submission.area_editor
        else
          redirect_to signin_path unless managing_editor?
        end

      else
        redirect_to security_breach_path
      end
    end
end


text:
#include "test.h"

#include <fcntl.h>

#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"

#define TEST_HANG_TIMEOUT 30 * 1000

/* 500 milliseconds allowed. An extreme number but lets be really conservative
   to allow old and slow machines to run this test too */
#define MAX_BLOCKED_TIME_US 500000

/* return the number of microseconds between two time stamps */
static int elapsed(struct timeval *before,
                   struct timeval *after)
{
  ssize_t result;

  result = (after->tv_sec - before->tv_sec) * 1000000 +
    after->tv_usec - before->tv_usec;
  if (result < 0)
    result = 0;

  return curlx_sztosi(result);
}

int test(char *URL)
{
  CURL *handle = NULL;
  CURLM *mhandle = NULL;
  int res = 0;
  int still_running = 0;

  start_test_timing();

  global_init(CURL_GLOBAL_ALL);

  easy_init(handle);

  easy_setopt(handle, CURLOPT_URL, URL);
  easy_setopt(handle, CURLOPT_VERBOSE, 1L);

  multi_init(mhandle);

  multi_add_handle(mhandle, handle);

  multi_perform(mhandle, &still_running);

  abort_on_test_timeout();

  while(still_running) {
    struct timeval timeout;
    fd_set fdread;
    fd_set fdwrite;
    fd_set fdexcep;
    int maxfd = -99;
    struct timeval before;
    struct timeval after;
    int e;

    timeout.tv_sec = 0;
    timeout.tv_usec = 100000L; /* 100 ms */

    FD_ZERO(&fdread);
    FD_ZERO(&fdwrite);
    FD_ZERO(&fdexcep);

    multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd);

    /* At this point, maxfd is guaranteed to be greater or equal than -1. */

    select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);

    abort_on_test_timeout();

    fprintf(stderr, "ping\n");
    before = tutil_tvnow();

    multi_perform(mhandle, &still_running);

    abort_on_test_timeout();

    after = tutil_tvnow();
    e = elapsed(&before, &after);
    fprintf(stderr, "pong = %d\n", e);

    if(e > MAX_BLOCKED_TIME_US) {
      res = 100;
      break;
    }
  }

test_cleanup:

  /* undocumented cleanup sequence - type UA */

  curl_multi_cleanup(mhandle);
  curl_easy_cleanup(handle);
  curl_global_cleanup();

  return res;
}