Skip to content

Instantly share code, notes, and snippets.

function html2pdf(path, outputPath, opt_callback) {
phantom.create(function(ph) {
ph.createPage(function(page) {
page.set('paperSize', {
format: 'A4',
orientation: 'portrait'
});
page.open(path, function() {
<!DOCTYPE html>
<html>
<body>
<script>
assert(document.readyState === 'loading');
document.addEventListener("DOMContentLoaded", function() {
assert(document.readyState === 'interactive'); // <--
setTimeout(function() {
assert(document.readyState === 'complete');
}, 0);
@eduardolundgren
eduardolundgren / gist:4260723
Created December 11, 2012 18:08
Liferay JSON Web Services (Object Composition)

Liferay JSON Web Services

JSON RPC

/jsonws/calendar-portlet/calendar/get-calendar/calendar-id/10466

Simple JavaScript API

function writeTempFile(content, opt_callback) {
tmp.file({ postfix: '.html' }, function(err, tmpHtmlPath) {
if (!err) {
grunt.file.write(tmpHtmlPath, content);
}
opt_callback && opt_callback(err, tmpHtmlPath);
});
}
@eduardolundgren
eduardolundgren / loop.js
Last active December 25, 2015 14:29
async loop
_checkBackgroundTasks: function() {
var instance = this;
Liferay.Service(
'/backgroundtask/get-background-tasks-count',
{
groupId: instance._groupId,
taskExecutorClassName: instance._taskExecutorClassName,
completed: instance._isPending
},
AUI().use('event-resize', function(A) {
A.one(window).on('resize', function(event) {
dialog.align();
});
});
@eduardolundgren
eduardolundgren / .jshintrc
Created September 18, 2013 15:01
.jshintrc
{
"bitwise": true,
"browser": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"evil": true,
"expr": true,
"immed": true,
"latedef": true,
AUI.add(
'liferay-scheduler',
function(A) {
var AArray = A.Array;
var AObject = A.Object;
var DateMath = A.DataType.DateMath;
var Lang = A.Lang;
var RecurrenceUtil = Liferay.RecurrenceUtil;
var Workflow = Liferay.Workflow;
YUI().use(
'aui-modal',
function(Y) {
var modal1 = new Y.Modal(
{
bodyContent: '<button id="inModalButton">foo</button>',
headerContent: 'Modal header',
render: '#modal',
}
<if>
<and>
<isgreaterthan arg1="${ant.java.version}" arg2="1.5"/>
<or>
<equals arg1="${ant.java.version}" arg2="1.6" />
<and>
<equals arg1="${ant.java.version}" arg2="1.7" />
<islessthan arg1="${ant.update.version}" arg2="25"/>
</and>
</or>