Skip to content

Instantly share code, notes, and snippets.

View leonelag's full-sized avatar

Leonel leonelag

  • Sorocaba - Brazil
View GitHub Profile
@leonelag
leonelag / pom.xml
Created March 19, 2012 14:30 — forked from anonymous/pom.xml
Prevent m2e error message: Plugin execution not covered by lifecycle configuration
<!-- http://wiki.eclipse.org/M2E_plugin_execution_not_covered#lifecycle_mapping_metadata_provided_by_maven_plugin -->
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
@leonelag
leonelag / index.html
Created April 25, 2012 11:50
Example of how to attach an event to HTML elements
<html>
<head>
<style>
li { border: thin solid red }
</style>
</head>
<body>
<ul>
<li id="my-elem-1">1</li>
<li id="my-elem-2">2</li>
@leonelag
leonelag / swank.sh
Created May 17, 2012 19:48
Quickly start a swank-clojure server outside a lein project.
#!/bin/sh
LOCAL_REPO="C:\Users\LLGD\work\maven-repository"
CLOJURE_JAR="$LOCAL_REPO\org\clojure\clojure\1.4.0\clojure-1.4.0.jar"
SWANK_JAR="$LOCAL_REPO\swank-clojure\swank-clojure\1.4.2\swank-clojure-1.4.2.jar"
CLJ_STACKTRACE="$LOCAL_REPO\clj-stacktrace\clj-stacktrace\0.2.4\clj-stacktrace-0.2.4.jar"
$JAVA_HOME/bin/java.exe -cp "$CLJ_STACKTRACE;$SWANK_JAR;$CLOJURE_JAR" clojure.main --eval "(require '[swank.swank])(swank.swank/start-server :port 8000)"
@leonelag
leonelag / jetty-env.xml
Created October 4, 2012 11:23
How to add dependencies to a project run with jetty-maven-plugin
<!--
Example of data source configuration for Jetty 8
-->
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/myapp</Set>
@leonelag
leonelag / 403.jsp
Created October 4, 2012 12:23
Advanced Spring Security. How to configure Spring beans to set up Spring Security without using the Spring Security namespace.
<%@page contentType="application/json; charset=UTF-8"%>{"status":"nauth","message":"Not authorized."}
@leonelag
leonelag / SSLPoke.java
Last active December 11, 2015 17:18
Checks that the Java runtime is able to connect to and communicate with an SSL server. Useful for checking whether the security key chain contains valid keys.
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
@leonelag
leonelag / build.xml
Last active December 11, 2015 17:19
Use Ant to download dependencies from Maven repositories.
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
Dependency download
Downloads dependencies from Maven repositories.
Maven-ant-tasks jar:
http://www.apache.org/dyn/closer.cgi/maven/ant-tasks/2.1.3/binaries/maven-ant-tasks-2.1.3.jar
Tasks documentation:
;;
;; Utility script to convert files between character encodings.
;;
;; I've used this to fix the character encoding in a messy project where files
;; were encoded with different encodings
;;
(require '[clojure.java.io :as io])
(defn has-suffix [f suffixes]
(some #(.endsWith (.getName f) %)
@leonelag
leonelag / InstallCert.java
Created May 16, 2013 16:13
This class connects to a host and generates a certificate file. Copy this certificate to folder $JDK_HOME/jre/lib/security and the Java environment will use it to access the host.
/*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
@leonelag
leonelag / pom.xml
Created May 16, 2013 16:24
Snippet of Maven POM file that creates a file named REV in your project, before packaging. The contents of the file are the following env variables: SVN_REVISION BUILD_NUMBER BUILD_ID BUILD_TAG
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>prepare-package</phase>