text:
<?xml version="1.0" encoding="UTF-8"?>

<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You 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.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.jackrabbit</groupId>
        <artifactId>oak-parent</artifactId>
        <version>1.39-SNAPSHOT</version>
        <relativePath>../oak-parent/pom.xml</relativePath>
    </parent>

    <artifactId>oak-run-elastic</artifactId>
    <name>Oak Elastic Runnable Jar</name>

    <properties>
        <jetty.version>8.2.0.v20160908</jetty.version>
        <groovy.version>2.4.17</groovy.version>
        <max.jar.size>27000000</max.jar.size>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>addSources</goal>
                            <goal>addTestSources</goal>
                            <goal>generateStubs</goal>
                            <goal>compile</goal>
                            <goal>testGenerateStubs</goal>
                            <goal>testCompile</goal>
                            <goal>removeStubs</goal>
                            <goal>removeTestStubs</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>enforce-file-size</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <rules>

                                <requireFilesSize>
                                    <maxsize>${max.jar.size}</maxsize>
                                    <files>
                                        <file>${project.build.directory}/${project.build.finalName}.jar</file>
                                    </files>
                                </requireFilesSize>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-run-commons</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-jcr</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-query-spi</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-core-spi</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-blob-cloud</artifactId>
            <version>${project.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-segment-tar</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-segment</artifactId>
            <version>1.6.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-store-document</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-search-elastic</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-run</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- Nullability annotations -->
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-core</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>


text:
var path = require('path');
var webpack = require('webpack');
var nodeExternals = require('webpack-node-externals');

module.exports = {
    entry: ['./src/index.ts'],
    devtool: 'sourcemap',
    output: {
        path: path.resolve('./dist'),
        filename: 'redux-app.js',
        library: 'redux-app',
        libraryTarget: 'umd',
        umdNamedDefine: true,
        devtoolModuleFilenameTemplate: '[absolute-resource-path]',
        devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
    },
    externals: [nodeExternals()],
    module: {
        rules: [
            { test: /.ts$/, use: ['ts-loader', 'ts-nameof-loader'] }
        ]
    },
    resolve: {
        extensions: ['.ts', '.js'],
        modules: [path.resolve("./src"), "node_modules"]
    },
    plugins: [
        new webpack.optimize.ModuleConcatenationPlugin()
    ]
};

redpajama_set_name: RedPajamaGithub


text:
/**
 * Support and FAQ: visit Atmel Support
 */

#ifndef CONF_BOARD_H_INCLUDED
#define CONF_BOARD_H_INCLUDED

// Enable SD MMC interface pins through HSMCI
#define CONF_BOARD_SD_MMC_HSMCI

// UART pins are used
#define CONF_BOARD_UART_CONSOLE
#define CONSOLE_UART_ID          ID_UART

// USB pins are used
#define CONF_BOARD_USB_PORT

// Support NAND
#define CONF_BOARD_NAND

#endif /* CONF_BOARD_H_INCLUDED */


text:
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_height="fill_parent"
              android:layout_width="fill_parent"
              android:orientation="vertical">

	<LinearLayout android:layout_width="fill_parent"
	    		  android:layout_height="wrap_content"
	    		  android:layout_marginLeft="5dp">
          <TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="@string/main_leg" />
          <TextView
                  android:id="@+id/mainActiveLeg"
			      android:layout_marginLeft="5dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  />
	</LinearLayout>

	<LinearLayout android:layout_width="fill_parent"
	    		  android:layout_height="wrap_content"
	    		  android:layout_marginLeft="5dp">
		<TextView android:text="@string/main_table_header_from" android:layout_margin="5dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:ellipsize="end" android:singleLine="true"/>
		<TextView android:text="@string/main_table_header_to"   android:layout_margin="5dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:ellipsize="end" android:singleLine="true"/>
		<TextView android:text="@string/distance"               android:layout_margin="5dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:ellipsize="end" android:singleLine="true"/>
		<TextView android:text="@string/azimuth"  				android:layout_margin="5dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:ellipsize="end" android:singleLine="true"/>
		<TextView android:text="@string/slope"    				android:layout_margin="5dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:ellipsize="end" android:singleLine="true"/>
		<TextView android:text="@string/main_table_header_more" android:layout_margin="5dp" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center" android:ellipsize="end" android:singleLine="true"/>

	</LinearLayout>

    <ScrollView android:id="@+id/mainTableScroll"
				android:layout_width="fill_parent"
        		android:layout_height="wrap_content"
                android:scrollbars="vertical">

        <TableLayout android:id="@+id/mainTable"
            		 android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
                     android:stretchColumns="*"
                     android:scrollbars="horizontal|vertical">
        </TableLayout>
    </ScrollView>

</LinearLayout>


text:
@interface MethodCell : UITableViewCell {
	IBOutlet UILabel *label;
}

@property (nonatomic, retain) IBOutlet UILabel *label;

@end


text:
layout: post
date: '2017-01-07'
title: "Strapless Sweetheart Neckline Beaded Chiffon Wedding Dress"
category: A-Line
tags: ["wedding","strapless","sweetheart","neckline","beaded"]
image: http://www.starbrideapparel.com/9531-thickbox_default/strapless-sweetheart-neckline-beaded-chiffon-wedding-dress.jpg
---
Strapless Sweetheart Neckline Beaded Chiffon Wedding Dress

On Sales: **$401.394**
<amp-img layout="responsive" width="600" height="600" src="//www.starbrideapparel.com/9531-thickbox_default/strapless-sweetheart-neckline-beaded-chiffon-wedding-dress.jpg" alt="Strapless Sweetheart Neckline Beaded Chiffon Wedding Dress 0" />
<amp-img layout="responsive" width="600" height="600" src="//www.starbrideapparel.com/9532-thickbox_default/strapless-sweetheart-neckline-beaded-chiffon-wedding-dress.jpg" alt="Strapless Sweetheart Neckline Beaded Chiffon Wedding Dress 1" />

Buy it: [Strapless Sweetheart Neckline Beaded Chiffon Wedding Dress](https://www.starbrideapparel.com/aline-wedding-dresses/4362-strapless-sweetheart-neckline-beaded-chiffon-wedding-dress-1463394424021.html "Strapless Sweetheart Neckline Beaded Chiffon Wedding Dress")

View more: [A-Line](https://www.starbrideapparel.com/2-aline-wedding-dresses "A-Line")


text:
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using Bari.Core.Generic;
using Bari.Core.Model;

namespace Bari.Plugins.VsCore.VisualStudio.ProjectSections
{
    /// <summary>
    /// .csproj section describing the project's assembly references
    /// </summary>
    public class ReferencesSection: MSBuildProjectSectionBase
    {
        private readonly IProjectGuidManagement projectGuidManagement;
        private readonly string sourceSetName;
        private readonly IProjectPathManagement pathManagement;
        private readonly IFileSystemDirectory targetDir;

        /// <summary>
        /// Initializes the class
        /// </summary>
        /// <param name="suite">Active suite</param>
        /// <param name="projectGuidManagement">Project GUID management service</param>
        /// <param name="sourceSetName">Source set name</param>
        /// <param name="pathManagement">Project-projectfile mapping</param>
        /// <param name="targetDir">Target directory where the compiled files will be placed</param>
        public ReferencesSection(Suite suite, IProjectGuidManagement projectGuidManagement, string sourceSetName, IProjectPathManagement pathManagement, [TargetRoot] IFileSystemDirectory targetDir)
            : base(suite)
        {
            this.projectGuidManagement = projectGuidManagement;
            this.sourceSetName = sourceSetName;
            this.pathManagement = pathManagement;
            this.targetDir = targetDir;
        }

        /// <summary>
        /// Writes the section using an XML writer
        /// </summary>
        /// <param name="writer">XML writer to use</param>
        /// <param name="project">The project to generate .csproj for</param>
        /// <param name="context">Current .csproj generation context</param>
        public override void Write(XmlWriter writer, Project project, IMSBuildProjectGeneratorContext context)
        {
            writer.WriteStartElement("ItemGroup");

            foreach (var refPath in context.References.Where(IsValidReference))
            {
                if (IsSolutionReference(refPath))
                {
                    var moduleAndprojectName = ((string) refPath).Substring(4);
                    var parts = moduleAndprojectName.Split('#');
                    var moduleName = parts[0];
                    var projectName = parts[1];

                    var referredProject = Suite.GetModule(moduleName).GetProjectOrTestProject(projectName);

                    if (referredProject.Type == ProjectType.Library ||
                        referredProject.Type == ProjectType.Executable ||
                        referredProject.Type == ProjectType.WindowsExecutable)
                    {
                        writer.WriteComment("Project reference " + projectGuidManagement.GetGuid(referredProject));

                        var projectPath = pathManagement.GetProjectFile(referredProject);
                        if (projectPath != null)
                        {
                            writer.WriteStartElement("ProjectReference");
                            writer.WriteAttributeString("Include",
                                Suite.SuiteRoot.GetRelativePathFrom(
                                    project.RootDirectory.GetChildDirectory(
                                        project.RootDirectory.ChildDirectories.First()), projectPath));
                            writer.WriteElementString("Project", projectGuidManagement.GetGuid(referredProject).ToString("B"));
                            writer.WriteElementString("Name", referredProject.Name);
                            writer.WriteEndElement();
                        }
                        else
                        {
                            writer.WriteStartElement("Reference");
                            writer.WriteAttributeString("Include", projectName);
                            writer.WriteElementString("HintPath",
                                ToProjectRelativePath(project,
                                    Path.Combine(Suite.SuiteRoot.GetRelativePath(targetDir), referredProject.Module.Name,
                                        referredProject.Name + ".dll"), sourceSetName));
                            writer.WriteElementString("SpecificVersion", "False");
                            writer.WriteEndElement();
                        }
                    }
                }
                else
                {
                    writer.WriteStartElement("Reference");
                    if (IsGACReference(refPath))
                    {
                        var assemblyName = ((string) refPath).Substring(4);
                        writer.WriteAttributeString("Include", assemblyName);
                    }
                    else
                    {
                        string relativePath = ToProjectRelativePath(project, Path.Combine("target", refPath), sourceSetName);

                        writer.WriteAttributeString("Include", Path.GetFileNameWithoutExtension(relativePath));
                        writer.WriteElementString("HintPath", relativePath);
                        writer.WriteElementString("SpecificVersion", "False");
                        writer.WriteElementString("Private", "True");
                    }
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }

        private static bool IsSolutionReference(TargetRelativePath refPath)
        {
            return ((string)refPath).StartsWith("SLN!");
        }

        private static bool IsGACReference(TargetRelativePath refPath)
        {
            return ((string) refPath).StartsWith("GAC!");
        }

        private static readonly ISet<string> allowedExtensions = new HashSet<string>
        {
            ".dll",
            ".exe"
        };

        private bool IsValidReference(TargetRelativePath reference)
        {
            if (IsGACReference(reference) || IsSolutionReference(reference))
                return true;
            else
            {
                var extension = Path.GetExtension(reference);
                if (extension != null)
                {
                    return allowedExtensions.Contains(extension.ToLowerInvariant());
                }
                else
                {
                    return false;
                }
            }
        }
    }
}


text:
'use trict';

const assert = require('assert');
const io = require('io');
const os = require('os');
const path = require('path');
const system = require('system');

const TEXT = 'hello sjs!\n';

function popen(filename) {
    var stdin = os.pipe();
    var stdout = os.pipe();
    var stderr = os.pipe();

    var pid = os.fork();
    if (pid === 0) {
        // child
        os.dup2(stdin[0], 0, false);
        os.dup2(stdout[1], 1, false);
        os.dup2(stderr[1], 2, false);
        os.execv(system.executable, [system.executable, filename]);
        assert(false);
    } else {
        // parent
        os.close(stdin[0]);
        os.close(stdout[1]);
        os.close(stderr[1]);
        var r = {
            pid: pid,
            stdin_fd: stdin[1],
            stdout_fd: stdout[0],
            stderr_fd: stderr[0]
        };
        return r;
    }
}

var data;
var r = popen(path.join(__dirname, 'helper3.js'));
os.write(r.stdin_fd, TEXT);
data = os.read(r.stdout_fd);
data = new TextDecoder().decode(data);
assert.equal(data, TEXT);
data = os.read(r.stderr_fd);
data = new TextDecoder().decode(data);
assert.equal(data, TEXT);

os.close(r.stdin_fd);
os.close(r.stdout_fd);
os.close(r.stderr_fd);

var res = os.waitpid(r.pid);
assert.equal(r.pid, res.pid);
assert(os.WIFEXITED(res.status));
assert.equal(os.WEXITSTATUS(res.status), 0);


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Microsoft.Diagnostics.Runtime.DacInterface;
using Microsoft.Diagnostics.Runtime.Implementation;

namespace Microsoft.Diagnostics.Runtime.Builders
{
    internal class ThreadBuilder : IThreadData
    {
        private readonly SOSDac _sos;
        private readonly ulong _finalizer;
        private ThreadData _threadData;

        public ThreadBuilder(SOSDac sos, ulong finalizer, IThreadHelpers helpers)
        {
            _sos = sos;
            _finalizer = finalizer;
            Helpers = helpers;
        }

        public ulong Address { get; private set; }
        public IThreadHelpers Helpers { get; }

        public bool Init(ulong address)
        {
            Address = address;
            return _sos.GetThreadData(Address, out _threadData);
        }

        bool IThreadData.IsFinalizer => _finalizer == Address;
        uint IThreadData.OSThreadID => _threadData.OSThreadId;
        int IThreadData.ManagedThreadID => (int)_threadData.ManagedThreadId;
        uint IThreadData.LockCount => _threadData.LockCount;
        int IThreadData.State => _threadData.State;
        ulong IThreadData.ExceptionHandle => _threadData.LastThrownObjectHandle;
        bool IThreadData.Preemptive => _threadData.PreemptiveGCDisabled == 0;
        ulong IThreadData.StackBase
        {
            get
            {
                if (_threadData.Teb == 0)
                    return 0;

                ulong ptr = _threadData.Teb + (ulong)IntPtr.Size;
                if (!Helpers.DataReader.ReadPointer(ptr, out ptr))
                    return 0;

                return ptr;
            }
        }

        ulong IThreadData.StackLimit
        {
            get
            {
                if (_threadData.Teb == 0)
                    return 0;

                ulong ptr = _threadData.Teb + (ulong)IntPtr.Size * 2;
                if (!Helpers.DataReader.ReadPointer(ptr, out ptr))
                    return 0;

                return ptr;
            }
        }

        public ulong NextThread => _threadData.NextThread;
        public ulong Domain => _threadData.Domain;
    }
}


text:
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Simplification;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp.Simplification
{
    internal partial class CSharpCastReducer
    {
        private class Rewriter : AbstractReductionRewriter
        {
            public Rewriter(ObjectPool<IReductionRewriter> pool)
                : base(pool)
            {
            }

            public override SyntaxNode VisitCastExpression(CastExpressionSyntax node)
            {
                return SimplifyExpression(
                    node,
                    newNode: base.VisitCastExpression(node),
                    simplifier: s_simplifyCast);
            }

            public override SyntaxNode VisitBinaryExpression(BinaryExpressionSyntax node)
            {
                var result = base.VisitBinaryExpression(node);
                var reducedNode = result as BinaryExpressionSyntax;
                if (reducedNode != node && reducedNode != null)
                {
                    if ((node.Left.IsKind(SyntaxKind.CastExpression) && !reducedNode.Left.IsKind(SyntaxKind.CastExpression)) ||
                        (node.Right.IsKind(SyntaxKind.CastExpression) && !reducedNode.Right.IsKind(SyntaxKind.CastExpression)))
                    {
                        // Cast simplification inside a binary expression, check if we need to parenthesize the binary expression to avoid breaking parent syntax.
                        // For example, cast removal in below case leads to syntax errors in error free code, unless parenting binary expression is parenthesized:
                        //   Original:                  Goo(x < (int)i, x > y)
                        //   Incorrect cast removal:    Goo(x < i, x > y)
                        //   Correct cast removal:      Goo((x < i), x > y)

                        // We'll do the following to detect such cases:
                        // 1) Get the topmostExpressionAncestor of node.
                        // 2) Get the reducedAncestor after replacing node with reducedNode within it.
                        // 3) Reparse the reducedAncestor to get reparsedAncestor.
                        // 4) Check for syntax equivalence of reducedAncestor and reparsedAncestor. If not syntactically equivalent,
                        //    then cast removal breaks the syntax and needs explicit parentheses around the binary expression.

                        var topmostExpressionAncestor = node
                            .AncestorsAndSelf()
                            .OfType<ExpressionSyntax>()
                            .LastOrDefault();

                        if (topmostExpressionAncestor != null && topmostExpressionAncestor != node)
                        {
                            var reducedAncestor = topmostExpressionAncestor.ReplaceNode(node, reducedNode);
                            var reparsedAncestor = SyntaxFactory.ParseExpression(reducedAncestor.ToFullString());
                            if (reparsedAncestor != null && !reparsedAncestor.IsEquivalentTo(reducedAncestor))
                            {
                                return SyntaxFactory.ParenthesizedExpression(reducedNode)
                                    .WithAdditionalAnnotations(Simplifier.Annotation);
                            }
                        }
                    }
                }

                return result;
            }
        }
    }
}


text:
<?php

class Google_Service_Dialogflow_GoogleCloudDialogflowCxV3ResponseMessageOutputAudioText extends Google_Model
{
  public $allowPlaybackInterruption;
  public $ssml;
  public $text;

  public function setAllowPlaybackInterruption($allowPlaybackInterruption)
  {
    $this->allowPlaybackInterruption = $allowPlaybackInterruption;
  }
  public function getAllowPlaybackInterruption()
  {
    return $this->allowPlaybackInterruption;
  }
  public function setSsml($ssml)
  {
    $this->ssml = $ssml;
  }
  public function getSsml()
  {
    return $this->ssml;
  }
  public function setText($text)
  {
    $this->text = $text;
  }
  public function getText()
  {
    return $this->text;
  }
}


text:
builder_class = function () {

    // Keep track of column to append modules to
    this.$activeColumn = null;

    this.pageId = $("#BuilderContents").attr("data-id");

    // If it's inline allow CKEditor control
    if (typeof (CKEDITOR) != "undefined") {

        // todo : comment
        $("#BuilderContents div.richTextArea .content").attr("contenteditable", "true");

        CKEDITOR.disableAutoInline = false;
    }

    // Will be appended to row to offer further controls. Is a reusable element
    this.rowHelperHtml = '

';

    // Appended to static module to remove from page, edit module contents, etc.
    this.editStaticModuleHelperHtml = '

';

    // Appended to static module to remove from page, edit module contents, etc.
    this.editRichTextModuleHelperHtml = '
 Rich Text
';
};

builder_class.prototype.initPageEvents = function () {
    var self = this;

    // Experimental - Sortable Modules
    $("#BuilderContents > div.row").sortable({
        placeholder: "ui-state-highlight",
        forcePlaceholderSize: false,
        items: ".sortableModule",
        connectWith: "#BuilderContents > div.row > div.columns",
        dropOnEmpty: true
    });

    // Add edit buttons, etc.
    this.initPageLoadedEvents();

    this.initToolBarEvents();

    this.initColumnEvents();

    this.initAddModuleEvent();

    this.initAddRowEvents();

    // Move, delete, etc.
    this.initRowEvents();

    this.initRichTextAreaEvents();

    this.initSaveEvent();

    this.initPageSettingsEvents();
};

builder_class.prototype.initRichTextAreaEvents = function () {
    var self = this;

    // Add Rich Text Area
    $("#AddRichTextArea").click(function () {

        // Close the dialog box
        $('#AddModuleModal').trigger('reveal:close');

        var id = self.generateEditableId();

        // Append Lorem Ipsum
        self.$activeColumn.append("

Header 1

Header 2

Header 3

Dirigo ipsum dolor sit amet trifecta edgie unicorn, json api jquery steak beef boudin salami meatball shankle ground round andouille short loin. Chicken pork loin doner tenderloin ham andouille.

" + self.editRichTextModuleHelperHtml + "
");

        // Start editing
        CKEDITOR.inline(id);
    });

    // Rich Text Area - Delete Rich Text Area Modal Event
    $("#BuilderContents div.richTextModuleEditBar i.remove").live("click", function () {
        self.$activeColumn = $(this).parent().parent(); // parent parent should be more reliable than .closest()

        $("#ConfirmDeleteRichTextModal").reveal();
    });

    // Confirm Delete Rich Text Area
    $("#ConfirmBuilderRichTextDelete").click(function () {

        $('#ConfirmDeleteRichTextModal').trigger('reveal:close');

        setTimeout(function () {
            // remove from dom after modal is closed
            self.$activeColumn.remove();
        }, 300);
    });
};

builder_class.prototype.initSaveEvent = function () {
    var self = this;

    // Save Content
    $("#SavePageButton").click(function (e) {
        e.preventDefault();

        var pageId = $("#BuilderContents").attr("data-id");

        var data = {
            entity: {
                ContentPageId: pageId,
                HTMLContent: self.getHtmlContent(),
            }
        };

        $.ajax({
            url: "/ContentAdmin/SaveBuilderPage",
            type: "POST",
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify(data, null, 2),
            success: function (data) {
                var noty_id = noty({ text: 'Changes saved successfully.', type: 'success', timeout: 1200 });
            },
            error: function (data) {
                var noty_id = noty({ text: 'There was an error processing your request.', type: 'error' });
                $("#SaveSpinner").hide();
            }
        });
    });
};

builder_class.prototype.initRowEvents = function () {
    var self = this;

    $("#BuilderContents > .row:not('#AddRowContainer')").append(self.rowHelperHtml);

    // On hover show toobar to allow moving the row around, delete, etc.
    $("#BuilderContents > .row:not('#AddRowContainer')").live(
        {
            mouseenter: function () {

                var height = parseInt($(this).outerHeight()) - 40; // 40 is for margin. Could calculate, faster to hardcode
                var $rowHelper = $(this).find(".rowHelper");

                $rowHelper.height(height);
            },
            mouseleave: function () {

            }
        }
    );

    // Sortable Rows
    $("#BuilderContents").sortable({
        placeholder: "ui-state-highlight",
        forcePlaceholderSize: false,
        items: ".row",
        handle: ".icon-move",
        //connectWith: ".row",
        cancel: ':input,button,[contenteditable]'
    });

    // Delete Row Modal Event
    $("#BuilderContents div.rowHelper .rowDeleteIcon").live("click", function () {
        self.$activeRow = $(this).parent().parent(); // parent parent should be more reliable than .closest()

        $("#ConfirmDeleteRowModal").reveal();
    });

    // Confirm Delete Row
    $("#ConfirmBuilderRowDelete").click(function() {

        $('#ConfirmDeleteRowModal').trigger('reveal:close');

        setTimeout(function() {
            // remove from dom after modal is closed
            self.$activeRow.remove();
        }, 300);
    });
};

builder_class.prototype.initAddRowEvents = function () {
    var self = this;

    $("ul.addRowListing li a").click(function(e) {

        e.preventDefault();

        var cols = $(this).attr("data-cols");
        var html = "
";

        if (cols == "1") {
            html += "

";
        }
        else if (cols == "2") {
            html += "

";
        }
        else if (cols == "3") {
            html += "

";
        }
        else if (cols == "4") {
            html += "

";
        }
        else if (cols == "5") {
            html += "

";
        }
        html += "
";

        var $html = $(html);

        // Add the add module button
        $html.find("div.columns").each(function() {
            $(this).append("+");
        });

        // Add the Row Helper element
        $html.append(self.rowHelperHtml);

        $("#AddRowModal").trigger('reveal:close');

        $("#AddRowContainer").before($html);

        // Scroll to the newly appended row
        $('html,body').animate({ scrollTop: $html.offset().top }, 300);
    });

    // Add a row to the bottom of the page
    $("#AddRowButton").click(function (e) {
        e.preventDefault();

        $("#AddRowModal").reveal();
    });
};

builder_class.prototype.initColumnEvents = function() {
    var self = this;

    // Shortcodes - Delete Column Modal Event
    $("#BuilderContents div.shortCodeInsert div.staticModuleEditBar i.remove").live("click", function () {
        self.$activeColumn = $(this).parent().parent(); // parent parent should be more reliable than .closest()

        $("#ConfirmDeleteColumnModal").reveal();
    });

    // Confirm Delete Column
    $("#ConfirmBuilderColumnDelete").click(function () {

        $('#ConfirmDeleteColumnModal').trigger('reveal:close');

        setTimeout(function () {
            // remove from dom after modal is closed
            self.$activeColumn.remove();
        }, 300);
    });
};

builder_class.prototype.initAddModuleEvent = function () {
    var self = this;

    // Static Modules
    $("#staticModulesTab a.moduleEntry").live("click", function() {

        var moduleName = $(this).attr("data-name");
        var moduleId = $(this).attr("data-id");

        var $html = $("

");

        var $container = $("#AddModuleModal div.moduleListingContainer");
        common.showAjaxLoader($container);
        $.post('/admin/getModuleData', { id: moduleId }, "json").done(function(result) {

            // Insert the html inside
            $html.append(result.html);

            // Append editor bar (remove, edit, etc)
            var $editorHtml = $(self.editStaticModuleHelperHtml);
            $editorHtml.find("span.title").text(moduleName);
            $html.append($editorHtml);

            // Insert gathered html into the active column
            self.$activeColumn.append($html);

            // Fire off script if any
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.text = result.js;               // use this for inline scripts
            $("#UserScripts").append(script);
            //document.body.appendChild(script);

            common.hideAjaxLoader($container);

            // Close the dialog box
            $('#AddModuleModal').trigger('reveal:close');
        });
    });

    // Dynamic Modules
    $("#dynamicModulesTab a.moduleEntry").live("click", function () {

        var moduleName = $(this).attr("data-module");

        var $container = $("#AddModuleModal div.moduleListingContainer");
        common.showAjaxLoader($container);
        $.post('/admin/addDynamicModuleData', { name: moduleName }, "json").done(function (result) {

            // Insert gathered html into the active column
            var $html = $(result.html);

            // Append editor button
            var editButton = "";
            $html.append(editButton);

            // Append
            self.$activeColumn.append($html);

            // Fire off script if any
            if (typeof(result.js) != "undefined" && result.js.length > 0) {
                var script = document.createElement("script");
                script.type = "text/javascript";
                script.text = result.js;               // use this for inline script
                document.body.appendChild(script);
            }

            common.hideAjaxLoader($container);

            // Close the dialog box
            $('#AddModuleModal').trigger('reveal:close');
        });
    });

};

builder_class.prototype.getHtmlContent = function() {

    var $html = $("#BuilderContents").clone();

    // Remove anything that is deemed..well, removable
    $html.find(".editor-removable").remove();

    // Strip out inline styles jqueryui sortable may have thrown on sortable rows
    $html.find("div.row").removeAttr("style").removeClass("ui-sortable");

    // Strip out extra crap that CKEditor throws on editable items
    $html.find("div.richTextArea").each(function () {

        $(this).removeClass("cke_editable cke_editable_inline cke_contents_ltr").removeAttr("style tabindex spellcheck contenteditable");

        $(this).find("div.content").removeClass("cke_editable cke_editable_inline cke_contents_ltr").removeAttr("style tabindex spellcheck contenteditable");
    });

    // Replace generated modules with their shortcode equivalent
    $html.find("div.shortCodeInsert").each(function() {
        var moduleName = $(this).attr("data-name");

        // replace with [modulename]
        $(this).replaceWith("[" + moduleName + "]");
    });

   return $html.html();
};

builder_class.prototype.initPageLoadedEvents = function () {
    var self = this;

    // Add "Add Module" buttons to every column
    $("#Main .pageBuilder > div.row > div.columns").each(function () {
        var $button = $("+");

        $(this).append($button);
    });

    // Edit Static Module button to every editable static module
    $("#Main .pageBuilder .shortCodeInsert").each(function () {
        var moduleName = $(this).attr("data-name");

        // Append editor bar (remove, edit, etc)
        var $editorHtml = $(self.editStaticModuleHelperHtml);
        $editorHtml.find("span.title").text(moduleName);

        $(this).append($editorHtml);
    });

    // Edit Rich Text Module button to every editable rich text module
    $("#Main .pageBuilder .richTextArea").each(function () {
        // Append editor bar (remove, edit, etc)
        var $editorHtml = $(self.editRichTextModuleHelperHtml);

        $(this).append($editorHtml);
    });

    // Add the "Add Row" button at the end of the page content
    var addButtonHtml = '

Add Row +

';
    $("#BuilderContents").append(addButtonHtml);

    // Edit Button Click
    $("a.addModule").live("click", function (e) {

        e.preventDefault();

        self.$activeColumn = $(this).parent();

        $("#AddModuleModal").reveal();
    });
};

builder_class.prototype.initToolBarEvents = function () {

    // Preview Button
    $("#PreviewPageButton").click(function (e) {
        e.preventDefault();

        $("body").removeClass("building").addClass("previewing");

        // disable all contenteditable items
        $("div.richTextArea .content").attr("contenteditable", "false");
    });

    // Edit / Un-Preview Button
    $("#EditPageButton").click(function (e) {
        e.preventDefault();

        $("body").removeClass("previewing").addClass("building");

        // re-enable all contenteditable items
        $("div.richTextArea .content").attr("contenteditable", "true");
    });
};

builder_class.prototype.initPageSettingsEvents = function () {
    var self = this;

    // Open Page Settings and load info if necessary
    $("#PageSettingsButton").parent().click(function (e) {
        e.preventDefault();

        $("body").toggleClass("showPageSettings");

        // Populate form fields if we haven't yet, this page load
        if (!$("#PageSettingsMenu").hasClass("activated")) {

            var $container = $("#PageSettingsMenu div.content .innerContent");

            common.showAjaxLoader($container);

            $.post('/contentadmin/getPageSettings', { pageId: self.pageId }, "json").done(function (result) {
                $("#PageUrl").val(result.pageUrl);
                $("#PageTitle").val(result.pageTitle);

                common.hideAjaxLoader($container);

                // Let the handler know not to populate again
                $("#PageSettingsMenu").addClass("activated");
            });
        }
    });

    // Close Settings
    $("#CloseSettingsButton").click(function (e) {
        e.preventDefault();
        $("body").removeClass("showPageSettings");
    });

    // Save Settings
    $("#SaveBuilderPageSettings").click(function(e) {
        e.preventDefault();

        var pageUrl = $("#PageUrl").val();
        var pageTitle = $("#PageTitle").val();

        var $container = $("#PageSettingsMenu div.content .innerContent");

        common.showAjaxLoader($container);

        $.post('/contentadmin/savePageSettings', { pageId: self.pageId, pageTitle : pageTitle, pageUrl : pageUrl }, "json").done(function (result) {

            noty({ text: 'Page Settings Successfully Saved.', type: 'success', timeout: 1200 });

            common.hideAjaxLoader($container);
        });

    });

};

// Generate an id for the current active item
builder_class.prototype.generateEditableId = function ($el) {

    // if duplicate, imcrement till we find a free spot
    var count = 0;
    var tagName = "rt";
    var id = tagName + "_" + count;
    var $frame = $("#Main");
    while ($frame.find("#" + id).length > 0) {
        id = tagName + "_" + count;
        count++;
    }
    return id;
};

// Keep at the bottom
$(document).ready(function () {
    builder = new builder_class();
    builder.initPageEvents();
});


text:
package org.apache.jena.rdf.model.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.jena.graph.test.GraphTestBase ;
import org.apache.jena.rdf.listeners.ChangedListener ;
import org.apache.jena.rdf.listeners.NullListener ;
import org.apache.jena.rdf.listeners.ObjectListener ;
import org.apache.jena.rdf.listeners.StatementListener ;
import org.apache.jena.rdf.model.Model ;
import org.apache.jena.rdf.model.ModelChangedListener ;
import org.apache.jena.rdf.model.Statement ;
import org.apache.jena.rdf.model.StmtIterator ;
import org.apache.jena.rdf.model.impl.StmtIteratorImpl ;
import org.apache.jena.rdf.model.test.helpers.ModelHelper ;
import org.apache.jena.rdf.model.test.helpers.RecordingModelListener ;
import org.apache.jena.rdf.model.test.helpers.TestingModelFactory ;
import org.junit.Assert;

/**
 * Tests for model events and listeners.
 */
public class TestModelEvents extends AbstractModelTestBase
{
	static class OL extends ObjectListener
	{
		private Object recorded;
		private String how;

		@Override
		public void added( final Object x )
		{
			recorded = x;
			how = "add";
		}

		private Object comparable( final Object x )
		{
			if (x instanceof Statement[])
			{
				return Arrays.asList((Statement[]) x);
			}
			if (x instanceof Iterator<?>)
			{
				return GraphTestBase.iteratorToList((Iterator<?>) x);
			}
			return x;
		}

		public void recent( final String wantHow, final Object value )
		{
			Assert.assertTrue(RecordingModelListener.checkEquality(
					comparable(value), comparable(recorded)));
			// Assert.assertEquals(comparable(value), comparable(recorded));
			Assert.assertEquals(wantHow, how);
			recorded = how = null;
		}

		@Override
		public void removed( final Object x )
		{
			recorded = x;
			how = "rem";
		}
	}

	/**
	 * Local test class to see that a StatementListener funnels all the changes
	 * through
	 * add/remove a single ModelHelper.statement
	 */
	public static class WatchStatementListener extends StatementListener
	{
		List<Statement> statements = new ArrayList<>();
		String addOrRem = "<unset>";

		@Override
		public void addedStatement( final Statement s )
		{
			statements.add(s);
			addOrRem = "add";
		}

		public List<Statement> contents()
		{
			try
			{
				return statements;
			}
			finally
			{
				statements = new ArrayList<>();
			}
		}

		public String getAddOrRem()
		{
			return addOrRem;
		}

		@Override
		public void removedStatement( final Statement s )
		{
			statements.add(s);
			addOrRem = "rem";
		}
	}

	protected RecordingModelListener SL;

	public TestModelEvents( final TestingModelFactory modelFactory,
			final String name )
	{
		super(modelFactory, name);
	}

	public void another( final Map<Object, Integer> m, final Object x )
	{
		Integer n = m.get(x);
		if (n == null)
		{
			n = new Integer(0);
		}
		m.put(x, new Integer(n.intValue() + 1));
	}

	public Map<Object, Integer> asBag( final List<Statement> l )
	{
		final Map<Object, Integer> result = new HashMap<>();
        for ( Statement aL : l )
        {
            another( result, aL.asTriple() );
        }
		return result;
	}

	protected StmtIterator asIterator( final Statement[] statements )
	{
		return new StmtIteratorImpl(Arrays.asList(statements).iterator());
	}

	public void assertSameBag( final List<Statement> wanted,
			final List<Statement> got )
	{

		Assert.assertEquals(asBag(wanted), asBag(got));
	}

	@Override
	public void setUp()
	{
		super.setUp();
		SL = new RecordingModelListener();
	}

	public void testAddInPieces()
	{
		model.register(SL);
		model.add(ModelHelper.resource(model, "S"),
				ModelHelper.property(model, "P"),
				ModelHelper.resource(model, "O"));
		SL.assertHas(new Object[] { "add",
				ModelHelper.statement(model, "S P O") });
	}

	public void testAddModel()
	{
		model.register(SL);
		final Model m = ModelHelper.modelWithStatements(this,
				"NT beats S; S beats H; H beats D");
		model.add(m);
		SL.assertHas(new Object[] { "addModel", m });
	}

	public void testAddSingleStatements()
	{
		final Statement S1 = ModelHelper.statement(model, "S P O");
		final Statement S2 = ModelHelper.statement(model, "A B C");
		Assert.assertFalse(SL.has(new Object[] { "add", S1 }));
		model.register(SL);
		model.add(S1);
		SL.assertHas(new Object[] { "add", S1 });
		model.add(S2);
		SL.assertHas(new Object[] { "add", S1, "add", S2 });
		model.add(S1);
		SL.assertHas(new Object[] { "add", S1, "add", S2, "add", S1 });
	}

	public void testAddStatementArray()
	{
		model.register(SL);
		final Statement[] s = ModelHelper.statements(model, "a P b; c Q d");
		model.add(s);
		SL.assertHas(new Object[] { "add[]", Arrays.asList(s) });
	}

	public void testAddStatementIterator()
	{
		model.register(SL);
		final Statement[] sa = ModelHelper.statements(model,
				"x R y; a P b; x R y");
		final StmtIterator it = asIterator(sa);
		model.add(it);
		SL.assertHas(new Object[] { "addIterator", Arrays.asList(sa) });
	}

	public void testAddStatementList()
	{
		model.register(SL);
		final List<Statement> L = Arrays.asList(ModelHelper.statements(model,
				"b I g; model U g"));
		model.add(L);
		SL.assertHas(new Object[] { "addList", L });
	}

	public void testChangedListener()
	{
		final ChangedListener CL = new ChangedListener();
		model.register(CL);
		Assert.assertFalse(CL.hasChanged());
		model.add(ModelHelper.statement(model, "S P O"));
		Assert.assertTrue(CL.hasChanged());
		Assert.assertFalse(CL.hasChanged());
		model.remove(ModelHelper.statement(model, "ab CD ef"));
		Assert.assertTrue(CL.hasChanged());
		model.add(ModelHelper.statements(model, "gh IJ kl"));
		Assert.assertTrue(CL.hasChanged());
		model.remove(ModelHelper.statements(model, "mn OP qr"));
		Assert.assertTrue(CL.hasChanged());
		model.add(asIterator(ModelHelper.statements(model, "st UV wx")));
		Assert.assertTrue(CL.hasChanged());
		Assert.assertFalse(CL.hasChanged());
		model.remove(asIterator(ModelHelper.statements(model, "yz AB cd")));
		Assert.assertTrue(CL.hasChanged());
		model.add(ModelHelper.modelWithStatements(this, "ef GH ij"));
		Assert.assertTrue(CL.hasChanged());
		model.remove(ModelHelper.modelWithStatements(this, "kl MN op"));
		Assert.assertTrue(CL.hasChanged());
		model.add(Arrays.asList(ModelHelper.statements(model, "rs TU vw")));
		Assert.assertTrue(CL.hasChanged());
		model.remove(Arrays.asList(ModelHelper.statements(model, "xy wh q")));
		Assert.assertTrue(CL.hasChanged());
	}

	public void testDeleteModel()
	{
		model.register(SL);
		final Model m = ModelHelper.modelWithStatements(this,
				"NT beats S; S beats H; H beats D");
		model.remove(m);
		SL.assertHas(new Object[] { "removeModel", m });
	}

	public void testDeleteStatementArray()
	{
		model.register(SL);
		final Statement[] s = ModelHelper.statements(model, "a P b; c Q d");
		model.remove(s);
		SL.assertHas(new Object[] { "remove[]", Arrays.asList(s) });
	}

	public void testDeleteStatementIterator()
	{
		model.register(SL);
		final Statement[] sa = ModelHelper.statements(model,
				"x R y; a P b; x R y");
		final StmtIterator it = asIterator(sa);
		model.remove(it);
		SL.assertHas(new Object[] { "removeIterator", Arrays.asList(sa) });
	}

	public void testDeleteStatementList()
	{
		model.register(SL);
		final List<Statement> lst = Arrays.asList(ModelHelper.statements(model,
				"b I g; model U g"));
		model.remove(lst);
		SL.assertHas(new Object[] { "removeList", lst });
	}

	public void testGeneralEvent()
	{
		model.register(SL);
		final Object e = new int[] {};
		model.notifyEvent(e);
		SL.assertHas(new Object[] { "someEvent", model, e });
	}

	public void testGot( final WatchStatementListener sl, final String how,
			final String template )
	{
		assertSameBag(Arrays.asList(ModelHelper.statements(model, template)),
				sl.contents());
		Assert.assertEquals(how, sl.getAddOrRem());
		Assert.assertTrue(sl.contents().size() == 0);
	}

	/**
	 * Test that the null listener doesn't appear to do anything. Or at least
	 * doesn't crash ....
	 */
	public void testNullListener()
	{
		final ModelChangedListener NL = new NullListener();
		model.register(NL);
		model.add(ModelHelper.statement(model, "S P O "));
		model.remove(ModelHelper.statement(model, "X Y Z"));
		model.add(ModelHelper.statements(model, "a B c; d E f"));
		model.remove(ModelHelper.statements(model, "g H i; j K l"));
		model.add(asIterator(ModelHelper.statements(model, "model N o; p Q r")));
		model.remove(asIterator(ModelHelper.statements(model, "s T u; v W x")));
		model.add(ModelHelper.modelWithStatements(this, "leaves fall softly"));
		model.remove(ModelHelper.modelWithStatements(this,
				"water drips endlessly"));
		model.add(Arrays.asList(ModelHelper.statements(model, "xx RR yy")));
		model.remove(Arrays.asList(ModelHelper.statements(model, "aa VV rr")));
	}

	public void testObjectListener()
	{
		final OL ll = new OL();
		model.register(ll);
		final Statement s = ModelHelper.statement(model, "aa BB cc"), s2 = ModelHelper
				.statement(model, "dd EE ff");
		model.add(s);
		ll.recent("add", s);
		model.remove(s2);
		ll.recent("rem", s2);
		/* */
		final List<Statement> sList = Arrays.asList(ModelHelper.statements(
				model, "gg HH ii; jj KK ll"));
		model.add(sList);
		ll.recent("add", sList);
		final List<Statement> sList2 = Arrays.asList(ModelHelper.statements(
				model, "mm NN oo; pp QQ rr; ss TT uu"));
		model.remove(sList2);
		ll.recent("rem", sList2);
		/* */
		final Model m1 = ModelHelper.modelWithStatements(this,
				"vv WW xx; yy ZZ aa");
		model.add(m1);
		ll.recent("add", m1);
		final Model m2 = ModelHelper.modelWithStatements(this, "a B g; d E z");
		model.remove(m2);
		ll.recent("rem", m2);
		/* */
		final Statement[] sa1 = ModelHelper.statements(model,
				"th i k; l model n");
		model.add(sa1);
		ll.recent("add", sa1);
		final Statement[] sa2 = ModelHelper.statements(model, "x o p; r u ch");
		model.remove(sa2);
		ll.recent("rem", sa2);
		/* */
		final Statement[] si1 = ModelHelper.statements(model,
				"u ph ch; psi om eh");
		model.add(asIterator(si1));
		ll.recent("add", asIterator(si1));
		final Statement[] si2 = ModelHelper.statements(model,
				"at last the; end of these; tests ok guv");
		model.remove(asIterator(si2));
		ll.recent("rem", asIterator(si2));
	}

	public void testRegistrationCompiles()
	{
		Assert.assertSame(model, model.register(new RecordingModelListener()));
	}

	public void testRemoveSingleStatements()
	{
		final Statement S = ModelHelper.statement(model, "D E F");
		model.register(SL);
		model.add(S);
		model.remove(S);
		SL.assertHas(new Object[] { "add", S, "remove", S });
	}

	public void testTripleListener()
	{
		final WatchStatementListener sl = new WatchStatementListener();
		model.register(sl);
		model.add(ModelHelper.statement(model, "b C d"));
		testGot(sl, "add", "b C d");
		model.remove(ModelHelper.statement(model, "e F g"));
		testGot(sl, "rem", "e F g");
		/* */
		model.add(ModelHelper.statements(model, "h I j; k L model"));
		testGot(sl, "add", "h I j; k L model");
		model.remove(ModelHelper.statements(model, "n O p; q R s"));
		testGot(sl, "rem", "n O p; q R s");
		/* */
		model.add(Arrays.asList(ModelHelper.statements(model, "t U v; w X y")));
		testGot(sl, "add", "t U v; w X y");
		model.remove(Arrays.asList(ModelHelper
				.statements(model, "z A b; c D e")));
		testGot(sl, "rem", "z A b; c D e");
		/* */
		model.add(asIterator(ModelHelper.statements(model, "f G h; i J k")));
		testGot(sl, "add", "f G h; i J k");
		model.remove(asIterator(ModelHelper.statements(model, "l M n; o P q")));
		testGot(sl, "rem", "l M n; o P q");
		/* */
		model.add(ModelHelper.modelWithStatements(this, "r S t; u V w; x Y z"));
		testGot(sl, "add", "r S t; u V w; x Y z");
		model.remove(ModelHelper.modelWithStatements(this, "a E i; o U y"));
		testGot(sl, "rem", "a E i; o U y");
	}

	public void testTwoListeners()
	{
		final Statement S = ModelHelper.statement(model, "S P O");
		final RecordingModelListener SL1 = new RecordingModelListener();
		final RecordingModelListener SL2 = new RecordingModelListener();
		model.register(SL1).register(SL2);
		model.add(S);
		SL2.assertHas(new Object[] { "add", S });
		SL1.assertHas(new Object[] { "add", S });
	}

	public void testUnregisterWorks()
	{
		model.register(SL);
		model.unregister(SL);
		model.add(ModelHelper.statement(model, "X R Y"));
		SL.assertHas(new Object[] {});
	}

	public void testUnregistrationCompiles()
	{
		model.unregister(new RecordingModelListener());
	}
}


text:
UILabel *label13 = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 42.0, 83.0)];
label13.frame = CGRectMake(0.0, 0.0, 42.0, 83.0);
label13.adjustsFontSizeToFitWidth = YES;
label13.alpha = 1.000;
label13.autoresizesSubviews = YES;
label13.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
label13.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
label13.clearsContextBeforeDrawing = YES;
label13.clipsToBounds = YES;
label13.contentMode = UIViewContentModeLeft;
label13.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
label13.enabled = YES;
label13.hidden = NO;
label13.lineBreakMode = UILineBreakModeTailTruncation;
label13.minimumFontSize = 10.000;
label13.multipleTouchEnabled = NO;
label13.numberOfLines = 1;
label13.opaque = NO;
label13.shadowOffset = CGSizeMake(0.0, -1.0);
label13.tag = 0;
label13.text = @"ss";
label13.textAlignment = UITextAlignmentLeft;
label13.textColor = [UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000];
label13.userInteractionEnabled = NO;

UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 235.0, 220.0)];
view3.frame = CGRectMake(0.0, 0.0, 235.0, 220.0);
view3.alpha = 1.000;
view3.autoresizesSubviews = YES;
view3.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
view3.backgroundColor = [UIColor colorWithRed:1.000 green:1.000 blue:1.000 alpha:1.000];
view3.clearsContextBeforeDrawing = YES;
view3.clipsToBounds = NO;
view3.contentMode = UIViewContentModeScaleToFill;
view3.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
view3.hidden = NO;
view3.multipleTouchEnabled = NO;
view3.opaque = YES;
view3.tag = 0;
view3.userInteractionEnabled = YES;

UILabel *label7 = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 58.0, 195.0, 55.0)];
label7.frame = CGRectMake(20.0, 58.0, 195.0, 55.0);
label7.adjustsFontSizeToFitWidth = YES;
label7.alpha = 1.000;
label7.autoresizesSubviews = YES;
label7.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
label7.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
label7.clearsContextBeforeDrawing = YES;
label7.clipsToBounds = YES;
label7.contentMode = UIViewContentModeLeft;
label7.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
label7.enabled = YES;
label7.hidden = NO;
label7.lineBreakMode = UILineBreakModeTailTruncation;
label7.minimumFontSize = 10.000;
label7.multipleTouchEnabled = NO;
label7.numberOfLines = 1;
label7.opaque = NO;
label7.shadowOffset = CGSizeMake(0.0, -1.0);
label7.tag = 0;
label7.text = @"Owner";
label7.textAlignment = UITextAlignmentLeft;
label7.textColor = [UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000];
label7.userInteractionEnabled = NO;

UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 30.0, 195.0, 58.0)];
label4.frame = CGRectMake(20.0, 30.0, 195.0, 58.0);
label4.adjustsFontSizeToFitWidth = YES;
label4.alpha = 1.000;
label4.autoresizesSubviews = YES;
label4.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
label4.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
label4.clearsContextBeforeDrawing = YES;
label4.clipsToBounds = YES;
label4.contentMode = UIViewContentModeLeft;
label4.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
label4.enabled = YES;
label4.hidden = NO;
label4.lineBreakMode = UILineBreakModeTailTruncation;
label4.minimumFontSize = 10.000;
label4.multipleTouchEnabled = NO;
label4.numberOfLines = 1;
label4.opaque = NO;
label4.shadowOffset = CGSizeMake(0.0, -1.0);
label4.tag = 0;
label4.text = @"Meeting Headline";
label4.textAlignment = UITextAlignmentLeft;
label4.textColor = [UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000];
label4.userInteractionEnabled = NO;

