Skip to content

Instantly share code, notes, and snippets.

@maclochlainn
maclochlainn / get_common_lookup.php
Created February 2, 2013 21:14
This is a reusable artifact that lets you query a COMMON_LOOKUP table from a MySQL Server database. It requires that you create an include file with your valid database credentials.
<?php
/*
|| Program Name: library.inc
*/
function get_common_lookup($table_name, $column_name, $lookup_key = 0) {
// Include the credentials file if omitted.
include_once("MySQLCredentials.inc");
@maclochlainn
maclochlainn / credentials.php
Last active December 12, 2015 02:38
This is a standard credentials.inc file, which allows you to place your connection variables in a single location and refer to them by the global variable names.
<?php
// Program name: credentials.inc
// MySQL Connection variables.
define('HOSTNAME',"localhost");
define('USERNAME',"student");
define('PASSWORD',"student");
define('DATABASE',"studentdb");
?>
@maclochlainn
maclochlainn / ConnectOraclePDB.php
Last active January 9, 2016 05:40
PHP Test Connection to an Oracle 12c Pluggable Database (PDB). The user is video, the TNS alias is video, and the service name is videodb. The service name is listed in the tnsnames.ora file as the SID_NAME.
<?php
// Attempt to connect to your database.
$c = @oci_connect("video", "video", "localhost/videodb");
if (!$c) {
print "Sorry! The connection to the database failed. Please try again later.";
die();
}
else {
print "Congrats! You've connected to an Oracle database!";
oci_close($c);
@maclochlainn
maclochlainn / GistEmbed.js
Created September 2, 2013 18:58
A JSON function to embed public gist files.
$(document).ready(function(){
$('.gistinclude').each(function(){
var gistLocation = $(this);
var state = 0;
$.getJSON('http://gist.github.com/'+$(this).attr('data-gistid')+'.json?callback=?'
, function(data){
gistLocation.replaceWith(data.div);
if (state == 0) {
$('head').append('<link rel="stylesheet" href="https://gist.github.com'+data.stylesheet+'" type="text/css" />');
state = 1;
@maclochlainn
maclochlainn / ConnectOracleCDB.php
Created September 2, 2013 19:09
PHP Test Connection to an Oracle 12c Container Database (CDB). The user is orcl, the TNS alias is orcl, and the service name is orcl (applies to the standard sample database). The service name is listed in the tnsnames.ora file as the SID_NAME.
<?php
// Attempt to connect to your database.
$c = @oci_connect("orcl", "orcl", "localhost/orcl");
if (!$c) {
print "Sorry! The connection to the database failed. Please try again later.";
die();
}
else {
print "Congrats! You've connected to an Oracle database!";
oci_close($c);