Posts

javascript - Removing Size and font-size from child elements -

i want remove element attributes divs. divs generated automatically. want iterate through each div , child divs , want remove font-size (font-size: xpx) , size inside font tag <font size="x"> . these examples of div. <div id="headline" class="headline" style="position: word-break: break-all; background-color: rgb(90, 88, 84); width:300px;height:250px"> <div style="text-align: center; font-size: 12px; color: rgb(1, 69, 18);"> <div> <div> <font color="#ffffff" size="6" > <b>this is&nbsp;</b> </font> <b style="color: rgb(255, 255, 255); font-size: xx-large;">a test&nbsp;</b> </div> </div> <div> <div> <b style="color: rgb(255, 255, 255); font-size: xx-large;">demo&nbsp;</b> </div> </div...

How to scan a string line, then scan inside that line without creating a nested loop? Java -

i want write code scan each line of file, takes each line , scan each next token on (by specified delimiter), compare token input, if there no match moves next line..etc. but, couldn't think of other way doesn't involves making nested loop! there other way, or better approach? try { scanner scan = new scanner(clock_time); while (scan.hasnext()) { //scan next line //scan specified tokens each line //if no match repeat, otherwise break } } use inner loop, that's tool (for life of me, don't know why you're worried using it). sure conserve resources closing inner scanner when you're done after end of inner loop, , same outer scanner. scanner filescanner = new scanner(somefile); while (filescanner.hasnextline()) { string line = filescanner.nextline(); scanner innerscanner = new scanner(line); while (innerscanner.hasnext()) { // whatever } innerscanner.close(); } filescanner.close();

regex - PHP - How do I convert string number to number -

i have string this $str = "one 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 nine"; with php language pattern can convert string: $str = "1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9"; for php can this: $string = "one 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 nine"; $replace = array(0,1,2,3,4,5,6,7,8,9); $search = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'); echo str_ireplace($search, $replace, $string); as fred -ii- pointed in comment str_ireplace trick insensitive replacement.

javascript - How to split a string by a character not directly preceded by a character of the same type? -

let's have string: "we.need..to...split.asap" . split string delimiter . , wish split first . , include recurring . s in succeeding token. expected output: ["we", "need", ".to", "..split", "asap"] in other languages, know possible look-behind /(?<!\.)\./ javascript unfortunately not support such feature. i curious see answers question. perhaps there clever use of look-aheads presently evades me? i considering reversing string, re-reversing tokens, seems work after... plus controversy: how reverse string in place in javascript? thanks help! here's variation of the answer guest271314 handles more 2 consecutive delimiters: var text = "we.need.to...split.asap"; var re = /(\.*[^.]+)\./; var items = text.split(re).filter(function(val) { return val.length > 0; }); it uses detail if split expression includes capture group, captured items included in returned array. these captu...

webjars - How to use RequireJS optimizer in Play framework? -

Image
as advertised, rjs in play can ensure javascript resources referenced within webjar automatically referenced jsdelivr cdn. in addition if .min.js file found used in place of .js. added bonus here there no change required html! however, cannot seem of work. i tried running play app in production mode, , webjar javascripts still being referenced local. i not see .min version of javascript files being used in production. i cannot dependency injection work in production mode. example, when want inject jquery in code this define(['jquery'], function ($) { 'use strict'; console.log($.grep); return { sum: function (a, b) { return + b; } }; }); i can work fine in dev mode, in production mode, rjs failed saying [info] error: enoent, no such file or directory '/users/khanguyen/desktop/rjsdemo/target/web/rjs/build/js/jquery.js' [info] in module tree: [info] main [info] app [info] [info...

Does django (python) reuse object? -

suppose have model field field1 class myclass(models.model): field1 = models.charfield(max_length=100) somewhere have code like my_object = myclass() my_object.field1 = 'a' my_object.another_field = 'b' # (it's not defined in model class) is there chance another_object = myclass() have another_field set ? no, another_field unique instance assigned to. particular python, irrespective of django. try in python console: >>> class myclass(): >>> field1 = "field 1" >>> x = myclass() >>> x.another_field = "another field!" >>> x.field1 'field 1' >>> x.another_field 'another field!' >>> y = myclass() >>> y.field1 'field 1' >>> y.another_field traceback (most recent call last): file "<stdin>", line 1, in <module> attributeerror: myclass instance has no attribute 'another_field' if want add ...

python - Using Django with an existing database id field trouble -

i'm using django existing database. used inspectdb create models of existing database. works except 1 important detail. seems though django assumes there id field. example, when delete field called date run migration, date deleted table. however, when try delete id field, says -alter field id on table_name if there no id field in actual database table. so, if want make , use id field in existing database have manually specify in model , database or there better way? by default django creates id field models if don't specify it, so, in case, if delete autogenerated: id = models.integerfield(primary_key=true) django models assume 1 exists, message see. because need have 1 primary key field. so, yes, have specify primary key adding primary_key=true attribute appropriate field on model generated inspectdb , or django assume primary key column id . keep in mind that, if decide add id column table, shouldn't set explicitly in model : each gene...