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 / authsources.php
Created April 2, 2014 08:00
simplesamlphp 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.
'core:AdminPassword',
),
@dangtrinhnt
dangtrinhnt / config.php
Created April 2, 2014 08:44
simplesamlphp config.php
<?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
dangtrinhnt / logout_relay.php
Created April 2, 2014 08:50
simplesamlphp logout_relay.php
<?php
/* Redirect browser */
header("Location: https://mydomain.com/simplesaml/saml2/idp/initSLO.php?RelayState=/simplesaml/logout.php");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
@dangtrinhnt
dangtrinhnt / sshutils.py
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
dangtrinhnt / tasks.py
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//')
@app.task
def add(x, y):
result = x + y
if result < 10:
result = 'Fail'
<VirtualHost _default_:443>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName my.domain.com:443
ServerAdmin admin@my.domain.com
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
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