Skip to content

Instantly share code, notes, and snippets.

@press0
press0 / find all 2 character unix utilities in PATH.sh
Last active December 6, 2022 14:08
find all 2 character unix utilities in PATH
# get all 2 char unix utilities
for i in /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin ; do find $i >> qq ; done
while read i; do basename $i >> qq.basename ; done < qq
cat qq.basename |sort|uniq|grep -w '^\w\{2\}$' > qq.basename.sort.2
# print man description
while read i; do man -f $i >> qq.basename.sort.2.man ; done < qq.basename.sort.2
7z (1) - A file archiver with highest compression ratio
ar (1) - create, modify, and extract from archives
as (1) - the portable GNU assembler.
ApplicationContext ctx = SpringApplication.run(Application.class, args);
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
@press0
press0 / pastebin
Last active April 23, 2018 01:00
javaPuzzles
alias tdebug='cd /opt/tomcat; bin/catalina.sh jpda start; cd - > /dev/null'
alias tlogd='rm /opt/tomcat/logs/*'
alias tstart='cd /opt/tomcat; bin/startup.sh; cd - > /dev/null'
alias tstat='ps -ef|grep tomcat|grep -v grep'
alias tstop='/opt/tomcat/bin/shutdown.sh'
//void arrays - Which of the following doesn’t compile
void[] voids1 = new void[1]; (1)
@press0
press0 / BST.java
Last active October 2, 2020 16:39
generic binary search
public class BST <T extends Comparable<T>> implements Iterable<T>
{
public static void main(String[] args)
{
Integer[] a = {1,5,2,7,4};
BST<Integer> bst = new BST<Integer>();
for(Integer n : a) bst.insert(n);
bst.preOrderTraversal();
System.out.println();
@press0
press0 / 312.java
Last active October 2, 2020 16:41
functional array update 'in place'; in 2 passes; order by 3,1,2; no other values
import static java.util.stream.Collectors.counting;
import static org.junit.Assert.assertArrayEquals;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@press0
press0 / TradeExecutorJUnit4Test
Last active February 15, 2021 14:32
TradeExecutorJUnit4Test
package trp2.redonejunit4;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
public class TradeExecutorJUnit4Test {
@press0
press0 / TradeExecutorJUnit5Test
Created February 10, 2021 19:10
TradeExecutorJUnit5Test
package trp2.redonejunit5;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class TradeExecutorJUnit5Test {
@press0
press0 / ConvertMoneyToEnglish.java
Last active February 19, 2021 15:44
ConvertMoneyToEnglish
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
public class ConvertMoneyToEnglish {
public static String convertMoneyToEnglish(int i) {
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>
<DL><p>
<DL><p>
@press0
press0 / gist:2a6529d7fe376d285b1c5ed976000d37
Last active June 21, 2021 03:01
git log --oneline --decorate --all --graph
git log --oneline --decorate --all --graph