Posts

javascript - How do I extract the name from HTML collection? -

Image
here's step through of javascript. i have htmlcollection, want loop through , extract object id of fileuploadcontrol. how do it? here's code, how proceed? function uploadimage(lnk) { var row = lnk.parentnode.parentnode; var rowindex = row.rowindex - 1; var abc = row.cells[2].getelementsbytagname("input"); var arr = [].slice.call(abc); } this it: abc.nameditem('fileuploadcontrol') but beware that: different browsers behave differently when there more 1 elements matching string used index (or nameditem's argument). firefox 8 behaves specified in dom 2 , dom4, returning first matching element. webkit browsers , internet explorer in case return htmlcollection , opera returns nodelist of matching elements. from here . this means if in markup had this: <div id='id'>foo</div> <div id='id'>bar</div> browsers behave differently when executing following code...

c++ - Boost, inserting static library in repository -

i'm working on large project, cross platform between linux , osx. i'm include boost functionalities, don't want force the collaborators install on machine (with totally different environment) boost libraries. if compile boost on machine, , put static libraries inside repository, problem face? can colleagues use same static libraries on environment? afaik there difference. static libraries not same on os x , linux. compilation depends on toolset (see boost guide ). , there can issues if ides different. however can compile both versions 1 platform (see cross-compilation ) , put them in repository, putting binary objects not best idea (even if don't depend on platform). i think try compile , link boost on different platforms, maybe succeed, can not cover scenarios sure. better create boost compilation script , tell use it.

php - Regular Expression for preg_match -

this question has answer here: how parse , process html/xml in php? 27 answers i got following string: elftksuqmcc" alt="" width="auto" height="auto" /></td> <td style="padding: 10px;">xx,x%</t and want have "xx,x", build following regular expression: /qmcc" alt="" width="auto" height="auto" \/><\/td>\n<td style="padding: 10px;">(.*?)%/ i tested online , got match xx,x when try execute in php following code preg_match_all('/regex/',$string,$match); it didn't match. have suggestions? string in there. var_dump($match) gives me empty array. thank you! problem in newline. in regex, there \n . use \r\n instead , work.

javascript - Jasper Async Report - Empty, why? -

lets start , firstly parameters specific report exmaple var config = { url : "http://exmaple.com/jasperserver/rest_v2/reports/reportfolder/examplereport/inputcontrols", method: "get", headers: { accept: "application/json;" }, } everything ok, response array of inputs, the array contains, 2 objects : first: { description: "date_from", id: "date_from", label: "date from", type: "singlevaluedate" } second: { description: "date_to", id: "date_to", label: "date_to", type: "singlevaluedate" } both inputs have property: validationrules[0].datetimeformatvalidationrule.format = "yyyy-mm-dd" so want run async report (i pass async parameter false now, se there less code here) var params ={ reportunituri: "/reportfolder/examplereport", outputformat: "html", freshdata : true, savedatasnapshot : f...

python - Django REST: create CRUD operations for OneToOne Field -

i'm trying create basic crud operations onetoone field. user not required set profile when signing in. how create/update/delete profile when needed (assuming user in db)? my models default user models django rest and: class userprofile(models.model): user = models.onetoonefield(user) location = models.charfield(max_length=50,blank=true) title = models.charfield(max_length=80,blank=true) #picture = models.imagefield(upload_to='user_imgs', blank=true) website = models.urlfield(blank=true) my viewsets are: class userviewset(viewsets.modelviewset): queryset = user.objects.all() serializer_class = userserializer filter_fields = ['id', 'username', 'email', 'first_name', 'last_name'] class userprofileviewset(viewsets.modelviewset): queryset = userprofile.objects.all() serializer_class = userprofileserializer filter_fields = ['user_id', 'location', ...

Java: Equivalent to Python's str.format() -

in python, there nice method simplifies creation of strings, making code beautiful , readable. for example, following code print exampleprogram -e- cannot something print_msg('e', 'cannot something') def print_msg(type, msg): print 'exampleprogram -{0}- {1}'.format(type, msg) i.e. can specify "slots" within string, using {x} syntax, x parameter index, , returns new string, in replaces these slots parameters passed .format() method. currently java knowledge, implement such method ugly way: void printmsg(string type, string msg) { system.out.println("exampleprogram -" + type + "- " + msg); } is there equivalent python's .format() string method? messageformat has exact usage. int planet = 7; string event = "a disturbance in force"; string result = messageformat.format( "at {1,time} on {1,date}, there {2} on planet {0,number,integer}.", planet, new date(), eve...

Preserving whitespace / indentation in Rails database column -

i have blocks of pseudo-code text stored in database printed off line-by-line , displayed in html. pseudo-code entered in text column in database: while (counter <= 10) { printf("enter grade: "); scanf("%d", &grade); total = total + grade; counter = counter + 1; } /* end while */ controller: def index @code = code.first // filler time being end index: - @code.cont.each_line |line| - += 1 .line %span= %li.line= line - = 0 somewhere along way ruby automatically strips out whitespace , leaves me text. i'd know how preserve this: while (counter <= 10) { printf("enter grade: "); scanf("%d", &grade); total = total + grade; counter = counter + 1; } /* end while */ doesn't come out this: while (counter <= printf("enter grade: "); scanf("%d", &grade); total = total + grade; counter = counter + 1; } /* end while */ i'm pretty...