Skip to content

Instantly share code, notes, and snippets.

@mostlylikeable
mostlylikeable / groovy_suppress_auto_timestamp.groovy
Last active August 29, 2015 14:05
Suppress auto-timestamping in Groovy
def withAutoTimestampSuppression(entity, closure) {
toggleAutoTimestamp(entity, false)
try {
def result = closure()
return result
} finally {
toggleAutoTimestamp(entity, true)
}
}
@mostlylikeable
mostlylikeable / gist:7749878
Last active December 30, 2015 00:29
ssh util
import com.jcraft.jsch.Channel
import com.jcraft.jsch.ChannelSftp
import com.jcraft.jsch.JSch
import com.jcraft.jsch.Session
import java.util.concurrent.TimeUnit
class Ssh {
JSch jsch = new JSch()
@mostlylikeable
mostlylikeable / gist:6311607
Created August 22, 2013 19:20
rm to Trash function
function rm () {
local path
for path in "$@"; do
# ignore any arguments
if [[ "$path" = -* ]]; then :
else
local dst=${path##*/}
# append the time if necessary
while [ -e ~/.Trash/"$dst" ]; do
dst="$dst "$(date +%H-%M-%S)