Skip to content

Instantly share code, notes, and snippets.


Joe Winter Joeventures

View GitHub Profile
Joeventures / gravity_times.php
Last active Dec 29, 2015
Add the course times to a Gravity Form
View gravity_times.php
// Add course times for the Ignite enrollment form.
// Note: Some data is removed for security purposes.
add_filter('gform_pre_render_#', 'c4a_pre_render_#' );
add_filter('gform_admin_pre_render_#', 'c4a_pre_render_#');
function c4a_pre_render_# ($form) {
foreach($form['fields'] as &$field ) {
// If this is the "Ignite Time" radio button field in the form...
if( $field['adminLabel'] != 'Ignite Time' ) { continue; }
// ... remove the existing items so we can start with a new list.
Joeventures / event_array.php
Last active Dec 28, 2015
Build Event Array
View event_array.php
// Return an array of course offerings belonging to a category ID
// If it's a multi-week course, it should be set up as a recurring event
// This is a function used in several other areas of the code to simplify
// the process of grabbing event data for C4's class offerings.
function c4_event_array( $catid, $recur = true, $limit = 99 ) {
// First, grab the data based on the criteria given
$post_type = ( true == $recur ? 'event-recurring' : 'event' );
$events = new WP_Query(
View 10-28 Quiz Answers.txt
1.1. rake routes
1.2. Add the as: parameter
1.3. Run rake routes
2.1. Creating an object with an API may involve using any one or more of several types of requests. Creating an object with a website involves using a GET request.
2.2. <form> and <input type="submit">. Rails equivalents: form_tag and submit_tag.
View 10-26 Quiz Answers.txt
1.1. Presumably it would delete the first post by the comment author. A user would need to have a has_many :posts relationship.
1.2. It would create a new comment in a post titled "New Years Resolution." It tells us that Post has a has_many relationship to comments.
2.1. One is with a query string, and the other is with a body.
2.2. Through the browser, at the end of a URL.
3.1. Less specific <== HTML element, Class, ID ==> More specific
View 10-20 Quiz Answers.txt
1.1. The Student table has a one-to-many relationship with the Assignments table. One student to many assignments.
2.1 Four parts of a request: URL, Head, Body, and ??
Three parts of a response: Status code, Head, Body
2.2. Query string is generally used for just retrieving data -- i.e., executing a query, where the response is the result of the query. The query string can be passed in the url. For example:
Post data is generally used for sending data and receiving a response, where the response may be the updated data or a confirmation that the data was received. POST data cannot be passed in the url.
2.3. A POST request is usually the equivalent to Create, and a PATCH request is usually the equivalent to Update.
View Quiz 10-15 Answers.txt
1.1. What is the result of the call? What about ages.each?
The result of [28, 32, 42, 64] is [56, 64, 84, 128]
The result of ages.each is:
Age is: 28
Age is: 32
Age is: 42
Age is: 64
1.2. Is x in scope during ages.each? x is not in scope.

Today's homework

The weekend assignment will not be a group project, but today will continue from where you left off yesterday.

Pair up and share a computer, switching off at the keyboard after each commit. Talk through your thought process with your pair and ...

Write API wrappers to:

  • create an issue

Normal Mode - No Joins Required!

How many users are there?

SELECT COUNT(id) FROM users; returns 50

What are the 5 most expensive items?

SELECT title, price FROM items ORDER BY price DESC LIMIT 5; returns the following items:

Joeventures / tic-tac-toe.rb
Created Sep 28, 2015
Semi-Intelligent Computer Player
View tic-tac-toe.rb
# The board is laid out as a simple array 0..8
#all_guesses is a hash: {"x"=>[1,2,3,4], "o"=>[5,6,7,8]}
[0,1,2], [3,4,5], [6,7,8],
[0,3,6], [1,4,7], [2,5,8],
[0,4,8], [2,4,6]
def be_intelligent_or_something( all_guesses, available_spaces )
available_spaces.each do |o|
Joeventures / tic-tac-toe.rb
Created Sep 27, 2015
Tic-Tac-Toe Normal Mode
View tic-tac-toe.rb
# The board is laid out as a simple array 0..8
#all_guesses is a hash: {"x"=>[1,2,3,4], "o"=>[5,6,7,8]}
[0,1,2], [3,4,5], [6,7,8],
[0,3,6], [1,4,7], [2,5,8],
[0,4,8], [2,4,6]
def winning_set?( player_guesses )
winner = false