Skip to content

Instantly share code, notes, and snippets.

View jakemcgraw's full-sized avatar
📈
start up cash in sell out bro down

Jake McGraw jakemcgraw

📈
start up cash in sell out bro down
View GitHub Profile
@jakemcgraw
jakemcgraw / pear.rb
Created February 16, 2010 18:40
Puppet PHP Pear provider
We couldn’t find that file to show.
@jakemcgraw
jakemcgraw / check_php.pl
Created March 5, 2010 20:58
Nagios check for PHP configuration
#!/usr/bin/perl
use strict;
# default php executable, version
my $PHPBIN= '/usr/bin/php';
my $PHPVER= '5.2.10';
my $PEARBIN= '/usr/bin/pear';
my $MESSAGE= 'OK ';
use lib "/usr/lib/nagios/plugins";
@jakemcgraw
jakemcgraw / ZendFramework_Auth.php
Created March 9, 2010 02:47
One way to do authorization in Zend Framework
<?php
// .. bootstrap
Zend_Registry::set('identity', new Zend_Session_Namespace());
// .. login
$result = $this->_auth->authenticate($adapter);
if ($result->isValid()) {
$ident = $this->_auth->getIdentity();
$model = new Model_User;
@jakemcgraw
jakemcgraw / modular.js
Created March 10, 2010 20:17
Organize jQuery code
var tspot = jQuery.extend(true, window.tspot || {}, {
log : function(message) {
(window.console && window.console.log) ?
window.console.log(message) :
alert(message);
},
// page specific functions under their own ns
});
jQuery(function($){
@jakemcgraw
jakemcgraw / process_stdio.js
Created March 16, 2010 15:07
Read a stream in nodejs
// use tail -f /file/to/watch | node process_stdio.js to consume a stream
var partial = "", queue = [];
stdio = process.stdio;
stdio.open();
// Grab whole lines off of stdio
stdio.addListener("data", function(chunk) {
if (chunk) {
if ("" != partial) {
<?php
/**
* Zend_Application, Zend_Loader, Zend_Loader_* and Zend_Exception require
* a 'hard coded' path. We've set up a special copy of the Zend Framework at:
*
* /usr/share/php/ZendFrameworkLoader/library
*
* This prevents the autoloader from confusingly loading the incorrect version
* of a given file.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title></title>
<script>
function foo(){
alert(this.tagName || this.nodeName);
};
<?php
$str;
while(true) {
if (preg_match('/^(.{1,60})( |$)/', $str, $match)) {
print $match[1];
$str = substr($str, strlen($match[1]));
}
else {
<?php
// For the following sequence, the correct answer is set '79778' produces product '24696'
$numbers = <<<EOD
73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907296290491560440772390713810515859307960866701724271218839987979087922749219016997208880937766572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397536978179778461740649551492908625693219784686224828397224137565705605749026140797296865241453510047482166370484403199890008895243450658541227588666881164271714799244429282308634656748139191231628245861786645835912456652947654568284891288314260769004224219022671055626321111109370544217506941658960408071984038509624554443629812309878799272442849091888458015616609791913387549920052406368991256071760605886116
// In global scope
ANDREW = $.extend(window.ANDREW||{}, {
someVar : 1,
someOtherVar : false,
someFunc : function(params) {},
someOtherFunc : function(params) {},
});
// ... Later