Skip to content

Instantly share code, notes, and snippets.

View mhull's full-sized avatar

Michael Hull mhull

View GitHub Profile
@mhull
mhull / functions.php
Last active June 8, 2021 19:09
Demonstrates how to pre-populate checkbox fields when using the Gravity Forms plugin for WordPress
<?php
# Make sure to replace {id} with your form's id
add_filter( 'gform_pre_render_{id}', 'my_populate_checkbox' );
function my_populate_checkbox( $form ) {
/**
* Loop through form fields
*
@mhull
mhull / 0.autoload_setup.php
Last active September 14, 2018 12:47
A basic PHP autoloader setup
<?php
/**
* In this example, we are autoloading classes within the namespace `Acme\ExampleProject`. The file `index.php` is the
* entry point to our project; and we are using the `src` directory to store and organize our PHP class files. Our
* autoloader is located in `autoload.php`
*
* The basic behavior is illustrated in the fact that PHP will autoload the file `src/mammals/human.php` whenever we
* attempt to create a `new \Acme\ExampleProject\Mammals\Human` anywhere in our project's codebase.
*
* This diagram illustrates our project structure. Each file's contents can be found below.
@mhull
mhull / .Autoload.php
Last active March 31, 2018 13:28
Demonstrates how to autoload classes in PHP, so that we don't have to explicitly require each file for each class used within our code
<?php
/**
* Uses the `spl_autoload_register` function to autoload classes so that we don't have to
* explicitly require each file for each class we use in our code
*/
@mhull
mhull / Draggable.html
Last active October 13, 2017 05:02
Draggable elements that have been styled to indicate draggability to users
<!-- CSS Stylesheet -->
<link rel='stylesheet' type='text/css' href='css/draggable.css' />
<!-- The things we are dragging -->
<div class='thing'><label>Thing 1</label></div>
<div class='thing'><label>Thing 2</label></div>
<div class='thing'><label>Thing 3</label></div>
<!-- jQuery and jQuery-UI -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
@mhull
mhull / 0.defining_function.html
Last active August 11, 2017 21:53
Exploring function and set notation
<script>
/**
* An example function in JavaScript
*
* @param int myInt
* @param string myString
*
* @return string
*/
@mhull
mhull / 0.no_inputs.php
Last active June 21, 2017 15:23
Exploring the definition of a function in math and how it can inform my understanding of functions in programming
<?php
/**
* This function has no inputs, so it is not a function from a mathematical
* perspective. Furthermore, the function is not predictable because it depends on
* the state of the underlying program
*/
function say_hello() {
$name = 'World';
@mhull
mhull / 0.function_composition.php
Created May 9, 2017 14:10
Examples of function composition using PHP and JavaScript
<?php
function f( $x ) {
return $x+5;
}
function g( $x ) {
return $x+1;
}
@mhull
mhull / 00.src\app\app.component.ts
Last active March 21, 2017 20:31
Exploring Angular 2
import { Component } from '@angular/core';
@mhull
mhull / 01-coin-tosses.js
Last active February 1, 2017 13:45
Comparing the .some() and .every() functions in JavaScript to the "At Least One" rule
var coinTosses = [
{ isHeads: true, user: 'Michael', time: 1485954569 },
{ isHeads: false, user: 'Michael', time: 1485954575 },
/* ... etc ... */
];
@mhull
mhull / _0.es6-string-literals.js
Last active December 17, 2016 21:28
Highlights on making a CSS & JS clock, based on Wes Bos's 30 Day Vanilla JS challenge
/**
* In the `person.sayHello` function, we are using an ES6 template literal
* to dynamically create a string
*/
var person = {
first: 'Michael',
last: 'Hull',
sayHello: function() {
console.log( `Hi, my name is ${this.first} ${this.last}` );
},