Skip to content

Instantly share code, notes, and snippets.

@cmlewis
cmlewis / ..Emarsys API Samples - Node js
Last active August 29, 2018 19:05
Emarsys API Samples - Node.js
Emarsys API Samples - Node.js
@cmlewis
cmlewis / agendaJobSameNameDifferentConfig.js
Created April 12, 2018 19:20
Agenda - create multiple job definitions with same name, different job config
// Create each job with the same name so we can control concurrency (the number of parallel jobs that can be run).
// Each job will have the same name, but different configs. Use the 'unique' method to prevent duplicates.
agenda.define('MyJob', {concurrency: 3}, loadData);
_.each(myJobs, function(job){
agenda.create('MyJob', job)
.unique({'job.name': job.name}, { insertOnly: true })
.repeatEvery('1 hour')
.save();
});
@cmlewis
cmlewis / AlfrescoGetTotalObjectCountForOneType.js
Created September 27, 2017 12:42
Get the total number of objects (files or folders) of a particular type in Alfresco. This helps bypass Alfresco's query limit of 1000.
// Get the total number of objects of one type.
// This accounts for the query limits in Alfresco (which is 1000 results by default)
var query = 'TYPE:"myco:document"';
var totalNumOfDocs = 0;
do {
var page = {
maxItems: 1000,
@cmlewis
cmlewis / Alfresco-UpdatePermissionsOnNode.js
Created August 7, 2017 20:35
Alfresco - Update Permissions on Node
var nodes = search.luceneSearch('@hpi\\:trac:"HR"');
logger.log("Document Count: " + nodes.length);
for each(var node in nodes) {
node.setPermission("Read", "GROUP_HR");
node.setPermission("Read", "GROUP_HPI_CONSUMERS");
}
@cmlewis
cmlewis / Convert FLV to MP4 using ffmpeg
Created October 18, 2016 21:16
Convert FLV to MP4 using ffmpeg
_
@cmlewis
cmlewis / ffmpeg_copy_MTSorAVCHD_to_mp4.bat
Last active September 3, 2016 20:17
Copy AVCHD (MTS or MTS2) to MP4 using ffmpeg
ffmpeg -i 00002.MTS -vcodec copy 00002.mp4
@cmlewis
cmlewis / wp_display_all_custom_fields.php
Created June 21, 2016 22:59
Wordpress - Display all custom fields
<?php
$custom_fields = get_post_custom();
foreach ( $custom_fields as $field_key => $field_values ) {
foreach ( $field_values as $key => $value )
echo $field_key . ' - ' . $value . '<br />';
}
?>
@cmlewis
cmlewis / Alfresco-CreateManyMajorAndMinorVersions.js
Created April 5, 2015 16:02
Alfresco - Automate creation of many major and minor versions
var numMinorVersions = 15;
var numMajorVersions = 2;
for (var i = 0; i < numMinorVersions; i++) {
document.createVersion("automated minor version", false);
}
for (var i = 0; i < numMajorVersions; i++) {
document.createVersion("automated major version", true);
@cmlewis
cmlewis / Delete Windows Service.bat
Created March 9, 2015 19:27
Delete a Windows Service
call sc.exe delete MyServiceName
@cmlewis
cmlewis / Create Windows Service via Command_ Line.bat
Last active August 29, 2015 14:16
Create Windows Service via Command Line
call sc.exe create MyNewServiceName binPath= "\"C:\path\to\bin\mybin.exe\" --service --config
= \"C:\path\to\config\myconfig.cfg\"" DisplayName= "My New Service" start= "auto"