Skip to content

Instantly share code, notes, and snippets.

@dcai
dcai / redis.php
Last active April 6, 2016 15:19
moodle redis session handler
<?php
/**
* Redis based session handler.
*
* @copyright 2015 Dongsheng Cai {@link http://dongsheng.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
@dcai
dcai / postgres_pgpool_arch.md
Last active August 11, 2016 00:00 — forked from afair/gist:3803895
PostgreSQL and Pgpool Architecture

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

@dcai
dcai / mount_smb.sh
Last active August 29, 2015 14:13
Mount samba
#!/bin/sh
# smbclient -L 10.0.1.1
mounttc ()
{
sudo echo -n;
if [[ -z $1 ]]; then
SERVER="10.0.1.1";
else
SERVER="$1";
fi;
@dcai
dcai / .vimrc
Last active April 25, 2020 14:06
**NOT IN USE** a very old .vimrc, minimal one is here: https://gist.github.com/dcai/2667196
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" __ __ ____
" / | \ |___
" \__ |__/ ____|
"
" Author: Dongsheng Cai
" Version: 1.0
" Modified: 29/08/2014
" Changelog:
" 06/03/2013 vundle
@dcai
dcai / upgrade_pg93.sh
Last active October 26, 2017 03:41 — forked from ibussieres/upgrade_pg.sh
upgrade_pg93.sh
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo su - postgres -c "service postgresql stop"
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
@dcai
dcai / id_rsa.pub
Last active August 29, 2015 14:06
id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxH+9GYhS8qlhTcdlJuWkS38IKHbVuxsbcFHKSOaI9IbauvEkTfcR9DaAZrhFLDeDifSi9cy6IpzjZL30n1MkV9tN6i2TJ/OvhZPaJtNpKTFNyTLo/jY/NxRle/24LjSm4BnMmb1iijDpL91mi/EjkeccwO8LnWm/wMoRTJKimQSWTknhGmewDMRLXsmaCHOofQRLyOow0+xBGVjlDrO3Qp3r/CgD27ZgkkR/o/b52kxp8/N7EBCknV8Ytrw72IPlVZtlsjOBdkL5taXmhdBhOARBl1fWzUmm89ikITlwctpohDocnj/Qe/hYmh6p/gbgl/av5TwBfbx5KTsbKnTmNQ==
@dcai
dcai / ato.md
Last active October 26, 2017 03:41 — forked from warnergodfrey/gist:7512051
Setup ATO AusKey for mac
  • Install the latest JRE from Oracle
  • In the Java Control Panel, go to the Security tab and make sure 'Enable Java Content' is checked
  • Open Safari
  • Go to the ATO Business portal site https://bp.ato.gov.au/BpStatics/homepage.htm
  • Click Login
  • A dialog will apear asking you 'Do you want to trust the website “authentication.business.gov.au” to use the “Java” plug-in?'
  • Click 'Trust'
  • Now you will be asked 'Do you want to run this application?'
  • Click 'Run'
  • Another dialog will appear asking you to 'Allow access to the following application from this website?'
@dcai
dcai / cliclock.sh
Created December 18, 2013 05:58 — forked from Goles/cliclock.sh
World clock
#!/bin/sh
# Command-line world clock
# Taken from http://stackoverflow.com/questions/370075/command-line-world-clock
# .worldclock.zones file looks like:
# US/Pacific
# Europe/Berlin
# Chile/Continental
: ${WORLDCLOCK_ZONES:=$HOME/.worldclock.zones}
@dcai
dcai / customwiki2html.sh
Created September 28, 2013 10:36
alternative customwiki2html.sh for vimwiki, it supports template and interlink.
#!/bin/bash
MARKDOWN=markdown
MKD2HTML=mkd2html
FORCE="$1"
SYNTAX="$2"
EXTENSION="$3"
OUTPUTDIR="$4"
@dcai
dcai / php_error_log.sh
Last active December 23, 2015 16:59
Verify php error log
php -n -d error_log=./error.log -d log_errors=1 -r '<?php error;'