Skip to content

Instantly share code, notes, and snippets.

@angusdev
angusdev / SplitPdf.java
Created February 13, 2017 09:56
Single Java class to split a single PDF to multiple PDFs With several built-in scripts or write your own custom scripts using Groovy.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@angusdev
angusdev / yesterday.bat
Created February 13, 2017 10:04
DOS Batch to get Yesterday in YYYYMMDD
@echo off
REM usage: for /f "delims=" %%a in ('yesterday.bat') do @set YESTERDAY=%%a
setlocal
set yyyy=
set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
@angusdev
angusdev / today.bat
Created February 13, 2017 10:06
DOS Batch to get Today in YYYYMMDD
@echo off
REM usage: for /f "delims=" %%a in ('today.bat') do @set TODAY=%%a
setlocal
set yyyy=
set $tok=1-3
for /f "tokens=1 delims=.:/-, " %%u in ('date /t') do set $d1=%%u
@angusdev
angusdev / lastmonth.bat
Created February 13, 2017 10:17
DOS Batch to get last month end date in YYYYMMDD or YYYYMM
@echo off
REM usage: for /f "delims=" %%a in ('lastmonth.bat') do @set LASTMONTH=%%a
REM usage: for /f "delims=" %%a in ('lastmonth.bat YYYYMM') do @set LASTMONTH=%%a
setlocal
set yyyy=
set $tok=1-3
@angusdev
angusdev / TestGson.java
Created February 14, 2017 05:58
Sample Code for using Gson
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* https://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.0/
* <p>
* Output:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.eaio.stringsearch.BNDMWildcards;
import com.eaio.stringsearch.BoyerMooreHorspool;
import com.eaio.stringsearch.BoyerMooreHorspoolRaita;
import com.eaio.stringsearch.StringSearch;
@angusdev
angusdev / pom.groovy
Last active February 21, 2017 05:01
Groovy script to print the dependency of maven pom
#!/usr/bin/env groovy
def xml = new XmlSlurper().parseText(new File(this.args.length>0?this.args[0]:"pom.xml").getText("UTF-8"));
println "${xml.groupId}/${xml.artifactId}:${xml.version}"
xml.dependencies.dependency.each() { dep ->
println " ${dep.groupId}/${dep.artifactId}:${dep.version}"
}
@angusdev
angusdev / .bashrc
Created February 21, 2017 04:58
.bashrc
export DEVLIB_HOME=/cygdrive/d/devlib
export APP_HOME=/cygdrive/d/apps
# PATH
export PATH=/usr/bin:$PATH
export PATH=$APP_HOME/tools/:/cygdrive/c/Program\ Files/cvsnt:$PATH
# Java
export JAVA13_HOME=$DEVLIB_HOME/jdk1.3.1_09
export JAVA14_HOME=$DEVLIB_HOME/j2sdk1.4.2_10
@angusdev
angusdev / oracle-working-day.sql
Last active May 2, 2017 03:22
Get the last working date (mon-fri) from oracle
WITH cal AS (SELECT TRUNC(TO_DATE('20170505', 'YYYYMMDD')) + ROWNUM - 1 dt FROM DUAL CONNECT BY LEVEL < 13)
SELECT dt as TODAY,
1 + TRUNC(dt - 1) - TRUNC(dt, 'iw') AS dow,
TO_CHAR(dt, 'DY') AS dow_name,
dt - GREATEST((1 + TRUNC (dt) - TRUNC (dt, 'iw')) - 5, 0) AS last_working_date,
dt - 1 as YESTERDAY,
dt - 1 - GREATEST((1 + TRUNC (dt - 1) - TRUNC (dt - 1, 'iw')) - 5, 0) AS last_working_date_of_yesterday
FROM cal;
select trunc(sysdate-GREATEST((1+TRUNC(sysdate)-TRUNC(sysdate, 'iw'))-5, 0)) from dual;