Skip to content

Instantly share code, notes, and snippets.

@dcai
dcai / cron-git-update-equella.sh
Last active October 26, 2017 03:39
cron-git-update-equella.sh
#!/bin/bash
GITLOG="/var/log/equella/cron-update.log"
LOGFILE="/tmp/equellacodeupdate.log"
HTMLFILE="/tmp/equellacodeupdate.html"
EMAILADDR="[email protected]"
FROMEMAILADDR="[email protected]"
SUBJECT="EQUELLA code"
EQSRC=/var/equella-source/
@dcai
dcai / launch.sh
Last active December 22, 2015 03:09
mysql-proxy
echo `pwd`/proxy.lua
mysql-proxy --proxy-lua-script=`pwd`/proxy.lua --log-level=debug
@dcai
dcai / git_update_moodle.sh
Last active October 26, 2017 03:39
git_update_moodle.sh
#!/bin/bash
# Your github username
github_user="dcai"
# The remote name of your github repo, it usually origin
github_remote_name="github"
### STOP CONFIG SINCE HERE! ###
github_diff_root="https://github.com/$github_user/moodle/compare/"
@dcai
dcai / valid.php
Last active December 15, 2015 09:49
This is valid php, it passed `php -l` check O_o
<?php
https://gist.github.php
?>
@dcai
dcai / item.xml
Last active December 14, 2015 16:09
EQUELLA resource integration information
<xml>
<script/>
<integration>
<moodlecoruseidnumber/>
<moodlecourseid>2</moodlecourseid>
<moodlecourseshortname>M101</moodlecourseshortname>
<moodlecoursefullname>Moodle 101</moodlecoursefullname>
</integration>
<item id="ee50ebe5-82a2-45d7-9868-9ac305a49670" itemdefid="2a6022ef-7947-47c6-bb6d-b1b9c2bbbba4" itemstatus="live" key="1287" moderating="false" version="1">
<itembody>
@dcai
dcai / .bashrc
Last active April 25, 2020 13:35
minimal .bashrc
#!/bin/bash
# https://gist.github.com/dcai/3847582/
[[ -r /etc/bash_completion ]] && source /etc/bash_completion
# TERM COLOR
export WHITE="\033[1;37m"
export YELLOW="\033[1;33m"
export GREEN="\033[1;32m"
@dcai
dcai / gist:3825564
Created October 3, 2012 07:20
Hide/show vbox menubar and status bar
VBoxManage setextradata global GUI/Customizations noMenuBar,noStatusBar
VBoxManage setextradata global GUI/Customizations MenuBar,StatusBar
@dcai
dcai / tmux.conf-2.x
Last active May 6, 2025 07:57
tmux config
# Author: Dongsheng Cai
#
# Gist: https://gist.github.com/dcai/3824286
#
# c-d to close shell
# <prefix> s to switch to another session
# <prefix> f to find a window
# <prefix> o to switch to another panel
# <prefix> ! to close other panes except current one
# <prefix> x Kill the current pane
@dcai
dcai / gist:3187294
Created July 27, 2012 10:20
Restore dmg image
sudo asr restore -source /Volumes/saturn/Software/InstallESD.dmg -target /Volumes/InstallOSX/ -erase -noverify --noprompt
@dcai
dcai / 2010-10-02-14-00-test-migration.py
Created June 26, 2012 14:08 — forked from galvez/2010-10-02-14-00-test-migration.py
A minimalist Python migration management script based on Fabric and sqlwitch
# 2010-10-02 14h00
# Update created field in user_prefs table
def migrate(db):
with db.select('user_id, created', from_='users'):
all_users = db.fetchall()
for user in all_users:
with db.update('user_prefs') as obj:
obj.created = user['created']
db.where('user_id = %s', user['user_id'])