Friday, July 19, 2013

[Grails] Use Domain.withNewSession instead of refresh()

Waaaaaaay faster.
For instance, if you have a service run by a scheduled recurring Quartz job, the service seem to be attached to a thread which does not see the updated fields in the database (always returns cached values). We may refresh the whole domain calling the refresh() method on the domain class instance, or just do this:

def allCampaigns
        Campaign.withNewSession{ session ->
            allCampaigns = Campaign.findAll("from Campaign where myStatus IN ('active','paused') OR myStatus = null")
        }


Saturday, July 6, 2013

Cleaning up /boot


dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic" |while read n;do apt-get -y remove $n;done
 
 

Monday, May 27, 2013

Blocking one calling to one called

!
voice translation-rule 1001
 rule 1 reject /17771238001/
!
voice translation-profile 1001
 translate calling 1001
!
!incoming dial-peer 4 all
dial-peer voice 1 pots
 incoming called-number .
 direct-inward-dial
!
!incoming dial-peer special
dial-peer voice 1001 pots
 call-block translation-profile incoming 1001
 incoming called-number 0012021111001
 direct-inward-dial
!
!outgoing dialpeer to CUCM
dial-peer voice 9000 voip
 destination-pattern 0012021111...
 session target ipv4:192.168.210.11
 no vad

Tuesday, October 2, 2012

Monday, August 6, 2012

Well done, Oracle. Go Groovy!

I just wanted to download the JDK and look what welcomes you at the Oracle website:


Friday, June 15, 2012

Mounting Popcorn Hour NFS share under Ubuntu 12.04

greg@antares:~$ sudo mount -t nfs -o vers=3 192.168.90.101:/share /media/popcorn

Thursday, June 7, 2012

ByteArrayOutputStream.toString() human readable

I can do this for a readable output:

public class Changer {
    public static void main(String[] args) {
        try {
        java.io.InputStream in = new java.io.FileInputStream(new java.io.File("DBSDashboard.XML"));
        java.io.OutputStream out = new java.io.ByteArrayOutputStream();
        org.jdom2.input.SAXBuilder builder = new org.jdom2.input.SAXBuilder();
        org.jdom2.Document document = (org.jdom2.Document) builder.build(in);
        org.jdom2.Element rootNode = document.getRootElement();
        org.jdom2.Element ccc= rootNode.getChild("CallCentreClosed").getChild("callCentreClosed");
        ccc.setText("true");
        /* or, ccc.setText("false") */
        org.jdom2.output.XMLOutputter xmlOutputter = new org.jdom2.output.XMLOutputter();
        xmlOutputter.setFormat(org.jdom2.output.Format.getPrettyFormat());
        xmlOutputter.output(document, out);
        System.out.println(out);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

And voila:



 
    false
 
(...)

Good to know.

Sunday, June 3, 2012

MKP, y u no have English?!


Az előbb - unalomból - megnéztem az MKP hivatalos honlapjának angol nyelvű verzióját. A jobb felső sarokban: random kép. Csáky-Bugár dwa bratanki, azaz két jó szivar. Pártszakadás volt? Ezek szerint nem. So keep smiling.

Monday, April 23, 2012

Ubuntu open router

ip_forwarding = 1
sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

... think about your network design before you start kicking your head against the wall.
Poor external router does not know anything about internal addresses.
Fsck.