Skip to content

Instantly share code, notes, and snippets.

@wytten
wytten / gist:c610fbe7d26c3c980d19f43a8beffcf0
Created January 31, 2018 18:21
Bash function that executes Oracle SQL and builds URL and opens it with chrome
function report
{
num="$1"
chrome $(sqlplus -S username/password@connect_identifier <<EOF
set echo off
set verify off
set timing off
set heading off
set feedback off
set linesize 32767
@wytten
wytten / count-log-events.sh
Created September 28, 2017 15:45
Use awk to count log events by day, or by hour assuming each line starts with (date)(space)(hour)(colon)
#!/bin/bash
# EXAMPLE 1, BY DAY (default delimiter space)
# otus.decare.com:/logs/foster/WebLogic/DDS_Prod/claimservices > ~/bin/count-log-events.sh " MapMessage received" *.out
# 2016-08-11 35306
#
# EXAMPLE 2, BY HOUR (delimiter colon)
# otus.decare.com:/logs/foster/WebLogic/DDS_Prod/claimservices > ~/bin/count-log-events.sh -F: " MapMessage received" *.out
# 2016-08-11 02 6501
# 2016-08-11 03 3529
# 2016-08-11 04 13221
@wytten
wytten / crontab
Created September 13, 2017 13:57
Check for new mail once daily and mail summary
/usr/bin/find /var/mail/yourself -mtime -1 -size +600c | /bin/egrep '.*' > /dev/null && (from | grep -v 'FOLDER INTERNAL DATA' | /usr/bin/mail -s Summary yourself@gmail.com)
@wytten
wytten / gist:3d8e86728c2c12f6cfe6fd83d5d8be68
Created September 11, 2017 20:39
Setting environments variables on MacOS 10.12 (Sierra)
PATH:
A. bash - Edit /etc/paths
B. apps - sudo launchctl config user path $PATH
OTHER:
https://diaryproducts.net/EnvPane
@wytten
wytten / gist:56c44d494b6a33868ee4dff1f4cfe665
Created September 5, 2017 15:25
xpath to report maven project version as parsed from pom.xml
public static void main(String[] args) throws Exception {
String uri = "pom.xml";
if (args.length > 0) {
uri = args[0];
}
String path = "/project/version/text()";
if (args.length > 1) {
path = args[1];
}
if (!path.startsWith("/")) {
function play {
local wav=`cygpath -W`/Media/$1.wav
if [ -f "$wav" ]; then
cp "$wav" /dev/dsp
else
echo "$wav" not found
fi
}
function tada {
function devssh
{
for i in nova regal saab paxton; do
ssh $i "$@"
done
}
function devpull
{
devssh "(cd weblogic; git pull)"
@wytten
wytten / gist:84a0a13547d697afb0059904cea02558
Last active May 11, 2016 15:23
Count log events per hour using awk, for a log file containing messages prefixed with date and time e.g., '2016-04-18 02:03:07'
$awk -F: '/logMessageOfInterest/ {counts[$1] = counts[$1] + 1; } END { for (val in counts) print val, counts[val]; }' LOG.TXT | sort
@wytten
wytten / Class.java
Created May 7, 2014 15:47
This is the method invoked by java.lang.Class.getResourceAsStream()...See the comment, I don't think it is intuitive behavior
/**
* Add a package name prefix if the name is not absolute Remove leading "/"
* if name is absolute
*/
private String resolveName(String name) {
...
}
@wytten
wytten / GroovySystemTest.java
Last active August 29, 2015 14:00
Locate all the groovy scripts in a certain package within the classpath, and execute them as a JUnit 4.x test suite
@RunWith(Parameterized.class)
public class GroovySystemTest {
@Parameters(name = "{0}")
public static Collection<Object[]> data() throws Exception {
Collection<Object[]> data = new ArrayList<Object[]>();
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
provider.addIncludeFilter(new AssignableTypeFilter(Script.class));