Skip to content

Instantly share code, notes, and snippets.

@CesarCapillas
CesarCapillas / Importing JS
Last active September 10, 2024 14:15
Alfresco Javascript Console Recipes
Import a script from the repository using a name-based path:
<import resource="/Company Home/Data Dictionary/Scripts/library.js">
Import a script from the repository using a NodeRef reference:
<import resource="workspace://SpacesStore/6f73de1b-d3b4-11db-80cb-112e6c2ea048">
Import a script from a Java classpath location:
@CesarCapillas
CesarCapillas / Check ballooning
Last active May 16, 2017 21:47
Ubuntu recipes
#Si difieren mucho puede indicar balloning
ps aux | tr -s ' ' | awk 'BEGIN{sum=0}{ sum+=$6 }END{print expr sum/1024}'
free -m
@CesarCapillas
CesarCapillas / Check site members
Last active May 16, 2017 21:43
Alfresco Shell Scripts
$ curl --silent https://services.zylk.net/alfresco/service/api/sites |grep shortName|wc -l
31
In JS Console
var s = siteService.getSites("", "", 0);
s.forEach(function(entry) {
var members = entry.listMembers(null, "", 0, false);
for (userName in members) {
logger.log(entry.shortName+ " :: "+userName);
@CesarCapillas
CesarCapillas / Basic apache setup
Last active May 16, 2017 22:08
Apache recipes
$ sudo apt-get install apache2
$ sudo a2enmod proxy
$ sudo a2enmod proxy_ajp
$ sudo a2enmod rewrite
$ sudo vim /etc/apache2/sites-enabled/default-ssl.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
SELECT count(alf_node.id)
FROM alf_node INNER JOIN alf_node_aspects ON alf_node.id = alf_node_aspects.node_id
WHERE alf_node.store_id = 6
AND alf_node_aspects.qname_id = 2929;
/**
* Script to locate error nodes from solr error report, and do something with them.
*
* @author Younes Regaieg <[email protected]>
* @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 = {
@CesarCapillas
CesarCapillas / gist:d3317213413f2913d99e2a301cad0ce0
Created March 4, 2018 19:54 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
@CesarCapillas
CesarCapillas / add-by-id.sh
Last active April 23, 2024 21:14
SOLR bash recipes for creating, deleting or truncating collections, monitoring and searching.
#!/bin/bash
COLLECTION=${2:-zylk}
SERVER=${3:-localhost}
PORT=${4:-8983}
if [ -z "$1" ]; then
# Usage
echo 'Usage: add-by-id.sh <id> [<collection> <solr-server=localhost> <port=8383>]'
else
curl -X POST "http://${SERVER}:${PORT}/solr/${COLLECTION}/update?commit=true" -H "Content-Type: text/xml" --data-binary "<add><doc><field name='id'>$1</field><field name='url'>$1</field></doc></add>"
#! /bin/bash
./bin/nutch plugin urlfilter-regex org.apache.nutch.urlfilter.regex.RegexURLFilter -Durlfilter.regex.file=regex
@CesarCapillas
CesarCapillas / check-elastic-health.sh
Last active July 27, 2023 06:33
ELK shell scripts
#!/bin/bash
ELKSERVER=${1:-localhost}
ELKPORT=${2:-9200}
if [ -z "$ELKSERVER" ]; then
# Usage
echo 'Usage: check-health.sh <elk-server=localhost> <elk-port=9200>'
# create-index.sh "logstash-solr-*"
else
curl -s "http://$ELKSERVER:$ELKPORT/_cat/health?v"