Posts

Showing posts from September, 2011

Ansible: Change SSH key -

i have inventory of multiple servers. ssh access these servers secured using pem key files. periodically change pem key used servers. so, use ansible following: generate new pem key file for each server in inventory, connect server using old pem key file install new pem key file test ensure ssh new key works , old key does not work what best way via ansible? you should split in 3 playbooks. the first generate new pem key. run locally. see: https://docs.ansible.com/ansible/playbooks_delegation.html#local-playbooks the second 1 rollout. copies key servers. can use authorized_key or copy depending on preferred workflow is. thats question. the third step testing playbook, maybe assert statement or using ping ensure connection works. when have playbooks combine them in single include or add 3 plays in 1 playbook in right order. see: https://docs.ansible.com/ansible/playbooks_intro.html

java - SQL Exception: ORA-00936: missing expression -

i running following query: my query = insert tbl_name (id,name, address,...)" +" values (?,?,?) then using query runner class insert. myqueryrunnerobj.insert("my query", result set handler obj, generated id, 'my name', 'my address',...); after getting following exception: exception in thread "main" java.sql.sqlexception: ora-00936: missing expression , invalid number of arguments expecting 11 given 10 what reason exception? correct syntax is: insert dept (deptno, dname) values (dept_seq.nextval, 1); or insert dept (deptno, dname) select dept_seq.nextval, 2 dual;

lua - Trying to access table value within the table -

i'm trying this local ball = { width = 20, height = 20, position = { x = (game.width / 2) - (width / 2), -- place ball @ center of screen y = (game.height / 2) - (height / 2) }, velocity = 200, color = { 255, 255, 255 } } but love2d me attempt perform arithmetic on global 'width' (a nil value) . how can fix it? tried replace width / 2 ball.width / 2 got attempt index global 'ball' (a nil value) . remember local some_name = expression equivalent to: local some_name some_name = expression this allows some_name appear in expression . in particular, allows recursion local functions. however, until expression finished being evaluated, value of some_name still nil . so within table initialization, ball nil value. there no way access members of table while table being initialized. can afterwards: local ball = { width = 20, height = 20, velocity = 2...

android - Retrofit,onResponse method doesnt work -

