Skip to content

Instantly share code, notes, and snippets.

@JeffHoover
JeffHoover / gist:4a04ac102f7710a406fc4a122635c4b0
Created September 28, 2016 20:24
using struct in looping test of arabic-to-roman
#define DATA_COUNT 6
int arabic_values[DATA_COUNT] = { 1, 2, 3, 4, 5, 6};
char *roman_values[DATA_COUNT] = { "I", "II", "III", "IV", "V", "VI"};
typedef struct Roman_Arabic_pair {
char * roman;
int arabic;
} Roman_Arabic_pair;
void check_arabic_to_roman(const Roman_Arabic_pair test_data, const char *actualRoman)
@JeffHoover
JeffHoover / dead_cell_assertion
Created December 5, 2011 18:14
From my data-driven Game of Life code from Global Day of CodeRetreat
// Full code base:
// https://github.com/JeffHoover/Data-Driven-GoL
// Hard to read bare assertion:
// Assert.AreEqual(State.DEAD, _ruleEngine.GetNextCellState(State.DEAD, numNeighbors));
// Easier to read helper method:
Assert_Dead_Cell_Stays_Dead_With_X_Neighbors(numNeighbors));
// Suggested by @mattslavicek - loses important information about cell starting state
@JeffHoover
JeffHoover / edit view.erb
Created February 20, 2011 20:29
new.html.erb
<h1>Edit user</h1>
<%= form_for(@user) do |f| %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
@JeffHoover
JeffHoover / _form.html.erb
Created February 20, 2011 20:08
form partial for new and edit
# app/views/shared/_form.html.erb:
<%= form_for(@user, button_text) do |f| %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit button_text %>
</div>
<% end %>