[Solved] Rails: Form fields & Loops

Rails has a built in mechanism for handling nested forms. Lets say you have: class Company < ActiveRecord::Base has_many :brands accepts_nested_attributes_for :brands end class Brand < ActiveRecord::Base belongs_to :company end class CompaniesController < ApplicationController def new @company = Company.new @company.brands.new # seeds the form with a new record for brands end def edit @company = … Read more

[Solved] Which ways are best to define my method.

So, you’ve proposed two functions that look like they are primarily designed to work with arrays, but they should return intelligent results if you pass them something other than an array. So, right away, you can’t use the Array.prototype method because if the data is not an array, that method won’t exist on the object … Read more

[Solved] How to detect voice in my iPhone app? [closed]

Use AVAudioRecorder – Audio Metering – checkout out this tutorial – dettect when a user blows into mic http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/ Quick Example: _audioRecorder.meteringEnabled = YES; //1. This method will get the current mic activity and will format it to a 0 – 1 scale. -(void)checkRecordingMeters:(NSTimer *)timer { [_audioRecorder updateMeters]; const double ALPHA = 0.2; float peakPower … Read more

[Solved] Which is better way? Variables related

If in a namespace eval, use variable to avoid the weirdness of the variable name resolver. (I don’t want to describe in detail what it does, other than to say that code that relies on it can be automatically described as buggy and in hard to accurately describe ways.) If in a procedure, (usually) use … Read more

[Solved] How would I go about Game Networking with C#? [closed]

If you have average skill using an SDK should be helpful for you. Start out with something like XNA Game Studio to see how those concepts are done. This document is the starting point for the SDK https://msdn.microsoft.com/en-us/library/bb200104.aspx and the “Network” concepts you are specially looking for are discussed here: https://msdn.microsoft.com/en-us/library/bb975947.aspx As for the database … Read more

[Solved] Regular Expression to get text from css

If you have CSS styles isolated in a javascript string, you can get the width value with this regex: var re = /\.body\s*\{[^\}]*?width\s*:\s*(.*);/m; var matches = str.match(re); if (matches) { var width = matches[1]; } Test case here: http://jsfiddle.net/jfriend00/jSDeJ/. The height value can be obtained with this regex: \.body\s*\{[^\}]*?height\s*:\s*(.*);/m; If you just want the text … Read more

[Solved] SQL Join with unique rows

Ok, let’s see if this answer suits your request. SELECT a.EMPLID,a.DEDCD, to_char(a.EFFDT,’YYYY-MM-DD’) EFFDT, b.DEDCD as DEDCD2,GTN FROM ( select EFFDT,GTN,EMPLID,DEDCD, row_number() over (partition by EMPLID order by DEDCD) rn from table1 ) A LEFT OUTER JOIN ( select EFFDT,EMPLID,DEDCD, row_number() over (partition by EMPLID order by DEDCD) rn from table2 ) B ON ( A.EMPLID=B.EMPLID … Read more

[Solved] How to get Jquery value in php [closed]

Remove the $() stuff around your result string. Also, you should check to make sure g.time.time isn’t zero before division. var speed = (g.time.time === 0 ? 0 : Math.floor( (Math.ceil(g.score.score / 5) / g.time.time) * 60)) var result=”<ul><li>You type “+g.score.score+’ characters in ‘+g.time.time+’ seconds.</li><li><u>Your speed</u> : about ‘ + speed +’ words per minutes!</li></ul>; … Read more