UIView *view14 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 235.0, 29.0)];
view14.frame = CGRectMake(0.0, 0.0, 235.0, 29.0);
view14.alpha = 1.000;
view14.autoresizesSubviews = YES;
view14.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
view14.backgroundColor = [UIColor colorWithRed:0.784 green:0.451 blue:0.157 alpha:1.000];
view14.clearsContextBeforeDrawing = YES;
view14.clipsToBounds = NO;
view14.contentMode = UIViewContentModeScaleToFill;
view14.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
view14.hidden = NO;
view14.multipleTouchEnabled = NO;
view14.opaque = YES;
view14.tag = 0;
view14.userInteractionEnabled = YES;

UIButton *button17 = [UIButton buttonWithType:UIButtonTypeCustom];
button17.frame = CGRectMake(145.0, 134.0, 70.0, 66.0);
button17.adjustsImageWhenDisabled = YES;
button17.adjustsImageWhenHighlighted = YES;
button17.alpha = 1.000;
button17.autoresizesSubviews = YES;
button17.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
button17.clearsContextBeforeDrawing = YES;
button17.clipsToBounds = NO;
button17.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
button17.contentMode = UIViewContentModeScaleToFill;
button17.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
button17.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
button17.enabled = YES;
button17.hidden = NO;
button17.highlighted = NO;
button17.multipleTouchEnabled = NO;
button17.opaque = NO;
button17.reversesTitleShadowWhenHighlighted = NO;
button17.selected = NO;
button17.showsTouchWhenHighlighted = NO;
button17.tag = 0;
button17.titleLabel.lineBreakMode = UILineBreakModeMiddleTruncation;
button17.titleLabel.shadowOffset = CGSizeMake(0.0, 0.0);
button17.userInteractionEnabled = YES;
[button17 setTitleColor:[UIColor colorWithRed:0.196 green:0.310 blue:0.522 alpha:1.000] forState:UIControlStateNormal];
[button17 setTitleColor:[UIColor colorWithWhite:1.000 alpha:1.000] forState:UIControlStateHighlighted];

UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(20.0, -15.0, 42.0, 54.0)];
label5.frame = CGRectMake(20.0, -15.0, 42.0, 54.0);
label5.adjustsFontSizeToFitWidth = YES;
label5.alpha = 1.000;
label5.autoresizesSubviews = YES;
label5.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
label5.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
label5.clearsContextBeforeDrawing = YES;
label5.clipsToBounds = YES;
label5.contentMode = UIViewContentModeLeft;
label5.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
label5.enabled = YES;
label5.hidden = NO;
label5.lineBreakMode = UILineBreakModeTailTruncation;
label5.minimumFontSize = 10.000;
label5.multipleTouchEnabled = NO;
label5.numberOfLines = 1;
label5.opaque = NO;
label5.shadowOffset = CGSizeMake(0.0, -1.0);
label5.tag = 0;
label5.text = @"Start";
label5.textAlignment = UITextAlignmentLeft;
label5.textColor = [UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000];
label5.userInteractionEnabled = NO;

UILabel *label6 = [[UILabel alloc] initWithFrame:CGRectMake(173.0, -16.0, 42.0, 55.0)];
label6.frame = CGRectMake(173.0, -16.0, 42.0, 55.0);
label6.adjustsFontSizeToFitWidth = YES;
label6.alpha = 1.000;
label6.autoresizesSubviews = YES;
label6.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
label6.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
label6.clearsContextBeforeDrawing = YES;
label6.clipsToBounds = YES;
label6.contentMode = UIViewContentModeLeft;
label6.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
label6.enabled = YES;
label6.hidden = NO;
label6.lineBreakMode = UILineBreakModeTailTruncation;
label6.minimumFontSize = 10.000;
label6.multipleTouchEnabled = NO;
label6.numberOfLines = 1;
label6.opaque = NO;
label6.shadowOffset = CGSizeMake(0.0, -1.0);
label6.tag = 0;
label6.text = @"end";
label6.textAlignment = UITextAlignmentRight;
label6.textColor = [UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000];
label6.userInteractionEnabled = NO;

