Skip to content

Instantly share code, notes, and snippets.

package com.example.reference;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
/*
* https://dzone.com/articles/java-different-types-of-references
*/
public class ReferenceExample {
private String status ="Hi I am active";
@runnerdave
runnerdave / bash-calculator
Created March 5, 2018 04:41
bash script to test inputs
#!/bin/bash
# set -f only works when run in the prompt before executing the script, may be due to my
# local setup
set -f
expr "${1}" "${2}" "${3}"
if [ $# -lt 3 ]
then
echo "Usage : $0 Operand Operation Operand"
@runnerdave
runnerdave / FileRecursor.java
Created August 8, 2018 06:00
simple recursive app to recursively map a local directory as well as return its total size
import java.io.*;
import java.util.HashMap;
class FileRecursor {
private static HashMap<String, File> filesMap = new HashMap();
private static long totalSize = 0;
public static void main(String[] args) {
System.out.println("==List all files in current directory and total size they occupy==");
File folder = new File(".");
@runnerdave
runnerdave / gist:516550781e2a5fea83686a0076a4140e
Created May 20, 2019 04:34
lsof function for .bash_profile
# example usage:
# listening 22
# listening java
listening() {
if [ $# -eq 0 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P
elif [ $# -eq 1 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
else
echo "Usage: listening [pattern]"