Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / minimal_moodle_page.php
Last active August 10, 2016 23:59
minimal moodle page
<?php
require_once(dirname(dirname(__DIR__)).'/config.php');
require_login();
$context = context_system::instance();
$url = new moodle_url('/blocks/gcal/mappings.php');
$PAGE->set_url($url);
$PAGE->set_context($context);
@dcai
dcai / calendar_form.php
Last active August 11, 2016 00:01
basic moodle form
<?php
require_once("$CFG->libdir/formslib.php");
class calendar_form extends moodleform {
public function definition() {
global $CFG;
$mform = $this->_form;
$mform->addElement('text', 'calendarname', get_string('calendarname', 'block_gcal'));
@dcai
dcai / ca.cert
Created July 24, 2015 00:09
My CA public certificate
-----BEGIN CERTIFICATE-----
MIIGLTCCBBWgAwIBAgIJAMHi/0z+LKQcMA0GCSqGSIb3DQEBDQUAMGwxCzAJBgNV
BAYTAkFVMQwwCgYDVQQIEwNOU1cxFjAUBgNVBAoTDURvbmdzaGVuZyBDYWkxFjAU
BgNVBAMTDWRvbmdzaGVuZy5vcmcxHzAdBgkqhkiG9w0BCQEWEGhpQGRvbmdzaGVu
Zy5vcmcwHhcNMTQxMDIyMDUwNDI1WhcNMjQxMDE5MDUwNDI1WjBsMQswCQYDVQQG
EwJBVTEMMAoGA1UECBMDTlNXMRYwFAYDVQQKEw1Eb25nc2hlbmcgQ2FpMRYwFAYD
VQQDEw1kb25nc2hlbmcub3JnMR8wHQYJKoZIhvcNAQkBFhBoaUBkb25nc2hlbmcu
b3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7rHCBJbrQXnf5fgP
lEdOKG2DamPRdCzeSJH75uERxpVD8J+9vz8g+RJJtU50uotKbn1JzFXKiyxbgFyA
WC5fNuIHSil6LoXMqu+RycUT1snyx4Uv/Bj1kCaHFl8RYvzK0wK5aRKdR0vqK1jE
@dcai
dcai / pcp.conf
Last active October 22, 2015 08:36
pgpool II config
# PCP Client Authentication Configuration File
# ============================================
#
# This file contains user ID and his password for pgpool
# communication manager authentication.
#
# Note that users defined here do not need to be PostgreSQL
# users. These users are authorized ONLY for pgpool
# communication manager.
#
@dcai
dcai / 00_apt-essentials.bash
Last active October 4, 2021 14:23
ubuntu packages
#!/bin/bash
sudo apt update
sudo apt-get install -y \
apt-transport-https \
apt-utils \
ca-certificates \
locales \
gnupg2 \
software-properties-common \
wget
#!/usr/bin/env perl
use Getopt::Std;
use strict;
use Term::ANSIColor;
my %opts;
getopts('hic:l:',\%opts);
if ($opts{h}){
print<<EoF;
Use -l to specify the pattern(s) to highlight. To specify more than one