Skip to content

Instantly share code, notes, and snippets.

@adam-currie
adam-currie / bak.fish
Created August 3, 2025 14:15
fish functions that wrap cp/mv for backup/restore of files/directories
function _bak_help
echo "Usage: bak|unbak <file/dir> [suffix]"
echo " bak: Copy <file/dir> to <file/dir><suffix> (default: .bak)"
echo " unbak: Copy <file/dir><suffix> to <file/dir> (default: .bak)"
end
function bak
if test "$argv[1]" = "-h"
_bak_help
return
@adam-currie
adam-currie / toggledesktopicons
Last active August 3, 2025 14:43
Hides all desktop icons, or shows them if they're all hidden already.
#!/usr/bin/env bash
# Hides all unhidden tesktop icons, or if they are all hidden already,
# unhides all (excluding dot prefixed).
#
# Bind me to a global hotkey.
#
# This method allows adding new (unhidden) files even while icons are hidden,
# at which point they can be hidden also by executing again,
# since the script only unhides when ALL icons are hidden.
@adam-currie
adam-currie / lendx
Last active May 26, 2022 19:20
runs a command as another user with current users x server
#!/bin/bash
selfBaseName=$(basename -- "$(readlink -f -- "$0")")
usage="Usage: ${selfBaseName} <username> <command>"
if test $# -ne 2; then
echo $usage
exit
fi
@adam-currie
adam-currie / contains.h
Created December 30, 2021 18:55
checks if a container contains an item eg: strings>>contains("hello")
#pragma once
template<typename T>
class contains {
const T& item;
public:
contains(const T& item) : item(item) {}
template<typename C>
import android.arch.lifecycle.Observer;
import android.support.annotation.Nullable;
public abstract class IgnorantObserver<T> implements Observer<T>{
private boolean isIgnoring = false;
private boolean doingIgnorantly = false;
public IgnorantObserver(){
this(false);
}