Skip to content

Instantly share code, notes, and snippets.

@tomjamescn
tomjamescn / mount_qcow2.md
Created Jun 19, 2020 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image
View mount_qcow2.md

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@tomjamescn
tomjamescn / translate.go
Created Jun 9, 2020 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
View translate.go
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
View ubuntu18.04-install-vim8.1.sh
#!/bin/bash
sudo add-apt-repository ppa:jonathonf/vim
sudo apt-get update
sudo apt-get install vim
@tomjamescn
tomjamescn / key-my-complex-rules.json
Last active Apr 30, 2021
Karabiner-Elements的自定义配置,放到~/.config/karabiner/assets/complex_modifications/路径下,并到app中启用
View key-my-complex-rules.json
{
"title": "Personal Rules (@tomjamescn)",
"rules": [
{
"description": "Change caps_lock to control if pressed with other keys, to escape if pressed alone.",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
@tomjamescn
tomjamescn / install-python3.8.sh
Created Mar 31, 2020
ubuntu/debian install python3.8
View install-python3.8.sh
#!/bin/bash
set -e
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8 python3-venv
# python3.8 -m venv myenv
@tomjamescn
tomjamescn / letsencrypt_notes.sh
Created Mar 15, 2020 — forked from lachesis/letsencrypt_notes.sh
Set up LetsEncrypt using acme.sh without root
View letsencrypt_notes.sh
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge
@tomjamescn
tomjamescn / init-vps-shell.sh
Last active Mar 23, 2020
sudo init-server.sh
View init-vps-shell.sh
!#/bin/bash
apt update
apt install vim vim-nox git zsh
curl https://get.docker.com | bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl https://gist.githubusercontent.com/tomjamescn/ccdcda091650ff1d34b496e4eeba123f/raw/62166ff7e7d6d31f6d3964a69a131f1264d38a95/custom_oh_my_zsh.sh | bash
@tomjamescn
tomjamescn / init-server.sh
Created Feb 28, 2020
sudo init-server.sh
View init-server.sh
!#/bin/bash
apt update
apt install vim vim-nox git zsh
curl https://get.docker.com | bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl https://gist.githubusercontent.com/tomjamescn/ccdcda091650ff1d34b496e4eeba123f/raw/62166ff7e7d6d31f6d3964a69a131f1264d38a95/custom_oh_my_zsh.sh | bash
View custom_oh_my_zsh.sh
#!/bin/bash
if [[ -z "$ZSH" ]]; then
echo "还未安装oh-my-zsh!"
exit 1
fi
os=`uname`
cp "$ZSH/themes/robbyrussell.zsh-theme" "$ZSH/custom/themes/robbyrussell.zsh-theme"