Skip to content

Instantly share code, notes, and snippets.

View cunneen's full-sized avatar

Mike Cunneen cunneen

  • Perth, Australia
View GitHub Profile
@cunneen
cunneen / setup_moodle_on_ubuntu.sh
Last active March 29, 2021 09:58
Set up moodle on ubuntu server 14.04 (on amazon EC2 instance, should work with little or no modification on others). The database username/password will be moodle/mymoodlepassword123 .
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 mysql-client mysql-server php5
sudo apt-get install graphviz aspell php5-pspell php5-curl php5-gd php5-intl php5-mysql php5-xmlrpc php5-ldap clamav
sudo service apache2 restart
sudo apt-get install git-core
cd /opt
sudo git clone git://git.moodle.org/moodle.git
cd moodle/
sudo git branch --track MOODLE_28_STABLE
@cunneen
cunneen / fill_pdf_in_meteor.js
Created October 19, 2014 16:42
This is the rough outline of a regular (weekly) job that fills in a PDF form and will email it. There are 3 aspects: 1. [percolate studio's meteor cron](https://github.com/percolatestudio/meteor-synced-cron) 2. PDFtk installed 3. [meteor pdftk wrapper](https://github.com/pascoual/meteor-pdftk) The sample PDF with acrofields for this demo can be …
var meteor_root = Npm.require('fs').realpathSync(process.cwd() + '/../');
var application_root = Npm.require('fs').realpathSync(meteor_root + '/../');
// if running on dev mode
var fs = Npm.require('fs');
if (Npm.require('path').basename(fs.realpathSync(meteor_root + '/../../../')) == '.meteor') {
application_root = fs.realpathSync(meteor_root + '/../../../../');
}
var assets_folder = meteor_root + '/server/assets/';
@cunneen
cunneen / safeScale.js
Last active August 29, 2015 14:07
DO NOT USE THIS, IT HAS A BUG. Keeping it for illustration purposes. A little thing I knocked up to safely scale a javascript number using strings to avoid floating point issues. The bug is where the multipleOfTenAsNumber has more digits than the original number. It doesn't work in that case. E.g. console.log(safeScale("109.87654",10000000000));…
// if you try this in javascript:
// 10.2 * 100
// you get this:
// 1019.9999999999999
/** Safely scale a number. Just a hacky little demo.
* @param {string} numberAsString the number you want to scale e.g. 10.987654
* @param {number} multipleOfTenAsNumber the number you want to scale by e.g. 1000
* @returns {safeScale.result} the safely scaled number e.g. 10987.654
*/
function safeScale(numberAsString, multipleOfTenAsNumber) {
@cunneen
cunneen / clean_windows_build.md
Last active August 29, 2015 14:06
How to create a clean Windows Build

How to create a clean windows build

  1. Install the operating system
  2. Install the service packs
  3. Apply updates from wsus offline
  4. Apply apps from ninite
  5. Apply third-party apps
  6. License keys should all be found/kept in lastpass
  7. Make a system image so you can do this quickly next time. Use Acronis TrueImage or Paragon Backup and Restore
@cunneen
cunneen / check_constraints_mysql.sql
Created August 20, 2014 03:25
Mimicking Check Constraints in MySQL
-- Modified from: http://stackoverflow.com/a/14248038/956779
-- Add a BEFORE INSERT constraint that only allows values between 1 and 5
DELIMITER $$
CREATE TRIGGER `test_before_insert` BEFORE INSERT ON cheese_shop.items
FOR EACH ROW
BEGIN
IF (NEW.ratings > 5 OR NEW.ratings < 1) THEN
SIGNAL SQLSTATE '12345'
SET MESSAGE_TEXT = 'check constraint on items.ratings failed';
END IF;