Skip to content

Instantly share code, notes, and snippets.

View William-Lake's full-sized avatar

William Lake William-Lake

  • State of Montana
View GitHub Profile
@William-Lake
William-Lake / MeasureElapsedTime.sh
Created June 28, 2017 21:41
Bash - Example of measuring elapsed time
#!/bin/bash
#############################################
# Determines how much time has elapsed.
#
# Takes advantage of the 'SECONDS' variable which is global environment variable in shell.
# 'SECONDS' is usually used by the environment to record how long it has been
# since a script was first executed.
#
# It's taken advantage of here to measure a length of time.
@William-Lake
William-Lake / HowToSendEmailFromTerminal.md
Last active February 27, 2018 13:57
How to send email from terminal.

How to send email from Terminal

Instructions 3, 5 from here

Instruction 6 from here

  1. Install mutt
sudo apt-get install mutt
@William-Lake
William-Lake / main.java
Last active September 18, 2017 18:45
How to create a BufferedImage from a bunch of smaller BufferedImages.
package main;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
@William-Lake
William-Lake / GetCurrentWorkingDirectory.java
Created September 1, 2017 20:03
Java - Get current working directory
public static String workingDir = Paths.get(".").toAbsolutePath().normalize().toString();
@William-Lake
William-Lake / RemovingDupLines.txt
Last active September 18, 2017 18:34
How to remove duplicate lines from text data in notepad++
Source: http://webcache.googleusercontent.com/search?q=cache:https://notepad-plus-plus.org/community/topic/11466/eliminate-duplicate-rows-show-unique-rows-only
(Cached with Google in case it ever goes down.)
1) Open notepad++ and paste in data you want duplicate lines removed from.
2) Edit -> Line Operations -> Sort Lines Lexicographically Ascending
3) Ctrl + F
4) Search for: ^(.+?)\R(\1\R?)+
5) Replace with: \1\r\n
@William-Lake
William-Lake / RemovePunct.java
Last active May 4, 2021 14:34
Java - Use .replaceAll() to remove punctuation from String via regex.
word = word.replaceAll("\\p{Punct}+", "");
@William-Lake
William-Lake / Main.java
Created September 18, 2017 19:04
JavaFX - VERY BASIC Sample application
package main;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@William-Lake
William-Lake / HowTo.md
Last active December 11, 2017 16:26
VBox Windows Host / Ubuntu 16.04 Server Guest : Create Shared folder
@William-Lake
William-Lake / HowTo.md
Created January 7, 2018 13:35
How to send an email via mutt in a bash script on a recurring basis with crontab.

How to send an email via mutt in a bash script on a recurring basis with crontab.

This was suprisingly difficult for me, so I'm making this quick guide so I have it handy in the future.

Steps

  1. Set up mutt using this guide
  2. Create your bash script that will be sending emails using mutt.
  3. When creating your bash script, add the following line to your mutt command:
@William-Lake
William-Lake / RSToPOJOConverter.java
Created October 11, 2018 18:55
Generic ResultSet to POJO Converter
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;