Skip to content

Instantly share code, notes, and snippets.

View Henryvw's full-sized avatar

Henry van Wagenberg Henryvw

View GitHub Profile
@Henryvw
Henryvw / recursive_flatten_method.rb
Last active August 19, 2019 11:50
Recursive Flatten Array Method
# Monkey Patch Array so we can already use my method on any array object
class Array
# I want to have the nice form of array_object DOT method, so I need to pass self in outside of the recursion
def flatten_me
incoming_array = self
recursive_flatten(incoming_array)
end
# Expose only one method
private
@Henryvw
Henryvw / recursive_flatten_method.rb
Created August 19, 2019 09:42
Recursively Flatten an Array
def recursive_flatten(incoming_array, new_flattened_array = [])
incoming_array.each do |item|
if item.class == Array
# Recursion
recursive_flatten(item, new_flattened_array)
else
new_flattened_array << item
end
end
new_flattened_array
@Henryvw
Henryvw / gist:be8fd0b09448bc9081a0
Last active February 11, 2016 17:07
Questions and Suggestions about Persephone
Questions
CSS / Atomic Design
1. Can you explain the grid system again?
2. So the Javascript files in "lib" basically prepare the content from PhraseApp and Contentful. Then these files are called into the Jade templates, e.g.
3. How does cityLandingData get its information from "entry"? Is this a giant Javascript object with all the other content inside, e.g. example trips, covered airports, etc.? If so, where does "entry" get created?
4. How can we play around with these Javascript objects like Ruby let's us do with, say, IRB or binding.pry?
Node
1. What's the relationship between Node and Nginx? Aren't they both web servers? Why not just use Node to serve up static files? If you are using Nginx, why do you then need Node anymore?
Missing template doctrines/doctrines_assent.html.haml with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder, :haml]}. Searched in:
* "/Users/Henryvw/Desktop/workspace/stoic_compass/app/views"
* "/Users/Henryvw/.rvm/gems/ruby-2.0.0-p451/bundler/gems/activeadmin-0c83cfe0b9b4/app/views"
* "/Users/Henryvw/.rvm/gems/ruby-2.0.0-p451/gems/kaminari-0.16.1/app/views"
* "/Users/Henryvw/.rvm/gems/ruby-2.0.0-p451/gems/devise-3.3.0/app/views"
* "/Users/Henryvw/Desktop/workspace/stoic_compass"
* "/"
Stoic Doctrines
= @doctrines.each do |doctrine|
= render file: "doctrines#{doctrine.file_name}.html.haml"
= form_for @rehearsal do |f|
.field
= f.label :tally
= f.number_field :tally
/ = render "e_answer_fields", :f => e_builder
%p
%b Questions:
- @exercise.e_questions.each do |e_question|
= form_for @rehearsal do |f|
.field
= f.label :tally
= f.number_field :tally
%p
%b Questions:
- @rehearsal.exercise.e_questions.each do |e_question|
%tr
= form_for @rehearsal do |f|
.field
= f.label :tally
= f.number_field :tally
%p
%b Questions:
- @rehearsal.exercise.e_questions.each do |e_question|
%tr
@Henryvw
Henryvw / rehearsals_form.html.haml
Created August 9, 2014 07:36
rough solution for how to display questions (and do an answer build for each one) on a new rehearsal
%b Questions:
- @rehearsal.e_questions.each do |e_question|
%tr
%td= e_question.question
%p
= f.fields_for :e_answers do |a_builder|
= render "e_answer_fields", :f => a_builder
= f.actions do
= f.action :submit, :as => :input
@Henryvw
Henryvw / rehearsals_form.html.haml
Created August 9, 2014 07:52
rough solution for how to display questions (and do an answer build for each one) on a new rehearsal
= semantic_form_for @rehearsal do |f|
= f.inputs do
= f.input :tally
%p
%b Questions:
- @rehearsal.e_questions.each do |e_question|
%tr
%td= e_question.question
%p
= f.fields_for :e_answers do |a_builder|