[view3 addSubview:label4];
[view14 addSubview:label5];
[view14 addSubview:label6];
[view3 addSubview:view14];
[view3 addSubview:label7];
[view3 addSubview:button17];


text:
'use strict';
var React = require('react');

/**
 * Determines if at least one element in the object matches a truth test.
 *
 * @param {function(val, key)} pred Predicate function.
 * @param {object|array} obj
 * @return {boolean}
 */
function some(pred, obj) {
  var val;
  for (var key in obj) {
    if(~this.props.keys.indexOf(key)) {
      continue;
    }
    if(React.isValidElement(obj[key])) {
      val = obj[key].props.sortValue ? obj[key].props.sortValue.toLocaleLowerCase() : '';
      if (pred(val, key) === true) {
        return true;
      }
    }
    if (pred(obj[key], key) === true) {
      return true;
    }
  }
  return false;
}

/**
 * Creates a compare function with a property to sort on.
 *
 * @param {string} prop Property to sort.
 * @return {function(object, object)} Compare function.
 */
var sortByFn =
  function(prop)
  {return function(a, b)  {return a[prop] < b[prop] ? -1 : a[prop] > b[prop] ? 1 : 0;};};

/**
 * Creates a compare function with a number property to sort on.
 *
 * @param {string} prop Property to sort.
 * @return {function(object, object)} Compare function.
 */
