createdbypete / createdbypete.com Goto Github PK
View Code? Open in Web Editor NEWMy personal website
Home Page: http://www.createdbypete.com
My personal website
Home Page: http://www.createdbypete.com
First thanks for the helpful guide on rsync
I have setup a sync that works pretty much. The one item that is irritating is that I have a structure in the source that includes a recursive mountpoint such as (some directories excluded:
/mnt/NAS_5TB
NAS_5TB/Acronis
NAS_5TB/Music (this has all the media files)
NAS_5TB/iocage
NAS_5TB/iocage/jails
NAS_5TB/iocage/jails/plex
NAS_5TB/iocage/jails/plex/root
NAS_5TB/iocage/jails/plex/root /media
NAS_5TB/iocage/jails/plex/root/media/mountpoint back to NAS_5TB/Music
So when my rsync runs it copies not only the media directory but also copies (redundantly) all the media files again because of the mountpoint. I can put an exclude in the rsync command line but my question is: If I manually delete the redundant files from the rsync destination will it invalidate the destination? In other words will manually modifying the data in the rsync destination affect the integrity of the destination structure?
Need to include open graph tags. http://ogp.me
Use javascript to generate a Table of Contents for each article on the fly from headings
Also consider Jekyll image size processor jekyll-minimagick
Breakpoints for mobile devices and large screen devices
This part: $(date +'%Y-%m-%d') doesn't expand properly if it's in crontab.
Works great if you just escape everything: $(date +%Y-%m-%d)
Still, your guide told me almost everything I wanted to know, I just needed to figure out how to get the variables to expand.
You have an article here: http://www.createdbypete.com/articles/working-with-nested-forms-and-a-many-to-many-association-in-rails-4/ that talks about building a survey, retrieving in a form, etc. But I've found that there seems to be a common problem in a lot of these survey demos that I hope you could help me resolve. Here goes:
Imagine a slightly different answers.html.erb
file that works with just one participant (perhaps a logged in participant, which we will say is using Devise, so there is a method similar to current_participant). The new form might look something like this:
<h1><%= @survey.name %> Answers</h1>
<%= form_for(@survey) do |f| %>
<h3><%= current_participant.name %></h3>
<table>
<thead>
<tr>
<td>Questions</td>
<td>Answer</td>
</tr>
</thead>
<tbody>
<% @questions.each do |question| -%>
<tr>
<td><%= question.content %></td>
<td>
<%= f.fields_for :questions, question do |q| -%>
<%= q.fields_for :answers, question.answers.find_or_initialize_by(participant: current_participant.id) do |a| -%>
<%= a.text_area :content %>
<%= a.hidden_field :participant_id, participant.id %>
<% end -%>
<% end -%>
</td>
</tr>
<% end -%>
</tbody>
</table>
<div class="actions">
<%= f.submit %>
</div>
<% end -%>
(note the changed lines: ** q.fields_for :answers, question.answers.find_or_initialize_by(participant: current_participant.id) ** and the lack of looping through each participant)
How do we validate that the participant_id is the actual participant that is logged into the application? Since we are setting it in the form, a malicious participant could always change their hidden participant_id to be another participants id, submitting or changing an answer for another participant.
The first thought I'd have would be to modify the controllers params somewhat and merge in the participant id after the form is submitted, ala:
def survey_params
params.require(:survey).permit(:name,
:questions_attributes => [:id, :content,
:answers_attributes => [:id, :content].merge(:participant_id => current_participant.id)
])
end
But merge doesn't work on nested attributes, nor do I think that would solve the problem.
Any thoughts as to what the best method to solve this would be?
Hey Pete,
Shouldn't this be "surveys" folder? Wondering because you have it as "survey" folder on your blog post.
"app/views/survey/answers.html.erb"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.