Skip to content

Instantly share code, notes, and snippets.

@uWayLu
uWayLu / .bashrc_git_ps1
Last active June 23, 2021 05:21
Show git branch info in PS1
# ~/.bashrc_git_ps1
# echo . ~/.bashrc_git_ps1 >> ~/.bashrc
#
# show git branch and time since last commit with color
# see: https://ihower.tw/blog/archives/5436
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
@uWayLu
uWayLu / ptt_autologin.sh
Created March 4, 2021 18:00 — forked from fkztw/ptt_autologin.sh
A shell script to login PTT via ssh automatically.
#!/usr/bin/env expect
# Login into PTT via SSH.
# Combine crontab with this script so you don't forget to login PTT everyday.
# Usage: /bin/bash -c ${FILE_PATH_OF_THIS_SCRIPT}
# Example in crontab:
# ptt auto login, every day at 12:00 PM
# 0 12 * * * /bin/bash -c ${ABSOLUTE_FILE_PATH_OF_THIS_SCRIPT}
[Unit]
Description=rclone daemon
After=network.target
[Service]
User=ywl
ExecStart=/usr/bin/rclone mount gd: /home/ywl/gdrive --allow-non-empty --vfs-cache-mode writes
ExecStop=/usr/bin/fusermount -uz /home/ywl/gdrive
Restart=on-abort
@uWayLu
uWayLu / resovle_CNAME_to_orig_hostname.php
Last active March 25, 2021 08:49
resovle CNAME to orig hostname
<?php
$hostname = $_SERVER['HTTP_HOST'];
$get_hostname_orig = function (&$hostname) use (&$get_hostname_orig) {
$record = dns_get_record($hostname, DNS_CNAME);
if (count($record) > 0) {
$hostname = $record[0]['target'];
$get_hostname_orig($hostname);
}
};