Skip to content

Instantly share code, notes, and snippets.

View RussPete's full-sized avatar

Russell Petersen RussPete

View GitHub Profile
@RussPete
RussPete / flatten.js
Last active January 30, 2019 04:01
Flatten array of arrays of integers.
// Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
function flatten(a)
{
var b = [];
if (a.constructor === Array)
{
for (var i = 0; i < a.length; i++)
{
var c = flatten(a[i]);
@RussPete
RussPete / clients_forms_helper.rb
Created July 9, 2012 05:00
route paths not working in a helper module
module ClientsFormsHelper
# works with setupClientFormLink() in application-js.js
def link_to_clients_form_options(rec_type, rec_id, able_type, able_id, options)
name = ''
route = ''
funct = ''
popup = ''
css_class = ''
form_class = case rec_type
= puts "======== #{contact.class.name} #{contact.inspect}"
- if contact.class.name == 'Symbol'
= builder.fields_for contact do |f|
else
= builder.fields_for :clients_contacts, contact do |f|
= hidden_field_tag 'mode', (f.object.id.nil? ? 'new' : 'edit')
<form accept-charset="UTF-8" action="/tasks_assigned/update" data-remote="true"
id="task_assigned_25" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="&#x2713;" />
<input name="authenticity_token" type="hidden"
value="aAQ+tic2/L7pBgblP5rjJDGmoNlCQL5owOWQFOvec78=" />
</div>
<input id="task_assigned_id" name="task_assigned[id]" type="hidden" value="25" />
<input name="task_assigned[provider_completed]" type="hidden" value="0" />
<input id="task_assigned_provider_completed" name="task_assigned[provider_completed]"
@task_assigned = TasksAssigned.find(25)
@task_assigned.provider_complete_dt = Time.now()
@task_assigned.save()