Skip to content

Instantly share code, notes, and snippets.

View pthis's full-sized avatar

pthis pthis

  • Nanjing, Jiangsu, China
  • 04:25 (UTC +08:00)
View GitHub Profile
@pthis
pthis / enterprise_token.rb
Created December 9, 2022 13:38 — forked from markasoftware/enterprise_token.rb
OpenProject Enterprise mode for free
############ REPLACE app/models/enterprise_token.rb in the source code with this file! ################
############ also be sure to RESTART OpenProject after replacing the file. ################
############ it doesn't show that enterprise mode is enabled in the settings, but all ################
############ enterprise mode features, such as KanBan boards, are enabled. ################
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
@pthis
pthis / Smart HTTP Git and CGIT on Nginx server with Auth on push
Created February 1, 2023 13:36 — forked from rtkay123/Smart HTTP Git and CGIT on Nginx server with Auth on push
Installing Git and Cgit to Debian NGINX server (with smart http and authentication on push)
# Just some notes on enabling smart http with nginx as well as authentication on push for repos
# install git, cgit and apache2-utils (for authentication)
apt install git cgit apache2-utils fcgiwrap
# create a git user
adduser git
su git
cd
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
@pthis
pthis / open-vm-tools-vmware-ubuntu-sharing.md
Created February 18, 2023 10:17 — forked from darrenpmeyer/open-vm-tools-vmware-ubuntu-sharing.md
open-vm-tools and VMWare Shared Folders for Ubuntu guests

(NB: adapted from this Ask Ubuntu thread -- tested to work on Ubuntu 16.04 LTS through Ubuntu 22.04 LTS (Jammy).

Unlike using VMWare Tools to enable Linux guest capabilities, the open-vm-tools package doesn't auto-mount shared VMWare folders. This can be frustrating in various ways, but there's an easy fix.

TL;DR

Install open-vm-tools and run:

sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
@pthis
pthis / encrypt_openssl.md
Created February 28, 2023 06:56 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@pthis
pthis / 7zip.bat
Created June 12, 2023 03:13 — forked from rumbu/7zip.bat
7-zip AES encryption from the command line
# Compress and encrypt all current subfolders on Windows
FOR /D %%X IN (*) DO "C:\Program Files\7-Zip\7z.exe" a -mhe -pMYPASSWORD "%%X.7z" "%%X"
@pthis
pthis / gitkeep.md
Created April 21, 2024 11:24 — forked from jlollis/gitkeep.md
.gitkeep - Push your entire folder structure to GitHub, including empty folders

.gitkeep

A .gitkeep file tells github to do the opposite of its default behaviour, which is to ignore empty folders.

If you want to track an empty folder, or a folder with untracked files, create a 0kb file with the .gitkeep file extension in that folder.

touch FOLDER_NAME/.gitkeep

@pthis
pthis / bash-script-path.sh
Created April 22, 2024 05:43 — forked from rdonkin/bash-script-path.sh
Getting the full path to current script in bash
#!/bin/bash
# All these options work on bash 3.2 on macOS where 'readlink -f' is not available
# Ref http://stackoverflow.com/a/246128
# 1. Get script path, don't canonicalise symlinks used in script path
# ${BASH_SOURCE[0]} is set but includes './' prefix
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" 2>/dev/null)" && pwd 2>/dev/null)"

Proxmox with LVM-thin and why we should use Trim/Discard

Excerpts from the Proxmox VE Administration Guide]

LVM normally allocates blocks when you create a volume. LVM thin pools instead allocates blocks when they are written. This behaviour is called thin-provisioning, because volumes can be much larger than physically available space.

8.10.2. Trim/Discard It is good practice to run fstrim (discard) regularly on VMs and containers. This releases data blocks that the filesystem isn’t using anymore. It reduces data usage and resource load. Most modern operating systems issue such discard commands to their disks regularly. You only need to ensure that the Virtual Machines enable the disk discard option.