var sortByNumberFn = function(prop) {
  return function(a, b)  {
    var aVal = a[prop] ? parseFloat(a[prop].replace(/[\s\$%,]/gm, ''), 10) : -Infinity,
      bVal = b[prop] ? parseFloat(b[prop].replace(/[\s\$%,]/gm, ''), 10) : -Infinity;
    return aVal - bVal;
  };
};

/**
 * Creates a compare function with a string property of ReactElement to sort on.
 *
 * @param {string} prop Property to sort.
 * @return {function(object, object)} Compare function.
 */
var sortByElementStringFn = function(prop) {
  return function(a, b) {
    var aVal = a[prop].props.sortValue ? a[prop].props.sortValue.toLowerCase() : '',
        bVal = b[prop].props.sortValue ? b[prop].props.sortValue.toLowerCase() : '';
    return aVal < bVal ? -1 : (aVal > bVal ? 1 : 0);
  };
};

/**
 * Creates a compare function with a number property of ReactElement to sort on.
 *
 * @param {string} prop Property to sort.
 * @return {function(object, object)} Compare function.
 */
var sortByElementNumberFn = function(prop) {
  return function(a, b) {
    var aVal = a[prop].props.sortValue ? parseFloat(a[prop].props.sortValue.replace(/[\s\$%,]/gm, ''), 10) : -Infinity,
        bVal = b[prop].props.sortValue ? parseFloat(b[prop].props.sortValue.replace(/[\s\$%,]/gm, ''), 10) : -Infinity;
    return aVal - bVal;
  };
};

