Posts

Featured post

Java - Combining two arrays? -

what i'm trying ask user list of items, , create 2 arrays - 1 itemname , 1 itemprice. program right deals itemprice , there's no indication of how can combine 2 arrays in 1 output list of both arrays combined, this: bread - 1.20 milk - 2.00 here have far, 2 arrays, name array isn't included in anything. thanks! public class taxclass { private input newlist; /** * constructor objects of class tax * enter number of items */ public taxclass(int anyamount) { newlist = new input(anyamount); } /** * mutator method add items , cost * enter sales tax percentage */ public void additems(double anytax){ double salestax = anytax; newlist.setarray(salestax); } } public class input { private scanner keybd; private string[] costarray; private string[] itemarray; /** * constructor objects of class scanner */ public input(int anyamountofitems) { keybd = new scanner(system.in); costarray = new string[anyamountofitems]; itemarray = new string[an

Python __call__ special method practical example -

i know __call__ method in class triggered when instance of class called. however, have no idea when can use special method, because 1 can create new method , perform same operation done in __call__ method , instead of calling instance, can call method. i appreciate if gives me practical usage of special method. django forms module uses __call__ method nicely implement consistent api form validation. can write own validator form in django function. def custom_validator(value): #your validation logic django has default built-in validators such email validators, url validators etc., broadly fall under umbrella of regex validators. implement these cleanly, django resorts callable classes (instead of functions). implements default regex validation logic in regexvalidator , extends these classes other validations. class regexvalidator(object): def __call__(self, value): # validation logic class urlvalidator(regexvalidator): def __call__(self, valu

arrays - jQuery - Retrieve values from HTML elements and return their sum -

i got form several checkbox 's user can choose multiple values, so: <div> <input id="myinput1" type="checkbox" value="choice_id_1" /> <label for="myinput1">5</label> </div> <div> <input id="myinput2" type="checkbox" value="choice_id_2" /> <label for="myinput2">10</label> </div> <div> <input id="myinput3" type="checkbox" value="choice_id_3" /> <label for="myinput3">10</label> </div> i need values each :selected checkbox label , return total sum (ie: total = 25) . so far have been trying strings labels .text() method, make array results, converting them int parsefloat() , sum array elements... obviosly no success. this got (for sure not best approach i'm open diferent solutions) : function totalsum() { var prices = $("

graphics - OpenGL -- What is the most efficient way to draw an oval in OpenGL? -

i have been using triangle_fan , drawing 90 triangles. what's better way? look @ page drawing . explain 2 different methods. edit: i forgetting nurbs. use them . have here

ruby - Tailor MCollective agent actions based on the machine's facts -

lets have mcollective agent named "foo" action "bar", in logic of action want x when fact "chicken" "true", , y when fact "beef" true. basically, how access facts mcollective agent? you can access configured fact source like: if pluginmanager["facts_plugin"]["yourfact"] == "foo" # else # else end do anywhere in agent u need access facts. hth, if not please ask on mcollective users list on google groups

QT, convert raw image to jpg using Hardware acceleration (gpu) -

i need convert raw image buffer jpg image buffer. at moment, operation in following way: qimage tmpimage = qimage(rawimgbuffer, img_width, img_height, image.format ); //image.format=rgb888 qbuffer bufferjpeg(&ba); bufferjpeg.open(qiodevice::writeonly); tmpimage.save(&bufferjpeg, "jpg"); qbytearray finaljpgbuffer = bufferjpeg.data(); it works fine cpu load high (i have lot of threads operation lot of time each second). reading qt documentation found article: hardware acceleration &amp embedded platforms . if understood, can use qpainter class execute gpu operations... possible convertion (from raw jpg) using class? (or similar qt class use hardware acceleration (gpu))!! my application need platform indipendent. thanx @ all. i don't think qimage uses gpu generate jpeg. wouldn't (except on limited cpus) since transfer time of getting data out of gpu dominate. reason using hardware acceleration display result in gpu ready d

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -

what put in vim config? how change it? i want .html extension...because html... i think need au bufread,bufnewfile *.ejs setfiletype html au short autocmd docs it's idea put inside test if has("autocmd") au bufread,bufnewfile *.ejs setfiletype html endif to avoid error messages if ever use cut-down version of vim doesn't support feature. finally, if have default filetype rule like: au bufread,bufnewfile * setfiletype text then *.ejs rule must above it.