Skip to content

Instantly share code, notes, and snippets.

View NoMan2000's full-sized avatar

Michael Ryan Soileau NoMan2000

  • Surge Forward
  • Reno, Nevada
View GitHub Profile
@NoMan2000
NoMan2000 / Base
Created January 31, 2014 22:19
PHP Always have a base root folder
<?php
define("DS",DIRECTORY_SEPARATOR,true);
define('BASE_PATH',realpath(dirname(__FILE__)).DS,true);
$include_file = BASE_PATH . '.mysql.inc.php';
?>
@NoMan2000
NoMan2000 / joeDebug.php
Last active August 29, 2015 13:56
A debug function that tells you variable name, line number, arrays, and prints to the javascript console or echos out directly.
<?php
// The Joe Debug function. To use successfully, create a global variable called $MSDebugVar.
// It accepts an optional string calls $testVals that can be used to pass in any values that
// You wish to be tested during debugging.
// Refactor to remove the isarray and just use the built-in php isarray
function joeDebug($testVals = null, $isJavaScript = false, $isArray = false){
if(!function_exists('print_var_name')){
function print_var_name($var) {
foreach($GLOBALS as $var_name => $value) {
if ($value === $var) {
@NoMan2000
NoMan2000 / appendToFooter.php
Last active August 29, 2015 13:56
AppendJavascript at the end of the footer Asynchronously.
<?php
global $dev_environment;
//$dev_environment = false;
?>
<script type='text/javascript'>
if((typeof $jQ == 'undefined') || (!$jQ)){
function downloadJSAtOnload() {
@NoMan2000
NoMan2000 / trim response whitespace
Created February 18, 2014 18:43
Strip Javascript whitespace
var trimmedResponse = xmlHttp.responseText.replace(/^\s*/,'').replace(/\s*$/,'').toLowerCase();
@NoMan2000
NoMan2000 / mutation.js
Created March 6, 2014 05:08
Mutation Observer Selection
/* The following are mutation observers for performance reasons. */
var canObserveMutation = 'MutationObserver' in window;
if(canObserveMutation){
var observer, callback;
callback = function( allmutations ){
allmutations.map( function(mr){
console.dir(mr);
(function addXhrProgressEvent($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: function() { console.log("standard progress callback"); },
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function") {
req.addEventListener("progress", function(evt) {
that.progress(evt);
@NoMan2000
NoMan2000 / infiniteAddobj.js
Created June 12, 2014 02:56
Infinite add Object
myObject = {
callFunction : function(){
alert("Hello there");
},
name : "Ryan",
add : function(){
var args = arguments;
var a = 0;
for(var i=1; i<args.length; i++){
a += (parseInt(args[i-1], 10) + parseInt(args[i], 10));
@NoMan2000
NoMan2000 / .htaccess
Created June 17, 2014 18:27
htaccess
# Begin HackRepair.com Blacklist
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^[Ww]eb[Bb]andit [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^binlar [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [NC,OR]
@NoMan2000
NoMan2000 / config.yaml
Created August 11, 2014 02:11
Access files using PHPuppet
---
vagrantfile-local:
vm:
box: puphpet/centos65-x64
box_url: puphpet/centos65-x64
hostname: null
memory: '512'
cpus: '1'
chosen_provider: virtualbox
network:
@NoMan2000
NoMan2000 / phing.xml
Last active August 29, 2015 14:05
phing playground
<?xml version="1.0"?>
<project name="demo" default="build">
<property name="build2.message" value="Michael Soileau"/>
<property file='build.properties' />
<!-- Currently has the variable build.dir and base.dir in it -->
<!-- Properties are how you include files in php from build.properties -->
<!-- Just say a message to make sure things are working. -->
<target name="build2.sayMessage">