/**
 * @param {object} sortBy Object containing `prop` and `order`.
 * @param {array} data Array to sort.
 * @param {string} type Field type.
 * @return {array} Sorted array.
 */
function sort(sortBy, data, type) {
  var sortedData;
  if (data.length === 0) {
    return [];
  }

  switch(type) {
    case 'ELEMENT_NUMBER':
      sortedData = data.sort(sortByElementNumberFn(sortBy.prop)); break;
    case 'ELEMENT_STRING':
      sortedData = data.sort(sortByElementStringFn(sortBy.prop)); break;
    case 'NUMBER':
      sortedData = data.sort(sortByNumberFn(sortBy.prop)); break;
    case 'STRING':
      sortedData = data.sort(sortByFn(sortBy.prop)); break;
    default:
      sortedData = data.sort(sortByFn(sortBy.prop)); break;
  }
  if (sortBy.order === 'descending') {
    sortedData.reverse();
  }
  return sortedData;
}

/**
 * @param {!object} filters
 * @param {!array} data
 * @return {function(*, string)} Function to be executed for each entry in data.
 */
function filterPass(filters, data) {
  return (filterValue, key) => {
    var filterDef = filters[key];
    var partial = filterDef.filter.bind(null, filterValue);
    if (!filterDef.prop) {
      // Filter is for all properties
      return some.call(this, function(each)  {
        return partial(each);}, data);
    } else {
      // Filter is for one property
      return partial(data[filterDef.prop]);
    }
  };
}

