Skip to content

Instantly share code, notes, and snippets.

@dlfinis
dlfinis / liferay-read-journal-article-xml
Last active August 29, 2015 14:21
Read the content of a Journal Article by xml with saxreader
## An list with elements
##Check if have elements
#if (!$listaArticulos.isEmpty())
#foreach ($entry in $listaArticulos)
#set ($doc = $saxReaderUtil.read($entry.getContentByLocale($entry.getDefaultLocale())))
#set ($rootEl = $doc.getRootElement())
@dlfinis
dlfinis / liferay-journal-article-image-xml
Created May 19, 2015 17:45
Application Display Template (ADT) to display nested repeatable elements (images)
#if (!$entries.isEmpty())
<div class="news">
#foreach ($entry in $entries)
#set($renderer = $entry.getAssetRenderer() )
#set($className = $renderer.getClassName() )
#if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
#set( $journalArticle = $renderer.getArticle() )
#set( $document = $saxReaderUtil.read($journalArticle.getContent()) )
#set( $rootElement = $document.getRootElement() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='Image_Text']/dynamic-element[@name='Image10593']") )
#############################################
# Push de la rama actual
git push origin $rama_actual
#############################################
# Volver a un commit anterior, descartando los cambios
git reset --HARD $SHA1
#############################################
# Ver y descargar Ramas remotas
@dlfinis
dlfinis / select-article-liferay-ajax
Created June 3, 2015 21:26
Change event of select menu by ajax laod the article content in a part of the page
$(function() {
$( "#listImages" )
.selectmenu();
$(""#listImages").on('selectmenuchange',function() {
var articleId=$(this).val();
var groupId= <%=themeDisplay.getScopeGroupId() %>;
var url= '<liferay-portlet:renderURL windowState="exclusive" portletName="56_INSTANCE_cam"> '+
'<liferay-portlet:param name="groupId" value="ScopeGroupID" />'+
@dlfinis
dlfinis / examples-sed
Last active March 3, 2024 04:01
Examples of Sed' Use
The syntax of sed command replacement is:
$ sed 's/find/replace/' file
This sed command finds the pattern and replaces with another pattern. When the replace is left empty, the pattern/element found gets deleted.
Let us consider a sample file as below:
$ cat file
Linux
## Atom Editor
## Master configuration of the Editor based in the user dlfinis
@dlfinis
dlfinis / .eslintrc.yaml
Created January 31, 2017 22:33
Strict ESLint config for React, ES6 (based on Airbnb Code style) YAML Format
parser: babel-eslint
env:
browser: true
node: true
es6: true
ecmaFeactures:
arrowFunctions: true
binaryLiterals: true
blockBindings: true
classes: true
@dlfinis
dlfinis / noise.sh
Created March 23, 2017 21:23 — forked from rsvp/noise.sh
noise : relaxing ambient Brown noise generator (cf. white noise) | Linux bash script using sox | CogSci notes
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-04
#
# _______________| noise : ambient Brown noise generator (cf. white noise).
#
# Usage: noise [minutes=59] [band-pass freq center=1786] [wave]
# ^minutes can be any positive integer.
# Command "noise 1" will display peak-level meter.
#
# Dependencies: play (from sox package)
@dlfinis
dlfinis / clean_audio.sh
Created March 24, 2017 16:44 — forked from devoncrouse/clean_audio.sh
Using Sox (http://sox.sourceforge.net) to remove background noise and/or silence from audio files (individually, or in batch).
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command
@dlfinis
dlfinis / tailc.sh
Created March 25, 2019 16:33
Tail with color
#!/bin/sh
tail ${@:1} | sed --unbuffered \
-e 's/\(.*FATAL.*\)/\o033[1;31m\1\o033[0;39m/' \
-e 's/\(.*ERROR.*\)/\o033[31m\1\o033[39m/' \
-e 's/\(.*Hibernate*\)/\o033[35m\1\o033[39m/' \
-e 's/\(.*WARN.*\)/\o033[36m\1\o033[39m/' \
-e 's/\(.*INFO.*\)/\o033[32m\1\o033[39m/' \
-e 's/\(.*DEBUG.*\)/\o033[34m\1\o033[39m/' \