im new in retrofit,try data 1 web server,create model,interface still not working.problem(maybe) in method onresponse() add method log.d , toast dont see log , toast when launch app.why dont work? can understand when wrong response or else,but onresponse() dont work in general,how think.maybe toast cant work withoud data,but log.d must work without it,and log.d havent data,just code of response. added depencies , tryind in tutorial,what wrong did , can fix that? , try tu put data adapter,but when launch app,i have error in log "recyclerview: no adapter attached; skipping layout" maybe it's same problem.onresponse dont work , adapter doesn't create,because adapter inilialze in onresponse method , if onresponse doesn't work,setadapter recyclerview doesn't work to.and videoapi class: public interface videoapi { @get("/videos/featured") call<list<video>>getfeaturedvideo(); } video class: public class video { @serializ...

angularjs - How to filter the the odata query with case insensitivity when already using a function? -

i have complex odata query passing through angular using odataangularresrouce library. know odata queries case sensitive , dont know how data being stored in database. here predicates used build query. var predicfirstname = new $odata.predicate(new $odata.func("startswith", "firstname", new $odata.func("tolower", $scope.searchobject.searchstring)), true); var prediclastname = new $odata.predicate(new $odata.func("startswith", "lastname", new $odata.func("tolower", $scope.searchobject.searchstring))); **odata uri:** https://localhost/app/tyleridentityuseradministrationservice/users/$count/?$filter=((startswith(firstname,tolower(fahad)))%20or%20startswith(lastname,tolower(fahad))) as can see, want put function check given string startswith. have seen several posts solution put tolower(). however, when put way mentioned above not returning data. can here? thanks -fahad both properties...

box - Found some square boxes in a xliff file and not sure what they are? -

Image
i'm looking @ xliff file , found weird boxes don't know are? (please see screenshot) do guys have ideas weird bug boxes are? thank , i'm looking forward reply! i have never seen character, here how go finding out is: the first thing check source , target language of xliff file, should defined in xliff header. perhaps character valid character in either source or target language script. the next step depends on whether can contact person created xliff file. if yes, can show them file looks , ask them if file has perhaps been garbled during transmission. if not, check encoding of xliff file. if utf-16, open file in hex editor, find code point character, , on unicode.org . if file encoded utf-8 open in notepad++ (or other text editor allows change encoding), convert utf-16, proceed described above. if don't know encoding of file becomes matter of guessing. can @ other <trans-units> (assuming there more 1 in xliff file): if contain other ext...

What is the benefit of using a pointer C++ -

this question has answer here: why should use pointer rather object itself? 21 answers i confused on part of using pointer on c++.. might say, "a pointer memory adress of variable , there certaintly conditions in program need them". dont mean pointer in general, mean pointer use "simulate" class... think code explain more: #include <iostream> #include <string> #include "book.h" int main() { book book1; book *bookpointer = &book1; book1.setbooksid(123); std::cout << "book id: " << book1.getbookid() << std::endl; (*bookpointer).setbooksid(300); std::cout << (*bookpointer).getbookid() << std::endl; /*when usage of arrow member selection member, left pointer. same thing above, better practice! */ bookpointer->setbooksid(100); ...

javascript - Replacing image and class with jquery -

i'm using code replace image , add/remove classes jquery when clicked. when click first time works fine, when click second time same thing first jquery click command though click commands called based on classes added , removed. in example find cursor turns pointer click, towards bottom middle, when click button move above cursor, when click fadeout , in same image appear. please help demo //on arrow click //fade page out //replace open nav $('.arrow_up').bind('click',function() { $('.bg').fadeout(500); settimeout(function(){ $('.bg').attr('src', 'other_files/images/bg_open_nav.png'); }, 500); $('.bg').fadein(500); $('.arrow').removeclass('arrow_up').addclass('arrow_down'); }); //on arrow down click //fade page out //replace closed nav $('.arrow_down').bind('click',function() { $('.bg').fadeout(500); settimeout(function(){ $('....

java - Where did my pop-up window go to? -

the case of disappearing pop-up window! i click link , supposed bring little dialog pop-up window can change state (like ma, va, etc). click ok, pop-up window disappear , i'd on main window having fun wild abandon. that's happens when manually. when through nifty selenium java project link gets clicked pop-up window briefly appears poof! it's gone , mean gone, not in background. here's code sniipet: webelement foo4 = driver.findelement(by.linktext("state:")); string mytext; mytext = foo4.gettext(); system.out.println("i got: " + mytext); foo4.click(); (do stuff in pop-up window down here) i threw println in there make absolutely sure foo4 link clicked , is! sanity checks sometimes. when click event happens, poof! pop-up window shows kinda ghost split second totally blank , it's gone. have no idea what's happening. intermittent. 10% of time pop-up window appear of time no dice. i'm open ideas here. it's not mat...

node.js - Quickbooks Connection Error - Node -

i've been trying find solution issue on week no luck, i've been trying different things on boards nothing worked far. i have node / soap server trying connect quickbooks through web connector, got point if run in host machine , connect via ip guest (where qb / qbwc installed), works, if put somewhere else on network, doesn't, can connect , handshake, gives following: 20160421.19:34:39 utc : qbwebconnector.webservicemanager.doupdateselected() : updatews() application = 'new api - live' has started 20160421.19:34:39 utc : qbwebconnector.registrymanager.getupdatelock() : hkey_current_user\software\intuit\qbwebconnector\updatelock = false 20160421.19:34:39 utc : qbwebconnector.registrymanager.setupdatelock() : hkey_current_user\software\intuit\qbwebconnector\updatelock has been set true 20160421.19:34:39 utc : qbwebconnector.registrymanager.setupdatelock() : ********************* update session locked ********************* 20160421.19:34:39 utc : qbweb...

progressdialog - Android Progress Dialog Issue -

i've been trying progressdialog work. at first, had inside activity, not showing no matter how many permutations , combinations tried. then moved inside asynctask. i'm initializing , showing in onpreexecute, , dismissing in onpostexecute. @override protected void onpreexecute(){ try { dialog = new progressdialog(context, progressdialog.style_spinner); dialog.settitle("please wait"); dialog.setprogressstyle(progressdialog.style_spinner); dialog.seticon(r.drawable.ic_error); dialog.show(); } catch (exception e) { log.e(task_tag, exceptionutils.getstacktrace(e)); } } however, i'm not sure should used context. when try activity.getapplicationcontext, following exception thrown android.view.windowmanager$badtokenexception: unable add window -- token null not application. when tried activity, dialog not shown. when enclose dialog.show in try / catch, doesn't show. when not ...

javascript - Image not loading on Canvas? -

i'm trying load image onto canvas , hasn't been working after trying everything... javascript: var canvas = document.getelementbyid('mycanvas'); var context = canvas.getcontext('2d'); var start = new image(); start.onload = function(){ context.drawimage(start, 0, 0, start.width, start.height, 0, 0, canvas.width, canvas.height); } start.src = "hangman0.png"; i don't see wrong code, trying draw image , scale canvas' width , height, picture isn't showing no matter what. pointers? i've tried changing both html5 , css code, still no avail. css: canvas{ background-color: rgb(0,198,255); border-style: ridge; border-width: 5px; border-color: rgb(157,255,0); position: relative; } html5: <body> <div id='section'> <canvas id='mycanvas' width='979px' height='560px'></canvas> <script src="projectjavascript.js...

ruby - Rails : has secure password stop me from registering new users in database -

i'm following michael hartl tutorial, , don't understand why when add lines password validation, get: created_at: nil updated_at: nil it seems there bug, , user i'm trying create doesn't appear in database...

android - Reading text file keeping previous format -

im making simple network app , want load chat log on start up, works fine formats text 1 line writing file charsequence cs = tv.gettext (); final string str = cs + "\r\n" + s; //write text file try { fileoutputstream fos = openfileoutput("chat log", context.mode_append); fos.write(s.getbytes()); fos.close(); } catch (exception e) { e.printstacktrace(); } } catch (ioexception e1) { e1.printstacktrace(); } //close socket socket.close(); reading text final textview tv = (textview)findviewbyid(r.id.textview1); try { bufferedreader inputreader = new bufferedreader(new inputstreamreader( openfileinput("chat log"))); string inputstring; stringbuffer stringbuffer = new stringbuffer(); while ((inputstring = inputreader.readline()) != null) { stringbuffer.append(inputstring + "\r\n"); tv.append(inputstring); } } catch (ioexception e) { e.printstacktrace(); } current result screenshot you should able save formatting using html....

Not able to see Google Maps APIs Usage Statistics -

Image
api statistics report in google console project doesn't show data though making hundreds of requests every day. refer attached screenshot, shows blank. have billing enabled in project. api statistics started showing once upgraded plan. i'm not sure if it's google's policy not collect stats free plan improve performance of paid plans.

javascript - How to find the position for an element in a li with jquery or vanilla js -

lets imagine have following html code. i need find position within li elements li has class focus applied. in example result should 2 (if @ 0 index). idea how it? <ul class="mylist"> <li>milk</li> <li>tea</li> <li class="focus">coffee</li> </ul> use .index() var index = $('.focus').index(); demo specific list $('.mylist .focus').index() demo

javascript - Count on click button1 and recount if on click button2 -

i have 2 buttons , counter, have reset counter every time change button. don't know how reset counter. var count = 0; var button1 = document.getelementbyid("button1"); var button2 = document.getelementbyid("button2"); var display = document.getelementbyid("displaycount"); function clickcount(){ count++; display.innerhtml = count; } button1.onclick = function(){ clickcount(); count=0; } button2.onclick = function(){ clickcount(); } <input type="button" value="button1" id="button1" /> <input type="button" value="button2" id="button2" /> <p>clicks: <span id="displaycount">0</span> times.</p> pass parameter clickcount function button name, , check if has changed. var count = 0; var lastbuttonclicked = ""; var button1 = document.getelementbyid("button1"); var button2...

c++ - Building dependencies with Cmake -

i'm new cmake , i'm trying figure out how build dependencies. project folders organized this: scrubber -- fileio -- cdes -- utilities -- scrubber fileio, cdes, , utilities static libraries used executable in scrubber. i want able execute single make command top dir build everything. if build each library independently, comes fine when execute top make. if don't ahead of time won't build dependencies and, not surprisingly, complains libraries weren't found. so simple question: how cause system build libraries? top level cmakelists in scrubber cmake_minimum_required(version 3.2) project(scrubber) set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11") add_subdirectory(fileio) add_subdirectory(cdes) add_subdirectory(utilities) add_subdirectory(scrubber) fileio cmakelists in scrubber/fileio cmake_minimum_required(version 3.2) project(fileio) set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11") file(glob source_files *.cpp) a...

c++ - Code Keeps saying: "[Error] cannot convert 'float*' to 'float' for argument '1' to 'void test(float, int)'" -

#include <iostream> using namespace std; void test(float, int); int main() { const int size=11; float a[size]; test(a, size); return 0; } void test(float a[], int size) { [....] } it points test(a, size); can't figure out whats wrong(i'm learning coding , learned arrays/confused) your function prototype void test(float, int); not match function void test(float a[], int size) . change prototype @ top void test(float a[], int size); (i leave input variable names in prototype consistency, not necessary).

javascript - RTCMultiConnection exception on connection.addStream() -

i'm trying switch source - screen webcam (live). i've started function addstream() , after executing i'm getting error: domexception: failed execute 'webkitgetusermedia' on 'navigator': @ least 1 of audio , video must requested(…) object {audio: false, video: false} here code: function switchtowebcam() { connection.sdpconstraints.mandatory = { offertoreceiveaudio: true, offertoreceivevideo: true }; connection.addstream({ video: true, audio: true }); } maybe there other ways switch source. can't find example. thanks. here how add audio+video stream in screensharing session: connection.session.audio = true; connection.session.video = true; connection.addstream({ audio: true, // because session.audio==true, works video: true, // because session.video==true, works oneway: true }); you can try...

Preventing Stanford Core NLP Server from outputting the text it receives -

i running stanford corenlp server: java -mx4g -cp "*" edu.stanford.nlp.pipeline.stanfordcorenlpserver -port 9001 -timeout 50000 whenever receives text, outputs in shell running it. how prevent happening? it matters, here code use pass data stanford core nlp server: ''' https://github.com/smilli/py-corenlp/blob/master/example.py ''' pycorenlp import stanfordcorenlp import pprint if __name__ == '__main__': nlp = stanfordcorenlp('http://localhost:9000') fp = open("long_text.txt") text = fp.read() output = nlp.annotate(text, properties={ 'annotators': 'tokenize,ssplit,pos,depparse,parse', 'outputformat': 'json' }) pp = pprint.prettyprinter(indent=4) pp.pprint(output) there's not way this, you're second person that's asked. so, it's in github code, , make next release. future, should able set -quiet flag, , server n...

freemarker - NetSuite Advanced PDF Multiplication -

looking way multiply rate * quantity in advanced pdf form. using ${item.rate}*${item.quantity} print 100*10 instead of 1000. know can grab amount field have custom quantity field set using need calculate it. try: ${item.rate*item.quantity}

angularjs - Angular directive for displaying cents as dollars in an input -

so, have make input currency stores value integer in cents. have directive works, not quite. following directive converts data model view , after being changed, strips extraneous what's going model. problem not update view again when model changes. so, if input showing $10.00 , type in $10.00a, model correctly show 1000, remains in input field. return { require: 'ngmodel', link: function (elem, $scope, attrs, ngmodel) { ngmodel.$formatters.push(function (val) { return '$' + (val / 100).tofixed(2); }); ngmodel.$parsers.push(function (val) { var replaced = val.replace(/[^\d\.]/g, ''); var split = replaced.split('.'); var merged = split[0] + split[1].slice(0, 2) return number(merged); }); } } in order update viewvalue need call these 2 functions in newly pushed parser : //update $viewvalue ngmodel.$setviewvalue(displayedvalue); //reflect on dom element ngmodel.$render(); so directiv...

c# - Can some one please explain how the two classes differ in execution? -

i testing class in linqpad , constructed basic class cannot head around how 2 classes differ in execution. can please me out? public class name // 1 { public string name1 {get;set;} public surname surname = new surname(); } public class name // 2 { public string name1 {get;set;} public surname surname {get;set;} public name() { surname = new surname(); } } public class surname { public string surname1 {get;set;} public string surname2 {get;set;} } i rewrite classes, clr define code this public class name // 1 { private string _name1; public string get_name1() { return _name1; } public void set_name1(string value) { this._name1=value; } public surname surname = new surname(); } public class name // 2 { private string _name1; public string get_name1() { return _name1; } public void set_name1(string value) { this._name1=value; ...

progress bar - Python progressbar http request -

in simple cli application, app makes http request takes seconds return json values. i'm looking way cretate progress bar process. looked @ tqdm , progressbar2, couldn't find way link progress bar on http request. is there way ? how? thanks

Assign multiple local vars to array entries in perl -

in perl, i've been confused how cleanly assign multiple local variables array entries. i use following syntax in subs time, i'm familiar it: my ($var1, $var2) = @_ but other variations of confuse me. instance, have following code works: $ctr (0 .. $#matchinglines) { $lineno = $matchinglines[$ctr][0]; $text = $matchinglines[$ctr][1]; where " @matchinglines " array of two-element arrays. i wish convert last 2 lines obvious: my ($lineno, $text) = $matchinglines[$ctr]; that of course not work. i've tried numerous variations, can't find works. it sounds have array of arrays. means inner arrays array references. if want allocate them vars need derference them. use strict; use warnings; @matchinglines = (['y','z'],['a','b']); $ctr (0 .. $#matchinglines) { ($lineno, $text) = @{$matchinglines[$ctr]}; print "#array index: $ctr - lineno=$lineno - text=$text\n" } thi...

Python unittest files in subdirectory causing import failures in parent -

i'm adding unit , integration tests existing oss library, , imports failing unexpectedly when add subdirectory of tests. i've boiled down following: . ├── driver.py ├── lib │ ├── __init__.py │ ├── a.py │ └── b.py └── test ├── __init__.py └── test_driver.py my driver.py imports lib classes , b: $ cat driver.py lib import a, b def do_it(): pass if __name__ == '__main__': do_it() and following integration test works: $ cat test/test_driver.py import unittest, driver lib import # import required tests class t(unittest.testcase): def test_a(self): pass running: $ python -m unittest discover => ran 1 test in 0.000s; ok i'm trying add tests library files: ... └── test ├── __init__.py ├── lib <== added dir , content │ ├── __init__.py │ └── test_b.py └── test_driver.py test_b.py contains following: import unittest lib import b class t2(unittest.testcase): def test_b(self): pass with added, t...

AVPlayer pause live stream on iOS 9.3 -

im having difficulties trying resume live stream playback paused moment. on ios 9.2 , below player continued play paused moment. on ios 9.3 , above, when resume playing, receive "playerbufferempty" , avplayeritemtimejumpednotification, , result playback doesnt continue paused moment. this looks issue in avplayer since works on ios versions 9.2 , below. tried playeritem.canusenetworkresourcesforlivestreamingwhilepaused , doesnt help. are there changes in avplayer/avplayeritem regarding ios 9.2 ios 9.3? thanks!

php - Best Way convert PHP5.4 Array Dereferences To Be PHP5.3 Compatible -

issue need convert array deference works in php 5.4 version works php 5.3. i'm unable update live site php i'm bit stuck. i'm trying accomplish create coupon code drupal 7 form submitted. where i've looked: php syntax dereferencing function result discussion. looks isn't possible @ all. there several solution examples haven't been able convert issue. 5.4 dereferencing valid 5.3 array call similar issue haven't been able figure out way using it. original works in php 5.4: $coupon->store_discount_reference = ['und'=>[['target_id'=>"57"]]]; $coupon->store_coupon_exclusive = ['und'=>[['value'=>"0"]]]; $coupon->store_coupon_conditions = ['und' => [ [ 'condition_name'=>'store_coupon_usage_evaluate_usage', 'condition_settings'=> ['max_usage'=>'1'], 'conditions_negative'=>0, ...

c++ - Segmentation fault in AVIFileInit() -

i’m using code::blocks gcc compiler on xp. call avifileinit() in following test code causes segmentation fault: #include <windows.h> #include <stdio.h> #include <vfw.h> int main() { printf("%s", "avi init...\n\n"); avifileinit(); /// <-- crashes here!!! printf("%s", "avi exit...\n\n"); avifileexit(); printf("%s", "return...\n\n"); return 0; } i can’t find cause or solution problem. appreciated. well i’ve solved problem, else having similar issue, thought i’d post answer: omit “.lib” filename in linker settings. (in case, write “vfw32”, not “vfw32.lib”.) that way, won’t complain can’t find file, won’t have waste lot of time looking in installation folder before giving , linking version of library didn’t come compiler , isn’t compatible.

C++ Pointer Assignment Clarification -

this question has answer here: what differences between pointer variable , reference variable in c++? 31 answers what difference when have example, int var1, *ptr; ptr = &var1; // pointer ptr copies address of var1, hence ptr points var1? int var1, *ptr; ptr = var1; // ptr points var1, not have address of var1, can not change value of address var1? int *var1, *ptr; *ptr = *var1; // copy value of var1 location pointed ptr? are comments correct ? the second ( ptr = var1 ) , third ( *ptr = *var1 ) options wrong. in second case, asking ptr point address written in var1 . i.e. var1 integer value interpreted address. not want, , cause compiler error or warning. in third case trying dereference not pointer ( *var1 ). compiler error.

jQuery UI autocomplete ajax with multiple values -

i've checked several solutions this: jquery ui autocomplete multiple values in textbox jquery ui autocomplete multiple values with no success. have jquery ui autocomplete working exception of search phrases spaces in them. instance, i'll search "real" , list of results if enter "real estate" bombs out after "real ". here's current working code adding space in textbox: <script type="text/javascript"> $(document).ready(function () { /* auto complete menu search option */ $("#txtsearchprogram").autocomplete({ source: function (request, response) { $.ajax({ type: 'get', url: '/specialpages/program-autocomplete.aspx', data: { 'searchtext' : encodeuricomponent(request.term), 'langspecific' : '1' }, datatype: 'json', success: function...

.net - How does the membership authentication flow work? What are the responsibilities of each step in the process? -

i'm having hard time finding adequate documentation on subject, question this: flow of authentication in mvc4? using custom provider (that i'm still in midst of coding gain better understanding of framework). let me elaborate current understanding can place question in context: as understand it, when user logs in, login(loginviewmodel model, string returnurl) action fired runs websecurity.login(model.username, model.password, persistcookie: false) . method, in turn, fires validateuser in custom membership class. here, need work authenticate user. doing hitting our auth service receive access , refresh tokens , store them in cookie. so, how work after user validated? how framework know user still logged in or logged out, user timeout, etc? feel there need doing during validateuser process user principal. if me better understanding of process, appreciated. when overriding asp.net membership provider. login(loginviewmodel model, string returnurl) action fi...

java - Spring MVC parent template model component -

i'm using spring mvc 4 , i'm building site template requires several common components across pages, such login status, cart status, etc. example of controller function this: @requestmapping( path = {"/"}, method=requestmethod.get) public modelandview index() { modelandview mav = new modelandview("index"); mav.addobject("listproducts", products ); mav.addobject("listcategories", menucategoriasutils.obtaincategories()); return mav; } what way/pattern feed these elements not belong controller calling don't repeat on , on unrelated operations in every method of every controller? thanks! there several approaches show common data in views. 1 of them using of @modelattributte annotation. lets say, have user login, needed shown on every page. also, have security service, security information current login. have create parent class controllers, add common information. publi...

Python 3 syntax error on raspbian but not on mac -

i thought python 3 code inter-operable, function raises syntax error on second line when run on raspbian / debian, not on mac. def cleanstr(s): toremove = dict.fromkeys((ord(c) c in u'\xa0\n ')) return s.translate(toremove) i'm confounded, function worked cleaning strings. can suggest why not running ? difference of unicode syntax or differences in escaping?

Getters And Setters C++ -

ok guys question here simple.. want construct getter , setter diffrent value type.. function overloading getters , setters.. tried this #include <iostream>; class vectors { public: vectors() {}; vectors(int a, int b) { x = a, y = b; } int getx() { return x; } int gety() { return y; } float getx() { return (float)x; } float gety() { return (float) y; } friend vectors operator+(const vectors& v1, const vectors& v2); friend vectors operator/(const vectors& v1, const vectors& v2); protected: int x, y; private: }; vectors operator+(const vectors& v1, const vectors& v2) { vectors brandnew; brandnew.x = v1.x + v2.x; brandnew.y = v1.y + v2.y; return (brandnew); }; vectors operator/(const vectors& v1, const vectors& v2) { vectors brandnew(v1.x / v2.x, v1.y/v2.y); return brandnew; } int main() { vectors v1(2, 3); vector...

mathematical optimization - Wrappers for solvers of general nonconvex/nonlinear constrained problems (NLP) for Matlab -

i have general nonconvex function general nonconvex inequality constraints. have feasible starting point, , i'd minimize energy under constraints. solver should never leave feasible domain (i.e. barrier method) , should never increase energy. far used fmincon failed on both accounts, , i'd easy way try other solvers such ipopt, knitro, , snopt. speaking of which, won't mind recommendation specific solver accomplish i'm looking (nonincreasing , stays in feasible area). i'd try other solvers, i'm looking modeling problem once @ wrapper (e.g. yalmip , cvx convex optimization; ampl?), translate other solvers (or call functions , convert output required each solver - i.e. i'd work single interface). flexible possible in terms of code, i'd prefer supply callback functions (written in matlab) objective , constraints functions , gradient, return real values. of course, if there option use internal variables provide things auto-diff without compromising co...

java - Infinite While Loop in Quick Sort -

i'm coding quick sort in java, , i've completed partitioning portion, reason, program keeps running forever with: x swapped x where x random integer, same integer every time printed. i've tried debug this, runs fine every time in debugger. doing wrong? here's code excluding parent class, array generator, etc. class quicksort extends basicsort { public quicksort() { super("quicksort"); } public void sort() { int pivot = data[data.length / 2]; int low = 0, high = data.length - 1; while (true) { while (low < (data.length - 1) && data[low] < pivot) { system.out.println(data[low] + " less " + pivot); low++; } while (high > 0 && data[high] > pivot) { system.out.println(data[high] + " greater " + pivot); high--; } if (low >= high) { break; } else { int temp = data[low];...

c++ - If I write a placement new?How should I write normal operator delete? -

in "effective c++" item 52:write placement delete if write placement new. meyers says widget *pw = new (std::cerr) widget; , placement new invoked. if placement new doesn't throw exception, , delete in client code: delete pw; . then, delete invoke normal delete, not placement delete. meyers comes conclusion must provide normal operator delete. so, should normal operator delete looks like? think inside of normal operator delete should resemble placement delete. but if use normal operator new instead of placement new create object widget *pw = new widget; , , use delete pw afterwards, call normal operator delete wrote placement new. not seems right. something this: struct widget { widget() { throw std::runtime_error(""); } // custom placement new static void* operator new(std::size_t sz, const std::string& msg) { std::cout << "custom placement new called, msg = " << msg << '\n';...

objective c - Thread 1: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP, SUBCODE=0x0) -

when run app, error in these lines: ballonview = (cell!.contentview.viewwithtag(0)!.viewwithtag(1) as? uiimageview)! label = (cell!.contentview.viewwithtag(0)!.viewwithtag(2) as! uilabel) here original code in objective-c, want in swift balloonview = (uiimageview *)[[cell.contentview viewwithtag:0] viewwithtag:1]; label = (uilabel *)[[cell.contentview viewwithtag:0] viewwithtag:2]; so, can do? if of associated storyboard elements youll need make sure connected , identified. in experience thats first place need check when there crash involving ui elements. also, extremely beneficial unwrap optionals in safe manner well. 3 bangs in same line giant red flag.

java - org.springframework.web.client.HttpClientErrorException: 415 Unsupported Media Type: javax.faces.FacesException: -

i working on login page client , server using users table created on mysql database. keep getting following error message , i'm not sure why. thoughts? warning [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-14) #{userbean.login()}: org.springframework.web.client.httpclienterrorexception: 415 unsupported media type: javax.faces.facesexception: #{userbean.login()}: org.springframework.web.client.httpclienterrorexception: 415 unsupported media type @ com.sun.faces.application.actionlistenerimpl.processaction(actionlistenerimpl.java:118) @ javax.faces.component.uicommand.broadcast(uicommand.java:315) @ javax.faces.component.uiviewroot.broadcastevents(uiviewroot.java:790) @ javax.faces.component.uiviewroot.processapplication(uiviewroot.java:1282) @ com.sun.faces.lifecycle.invokeapplicationphase.execute(invokeapplicationphase.java:81) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.exe...

ios - ObjectiveC UIBezierPath path close issue -

Image
i try hexagon , have issue in close path. here hexagon, , close path not smooth. here drawing code cashapelayer* shapelayer = [cashapelayer layer]; uibezierpath* path = [uibezierpath bezierpath]; // [path setlinejoinstyle:kcglinejoinround]; // [path setlinejoinstyle:kcglinejoinbevel]; [path setlinejoinstyle:kcglinejoinmiter]; // cgfloat dashes[] = {6, 2}; // [path setlinedash:dashes count:2 phase:0]; // [path stroke]; cgfloat radians = 100.0; nsinteger num = 6; cgfloat interval = 2*m_pi/num; nsinteger initx = radians*cosf(interval); nsinteger inity = radians*sinf(interval); [path movetopoint:cgpointmake(location.x - semiwidth + initx, location.y - semiheight + inity)]; for(int i=1; i<=num; i++){ cgfloat x = radians*cosf(i*interval); cgfloat y = radians*sinf(i*interval); [path addlinetopoint:cgpointmake(location.x - semiwidth + x, location.y - semiheight + y)]; } [path closepath]; shapelayer...

java - How can I update JPanel continuously? -

Image
i've got slight problem, i'm writing gps tracking app track several objects @ once. data comes in on serial interface, coming in fine can tell. issue need continually update jpanel map created , displayed. public jpanel mapdisplay(){ jpanel mappanel = new jpanel(); mappanel.setsize(560, 540); coordinate start = new coordinate (-34.9286, 138.6); trackmap.addmapmarker(new mapmarkerdot(1lat, 1lon)); trackmap.setdisplayposition(start,8); system.out.println(1lat); mappanel.add(trackmap); mappanel.setvisible(true); return mappanel; } this have , it's happy display point once won't update. if print out 1lat variable in serial method continually prints, once here. a lot of answers i've found refer setting markers arrays, won't work in case objects i'm tracking anywhere. any appreciated :) is possible use worker thread , not use arraylist ? run risk of missing data if do. not necessarily. in swingworker ...