I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Showing posts with label useful. Show all posts
Showing posts with label useful. Show all posts

Monday, 24 June 2013

python useful packages in combination with command line

I have been playing with python lately and discovered at least two small utility pacages providing useful features in combination with the commandline. For this reason I created two aliases:

alias openurl='python3 -m webbrowser -t'
alias webshare='python -m SimpleHTTPServer'

The first one opens a web page at the url given as a parameter, if the url does not have a protocol, e.g. http, then the command will interpret it as a local file. The second one starts a webserver for the directory where the command is called. Then you can provide in that way a simple mean of letting someone download local files.

Wednesday, 21 April 2010

git trick - shallow cloning

I am reading Oreilly's kurz & gut Git book. And I discovered, that it is possible to clone with a very shallow level by using the "--depth=" option. For example, if you want only to clone the repository with only the three latest commit, you may use:

$mygitworkingdirectory> git clone --depth=3 git:path/repository

Isn't that great.

Git rocks !!! ;-)

Wednesday, 13 January 2010

Interesting Loading Properties or files in Servlet Context

I was reading the documentation on tomcat in the web to be sure not to miss important information. And I found this at this wiki FAQ:

How do I load a properties file? Here are the two most popular ways:

  • Use a ResourceBundle. See the Java docs for the specifics of how the ResourceBundle class works. Using this method, the properties file must go into the WEB-INF/classes directory or in a jar file contained in the WEB-INF/lib directory.

  • Another way is to use the method getResourceAsStream() from the ServletContext class. This allows you update the file without having to reload the webapp as required by the first method. Here is an example code snippet, without any error trapping:

    // Assuming you are in a Servlet extending HttpServlet
    // This will look for a file called "/more/cowbell.properties" relative
    // to your servlet Root Context
    InputStream is = getServletContext().getResourceAsStream("/more/cowbell.properties");
    Properties p = new Properties();
    p.load(is);
    is.close();