Skip to content

Instantly share code, notes, and snippets.

View bmcculley's full-sized avatar

bmcculley

View GitHub Profile
@bmcculley
bmcculley / db-test.php
Created December 23, 2013 08:42
A PHP/MySQL connection test script.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>MySQL Connection Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#wrapper {
width: 600px;
margin: 20px auto 0;
@bmcculley
bmcculley / markov.php
Last active May 29, 2022 19:06
PHP Markov Chain class
<?php
/*
Levi Thornton from boogybonbon and wordze generously posted his php Markov
Chain class.. unfortunately there is a missing $nn++ thus the class can hang,
the working version is below all credit to Levi for the code, i just fixed a
bug.
Example Usage:
------------------
@bmcculley
bmcculley / rppg.php
Created January 6, 2014 18:43
Random pronounceable password generator
<?php
/*
* Random pronounceable password generator
*
* Found the orignal function here http://bit.ly/1iKeLBO
* Added in a capital letter.
*/
function rppg(){
$pw = '';
@bmcculley
bmcculley / dev-install.sh
Last active January 2, 2016 10:49
Easily setup a WordPress install with the plugins necessary for reviewing themes.
plugins=("http://downloads.wordpress.org/plugin/theme-check.20131213.1.zip"
"http://downloads.wordpress.org/plugin/debug-bar.0.8.1.zip"
"http://downloads.wordpress.org/plugin/log-deprecated-notices.0.2.zip"
"downloads.wordpress.org/plugin/debogger.0.71.zip"
"http://downloads.wordpress.org/plugin/monster-widget.zip"
"http://downloads.wordpress.org/plugin/wordpress-beta-tester.0.99.zip"
"http://downloads.wordpress.org/plugin/regenerate-thumbnails.zip")
for plugin in "${plugins[@]}"
do
sudo wget $plugin
@bmcculley
bmcculley / slope.py
Created January 18, 2014 05:23
Given two points find the slope of a line using python.
from __future__ import division
# example points from http://www.coolmath.com/algebra/08-lines/06-finding-slope-line-given-two-points-01.htm
(x1, y1) = (-2,-1)
(x2, y2) = (4,3)
slope = ((y2-y1)/(x2-x1))
print slope
@bmcculley
bmcculley / heat_index.php
Created February 18, 2014 08:47
Find the heat index temperature in PHP.
<?php
/*
* The heat index formula in PHP
* https://en.wikipedia.org/wiki/Heat_index#Formula
*/
function hi($T,$rh) {
$c1 = -42.379;
$c2 = 2.04901523;
$c3 = 10.14333127;
@bmcculley
bmcculley / wind_chill.php
Created February 19, 2014 03:39
Find the wind chill temperature in PHP.
<?php
/*
* Wind Chill formula in PHP
* https://en.wikipedia.org/wiki/Wind_chill
*/
function windChillTemp($V,$Ta)
{
$Vpower = pow($V, 0.16);
$TaV = $Ta * $Vpower;
@bmcculley
bmcculley / enable.sh
Created March 1, 2014 02:04
Enable a new site on apache2
# enable the site
a2ensite example.com
# restart apache2
service apache2 reload
@bmcculley
bmcculley / compatible.php
Created March 1, 2014 04:57
Make sure the server PHP version is compatible with code.
<?php
if (version_compare(phpversion(), '5.3.10', '<')) {
// php version isn't high enough
echo 'version too low.';
}
else {
echo 'good to go.';
}
@bmcculley
bmcculley / password_strength.php
Created March 4, 2014 03:01
Check for password strength, password should be at least n characters, contain at least one number, contain at least one lowercase letter, contain at least one uppercase letter, contain at least one special character.
<?php
$password_length = 8;
function password_strength($password) {
$returnVal = True;
if ( strlen($password) < $password_length ) {
$returnVal = False;
}