Skip to content

Instantly share code, notes, and snippets.

View douglascrp's full-sized avatar

Douglas C. R. Paes douglascrp

View GitHub Profile
@douglascrp
douglascrp / node-ubuntu-upstart-service.md
Created September 15, 2020 12:28 — forked from willrstern/node-ubuntu-upstart-service.md
Run Node.js App as Ubuntu Upstart Service

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@douglascrp
douglascrp / gist:50d0ae95c78181971e5f0ab9ec03e399
Created January 20, 2020 19:30 — forked from dexalex84/gist:334bdd189dd923a63e80c45300fb30be
Pentaho BA CE 7.0 Install with PostgreSQL repo DB on CentOS
Pentaho BA 7.0 Install with PostgreSQL repo DB
INSTALL POSTGRES
https://wiki.postgresql.org/wiki/YUM_Installation
1) find
/etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
remove
add
@douglascrp
douglascrp / gist:eef2ab7197fea613a77f593b7784aac8
Created February 6, 2019 13:25 — forked from flox1an/gist:2a726224e23381fa41f9
Change username for cm:owner cm:creator cm:modifier in Alfresco Javascript Console
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var behaviourFilter = ctx.getBean("policyBehaviourFilter");
// -----------------------------------------------------------------
function findAndReplaceAttribute(query, attribute, value) {
nodes = search.luceneSearch(query);
for each(var node in nodes) {
@douglascrp
douglascrp / start-wf-assigned-to-site-group.js
Created February 6, 2019 13:24 — forked from alfrescian/start-wf-assigned-to-site-group.js
Start Alfresco Workflow assigned to SiteManager group of a site
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var javaSiteService = ctx.getBean("siteService");
var site = javaSiteService.getSite(document.nodeRef);
var siteManagerGroup = javaSiteService.getSiteRoleGroup(site.getShortName(), "SiteManager", true);
var groupAssignee = people.getGroup(siteManagerGroup)
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$activitiParallelGroupReview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;
importClass(Packages.org.springframework.web.context.ContextLoader);
importClass(Packages.org.alfresco.service.cmr.repository.TransformationOptions);
var context = ContextLoader.getCurrentWebApplicationContext();
var alfThumbnailService = context.getBean("thumbnailService");
alfThumbnailService.updateThumbnail(document.getThumbnail("webpreview").nodeRef, new TransformationOptions());
@douglascrp
douglascrp / cleaner.js
Created February 6, 2019 13:24 — forked from wingyplus/cleaner.js
Delete all file in archive store
importClass(Packages.org.springframework.web.context.ContextLoader);
importClass(Packages.org.alfresco.service.cmr.repository.StoreRef);
var ctx = ContextLoader.getCurrentWebApplicationContext();
var archiveService = ctx.getBean("nodeArchiveService");
archiveService.purgeAllArchivedNodes(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
@douglascrp
douglascrp / runas.js
Created February 6, 2019 13:23 — forked from yv84/runas.js
var RunAsUtil = {
execute: function(workFunction, runAsUser) {
Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(new Packages.org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork()
{
doWork: workFunction
}, runAsUser);
},
doInTransaction: function(workFunction) {
var txs = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext().getBean("TransactionService");
var th = txs.getRetryingTransactionHelper();
// To be used with Alfresco JS Console. Select folder in js console to create export package for
var exportaction = actions.create("export");
exportaction.parameters["store"] = "workspace://SpacesStore";
exportaction.parameters["package-name"] = space.properties.name + "_export.acp";
exportaction.parameters["destination"] = space.parent;
exportaction.parameters["include-children"] = true;
exportaction.parameters["include-self"]=true;
exportaction.parameters["encoding"]="UTF-8";
exportaction.execute(space);
// Delete thumbnails if exists. To be used in Alfresco javascript console. Starts from selected space
recurse(space, function(node) {
var doclib = node.getThumbnail('doclib');
var webpreview = node.getThumbnail('webpreview');
var webpreview2 = node.getThumbnail('web-preview');
var imgpreview = node.getThumbnail('imgpreview');
var pdf = node.getThumbnail('pdf');
if(doclib){
doclib.remove();
/**
* Script to locate error nodes from solr error report, and do something with them.
*
* @author Younes Regaieg <younes.regaieg@xenit.eu>
* @version 1.0
**/
//----- Solr error report to be fetched from solr /solr4/alfresco/query?q=EXCEPTIONMESSAGE:*&wt=json&rows=<number-of-rows-to-fetch>
//----- Swap this dummy object with a real object from the output of the endpoint mentionned above.
var solrErrorsReport = {