/**
 * Example of filter and filterValues.
 * filters = { globalSearch: { filter: containsIgnoreCase } }
 * filterValues = { globalSearch: 'filter value' }
 *
 * @param {object} filters Definition of the filters.
 * @param {object} filterValues Values of the filters.
 * @param {array} data Array to filter.
 * @return {array} Filtered array.
 */
function filter(filters, filterValues, data) {
  var filterFunc = filterPass.bind(this, filters);
  return data.filter(each => {return some.call(this, filterFunc(each), filterValues);});
}

module.exports = {filter:filter, filterPass:filterPass, sort:sort, sortByFunc: sortByFn, some:some};


text:
layout: article
title: "Monster Dash 10k"
categories: race-recaps
excerpt: "A wet halloween race and my first 10k."
ads: false
share: true
image:
  feature: monster-start.jpg
  teaser: monster-start.jpg
---

Ran my first 10k race at the Team Ortho Monster Dash on Halloween.  It was a costume race and more of
a fun race than a serious runner's race.

A few notes about this year's Monster Dash:

* A super rainy day means this race is tied with the super hot Rock 'n Roll Half for worst race weather I've run in.  I ran the race in clear poncho that I tried to keep over my head and tucked into my hat.
* Confusion on the course meant I didn't know where to turn around.  This was pretty bad.  A sign said "turn-around ahead" and a couple steps further along were two orange cones, but I had no idea whether or not the cones were the actual turning point.  It was clear that no one else could tell either, since everyone kind of slowed down and looked at each other in confusion.  I'm just guessing that that was the correct place to turn around since my total distance at the end of the race was ok.  I'm not sure why there weren't any volunteers directing anyone to turn around at that point.
* Another race - a 50k/50miler I think - was also racing along the lakefront trail at the same time.  This made the signage on the trail really confusing.  I also saw water stops for that race but I think not for the Monster Dash.
* I heard beforehand that last minute sign-ups meant they ran out of jackets and also out of medals at the end of the race.  Not sure why the organizers oversold it then.

### Swag

I registered for this race at the Chicago Marathon expo for $50 with a discount expo code.
I didn't run the Chicago Marathon, but I did a long run that Saturday ending at the expo to check it out.
I got free bonus Monster Dash socks and picked up an x-small zip-up on site (since they had run out of smalls).

Monster Dash women's x-small full zip from Team Ortho and
stained glass finisher's medal.  The full zip is pretty nice with thumb holes and a pocket on the lower back.

### Race

For the 10k, there were 908 runners, 634 of whom were women.
It was neat to see a lot of people running in costume, and some of them were pretty ridiculous.
The least runnable costume I saw was some sort of caterpillar thing made up of six or so
connected runners.  Since it rained pretty heavily, I'm glad I only ran the 10k and not the
half marathon.  My last minute not-so-well-thought-out pretend costume was Marty McFly
with the wrong sports almanac - with a Cavs jersey, a cubs hat, a UChicago gaiter, and an orange
vest.  (Bunch of losing teams, get it?!?) Well, that's what I had in my closet.

Chicago Monster Dash 10k Nike+ course map.

Since this was my first 10k, I PR-ed by default with a time of 1:05:27, which put me at a 10:32'
pace.  I did a pretty good job (for me) relative to other runners, and I cut 23 seconds off my 10k
split time from the Magnificent Mile Women's Half Marathon.

Compared to the other runners, I was

* Overall: 399 of 908 (56.1%)
* Gender: 258 of 634 (59.3%)
* Age/gender group: 84 of 208 (59.6%)
* Age graded place: 387 of 908 (57.4%)
* Passed/By 173/185

