### Run Closure Compiler in Interactive Mode - Bash
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
Execute this command from the project root to start the Closure Compiler in interactive mode, allowing you to type JavaScript code directly into the console for compilation and execution.
```bash
java -jar target/closure-compiler-1.0-SNAPSHOT.jar
```
--------------------------------
### Input JavaScript in Interactive Mode - Javascript
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
Example of JavaScript code entered into the Closure Compiler when running in interactive mode. After typing the code, press Enter, then Ctrl-Z (Windows) or Ctrl-D (Mac/Linux) followed by Enter to process the input.
```javascript
var x = 17 + 25;
```
--------------------------------
### Defining Python Dependencies (requirements.txt)
Source: https://github.com/chembl/glados/blob/master/requirements.txt
Specifies the necessary Python libraries and their exact or minimum versions required to run the project. This list is typically used by package managers like pip to install the project's dependencies.
```Python
django==2.2
django-compressor==2.3
django-cors-headers==2.4.0
selenium==3.14.0
twitter
python3-memcached
pyScss==1.3.5
CoffeeScript==1.1.2
watchdog==0.8.3
whitenoise
requests
python-gettext
gunicorn==19.8.1
elasticsearch>=7.0.0,<8.0.0
elasticsearch-dsl>=7.0.0,<8.0.0
google-api-python-client==1.6.6
timeago==1.0.8
simplejson>=3.16.0
pyyaml==5.1
# requirements from ws2es
progressbar2==3.10.1
wrapt==1.11.1
blessings==1.6
```
--------------------------------
### Display Closure Compiler Help - Bash
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
Run this command to view the command-line options and usage information for the Closure Compiler. This provides details on various flags for input/output, checks, and optimizations.
```bash
java -jar compiler.jar --help
```
--------------------------------
### Configuring Maven for Snapshots
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
This XML snippet is added to the Maven settings file (~/.m2/settings.xml) to include the Sonatype snapshots repository. This allows Maven to download snapshot versions of the Closure Compiler.
```XML
allow-snapshots
true
snapshots-repo
https://oss.sonatype.org/content/repositories/snapshots
false
true
```
--------------------------------
### Implement URL Redirections - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
These RedirectMatch directives handle specific URL patterns. The first redirects the base path to ensure a trailing slash, while the others redirect old '/chembl/beta' and '/chembldb' paths to the new base path.
```Apache Config
RedirectMatch ^/{SERVER_BASE_PATH}$ /{SERVER_BASE_PATH}/
# Old beta and chembldb redirections
RedirectMatch ^/chembl/beta(.*)$ /{SERVER_BASE_PATH}$1
RedirectMatch ^/chembldb(.*)$ /{SERVER_BASE_PATH}$1
```
--------------------------------
### Serve Static Files Directly - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
This snippet configures Apache to serve static files directly from a specified directory ('{STATIC_ROOT}') using the Alias directive. The Directory block sets permissions, allowing access from all origins for these static assets.
```Apache Config
# serve directly static files
Alias "/{SERVER_BASE_PATH}/static" "{STATIC_ROOT}"
AllowOverride None
Order allow,deny
Allow from all
```
--------------------------------
### Enable and Configure Deflate Compression - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
This snippet loads the mod_deflate module and configures it to compress various content types (text, images, applications) before sending them to the client, reducing bandwidth usage and improving load times.
```Apache Config
LoadModule deflate_module modules/mod_deflate.so
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/svg
AddOutputFilterByType DEFLATE application/font-woff
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json .json
```
--------------------------------
### Define Virtual Host and Server Names - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
This snippet defines the main virtual host listening on port 80 and specifies the server names and aliases it should respond to. The '*' alias is a broad match.
```Apache Config
ServerName www.ebi.ac.uk
ServerAlias wwwdev.ebi.ac.uk
ServerAlias *.ebi.ac.uk
ServerAlias *
```
--------------------------------
### Compile JavaScript Files Using Glob Pattern - Bash
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
This command demonstrates compiling multiple JavaScript files using a glob pattern. The pattern `'src/**.js'` recursively includes all `.js` files within the `src` directory and its subdirectories.
```bash
java -jar compiler.jar --js_output_file=out.js 'src/**.js'
```
--------------------------------
### Configure Proxying Behavior - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
These directives configure how Apache proxies requests to the backend server. 'SetEnv force-proxy-request-1.0 1' forces HTTP 1.0 for compatibility (specifically noted for gunicorn), and 'ProxyPreserveHost On' ensures the original Host header is passed to the backend.
```Apache Config
# Force http 1.0 for proxying: needed for gunicorn!
SetEnv force-proxy-request-1.0 1
ProxyPreserveHost On
```
--------------------------------
### Handle OPTIONS Requests with 200 Response - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
This uses the RewriteEngine to specifically handle HTTP OPTIONS requests. If the request method is OPTIONS, the RewriteRule returns a 200 OK status code immediately, which is common practice for handling CORS preflight requests.
```Apache Config
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
```
--------------------------------
### Define ProxyPass and ProxyPassReverse Rules - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
These directives define which URLs are proxied to the backend application server running on localhost:8000. Specific paths like '/static', '/dynamic-downloads', and '/v' are excluded from proxying using the '!' flag, allowing them to be handled differently (e.g., served directly).
```Apache Config
# proxy everything except static files and dynamic downloads to gunicorn
ProxyPassMatch /{SERVER_BASE_PATH}/static/(.*)$ !
ProxyPassMatch /{SERVER_BASE_PATH}/dynamic-downloads/(.*)$ !
ProxyPassMatch /{SERVER_BASE_PATH}/v/(.*)$ !
ProxyPassMatch /{SERVER_BASE_PATH}/(?!(?:beta))(.*)$ http://localhost:8000/{SERVER_BASE_PATH}/$1
ProxyPassReverse /{SERVER_BASE_PATH}/static/(.*)$ !
ProxyPassReverse /{SERVER_BASE_PATH}/dynamic-downloads/(.*)$ !
ProxyPassReverse /{SERVER_BASE_PATH}/v/(.*)$ !
ProxyPassReverse /{SERVER_BASE_PATH}/(.*)$ http://localhost:8000/{SERVER_BASE_PATH}/$1
```
--------------------------------
### Compile Multiple JavaScript Files - Bash
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
Use this command to compile multiple JavaScript files (`in1.js`, `in2.js`, etc.) together into a single output file (`out.js`). The compiler concatenates and processes the files in the order listed.
```bash
java -jar compiler.jar --js_output_file=out.js in1.js in2.js in3.js ...
```
--------------------------------
### Configure Caching with Expires Module - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
This loads the mod_expires module and enables it. It sets expiration headers for different file types (images, fonts, CSS, JS, zip) based on access time, instructing browsers to cache these resources for specified durations (1 week or 1 day) to improve performance on subsequent visits.
```Apache Config
# cache
LoadModule expires_module modules/mod_expires.so
ExpiresActive On
# image and font files are expected to change less
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/svg "access plus 1 week"
ExpiresByType application/font-woff "access plus 1 week"
ExpiresByType application/font-woff2 "access plus 1 week"
ExpiresByType application/font-ttf "access plus 1 week"
# style and javascript files are expected to change daily
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType application/javascript "access plus 1 day"
ExpiresByType application/x-javascript "access plus 1 day"
# generated downloads are expected to change only after a new release is done. Browsers won't cache big files, but we can try
# this to see how it works. It shouldn't hurt.
ExpiresByType application/zip "access plus 1 week"
Header append Cache-Control "public"
```
--------------------------------
### Configuring Eclipse .classpath for Closure Compiler
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
This XML snippet is used to modify the .classpath file in the Eclipse project for the Closure Compiler. It includes generated sources and excludes specific GWT-related source paths.
```XML
```
--------------------------------
### Compile JavaScript Files Using Glob with Exclusion - Bash
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
This command compiles JavaScript files using a glob pattern while excluding specific files. The pattern `'src/**.js'` includes all `.js` files, and `'!**_test.js'` excludes any file ending with `_test.js`. Single quotes are used to prevent shell expansion.
```bash
java -jar compiler.jar --js_output_file=out.js 'src/**.js' '!**_test.js'
```
--------------------------------
### Configure CORS and Other Headers - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
These Header directives manage HTTP response headers. They first unset potentially existing CORS headers and then always set 'Access-Control-Allow-Origin' to '*' for broad access, along with allowed methods, max age, and allowed headers for CORS preflight requests.
```Apache Config
# Always set these headers.
Header unset access-control-allow-Origin
Header unset Access-Control-Allow-Origin
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
```
--------------------------------
### Configure Server Status Location - Apache Config
Source: https://github.com/chembl/glados/blob/master/util/http.d/apache_config_template.txt
This Location block configures access to the Apache server status page. It restricts access to clients within the '.ebi.ac.uk' domain, denying access from all other locations for security.
```Apache Config
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from .ebi.ac.uk
```
--------------------------------
### Output from Interactive Mode - Javascript
Source: https://github.com/chembl/glados/blob/master/src/external_tools/closure_compiler/README.md
This is the expected output from the Closure Compiler in interactive mode after processing the input `var x = 17 + 25;`. The compiler evaluates the expression and outputs the result.
```javascript
var x=42;
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.