Skip to content

Instantly share code, notes, and snippets.

Andrew awwsmm

Block or report user

Report or block awwsmm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@awwsmm
awwsmm / clickableValueBoxModule.R
Created Jul 12, 2019
Clickable valueBox in R Shiny which opens a modal with reactive inputs, in a module
View clickableValueBoxModule.R
# define the UI of the module
clickableValueBoxUI <- function(id) {
# create the namespace
ns <- NS(id)
# define the UI components
fluidRow(
valueBoxOutput(ns("my_valueBox"))
)
@awwsmm
awwsmm / modalModule.R
Created Jul 12, 2019
An R Shiny Modal in a Module
View modalModule.R
# define the module UI
moduleUI <- function(id) {
# create the namespace from the id
ns <- NS(id)
# As this is a function, the last statement will be the return value.
# Make sure it contains all of the UI elements you want to display
fluidPage(
@awwsmm
awwsmm / array_contains.sh
Last active Jun 22, 2019
Merge all Java-like "classpath"s in arguments into a single valid classpath, keep other arguments intact
View array_contains.sh
#!/usr/bin/env bash
#-------------------------------------------------------------------------------
#
# array_contains - returns 0 if array contains the specified value, else 1
#
# $1 : term to search for
# $2+ : array to inspect
#
# sources:
@awwsmm
awwsmm / printargs.sh
Last active Jun 23, 2019
Easily print arguments passed to a `bash` script
View printargs.sh
#!/usr/bin/env bash
#-------------------------------------------------------------------------------
#
# print_args - easily inspect arguments passed to a bash script
#
# sources:
# https://unix.stackexchange.com/a/332126/183920
#
#-------------------------------------------------------------------------------
@awwsmm
awwsmm / allvars.sh
Last active Jun 6, 2019
Get all environment and shell variables
View allvars.sh
#!/bin/bash
set | grep "^[A-Z]" | sed -e 's/[[:space:]].*//' -e 's/=.*//'
# tested on bash, ksh, tcsh, zsh
# Sources:
# https://askubuntu.com/a/275972/360539
# https://stackoverflow.com/a/20348145/2925434
# https://www.tutorialspoint.com/unix/unix-regular-expressions.htm
@awwsmm
awwsmm / FixedWidthFile.java
Created Mar 1, 2019
Infers the column widths of a fixed-width flat text file and parses its lines into tokens
View FixedWidthFile.java
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@awwsmm
awwsmm / JavadocPaths.java
Created Dec 17, 2018
Filesystem paths (Windows and Linux) in Javadoc
View JavadocPaths.java
/**
* Javadoc for filesystem path edge cases.
*
* <hr style="height:1px;border:0;border-top:1px solid #CCC">
*
* <h2><strong>Edge Case 0: Inline Windows Filesystem Paths</strong></h2>
*
* <p>Here is an inline Windows fs path with backslashes:
* <code>"C:&#92;Users&#92;user&#92;file.txt"</code>. You must replace the
* {@code '\'} characters with {@code "&#92;"} in the source code, otherwise
@awwsmm
awwsmm / GetDerbyDBO.java
Created Dec 9, 2018
Determine / find the database owner ("dbo") and current user in an embedded Derby (JavaDB) database
View GetDerbyDBO.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
/**
* Example class, showing how to find owner of an embedded Derby database.
*
@awwsmm
awwsmm / PNode.java
Created Nov 12, 2018
Ready-to-use node data structure for Java with examples in jshell
View PNode.java
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@awwsmm
awwsmm / ParseCLArgs.java
Created Nov 11, 2018
Parse command-line arguments and categorise them as "arguments", "flags", "long flags", or "other". Return an easy-to-use List<Entry>.
View ParseCLArgs.java
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
public class ParseCLArgs {
// try with
// $ java ParseCLArgs arg -short anotherArg --long - -- ---toolong
You can’t perform that action at this time.