Skip to content

Instantly share code, notes, and snippets.

@wildlarva
wildlarva / focus-input-element-component.html
Last active January 10, 2019 11:08
Focus conditional input element on Angular
<div *ngFor="let task of tasks">
<!-- Use # to set the name of the input element to focus -->
<input #taskInput *ngIf="task.isEditing" type="text" [(ngModel)]="task.name" (blur)="onEdited(task)" (keyup.enter)="taskInput.blur()">
<div *ngIf="!task.isEditing" (dblclick)="onEdit(task)">{{task.name}}</div>
</div>
@wildlarva
wildlarva / command to register webbrowser.sh for update-alternatives
Last active December 15, 2019 02:41
A shell script to open a web browser from WSL environment. This let you run Jupyter Notebook in WSL.
# Use webbrowser.sh as x-www-browser command
#
# Please follow the instructions below to install:
# 1. Modify the path to webbrowser.sh
# 2. Execute this command
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /path-to/webbrowser.sh 1 # Edit this path to point your webbrowser.sh
@wildlarva
wildlarva / minikube-docker-env
Last active June 7, 2019 22:36
A shell environment file to setup a WSL docker environment from minikube
# Usage: source /path-to/minikube-docker-env
eval $(minikube docker-env --shell zsh)
export DOCKER_CERT_PATH=$(wslpath "$DOCKER_CERT_PATH")
@wildlarva
wildlarva / DiffDumpUtils.java
Last active June 12, 2019 01:38
A snippet to dump java object differences with java-object-diff
import de.danielbechler.diff.ObjectDifferBuilder;
import de.danielbechler.diff.node.DiffNode;
import de.danielbechler.diff.node.Visit;
// implemented with java-object-diff(https://github.com/SQiShER/java-object-diff)
public final class DiffDumpUtils {
public static void dumpDiff(Object o1, Object o2) {
DiffNode root = ObjectDifferBuilder.buildDefault().compare(o2, o1);
root.visit((DiffNode node, Visit visit) -> {
@wildlarva
wildlarva / rarely_used_commands.md
Last active July 2, 2021 04:57
Rarely-used useful commands

Rarely used commands

utils

amusement

banner

print ascii art of text

@wildlarva
wildlarva / useful_commands.md
Last active August 20, 2023 02:09
Useful commands

Useful commands

utils

file

tree

list contents of directories in a tree-like format

@wildlarva
wildlarva / useful_tmux_commands.md
Last active July 2, 2021 04:57
Useful tmux commands

Useful tmux commands

# Find tmux command with a description
tmux list-commands | grep <description>

# Find tmux keybinding with a description
tmux list-keys | grep <description>
@wildlarva
wildlarva / commands to get apt packages manually installed.sh
Last active January 6, 2020 02:54
Get apt packages manually installed in ubuntu
# Edit 'MANIFEST' and point to the manifest file of the ubuntu version you installed
#
# Ubuntu server image 18.04.3
# MANIFEST=http://releases.ubuntu.com/18.04/ubuntu-18.04.3-live-server-amd64.manifest
#
# Ubuntu desktop image 18.04.3
# MANIFEST=http://releases.ubuntu.com/18.04/ubuntu-18.04.3-desktop-amd64.manifest
MANIFEST=http://releases.ubuntu.com/18.04/ubuntu-18.04.3-live-server-amd64.manifest
wget $MANIFEST -q -O - | cut -f 1 | cut -d':' -f1 | sort > preinstalled.txt
apt list --manual-installed | cut -d'/' -f1 | sort > manual_installed.txt
@wildlarva
wildlarva / useful_apt_commands.md
Last active July 2, 2021 04:57
Useful apt/dpkg commands

Useful apt/dpkg commands

Explore package contents

# Find file in installed packages
dpkg -S <file>

# List files in a package
dpkg -L 
@wildlarva
wildlarva / useful_gpg_commands.md
Last active August 20, 2023 02:43
Useful GPG commands

Useful commands for GPG

Check public key

# List public keys
gpg --list-keys

Backup and restore