Skip to content

Instantly share code, notes, and snippets.

@tjumyk
tjumyk / Ubuntu_24.04_Install_Sogou_Pinyin.md
Last active June 6, 2024 01:40
Ubuntu 24.04 Install Sogou Pinyin
  • Remove ibus
sudo apt purge ibus
sudo apt autoremove
  • Install Sogou Pinyin and dependencies
# Download deb installer from https://shurufa.sogou.com/linux
sudo dpkg -i <sogou_xxx.deb>
sudo apt install -f
@tjumyk
tjumyk / backup_folder.sh
Created February 23, 2024 01:27
Script for backing up a folder, suitable as cron jobs
#!/bin/bash
# Adapted from: https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux
set -e
if [ $# -lt 2 ] ; then
echo "$0 <SOURCE_DIR> <BACKUP_DIR>"
exit 1
fi
@tjumyk
tjumyk / msmtprc
Last active January 22, 2024 02:29
Register Aliyun DirectMail as SMTP provider for msmtp
# install system package: msmtp-mta
# put this config file at /etc/msmtprc
# find Aliyun DirectMail service at https://aliyun.com/product/directmail
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
aliases /etc/msmtp_aliases
logfile ~/.msmtp.log
#!/bin/bash
set -e
V2RAY_PORT=18900
NGINX_PORT_RANGE="8900-8999"
CLIENT_CFG_OUTPUT_PATH=v2ray_client.json
printf "Please make sure the firewall rules for ports 80, 443, $NGINX_PORT_RANGE have been set!\n"
@tjumyk
tjumyk / .bashrc
Created May 19, 2020 05:30
simple bash function for selecting GPU to use for CUDA
usecuda()
{
export CUDA_VISIBLE_DEVICES=$1
echo "Using cuda:$1"
}
@tjumyk
tjumyk / setup_openvpn.sh
Last active June 20, 2024 11:10
Setup OpenVPN on Ubuntu 22.04 LTS
#!/bin/bash
set -e
SERVER_PORT="8194"
WORK_DIR="$HOME/openvpn"
EASYRSA_VERSION="3.1.7"
EASYRSA_DIR="$WORK_DIR/EasyRSA-$EASYRSA_VERSION"
CLIENT_CONFIGS_DIR="$WORK_DIR/client-configs"
@tjumyk
tjumyk / conda
Last active December 27, 2023 01:38
bash auto completion for conda
# Shell auto-completion for conda
# For Ubuntu, you may put this file in /etc/bash_completion.d/ or append the contents to ~/.bashrc
_conda_auto_comp()
{
local cur opts
COMPREPLY=()
if [[ ${COMP_CWORD} == 1 ]]; then # list conda commands
cur="${COMP_WORDS[COMP_CWORD]}"
opts="clean config create help info init install list package remove uninstall run search update upgrade activate deactivate"
@tjumyk
tjumyk / index.php
Created March 4, 2018 13:52
Simple file index for apache
<?php $title="File Index";?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<title><?=$title?></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
@tjumyk
tjumyk / gpuprovider.vala
Created November 4, 2017 05:15
GPU Provider for Ubuntu indicator-multiload
/******************************************************************************
* Copyright (C) 2017 Yukai Miao <tjumyk@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
@tjumyk
tjumyk / fancy-motd.sh
Last active February 6, 2020 14:24
Fancy motd script for my Ubuntu
#!/bin/sh
cpu_model='Unknown CPU'
cpu_cores='?'
if [ -r "/proc/cpuinfo" ]; then
cpu_model=$(cat /proc/cpuinfo | grep 'model name' | head -n 1 | sed 's/^.*:\s*//')
cpu_cores=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
fi
mem_total='?G'
if [ -x "/usr/bin/free" ]; then