Tuesday, April 21, 2015

Find and clean / remove files with a specific pattern in a deep directory tree

If you need to remove all the files that comply to:
* file pattern (eg *Uploads/*.pdf)
* a size constraint (eg >= 50k)
* older than some days before today (eg 365 days older)


find . -wholename *Uploads/*.pdf -size +50k -mtime +365 -print0 | xargs -0 rm

Create a zip file per directory and delete the directories

for i in *do[ -d "$i" ] && zip -rmT "$i.zip" "$i"done
# just -r for only zip (mT is for delete)
Remove only directories in Linux

cd thedirrm -rf */

Installing VirtualBox in Linux could fail about no kernel sources available DKMS.



If this is the case then set KERN_DIR variable and then again retry installing VirtualBox

## Current running kernel on Fedora ##
KERN_DIR=/usr/src/kernels/`uname -r`
## Current running kernel on CentOS and Red Hat (RHEL) ##
KERN_DIR=/usr/src/kernels/`uname -r`-`uname -m`
## Fedora example ##
KERN_DIR=/usr/src/kernels/2.6.33.5-124.fc13.i686
## CentOS and Red Hat (RHEL) example ##
KERN_DIR=/usr/src/kernels/2.6.18-194.11.1.el5-x86_64
## Export KERN_DIR ##
export KERN_DIR



Source: http://www.if-not-true-then-false.com/2010/install-virtualbox-with-yum-on-fedora-centos-red-hat-rhel/

Wednesday, February 25, 2015

Find current sql sessions in MS SQL SERVER, getting also client IPs

SELECT
    B.login_name,
    A.client_net_address,
    NoOfConnections = COUNT(*)
FROM
    sys.dm_exec_connections A
        INNER JOIN sys.dm_exec_sessions B ON
            A.session_id = B.session_id
GROUP BY
    login_name,
    client_net_address

Sunday, April 6, 2014

Consume WSDL / SOAP web services from node.js

There are some open source libraries that could help you call WSDL web services such as:





I believe that a more flexible alternative is to:




Yes, this is a rather dirty and low level approach but it should work without problems

Thursday, May 9, 2013

Using getResource() and getResourceAsStream() in Grails

Want to include some static files into your Grails application? For example some document templates in order to be used by Freemarker, XDocReport etc?

You can:

  • create a package into conf/ eg named templates
  • put your files into conf/templates
  • reference the files from a service or controller using

this.class.getClassLoader().getResourceAsStream("templates/invoiceTemplate.docx");
or
this.class.getClassLoader().getResource("templates/invoiceTemplate.docx");

info: Don't forget to restart webapp (stop and run-app) to allow Grails to redeploy (including your resources)

This works for Grails 2.2.2