Public snipts »
lenni's
snipts
showing 1-13 of 13 snipts
-
∞ Getting a logger with Log4j
private static final Log LOG = LogFactory.getLog(SomeClassName.class);
-
∞ tar cheat sheet
#extract tar file (uncompressd) tar xf filename.tar #extract gzip'ed tar file (tar.gz) tar xvfz filename.tar.gz
-
∞ Running a class inside a jar
java -cp konsumtools.jar de.myToys.konsum.tools.export.Sitemapper
-
∞ ack examples
ack cancelcode --jsp --ignore-dir=target -
∞ JSP if-else
<c:choose> <c:when test='${param.p == "someValue"}'> </c:when> <c:otherwise> </c:otherwise> </c:choose>
-
∞ 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(); } } }
-
∞ 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); } } }
-
∞ 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>
-
∞ 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>
-
∞ .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/.*
-
∞ 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>
-
∞ 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>
-
∞ 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>



MySQL Cookbook