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 / massreset.php
Created August 27, 2014 07:15
Mass reset AD accounts's password
<?php
// Using the LTB Self Service Password's functions
// LTB-project.org
$ldap_url = "ldaps://<your active directory address>";
$ldap_binddn = "cn=manager,dc=example,dc=com";
$ldap_bindpw = 'MyPassword';
$ldap_base = "dc=example,dc=com";
$ldap_filter = "(&(objectClass=user)(description=Student*)(sAMAccountName={login})(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
@dangtrinhnt
dangtrinhnt / massreset_wrapper.py
Created August 27, 2014 07:25
massreset.php python wrapper
#! /usr/bin/env python
import subprocess
import csv
PHP_SCRIPT_DIR = 'massreset.php'
CSV_DIR = 'accounts.csv'
def get_data_from_csv(csv_file_path):
@dangtrinhnt
dangtrinhnt / csv_to_excel.py
Created September 26, 2014 08:03
Convert csv to excel
import os
import glob
import csv
import sys
from xlsxwriter.workbook import Workbook
import xlwt
def csv_to_excelX(csv_path):
workbook = Workbook(csv_path + '.xls')
@dangtrinhnt
dangtrinhnt / CreatePSParentAcc.php
Last active August 29, 2015 14:07
Create parent account in PowerSchool
<?php
require_once("PSSSOSettings.php");
function mySSOErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting
return;
}
@dangtrinhnt
dangtrinhnt / PSSSOSettings.php
Created October 15, 2014 03:07
PowerSchool Parent Account SSO settings
<?php
$ErrorMessage = ""; //leave as blank
$NotificationEmail = ""; //email with details will be sent here if an error occurs
$FromEmail = ""; //from address of the above email
$PowerschoolConnectedString = "Sign Out"; //things are working fine if this string exists in cURL buffer, no need to change
$PowerschoolErrorString = "<title>Error</title>"; //something went wrong if this string exists in cURL buffer, no need to change
$PowerschoolErrorString1 = "<div class=\"feedback-alert\">There was an error processing your sign in request. Please try again. If this problem continues, contact your school directly for assistance.</div>";
$PowerschoolErrorString2 = "<span class=\"error\">";
$OracleListener = ""; //listener name defined in tnsnames.ora. For example: your.oracle.server.address:1521/PSPRODDB
$OracleUsername = ""; //factory default powerschool read only ODBC login name, no need to change
@dangtrinhnt
dangtrinhnt / UpdatePSParentAcc.php
Created October 15, 2014 03:11
Update parent account in PowerSchool
<?php
require_once("PSSSOSettings.php");
function SSOUpdateGuardianAccount($Username, $NewUsername, $Password, $Last, $First, $Email, $Disable, $PSUsername, $PSPassword) {
date_default_timezone_set('Asia/Ho_Chi_Minh');
$old_error_handler = set_error_handler("mySSOErrorHandler");
$ParentID = "";
$LookupEmail = "";
$SyncCompleted = false;
$ErrorMessage = "";
@dangtrinhnt
dangtrinhnt / ad_settings.py
Last active August 29, 2015 14:09
Active Direcotry settings using django-auth-ldap
########################################################################
# LDAP Authentication
########################################################################
import ldap
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
from django_auth_ldap.config import NestedActiveDirectoryGroupType
#AUTH_LDAP_START_TLS = True
AUTH_LDAP_GLOBAL_OPTIONS = {
ldap.OPT_X_TLS_REQUIRE_CERT: False,
@dangtrinhnt
dangtrinhnt / moodle
Created November 14, 2014 07:16
Nginx configuration for Moodle 2.8
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/mdl_access.log;
error_log /var/log/nginx/mdl_err.log;
location / {
root /var/www/moodle;
index index.php index.html index.htm;
@dangtrinhnt
dangtrinhnt / googleemailscript.gs
Last active January 6, 2021 15:24
Google Apps Script to send email when submitting form
// Trinh Nguyen, Nov 18, 2014
function EmailFormConfirmation() {
// name of the response sheet
var sheetname = "sheet1"
// insert a blank column at the end of the response sheet
// store the sent mail result
// add this formula to the first row of this column:
// =indirect("AG"&counta(A1:A))
var columnnumber = 34
@dangtrinhnt
dangtrinhnt / findRowByValue.gs
Last active July 3, 2018 06:11
Find row number by value
function findRowByValue(sheet, value) {
var dataRange = sheet.getDataRange();
var values = dataRange.getValues();
for (var i = 0; i < values.length; i++) {
for (var j = 0; j < values[i].length; j++) {
if (values[i][j] == value) {
//Logger.log(i);
return i+1;
}