Skip to content

Instantly share code, notes, and snippets.

View mikevalstar's full-sized avatar

Mike Valstar mikevalstar

View GitHub Profile
<?php
class gPDO{
public static function init(){
$GLOBALS['gPDO'] = array();
$GLOBALS['gPDO']['server'] = '';
$GLOBALS['gPDO']['user'] = '';
$GLOBALS['gPDO']['password'] = '';
$GLOBALS['gPDO']['db'] = '';
$GLOBALS['gPDO']['charset'] = 'UTF-8';
@mikevalstar
mikevalstar / app.js
Created January 28, 2012 22:40
Part 3.1 of the node tutorial
/**
* Module dependencies.
*/
var express = require('express')
, mongoStore = require('session-mongoose');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
@mikevalstar
mikevalstar / AdminPages.js
Created January 27, 2012 15:33
Files for Node.js Tutorial Part 3
// Includes
var crypto = require('crypto');
function hashString(value) {
hash = crypto.createHash('sha1');
hash.update(value);
return hash.digest('hex');
}
var AdminPages = module.exports = function AdminPages(){};
@mikevalstar
mikevalstar / app.js
Created January 18, 2012 15:56
App.js changed for tutorial project
var error = require('./lib/ErrorHandler');
app.configure('development', function(){
//app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.use(error({ showMessage: true, dumpExceptions: true, showStack: true, logErrors: __dirname + '/log/error_log' }));
});
app.configure('production', function(){
//app.use(express.errorHandler());
app.use(error());
@mikevalstar
mikevalstar / ErrorHandler.js
Created January 18, 2012 15:47
Error Handler Class for Node js tutorial with Express
/**
* Modified from the Connect project: https://github.com/senchalabs/connect/blob/master/lib/middleware/errorHandler.js
*
* Flexible error handler, providing (_optional_) stack traces and logging
* and error message responses for requests accepting text, html, or json.
*
* Options:
*
* - `showStack` respond with both the error message and stack trace. Defaults to `false`
* - `showMessage`, respond with the exception message only. Defaults to `false`
@mikevalstar
mikevalstar / app.js
Created January 18, 2012 15:33
Tutorial app.js addition of 404 page
// 404 Page
app.use(function(req, res, next){
res.render('404.jade', {title: "404 - Page Not Found", showFullNav: false, status: 404, url: req.url });
});
function loadPage(hash, fn){
if(!hash || hash == ''){
if(typeof _gaq !== 'undefined')
_gaq.push(['_trackPageview']);
return; // nothing to do
}
var url = (hash[0] == '#') ? hash.substring(2): hash;
$('#C').html('Loading Content...'); // replace with loading screen code
@mikevalstar
mikevalstar / hashbangv1.js
Created November 15, 2011 18:46
Simple hashbang URL handler
function loadPage(hash, fn){
if(!hash || hash == '')
return; // nothing to do
var url = (hash[0] == '#') ? hash.substring(2): hash;
$('#C').html('Loading Content...'); // replace with loading screen code
var callback = function(responseText, textStatus, XMLHttpRequest){
$(document).attr('title', $(responseText).filter('title').text());
var StaticPages = module.exports = function StaticPages(){};
StaticPages.prototype = {
initPages: function(app){
// Routes
app.get('/', function(req, res){
res.render('index', {
title: 'Home'
<?PHP
while(true){
$x++
$y = 0;
while($y < 5000){
file_get_contents("http://yoursite.com/img/img_$x$y.jpg");
$y++;
}
}