Skip to content

Instantly share code, notes, and snippets.

View dangtrinhnt's full-sized avatar
😎
Busy changing the world

Trinh Nguyen dangtrinhnt

😎
Busy changing the world
View GitHub Profile
@dangtrinhnt
dangtrinhnt / bulk_delete.php
Last active August 29, 2015 14:02
Bulk Moodle's courses deletion utility
#!/usr/bin/php
<?php
// Place this script in /<moodle-root-path>/course/ directory and run it
// * To delete one specific course with id:
// ~# php bulk_delete.php <course_id>
//
// * To delete all courses in the system:
// ~# php bulk_delete.php
//
// Tested Moodle version:
ValueError: The file 'themes/ourtheme/images/bg.png' could not be found with <pipeline.storage.PipelineCachedStorage object at 0x38a18d0>.
@dangtrinhnt
dangtrinhnt / floating.js
Created June 9, 2014 02:37
Floating navigation menu
$(function() {
// Stick the #nav to the top of the window
var nav = $('#nav');
var navHomeY = nav.offset().top;
var isFixed = false;
var $w = $(window);
$w.scroll(function() {
var scrollTop = $w.scrollTop();
var shouldBeFixed = scrollTop > navHomeY;
if (shouldBeFixed && !isFixed) {
@dangtrinhnt
dangtrinhnt / bulkemail_template.html
Last active August 29, 2015 14:02
Bulk Email HTML Template
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns:fb='http://www.facebook.com/2008/fbml' xmlns:og='http://opengraph.org/schema/'> <head><meta property='og:title' content='Update from {course_title}'/><meta property='fb:page_id' content='43929265776' /> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> <title>Update from {course_title}</title> </head> <body leftmargin='0' marginwidth='0' topmargin='0' marginheight='0' offset='0' style='margin: 0;padding: 0;background-color: #ffffff;'> <center> <table align='center' border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' id='bodyTable' style='border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;margin: 0;padding: 0;background-color: #ffffff;height: 100% !important;width: 100% !important;'> <tr> <td align='center' valign='top' id='bodyCell' st
@dangtrinhnt
dangtrinhnt / plaintext_template.text
Created June 17, 2014 04:52
Bulk Emails Plain Text Template
{course_title}
{{message_body}}
----
Copyright 2013 edX, All rights reserved.
----
Connect with edX:
Facebook (http://facebook.com/edxonline)
Twitter (http://twitter.com/edxonline)
Google+ (https://plus.google.com/108235383044095082735)
@dangtrinhnt
dangtrinhnt / massimport.php
Created June 21, 2014 07:07
Mass import template course into all other courses of Moodle
#! /usr/bin/php
<?php
define('CLI_SCRIPT', true);
// Require both the backup and restore libs
require_once('../config.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plan_builder.class.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
require_once($CFG->dirroot . '/backup/util/ui/import_extensions.php');
require_once($CFG->dirroot . '/course/lib.php');
@dangtrinhnt
dangtrinhnt / mysqlfragfinder.sh
Created July 4, 2014 06:10
MySQL frag finder
#!/usr/bin/env bash
# Phil Dufault (2009)
# bumped to v1 (2011)
# [email protected]
VERSION="1.0.2"
log="$PWD/mysql_error_log.txt"
mysqlCmd="mysql"
echo "MySQL fragmentation finder (and fixer) v$VERSION"
@dangtrinhnt
dangtrinhnt / ps_db_utils.py
Created July 17, 2014 02:56
PowerSchool Oracle DB Connector
# To change this template, choose Tools | Templates
# and open the template in the editor.
from sqlalchemy import *
from sqlalchemy.orm import *
import os
import datetime
class PsDB(object):
engine = None
@dangtrinhnt
dangtrinhnt / ps_export_student.py
Last active August 29, 2015 14:04
Get student data from PowerSchool including custom fields data
#! /usr/bin/env python
from sqlalchemy import *
from sqlalchemy.sql import select
from ps_db_utils import *
import csv
import os
import shutil
from datetime import *
@dangtrinhnt
dangtrinhnt / get_parent_accounts.php
Last active August 29, 2015 14:04
Get all parent accounts in PowerSchool
#! /usr/bin/php
<?php
echo "\n\n===================== START =====================\n\n";
echo "\n>> Connecting to the Oracle database...\n";
$OracleListener = "my.oracle.com:1521/PSPRODDB";
$OracleUsername = "PS";
$OraclePassword = "MyOraclePasswd";
$conn = oci_connect($OracleUsername, $OraclePassword, $OracleListener);
if (!$conn) {