Posts

ruby on rails - Uploading files using remote:true and remotipart + carrierwave gems -

i want make remote file upload via remotipart + carrierwave. problem upload works, seems uploaded usual html. or uploaded via ajax, appropriate js file not called. have form_for remote:true, , corrseponding controller method create. since form submitted js, create.js.erb used. <% if @syllabus.errors.present? %> $('#syllabus-errors').html('<%= escape_javascript(render 'layouts/error_messages', object: @syllabus) %>'); <% else %> alert("ds"); $('#modal-body').html(<%= escape_javascript(render 'layouts/thanks') %>); $('#syllabus-errors').html(""); <% end %> logs show this: (0.1ms) begin transaction (0.1ms) rollback transaction rendered layouts/_error_messages.html.erb (1.0ms) rendered syllabuses/create.js.erb (12.0ms) it kinda strange error_messages rendered earlier create.js.erb, error_messages being rendered inside create.js.erb. i resolved probl...

javascript - trying to figure out how to load a fucntion after an onclik even -

<!doctype html> <html> <head> <script src="jquery-2.1.3.js"></script> <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" href="webpage.css"> <style type="text/css"> #mycanvas {left: 500px; top:500px; border: 2px solid black;} </style> <title>canvas basics</title> </head> <body> <canvas id="mycanvas" width="750" height="250"> </canvas> <br> <span id="count">3</span>seconds <button id="next">play</button> </body> </html> <script type="text/javascript"> var can; var ctx; var finish=false; function rannum(max) { return math.ceil(math.random()*max)+1; } window.onclick= function() { (function ...

c++ - Optimising data-structures so that they take advantage of virtual memory -

i know how optimise data-structures in opencv (the mat type specifically) able leverage operating systems built in memory/virtual memory management. for full context please read q , here - otherwise situation summed have large collection of mats * i'll need access arbitrarily , rapidly . main complication full amount of data above amount of ram available. (*conceptually data recursively defined 3d array of 3d arrays, let's not muddy water confusion!) rather build own lru cache , ram-hungry , inefficient 'page' addressing strategies access it, i'd rather let os me. i think concepts, when comes actual implementation i'm twiddling thumbs: is generic c++ consideration, or need address @ opencv level? is simple making granularity of of data close (but not over) 4kb? (see solution here 4kb motivation) how mat(s) saved, accessed , represented on disk? (is how memory-mapping involved?) is generic c++ consideration, or need address @ op...

sql server - SQL - How to insert values while checking condition based on another table? If null generate new ID -

i given task use cursor duplicate tables. (don't ask me why or suggest me use other way cause that's part of requirement of task given) set ansi_nulls on go set quoted_identifier on go alter procedure [dbo].[duplicatecompanyinfo] @comp_companyid nvarchar(80) begin set nocount on; declare @companyid nvarchar(30), @personid nvarchar(30), @personlinkid nvarchar(30), @addresslinkid nvarchar(30), @addressid nvarchar(30), @phonelinkid nvarchar(30), @phoneid nvarchar(30), @persphonelinkid nvarchar(30), @persphoneid nvarchar(30) exec @companyid = crm_next_id 5 exec @personid = crm_next_id 13 exec @addressid = crm_next_id 1 -- add company insert company ( comp_companyid, comp_primarypersonid, comp_primaryaddressid, comp_name, comp_type, comp_status, comp_createdby, comp_createddate, comp_updatedby, comp_updateddate, comp_timestamp, comp_secterr, comp_website ) select @companyid, @pe...

python - Read each line in a text file, store the values in a list, and compute scores -

read each line in text file, store values in list, , compute scores the best approach problem list functions need task. typical example is: read file. read list. take list , each string delimited space. store string array. ... then go python website , lookup how each function. example: input , output function in python: https://docs.python.org/2/tutorial/inputoutput.html also, can function asking google. google point answers questions: q: how find mean of list? a: finding average of list if enough times, able write problem solves problem listed. good luck!

javascript - How do I add a value to a list with button click? -

i'm having trouble using appendchild function... here's code <!doctype html> <html> <body> <form oninput="x.value=((parsefloat(winning_number.value)%(parsefloat(total_key_value.value)*100*2))/(parsefloat(total_key_value.value)*2)).tofixed(2)"> <input type="number" id="winning_number" value="" placeholder="winning number"> ~ <input type="number" id="total_key_value" value="" placeholder = "total (keys)"> = <output name="x" for="winning_number total_key_value"></output>% </form> <button type="submit" onclick="document.getelementbyid("container").appendchild(li);">submit</button> <ol id="list"></ol> </body> </html> i enter 2 numbers , calculates result using formula. how can make button add x value list once clicked? also, wa...

MySQL pivot table -

if have mysql table looking this: company_name action pagecount ------------------------------- company print 3 company print 2 company print 3 company b email company b print 2 company b print 2 company b print 1 company print 3 is possible run mysql query output this: company_name email print 1 pages print 2 pages print 3 pages ------------------------------------------------------------- companya 0 0 1 3 companyb 1 1 2 0 the idea pagecount can vary output column amount should reflect that, 1 column each action / pagecount pair , number of hits per company_name . i'm not sure if called pivot table suggested that? this is pivot table. a nice tutorial on how achieve can found here: http://www.artfulsoftware.com/infotree/qrytip.php?id=78 i advise reading post , adapt solution needs. update af...