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
from sqlalchemy import *
from sqlalchemy.orm import *
import os
from datetime import datetime
from MyProject.utils.my_models import MyTable
DB_HOST = 'mygeniusdomain.com'
DBMS = 'mysql'
@dangtrinhnt
dangtrinhnt / .zshrc
Created April 2, 2014 06:31
.zshrc template
autoload -U compinit promptinit colors
compinit
promptinit
colors
# set completion style
export ZLS_COLORS=$LS_COLORS
zstyle ':completion:*' menu select
zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==34=34}:${(s.:.)LS_COLORS}")';
@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 / simplesamlphp
Created April 2, 2014 09:12
nginx configuration for simplesamlphp
server {
listen 80;
root /var/www/simplesamlphp/www;
index index.php index.html index.htm;
server_name localhost;
ssl on;
ssl_certificate /etc/simplesamlphp_cert/simplesamlphp.crt;
@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'
@dangtrinhnt
dangtrinhnt / server-vars.yml
Last active December 31, 2020 15:51
Open edX server-vars.yml variables
# variables common to the lms role, automatically loaded
# when the role is included
---
# These are variables that default to a localhost
# setup and are meant to be overwritten for
# different environments.
#
# Variables in all caps are environment specific
# Lowercase variables are internal to the role
<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