Skip to content

Instantly share code, notes, and snippets.

View zkytony's full-sized avatar
🍊

Kaiyu Zheng zkytony

🍊
View GitHub Profile
@zkytony
zkytony / safe_rm.sh
Created October 21, 2017 15:49
Safe rm - moves deleted files to a dumping ground
# Some important aliases
SAFE_RM_DIR=${SAFE_RM_DIR:="$HOME/.safe_rm"}
REAL_RM=${REAL_RM:="/bin/rm"}
# Override rm, because it's always painful to recover
# files deleted by rm, if possible at all. Instead,
# simply move it to the $SAFE_RM_DIR for later cleaning.
rm()
{
force=false
@zkytony
zkytony / GraphKthLevelChildren.java
Last active November 15, 2015 06:27
Java Returns a set of Strings which represent vertices' data at the k-th level from the vertex with given data "start".
/**
* Returns a set of Strings which represent vertices' data at the k-th level from
* the vertex with given data "start". The level is 0 at the given vertex. The level
* increments by 1 when traversal goes one level deeper. For example, consider a graph
* where A has children {B,C}, B has children {D}, C has children {A}. Then when this
* method is called as kthLevelChildren("A", 2), the resulting set would contain
* {A, D}, since these vertices are 2 levels starting from "A".
*
* Note: the purpose of this method is more for testing, in the context of homework 6.
*