Skip to content

Instantly share code, notes, and snippets.

$mysql_config = $services["mysql-5.1"][0]["credentials"];
$db = mysql_connect( $mysql_config["hostname"],
$mysql_config["username"],
$mysql_config["password"]);
mysql_select_db( $mysql_config["name"] );
@lhitchon
lhitchon / gist:1424751
Created December 2, 2011 20:41
PHP Mongo Test AppFog
<html>
<head>
<title>Demo</title>
</head>
<body>
<h1>PHP Mongo Test</h1>
<?php
$services = getenv("VCAP_SERVICES");
echo "<h2>VCAP_SERVICES</h2>";
echo "<p>" . $services . "</p>";
$services = json_decode(getenv("VCAP_SERVICES"),true);
@lhitchon
lhitchon / app.js
Created February 10, 2012 18:00
Deploy to AppFog form a Gist
var http = require('http');
http.createServer(function (req, res) {
res.end("Hello, world!");
}).listen( process.env.VCAP_APP_PORT || 8001 );
@lhitchon
lhitchon / app.js
Created February 10, 2012 18:18
Gist node.js App
var http = require('http');
http.createServer(function (req, res) {
res.end("This is a gist app!");
}).listen( process.env.VCAP_APP_PORT);
@lhitchon
lhitchon / Gemfile
Created February 10, 2012 21:11
Gist Sinatra App
source 'http://rubygems.org'
gem 'sinatra'
@lhitchon
lhitchon / index.php
Created February 10, 2012 21:18
Gist PHP App
<?php echo "Hello" ?>
@lhitchon
lhitchon / index.php
Created April 12, 2012 18:10
PHP MySQL Test
<h1>Test MySQL Connection</h1>
<?php
$services = getenv("VCAP_SERVICES");
$services_json = json_decode($services,true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
// ** MySQL settings from resource descriptor ** //
$username = $mysql_config["username"];
@lhitchon
lhitchon / gist:3098643
Created July 12, 2012 14:57
docs server that automatically redirects to url with .html if that file exists
var connect = require('connect'),
fs = require('fs');
var serve_html = function(root) {
return function(req,res,next) {
var path = root + req.url + '.html';
fs.stat(path,function(err,stat) {
if (!err && !stat.isDirectory()) {
res.statusCode = 301;
res.setHeader('Location', req.url + '.html');
var connect = require('connect'),
mongodb = require('mongodb');
var showDBInfo = function(req,res) {
res.end("You are connected to the database");
};
var noDatabaseError = function(res) {
res.statusCode = 500;
res.end("Unable to connect to database");