Skip to content

Instantly share code, notes, and snippets.

View leonelag's full-sized avatar

Leonel leonelag

  • Sorocaba - Brazil
View GitHub Profile
#!C:/cygwin64/bin/bash.exe
# Version = 1.10.1.462
set -e
function join { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
#
# LLGD: this is to avoid confusion between C:\cygwin64\bin\cygpath.exe and C:\local\Git\cygpath.exe
@leonelag
leonelag / clojure.sh
Last active April 13, 2021 00:58
Clojure launcher for cygwin
#!/usr/bin/env bash
#
# From: https://raw.githubusercontent.com/clojure/brew-install/1.9.0/src/main/resources/clojure
#
# Version = 1.10.3.814
project_version=1.10.3.814
# Check for cygwin
@leonelag
leonelag / Main.java
Created March 15, 2018 19:53
Force Spring Boot application to use a config file.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
public class Main {
private static final String CONFIG_NAME = "myapp"; // FIXME - this will read configs from file myapp.properties; fix as required
@leonelag
leonelag / gist:6500811
Created September 9, 2013 20:08
Paste this in the REPL to see the current classpath of the application.
(println (string/join "\n"
(string/split (get (System/getProperties)
"java.class.path")
#";")))
@leonelag
leonelag / Pair.java
Created June 14, 2013 12:45
Immutable pair of elements. I have used this in many projects, too bad the Java library does not include it by default.
package util;
public class Pair<T extends Comparable<T>, U extends Comparable<U>> implements Comparable<Pair<T,U>> {
private T first;
private U second;
public Pair(T first, U second) {
if (first == null) throw new IllegalArgumentException("First argument must not be null");
if (second == null) throw new IllegalArgumentException("Second argument must not be null");
this.first = first;
@leonelag
leonelag / gist:5732218
Created June 7, 2013 20:34
Find version of the current Oracle instance you are connected to.
select * from v$version
@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>
@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.
*
;;
;; 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 / 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: