Search This Blog

Wednesday, September 26, 2012

Show Hidden Files in MACOSX

to display hidden Files in Macosx Finder enter the following cmds in your console:

defaults write com.apple.finder "AppleShowAllFiles" -bool "true" && killall Finder

Wednesday, August 29, 2012

Js Modules with Titanium Appcelerator Framework

Here are the two ways you could currently use JS modules within the Titanium Mobile Framework from appcelerator:

1. Function Module

Assume you have a FunctionModule.js with the following content:

// an internal variable, which is only accesible within the module
var internalMsg = "Only visible within the module";

// an exported function, which this module offers
exports.hello = function(msg) {
alert('your message: ' + msg + ' internal message: ' + internalMsg);
}


you could use you module like this:

// reference the module
var fmo = require('/ui/common/FunctionModule');

// call the exported function
fmo.hello('External Message');










// no access from the outside to the internal variable
alert('interal var from module: ' + fmo.internalMsg)




2. Object Module

Assume you have a ObjectModule.js with the following content:


// constructor of your object
function Sample(name) {
   this.name = name;
}
// function, which alerts the current name
Sample.prototype.showName = function() {
alert('Name: ' + this.name);
}
// function, which sets the name
Sample.prototype.setName = function(name) {
this.name = name;
}
// you just export your Object and override the methods as prototypes
module.exports = Sample;


you could use you module like this:


// reference the module
var SampleModule = require('/ui/common/ObjectModule');
// Create a sample Object
var sam = new SampleModule('Fred');
// call a Method
sam.showName();

// change the internal name
sam.setName('Hugo');
sam.showName();













Tuesday, August 21, 2012

Avoid the git username password prompt

Coming from cvs and svn I tend to clone git repos with https, which work but ask for the username password every time you connect.
To avoid the prompt you should use the ssh url an be done with it. If you already use a repo and want to switch to ssh follow the following steps



1. git remote show origin
Password for 'https://username@bitbucket.org': 
* remote origin
  Fetch URL: https://username@bitbucket.org/username/reponame.git
  Push  URL: https://username@bitbucket.org/username/reponame.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
2. git remote set-url origin git@bitbucket.org:username/reponame.git

3. git remote show origin
* remote origin
  Fetch URL: git@bitbucket.org:username/reponame.git
  Push  URL: git@bitbucket.org:username/reponame.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

You can easily get the URL for your repo from your Github, bitbucket or wherever you are hosting your repo. If you get a response i.e. like this


Permission denied (publickey).
fatal: The remote end hung up unexpectedly

then you might forgot to put your ssh key on the github repo server.



Tuesday, July 17, 2012

Timeout für das Umschalten auf die Voicemail einstellen


Wie stelle ich die Dauer für das Umschalten auf die Voicemail (IPhone) bei T-Mobil/Telekom ein?

**61*3311*11*XX#

eingeben. Wobei unter XX die Dauer eingestellt werden kann 5, 10, 15, 20, 25 oder 30 Sekunden.


**61*3311*11*20#

schaltet z.B. die Voicemail nach 20 Sekunden klingeln lassen ein.

Friday, February 24, 2012

Quick ref of managed Beans config in Spring

Within your service


@ManagedResource
(objectName="bean:name=SampleService",
description="Properties Service", log=true)
public class SampleImpl implements ISampleService

      @ManagedAttribute
      public void setName(String name) {
            ...
      }


Within your startup of your weblogic or whatever app container

 
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8088
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false



Startup jconsole and enter the hostname and the port within the "Remote Process" field.

done.


The full address to the remote process is

service:jmx:rmi:///jndi/rmi://SERVERNAME:PORT/jmxrmi



Thursday, February 9, 2012

Buffered File writing Snip

        byte[] content  = "Content is overrated".getBytes();
        String filename = "C:/temp/hirsch." + lieferung.getFormat();
        BufferedOutputStream bos = null;
        try {
            FileOutputStream fos = new FileOutputStream(new File(filename));
            bos = new BufferedOutputStream(fos);
            bos.write(content);
        } catch (Exception e) {
            LOG.error("Write Exception" , e);
        } finally {
            if (bos != null) {
                try {
                    bos.flush();
                    bos.close();
                } catch (Exception e) {
                    LOG.error("Close or Flush Exception" , e);
                }
            }
        }

Thursday, January 26, 2012

Database table history with triggers

Here is a short sample about keeping all data of a table within a history table. The way I prefer it to do is via database triggers. Lets assume you have a table called:

CREATE TABLE BOOK {
  • BOOK_ID       NUMBER(10),
  • NAME             VARCHAR2(10),
  • AUTHOR         VARCHAR2(10),
  • ISBN                VARCHAR2(13)
}

Your application as well as your database scripts are working on that table. Your aim is to keep track on all changes on that table. To do so you need a history table, which looks pretty much the same as the original table and you have to add to fields to your original table:

CREATE TABLE BOOK {
  • BOOK_ID                NUMBER(10),
  • NAME                      VARCHAR2(10),
  • AUTHOR                  VARCHAR2(10),
  • ISBN                         VARCHAR2(13)
  • CHANGE_DATE      DATE,
  • CHANGE_USER      VARCHAR2(20)
}

CREATE TABLE BOOK_HISTORY {
  • BOOK_ID                NUMBER(10),
  • NAME                      VARCHAR2(10),
  • AUTHOR                  VARCHAR2(10),
  • ISBN                         VARCHAR2(13)
  • CHANGE_DATE      DATE,
  • CHANGE_USER      VARCHAR2(20),
  • ACTION                   VARCHAR2(100)
}
and create db triggers for all manipulations to the original table:

CREATE OR REPLACE TRIGGER BOOK_INSERT
       BEFORE INSERT ON BOOK
       FOR EACH ROW
BEGIN
   INSERT INTO BOOK_HISTORY
                    (BOOK_ID, NAME, AUTHOR, ISBN, 
                     CHANGE_DATE, CHANGE_USER, ACTION)
    VALUES (:new.BOOK_ID,:new.NAME, :new.AUTHOR, :new.ISBN, 
                      :new.CHANGE_DATE, :new.CHANGE_USER, 'INSERTED');
 END;


CREATE OR REPLACE TRIGGER BOOK_CHANGE
       BEFORE UPDATE ON BOOK
       FOR EACH ROW
BEGIN
   INSERT INTO BOOK_HISTORY
                    (BOOK_ID, NAME, AUTHOR, ISBN, 
                     CHANGE_DATE, CHANGE_USER, ACTION)
    VALUES (:old.BOOK_ID, :old.NAME, :old.AUTHOR, :old.ISBN, 
                      :old.CHANGE_DATE, :old.CHANGE_USER, 'CHANGED');
 END;

CREATE OR REPLACE TRIGGER BOOK_DELETE
       BEFORE DELETE ON BOOK
       FOR EACH ROW
BEGIN
   INSERT INTO BOOK_HISTORY
                    (BOOK_ID, NAME, AUTHOR, ISBN, 
                     CHANGE_DATE, CHANGE_USER, ACTION)
    VALUES (:old.BOOK_ID, :old.NAME, :old.AUTHOR, :old.ISBN, 
                      :old.CHANGE_DATE, :old.CHANGE_USER, 'DELETED');
 END;


These are three simple triggers which will fire if someone (application, scripts or whatever) will change the book table. You might write more sophisticated triggers like WHERE clauses or a CHANGE_FIELD and CHANGE_VALUE column.