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 / authsources.php
Created April 2, 2014 08:00
simplesamlphp authsources.php
View authsources.php
$config = array(
// This is a authentication source which handles admin authentication.
'admin' => array(
// The default is to use core:AdminPassword, but it can be replaced with
// any authentication source.
dangtrinhnt / config.php
Created April 2, 2014 08:44
simplesamlphp config.php
View config.php
$config = array (
* Setup the following parameters to match the directory of your installation.
* See the user manual for more details.
* Valid format for baseurlpath is:
* [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]
dangtrinhnt / logout_relay.php
Created April 2, 2014 08:50
simplesamlphp logout_relay.php
View logout_relay.php
/* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
dangtrinhnt /
Last active August 29, 2015 14:00
SSH utils with connection fail-overs
import paramiko
import sys
SERVERS = ['<my first ssh server ip>', '<my second ssh server ip>', '<my third ssh server ip>']
USER = 'genius'
PASSWORD = 'mygeniuspassword'
class MySSHClient():
def __init__(self, domains=SERVERS, username=USER, password=PASSWORD):
dangtrinhnt /
Created April 29, 2014 09:05
Example celery task with result
from celery import Celery
import time
app = Celery('tasks', backend='amqp', broker='amqp://guest@localhost//')
def add(x, y):
result = x + y
if result < 10:
result = 'Fail'
View httpd-ssl.conf
<VirtualHost _default_:443>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ErrorLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/error.log"
TransferLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/access.log"
SSLEngine on
dangtrinhnt / bulk_delete.php
Last active August 29, 2015 14:02
Bulk Moodle's courses deletion utility
View bulk_delete.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:
View sasserror.scss
ValueError: The file 'themes/ourtheme/images/bg.png' could not be found with < object at 0x38a18d0>.
dangtrinhnt / floating.js
Created June 9, 2014 02:37
Floating navigation menu
View floating.js
$(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 / bulkemail_template.html
Last active August 29, 2015 14:02
Bulk Email HTML Template
View bulkemail_template.html
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' ''><html xmlns:fb='' xmlns:og=''> <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