Skip to content

Instantly share code, notes, and snippets.

View liuyigh's full-sized avatar

Yi Liu liuyigh

View GitHub Profile
@liuyigh
liuyigh / iPyTerm.applescript
Created September 11, 2017 19:16
iPyTerm - AppleScript Based iTerm2 launcher for IPython
on run {input, parameters}
#!/usr/bin/osascript
-- Run ipython on a new iTerm (OS X version)
-- See http://www.iterm2.com/#/section/documentation/scripting
tell application "iTerm"
activate
set ipy to (make new terminal)
@liuyigh
liuyigh / wp_gdrive_backup_manual.sh
Last active October 23, 2017 05:35
On-demand back up WordPress to Google Drive with Bash Script. Adapted frpm Mike@wp-bullet.com for serverpilot server. Removed some scripts for automatic backup, such as old backup deletion, directory checking etc.
#!/usr/bin/env bash
# Source: https://guides.wp-bullet.com
# Author: Mike
#define local path for backups
BACKUPPATH="/srv/users/serverpilot/bak/tmp"
#define remote backup path
BACKUPPATHREM="gBackup"
@liuyigh
liuyigh / wp_gdrive_backup.sh
Last active April 18, 2022 14:24
Automatically Back up WordPress to Google Drive with Bash Script. Adapted frpm Mike@wp-bullet.com for serverpilot server.
#!/usr/bin/env bash
# Source: https://guides.wp-bullet.com
# Author: Mike
# Editted by Yi Liu (http://liuyi.co).
# Changes: packup path, site path, use find wp-admin to skip non-wp apps, removed permission lines.
# Run this as user serverpilot
#define local path for backups
BACKUPPATH="/srv/users/serverpilot/bak/tmp"
@liuyigh
liuyigh / wp_helper.sh
Last active February 21, 2020 19:58 — forked from phlbnks/wp_helper.sh
Utility script to help manage WordPress sites on an Serverpilot server (but not limited to SP)
#!/bin/bash
# Help / usage info.
USAGE=$'WordPress Helper script, adapted from Phil Banks (emirpprime@github) EasyEngine script for Serverpilot .\nWithout any args it will search /srv/users/serverpilot/apps for WordPress sites, loop over them in alphabetical order and check for core and plugin updates.\nAlso accepts:\n\t--sites=[space seperated list of site paths relative to /srv/users/serverpilot/apps]\n\t--update=[plugins|wp|all].'
# Die function for exiting on errors.
die () {
echo "${1}, exitting..." >&2 ; echo ; exit 1
}
@liuyigh
liuyigh / history_vol.py
Last active October 2, 2015 16:41 — forked from johntyree/history_vol.py
Calculate annualized volatility from historical data.
#/usr/bin/env python
from pandas import np
from pandas.io.data import DataReader
def historical_volatility(sym, days):
"Return the annualized stddev of daily log returns of `sym`."
try:
quotes = DataReader(sym, 'yahoo')['Adj Close'][-days:]