This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Simple test of PhantomJS and the XContentReady event. | |
* | |
* This is the basic pattern used for the ember-prerender project: https://github.com/zipfworks/ember-prerender | |
* More info on the XContentReady event: https://github.com/n-fuse/the-XContentReady-Event/ | |
* | |
* Usage: phantomjs phantom_test.js | |
*/ | |
var page = require('webpage').create(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This script is useful for managing time series or log data | |
// that is stored in MongoDB. | |
// | |
// I'm currently using logstash to store system logs in MongoDB, where | |
// each database name denotes type of log and each collection name | |
// reflects the date on which the log entries it contains occurred. | |
// | |
// This script expects database collections to be in YYYY.MM.DD format. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($path_to_image)) { | |
header('HTTP/1.0 304 Not Modified'); | |
header('Cache-Control: public, max-age=2592000'); | |
header('Last-Modified: Mon, 27 Oct 2014 17:08:41 GMT'); | |
exit(0); | |
} else { | |
header('Content-type: image/jpeg'); | |
header('Cache-Control: public, max-age=2592000'); | |
header('Last-Modified: Mon, 27 Oct 2014 17:08:41 GMT'); | |
echo file_get_contents($path_to_image); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Oracle Java8 Dockerfile | |
# | |
FROM ubuntu | |
RUN apt-get update; \ | |
apt-get install -y \ | |
software-properties-common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To use: | |
// server.use(requestLogger); | |
function requestLogger(req, res, next) { | |
req._startTime = new Date(); | |
var logRequest = function() { | |
res.removeListener('finish', logRequest); | |
res.removeListener('close', logRequest); | |
var status = res.headersSent && res.statusCode || null; | |
var userAgent = req.headers['user-agent']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install emblem2hbs cli | |
npm -g install emblem2hbs | |
# Convert all emblem files to handlebars | |
for f in $(ls -1 {,**/}*.emblem); do; emblem2hbs $f; done; | |
# Optionally delete original emblem files | |
find . -name "*.emblem" -exec rm {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script provides start/stop/restart/status control | |
# over the JVM-based API service. | |
# | |
# Build Environment | |
BUILD_NAME="your-build-name" | |
BASE_DIR="/home/ubuntu/${BUILD_NAME}-deploy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOrdinal(value) { | |
const suffixes = ['th', 'st', 'nd', 'rd']; | |
const normalized = value % 100; | |
return value + (suffixes[(normalized - 20) % 10] || suffixes[normalized] || suffixes[0]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Example Dockerfile that builds PhantomJS 2.0 | |
# | |
# Build with: | |
# docker build --rm --tag=phantom2.0:latest . | |
# | |
# Run with: | |
# docker run --name=phantom2.0 phantom2.0 | |
# | |
# Copy the executable to your host machine for distribution: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Snippet to encode invalid characters from improperly formatted URIs | |
* | |
* RFC 3986 defines that URIs may contain the following characters: | |
* ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=`.``` | |
*/ | |
import java.net.URLEncoder | |
"""[^A-Za-z0-9-._~:/?#\[\]@!$&'\(\)*+,;=%`]|%[^0-9a-fA-F]{2}]""".r. |
OlderNewer