The end of the race was also pretty confusing because the medals were far from the finish line, so it
was unclear where to go after you crossed the finish.  Afterwards, got a banana and a free pair of ear warmers from a sponsor at the post-race tents and then booked it out of the rain for brunch at Dusek's.

### In short

Rainy day spoiled it a little for me, and the race was a bit disorganized.  I'll sit this one out next year.


text:
'use strict';

var gulp = require('gulp'),
  gulpSequence = require('gulp-sequence'),
  jshint = require('gulp-jshint'),
  mocha = require('gulp-mocha');

gulp.task('jshint', function () {
  return gulp.src(['lrucache.js', 'gulpfile.js', 'test/*.js'])
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});

gulp.task('mocha', function () {
  return gulp.src('test/index.js', {read: false})
    .pipe(mocha());
});

gulp.task('default', ['test']);

gulp.task('test', gulpSequence('jshint', 'mocha'));


text:
import * as _ from "lodash";
declare const pad: typeof _.pad;
export default pad;


text:
"""The decompressor object interface."""

import abc

class Decompressor(object):
  """Class that implements the decompressor object interface."""

  @abc.abstractmethod
  def Decompress(self, compressed_data):
    """Decompresses the compressed data.

    Args:
      compressed_data (bytes): compressed data.

    Returns:
      tuple(bytes, bytes): uncompressed data and remaining compressed data.
    """


text:
var express = require('express');
var router = express.Router();
var sha1 = require('sha1');

/* GET private room. */
router.post('/', function(req, res, next) {
  var simplepw = req.body.room
  if(!simplepw){
    return res.redirect('../');
  }
  if(/ /.test(simplepw)){
    return res.redirect('../errorMessage');
  }
  console.log('post',simplepw)
  return res.redirect('/private/' + sha1(simplepw))
})

router.get('/:id([a-z0-9]{40})/readme', function(req, res, next) {
  return res.render('readme', { title: 'readme', room : 'private/' + req.params.id });
})

router.get('/:id([a-z0-9]{40})', function(req, res, next) {
  return res.render('main', { title: 'private_room', room: 'private/' + req.params.id });
})

router.get('/', function(req, res, next) {
  return res.redirect('../');
})

module.exports = router;


text:
var gulp = require('gulp'),
    sass = require('gulp-ruby-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss = require('gulp-minify-css'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    imagemin = require('gulp-imagemin'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    notify = require('gulp-notify'),
    cache = require('gulp-cache'),
    livereload = require('gulp-livereload'),
    del = require('del'),
    flatten = require('gulp-flatten')
    combiner = require('stream-combiner2');

gulp.task('styles', function() {
  return sass('src/styles/main.scss', { style: 'expanded' })
    .pipe(autoprefixer())
    .pipe(gulp.dest('static/css'))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifycss())
    .pipe(gulp.dest('static/css'))
    .pipe(notify({ message: 'Styles task complete' }));
});

gulp.task('scripts', function() {
  var combined = combiner.obj([
    gulp.src('src/scripts/**/*.js'),
    concat('main.js'),
    gulp.dest('static/js'),
    rename({suffix: '.min'}),
    uglify(),
    gulp.dest('static/js'),
    notify({ message: 'Scripts task complete' })
  ]);
  combined.on('error', console.error.bind(console));
  return combined;
});

gulp.task('fonts', function() {
  return gulp.src('src/fonts/**/*')
    .pipe(gulp.dest('static/fonts'))
    .pipe(notify({ message: 'Fonts task complete' }));
});

gulp.task('dependencies', function() {
  return gulp.src(['bower_components/**/*.min.js', 'bower_components/**/*.min.js.map', '!bower_components/**/src/**/*.min.js'])
    .pipe(flatten({ includeParents: 0}))
    .pipe(gulp.dest('static/js'))
    .pipe(notify({ message: 'Dependencies task complete' }));
});

gulp.task('images', function() {
  return gulp.src('src/images/**/*')
    .pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
    .pipe(gulp.dest('static/img'))
    .pipe(notify({ message: 'Images task complete' }));
});

gulp.task('clean', function(cb) {
    del(['static/css', 'static/js', 'static/img'], cb)
});

gulp.task('default', ['clean'], function() {
    gulp.start('dependencies', 'styles', 'scripts', 'images', 'fonts');
});

gulp.task('watch', function() {
  // Watch .scss files
  gulp.watch('src/styles/**/*.scss', ['styles']);
  // Watch .js files
  gulp.watch('src/scripts/**/*.js', ['scripts']);
  // Watch font files
  gulp.watch('src/fonts/**/*', ['fonts']);
  // Watch image files
  gulp.watch('src/images/**/*', ['images']);
  // Watch dependencies
  gulp.watch('bower_components/**/*.min.js', ['dependencies']);
});


text:
module FlightSeeker
  class TripQuery
    def self.from_trip_description(trip_description)
      match = trip_description.match(/^(\d{4}-\d{2}-\d{2})-(.+)/)
      date, remainder = match[1], match[2]
      unless date
        raise "[!] Invalid date format in `#{trip_description}'."
      end
      airports = remainder.split('-').map(&:upcase)
      airports.each do |airport|
        unless airport =~ /^[A-Z]{3}$/
          raise "[!] Not a valid airport IATA designator `#{airport}' in `#{trip_description}'."
        end
      end
      unless airports.size >= 2
        raise "[!] Less than 2 airports specified in `#{trip_description}'."
      end
      new(date, airports)
    end

    attr_reader :date, :airports

    def initialize(date, airports)
      @date, @airports = date, airports
    end

    Segment = Struct.new(:origin, :destination)

    def segments
      if airports.size == 2
        [Segment.new(*airports)]
      else
        airports[2..-1].inject([Segment.new(*airports.first(2))]) do |segments, airport|
          segments << Segment.new(segments.last.destination, airport)
        end
      end
    end
  end
end


text:
(function() {
  var FormulaVisitor, TreeBuilder,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  FormulaVisitor = (function() {

    function FormulaVisitor() {}

    FormulaVisitor.prototype.visitIntegerLiteral = function(node) {
      return this.visitLiteral(node);
    };

    FormulaVisitor.prototype.visitDecimalLiteral = function(node) {
      return this.visitLiteral(node);
    };

    FormulaVisitor.prototype.visitStringLiteral = function(node) {
      return this.visitLiteral(node);
    };

    FormulaVisitor.prototype.visitParens = function(node) {
      return node.formula.visit(this);
    };

    FormulaVisitor.prototype.visitInfixExpression = function(node, fn) {
      var left, right;
      left = node.left.visit(this);
      right = node.right.visit(this);
      return fn(left, right);
    };

    return FormulaVisitor;

  })();

  TreeBuilder = (function(_super) {

    __extends(TreeBuilder, _super);

    function TreeBuilder() {
      return TreeBuilder.__super__.constructor.apply(this, arguments);
    }

    TreeBuilder.prototype.visitLiteral = function(node) {
      var val;
      val = node.value;
      return {
        name: val,
        value: val
      };
    };

    TreeBuilder.prototype.visitStringLiteral = function(node) {
      var val;
      val = "'" + node.value + "'";
      return {
        name: val,
        value: val
      };
    };

    TreeBuilder.prototype.visitReference = function(node) {
      var val;
      val = node.name;
      return {
        name: val,
        value: val
      };
    };

    TreeBuilder.prototype.visitParens = function(node) {
      var child, val;
      child = node.formula.visit(this);
      val = "( " + child.value + " )";
      return {
        name: '( )',
        children: [child],
        value: val
      };
    };

    TreeBuilder.prototype.visitInfixExpression = function(node) {
      return TreeBuilder.__super__.visitInfixExpression.call(this, node, function(a, b) {
        var op;
        op = node.operator;
        return {
          name: op,
          children: [a, b],
          value: "" + a.value + " " + op + " " + b.value
        };
      });
    };

    TreeBuilder.prototype.visitFunctionCall = function(node) {
      var child, children, param, val;
      children = (function() {
        var _i, _len, _ref, _results;
        _ref = node.parameters;
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          param = _ref[_i];
          _results.push(param.visit(this));
        }
        return _results;
      }).call(this);
      val = "" + node.name + "(";
      if (children.length !== 0) {
        val += " " + (((function() {
          var _i, _len, _results;
          _results = [];
          for (_i = 0, _len = children.length; _i < _len; _i++) {
            child = children[_i];
            _results.push(child.value);
          }
          return _results;
        })()).join(', ')) + " ";
      }
      val += ")";
      return {
        name: "" + node.name + "()",
        children: children,
        value: val
      };
    };

    return TreeBuilder;

  })(FormulaVisitor);

  module.exports = function(formula) {
    return formula.visit(new TreeBuilder());
  };

}).call(this);