<commit_before>#!/usr/bin/env bash

echo "Installing Compass..."
GEMS="gem install --quiet --no-rdoc --no-ri sass compass oily_png bootstrap-sass"
if [[ -z $TRAVIS ]]; then # If not on Travis, need to use sudo
   GEMS="sudo $GEMS"
fi
`$GEMS`

# Exit script on any error
set -e

echo "Installing PostGIS and other packages..."
sudo apt-get -qq update
sudo apt-get install -qq software-properties-common # to get next command: add-apt-repository
sudo add-apt-repository --yes ppa:ubuntugis/ppa
sudo add-apt-repository --yes ppa:chris-lea/node.js
sudo apt-get -qq update
sudo apt-get -qq install postgis postgresql-9.1-postgis rubygems nodejs apache2 php5-pgsql php5-cli php5-gd php5-mcrypt php5-intl

echo "Installing JS testing tools..."
sudo npm --global --quiet install karma karma-ng-scenario phantomjs uglify-js ngmin

# For Travis, we replace pre-installed PhantomJS with npm version (more recent)
if [[ ! -z $TRAVIS ]]; then
   sudo ln -sf "`sudo npm bin -g`/phantomjs" `which phantomjs`
fi

# For Travis CI, or full local install, we need more configuration (Apache and database)
if [[ "$1" = "configure" ]]; then
    echo "Configuring Apache..."
    WEBROOT="$(pwd)/htdocs"
    CGIROOT=`dirname "$(which php-cgi)"`
    sudo echo "<VirtualHost *:80>
            DocumentRoot $WEBROOT
            <Directory />
                    Options FollowSymLinks
                    AllowOverride All
            </Directory>
            <Directory $WEBROOT >
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
            </Directory>

            # Configure PHP as CGI
            ScriptAlias /local-bin $CGIROOT
            DirectoryIndex index.php index.html
            AddType application/x-httpd-php5 .php
            Action application/x-httpd-php5 '/local-bin/php-cgi'
    </VirtualHost>" | sudo tee /etc/apache2/sites-available/default > /dev/null

    sudo a2enmod actions
    sudo a2enmod rewrite
    sudo a2enmod headers
    sudo service apache2 restart

    echo "Configuring custom domain..."
    echo "127.0.0.1 gims.local" | sudo tee --append /etc/hosts

    echo "Init database..."
    cp config/autoload/local.php.dist config/autoload/local.php
    sudo -u postgres psql -c 'create database gims;' -U postgres
fi
<commit_msg>Downgrade to Node.js to 0.18 (with manually installed dependencies)<commit_after>#!/usr/bin/env bash

echo "Installing Compass..."
GEMS="gem install --quiet --no-rdoc --no-ri sass compass oily_png bootstrap-sass"
if [[ -z $TRAVIS ]]; then # If not on Travis, need to use sudo
   GEMS="sudo $GEMS"
fi
`$GEMS`

# Exit script on any error
set -e

echo "Installing PostGIS and other packages..."
sudo apt-get -qq update
sudo apt-get install -qq software-properties-common # to get next command: add-apt-repository
sudo add-apt-repository --yes ppa:ubuntugis/ppa
sudo add-apt-repository --yes ppa:chris-lea/node.js
sudo apt-get -qq update
sudo apt-get -qq install postgis postgresql-9.1-postgis rubygems apache2 php5-pgsql php5-cli php5-gd php5-mcrypt php5-intl

# Use old version of Node.js to workaround https://github.com/isaacs/npm/issues/2907
sudo apt-get install libc6 libgcc1 libstdc++6 rlwrap
curl -O https://chrislea.com/nodejs_0.10.18-1chl1~precise1_amd64.deb
sudo dpkg -i nodejs_0.10.18-1chl1~precise1_amd64.deb

echo "Installing JS testing tools..."
sudo npm --global --quiet install karma karma-ng-scenario phantomjs uglify-js ngmin

# For Travis, we replace pre-installed PhantomJS with npm version (more recent)
if [[ ! -z $TRAVIS ]]; then
   sudo ln -sf "`sudo npm bin -g`/phantomjs" `which phantomjs`
fi

# For Travis CI, or full local install, we need more configuration (Apache and database)
if [[ "$1" = "configure" ]]; then
    echo "Configuring Apache..."
    WEBROOT="$(pwd)/htdocs"
    CGIROOT=`dirname "$(which php-cgi)"`
    sudo echo "<VirtualHost *:80>
            DocumentRoot $WEBROOT
            <Directory />
                    Options FollowSymLinks
                    AllowOverride All
            </Directory>
            <Directory $WEBROOT >
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
            </Directory>

            # Configure PHP as CGI
            ScriptAlias /local-bin $CGIROOT
            DirectoryIndex index.php index.html
            AddType application/x-httpd-php5 .php
            Action application/x-httpd-php5 '/local-bin/php-cgi'
    </VirtualHost>" | sudo tee /etc/apache2/sites-available/default > /dev/null

    sudo a2enmod actions
    sudo a2enmod rewrite
    sudo a2enmod headers
    sudo service apache2 restart

    echo "Configuring custom domain..."
    echo "127.0.0.1 gims.local" | sudo tee --append /etc/hosts

    echo "Init database..."
    cp config/autoload/local.php.dist config/autoload/local.php
    sudo -u postgres psql -c 'create database gims;' -U postgres
fi

{'fraction_non_alphanumeric': 0.10214626391096979, 'fraction_numerical': 0.015500794912559618, 'mean_word_length': 2.5073170731707317, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '329995', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1549, 'n_words': 501}