Skip to content

Instantly share code, notes, and snippets.

@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 / 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)
ApplicationContext ctx = SpringApplication.run(Application.class, args);
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
@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.