Sign up to create your own snipts, or login.

Public snipts » lenni's snipts The latest snipts from lenni.

showing 1-13 of 13 snipts
  • Getting a logger with Log4j
    private static final Log LOG = LogFactory.getLog(SomeClassName.class);
    

    copy | embed

    0 comments - tagged in  posted by lenni on Feb 09, 2010 at 4:43 a.m. EST
  • tar cheat sheet
    #extract tar file (uncompressd)
    tar xf filename.tar
    
    #extract gzip'ed tar file (tar.gz)
    tar xvfz filename.tar.gz
    

    copy | embed

    0 comments - tagged in  posted by lenni on Jan 22, 2010 at 6:53 a.m. EST
  • Running a class inside a jar
     java -cp konsumtools.jar de.myToys.konsum.tools.export.Sitemapper
    

    copy | embed

    0 comments - tagged in  posted by lenni on Jan 22, 2010 at 5:33 a.m. EST
  • ack examples
    ack cancelcode --jsp --ignore-dir=target
    

    copy | embed

    0 comments - tagged in  posted by lenni on Jan 20, 2010 at 4:19 a.m. EST
  • JSP if-else
    <c:choose>
      <c:when test='${param.p == "someValue"}'>	
      </c:when>
      
      <c:otherwise> 	
      </c:otherwise>
    </c:choose>
    

    copy | embed

    0 comments - tagged in  posted by lenni on Jan 19, 2010 at 9:42 a.m. EST
  • Print a file line for line in Java (the 1.6 way)
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    
    public class SlugTester
    {
    
        static String FILENAME = "C:\\slug-test.txt";
    
        public static void main(String[] args)
        {
            try
            {
                BufferedReader reader = new BufferedReader(new FileReader(FILENAME));
    
                String line;
                while ((line = reader.readLine()) != null)
                {
                    System.out.println(line);
                }
    
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }
    }
    

    copy | embed

    0 comments - tagged in  posted by lenni on Jan 12, 2010 at 4:03 a.m. EST
  • Java regex tester
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    public class RegexTester {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
    	// TODO Auto-generated method stub
    
    	String regex = "/ajax/\\w+/(.*)";
    
    	String[] strings = { "/ajax/hello/KID/de-mt.vc.ca02.06.04/1559286",
    		"/ajax/hell_o/KID/de-mt.vc.ca02.06.04/1559286",
    		"/ajax/h0e-l8l_o/KID/de-mt.vc.ca02.06.04/1559286", };
    
    	for (String s : strings) {
    	    Pattern pattern = Pattern.compile(regex);
    	    Matcher matcher = pattern.matcher(s);
    
    	    String kid = "";
    	    if (matcher.find()) {
    		// group(0) returns the entire match, not a captured group
    		kid = matcher.group(1);
    	    }
    
    	    System.out.println(kid);
    	}
        }
    }
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 28, 2009 at 4:23 a.m. EST
  • jQuery HTML template
    <!DOCTYPE html>
    
    <html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>Lektion 7</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
        
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
        
        <script type="text/javascript">
                $(document).ready(function(){
                
                
                });
                
        </script>
    </head>
    
    <body>
        <h1 id="ueberschrift"></h1>    
    </body>
    </html>
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 15, 2009 at 6:21 a.m. EST
  • Protoype HTML Page template
    <!DOCTYPE html>
    
    <html lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8">
    	<title>Lektion 7</title>
    	<link rel="stylesheet" type="text/css" href="style.css" />
    	
    	<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
    	
    	<script type="text/javascript">
    			
    			var callback = function(event){
    				var clickedElement = event.element();
    				var styleObj = {
    					color:"red"
    				};
    				clickedElement.setStyle(styleObj);
    			};
    			
    			var el=$("ueberschrift");
    			el.observe("click", callback);
    	</script>
    </head>
    
    <body>
        <h1 id="ueberschrift">Lektion 8: Callbacks mit Prototype</h1>	
    </body>
    </html>
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 11, 2009 at 5:46 a.m. EST
  • .hgignore template
    syntax: glob
    .DS_Store
    
    # build directories and files
    **/build/*
    build/*
    target/**.*
    dist/**.*
    *.pyc
    
    # Backup files left behind by the Emacs editor.
    *~
    # Lock files used by the Emacs editor.
    .\#*
    # Temporary files used by the vim editor.
    .*.swp
    # Temporary files used by TestMate
    ._*
    # XCode user data
    **.pbxuser
    **.mode?v?
    **.perspectivev?
    # documentation
    **.docset/*
    # for those crazies using svn and hg at the same time
    *.svn*
    
    # temporary folders
    syntax: regexp
    .*/te?mp/.*
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 11, 2009 at 4:32 a.m. EST
  • Prototype & Scriptacolous template
    <!DOCTYPE html>
    
    <html lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8">
    	<title>Title Goes Here</title>
    	<link rel="stylesheet" type="text/css" href="style.css" />
    	<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"></script>
    	<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js" type="text/javascript"></script>
    </head>
    
    <body>
        <p>This is my web page</p>
    </body>
    
    </html>
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 01, 2009 at 9:21 a.m. EST
  • HTML5 template
    <!DOCTYPE html>
    
    <html lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8">
    	<title>Title Goes Here</title>
    	<link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    
    <body>
        <p>This is my web page</p>
    </body>
    
    </html>
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 01, 2009 at 8:19 a.m. EST
  • jsp jbacca template
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" 
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
                xmlns:jb="http://www.mytoys.de/jbacca"
                xmlns="http://www.w3.org/1999/xhtml"
                version="2.0">
    
    <jsp:directive.tag body-content="scriptless"
    		description="Erstellt einen horizontalen BilderSlider."
    		example="
    <jb:imageSlider width='400px' height='60px' leftButton='${leftButton}' rightbutton='${rightButton}'>
    	<ul>
    	  <li>Ein Element</li>
    	  <li>Ein anderes</li>
    	</ul>
    </jb:imageSlider>"/>
            
    		
    
            <jb:generateId />
    
            <jb:script>
    		new KONSUM.jbacca.ImageZoom("${jbaccaId}");
    	</jb:script>
    
    </jsp:root>
    

    copy | embed

    0 comments - tagged in  posted by lenni on Dec 01, 2009 at 4:36 a.m. EST
Sign up to create your own snipts, or login.