Posts

Showing posts from June, 2015

java - Spring Cloud Eureka: changing heartbeat and discovery path -

i unable conjure property change heartbeat , discovery context eureka server configbeans located in github: https://github.com/spring-cloud/spring-cloud-netflix/tree/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka seems i'm able set context path within client, not server. example, client configured as: eureka: instance: statuspageurlpath: /admin/info healthcheckurlpath: /admin/health homepageurlpath: /admin/dashboard client: registerwitheureka: false fetchregistry: false eurekaserverurlcontext: /admin serviceurl: defaultzone: http://localhost:8761/admin/eureka/ server: waittimeinmswhensyncempty: 0 dashboard: path: /admin/dashboard there seems nothing in eurekaserverconfigbean me modify on server change context /admin . when run clients, get: 2015-07-23 12:18:32.069 error 18894 --- [pool-7-thread-1] com.netflix.discovery.discoveryclient : can't response http://localhost:

android - A view with an equal width as its sibling but with a limit -

i trying build ui looks : underline width equal width of text when length of text short short text __________ underline width equal limit when length of text long sample long text ____________ how can build view underline width adaptive in way described above? i tried using relativelayout has textview text , empty textview underline (with alignleft , alignright properties) maxwidth property. looks maxwidth property not honored when alignleft , alignright set. any suggestions achieve appreciated. you can use following tags in xml: <view android:id="@+id/underline" android:layout_alignleft="@id/textview" android:layout_alignright="@id/textview" android:layout_below="@id/textview"/> the attributes layout_alignleft , layout_alignright set view aligned start , end of element specify. more information attributes can found on this answer kcoppock . edit: see tried this, ,

GIT: Checkout to other branch without doing a commit or stage the files in the first branch -

i beginner @ git. have file changes , need checkout other branch. clarify file exists in both branches. when checkout git says: the checkout cannot done because have changes not committed in first branch , these files overridden other times git allows me checkout second branch without doing commit or stage files in first branch why git doesn't allow me checkout , why does? thanks if there conflicts between changes , branch, git reasonably refuse clobber 1 or other. way around stash changes, apply stash (assuming wanted changes in newly checked out branch): > git stash save > git checkout <brannchname> > git stash pop

ios - Cancel LocalNotifications method not executing when user closes/exits the app -

i'm testing on ios 8.4 on xcode simulator , on iphone 6. notifications work fine , fire perfectly. can't figure out how cancel notifications when user quits/closes app. pressing home button should not cancel notifications , should still fire notification. this have tried. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { [application registerusernotificationsettings:[uiusernotificationsettings settingsfortypes:uiusernotificationtypealert|uiusernotificationtypebadge|uiusernotificationtypesound categories:nil]]; return yes; } [[uiapplication sharedapplication] cancelalllocalnotifications]; for below method - cancels notifications when user presses home button or closes app not want. - (void)applicationdidenterbackground:(uiapplication *)application for below method - notifications not cancel home button or closing app. - (void)applicationwillenterforeground:(uiapplication *)application for bel

create formatted excel spreadsheet with MySQL data and PHP using tables -

i working on exporting data mysql database excel spreadsheet. have found code doing before , works quite well. not format spreadsheet. first php/mysql site created , data didn't need pretty. current project requires formatted data. yesterday, found article may have allowed me need do. idiot, didn't copy link down. can't find today. here's code - <?php require_once("includes/connection.php"); require_once("includes/functions.php"); // set $closed 0 development $closed = 0; //create sting allow user see if s/he looking @ open or closed items if ($closed) { $filename = filename."_closed"; } else { $filename = filename."_open"; } // $data hold result $data = '<table>'; // row header? $th = false; // define separator character $sep = '\t'; // array keys $thkey = array(); // in first row? $firstrow =

c# - WPF Magic Strings -

Image
so more work wpf , third party vendors infragistics, seems there 1 common practice confuses me. why template parts have "magic strings"? everything have been taught since inception field mvvm, decouple, no magic strings , numbers, no 1 knows else, ect... so if that's case isn't there better way this? why accept common practice? templating changing visual parts of control. naming way of labeling parts can referenced elsewhere. mvvm binding data control, templating view concern, hence why templating doesn't know mvvm. when you're changing template shouldn't need know data control bound to. if controls template data specific that's anti-pattern in opinion. datatemplates want use data related templating. in control template you'd use presenter contentpresenter or itemspresenter give control template somewhere display data. side note - these things set strings can defined constants, can refactor them, etc. public class m

c++ - How to remove memory leak in Qthreads? 12+Gb leak -

i'm trying speed (qt c++ opencv) program should count number of colors in photos future filtering. there no leak in single-threaded approach, slow. with adding 8 threads i've speed process 5x times. the problem starts when switch program multithreading. there huge memory leak! http://snag.gy/chrrs.jpg following advises ( https://stackoverflow.com/a/12859444 ) prevented subclassing qthread , implementing run(). here loop counting each pixel in every new image shifted 1 pixel: colorcountercontroller *cntrl[arrsize]; (int = 0; < box; i++)//x { (int j = 0; j < box; ++j)//y { cv::mat res=process(image,i,j); //using 1 core //colors=colordetectcontroller::getinstance()->colorscount(res); //using 8 cores cntrl[cnt2%arrsize]= new colorcountercontroller(res,this); ++cnt2; } ++cnt; emit setstatusprogresssignal((int)(cnt/amnt*100)); } delete[] *cntrl; comments: when using 1 core (above c

javascript - I just can't figure out how to retrieve the name and value of the object passed -

i have function show, display nodes , attributes of xml. created object attributes store name , value of each attribute. part working well. now, when pass object function cant retrieve name , value of attributes. says aname , avalue undefined. can please help? my code: function show(){ : var mytag2 = child.nodename; var mytagvalue2 = child.textcontent; var attributes = []; (var k = 0; k < child.attributes.length; k++) { var attrib = child.attributes[k]; if (attrib.specified === true) { attributes.push({aname: attrib.name, avalue: attrib.value}); $("#maincontent").append("<li>" + attributes[k].aname + " = " + attributes[k].avalue + "</li>"); } } $("#maincontent").append("<td><button id=\"popup\" onclick=\"div_show('" + mytag2 + "','" + mytagvalue2 + "','" + attributes + "')\&quo

swift - Random Number Generator - Display 1 instead of Zero -

this question has answer here: how 1 make random number between range arc4random_uniform()? 13 answers in xcode 7 & swift have label generates random number between 0 - 50, when generates 0 want display number 1 instead. code need add this? label1textlabel.text = string(arc4random_uniform(51)) regards. del write code: var number = int(arc4random() % uint32(51)) if number == 0 { number = 1 } label1textlabel.text = "\(number)"

Permission to use my calendar in Android Xamarin -

i trying add event calendar in android app made in xamarin. keep getting error "requires android.permission.read_calendar or android.permission.write_calendar" . can please me this? here code..... thank you!!! using system; using myapp; using myapp.droid; using android.content; using android.provider; using xamarin.forms; [assembly: xamarin.forms.dependency (typeof (calendarmanager))] namespace myapp.droid { public class calendarmanager : icalendarmanager { public calendarmanager () {} //public const string write_calendar = "android.permission.write_calendar"; //public const string read_calendar = "android.permission.read_calendar"; //android.permission.write_calendar public void saveevent(datetime start, datetime end, string title, string notes, string location, bool allday) { contentvalues eventdetail

java - Not able to take screenshot in Android L programmatically -

i'm using nexus 5. version 5.1.1 i want take screenshot programmatically of phone @ given time. i'm okay if solution specific nexus 5. after reading many answers, i've tried below solution using screencap . issue creates image file, blank. private void takess() { try { if (isexternalstoragewritable()) { process su = runtime.getruntime().exec("/system/bin/screencap -p /storage/emulated/0/img.png\n"); dataoutputstream outputstream = new dataoutputstream(su.getoutputstream()); outputstream.flush(); su.waitfor(); bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(su.getinputstream())); string line; while ((line = bufferedreader.readline()) != null) { string output = line + system.getproperty("line.separator"); system.out.println(line); } } } catch (exception e) {

ms access - Can't create shortcut to .ACCDE file -

i have created access 2013 db need deploy several machines, of don't have access installed on them. can create .accde file .accdb file. when create shortcut .accde file using vbscript, shortcut insists on setting "opens with" field "ms access". since .accde file executable file, need open directly, not open using access. how can vbscript set this? here's using far. set objfilesys= createobject("scripting.filesystemobject") set ows = wscript.createobject("wscript.shell") if objfilesys.fileexists(ows.specialfolders("desktop") + "\clientdata.lnk") wscript.quit end if set olink = ows.createshortcut(ows.specialfolders("desktop") + "\clientdata.lnk") olink.targetpath = "c:\client data\unityclients.accde" olink.description = "client data" olink.workingdirectory = "c:\client data" olink.windowstyle = 3 olink.iconlocation = "c:\client data\ufslogo.ico" rem olin

javascript - Sendgrid: render an ejs template and then send as an email. -

so have index.ejs renders when start nodejs server: <!doctype html> <html> <head> <title<%= title %></title> </head> <body> <h1><%= title %></h1> <h3><%= yesterday %></h3> <h1> number of spins: <%= count %></h1> <h1> active user count: <%= usercount %></h1> <h1> users did not validate: </h1> <ul> <% for(var i=0; i<unvalid.length; i++) {%> <li><%= unvalid[i] %></li> <% } %> </ul> </body> </html> the thing is, send on email using sendgrid. far i've been doing using .sethtml method sort of "brute-force" it: email.sethtml('<h1> spotluck daily report </h1><h3>'+ yesterday + '</h3><h1> number of spins: '+cuenta+'<

php - Split Opencart Sitemap into multiple columns -

i using opencart 2.0.1.1 , in information/sitemap, categories in site map listed in 1 column , since have lots of categories generating long list in 1 column. i trying figure out if can split categories in multiple columns make good. tried using array_chunk or inserting if condition split different columns doesn't work. current code. $data['categories'] = array(); $categories_1 = $this->model_catalog_category->getcategories(0); foreach ($categories_1 $category_1) { $level_2_data = array(); $categories_2 = $this->model_catalog_category->getcategories($category_1['category_id']); foreach ($categories_2 $category_2) { $level_3_data = array(); $categories_3 = $this->model_catalog_category->getcategories($category_2['category_id']); foreach ($categories_3 $category_3) { $level_3_data[] = array(

google chrome - This webpage has a redirect loop (ERR_TOO_MANY_REDIRECTS) -

we have site not working in google chrome v44. works in ie , firefox. of sudden after updating chrome browser v44, unable login system , receiving problem. we're trying figure out why happening. have 2 instances of our system in our server. our live site 1 not working in chrome v44 while other - our demo site fine. difference of these sites our live has ssl. our first impression there's problem chrome v44 our site certificate. i think chrome can't establish secure connection site. has experienced issue? please help. thanks. this due ssl in chrome v44 incorrectly sends http_https header set, https header still set correctly. has been quite reported: http://www.zdnet.com/article/brand-new-chrome-44-release-added-a-bug/ https://ma.ttias.be/chrome-44-sending-https-header-by-mistake-breaking-web-applications-everywhere/ in order stop this, in php, added following top of index.php file: <?php if (!isset($_server['https'])) { $_server[

javascript - Classes not showing up in console: es6 and meteor -

i using grigio:babel transpile es6 in meteor. have simple file called camera.es6 provide camera functionality if (meteor.isclient) { class camera { constructor() { } getstream() { return new promise(function (resolve, reject) { navigator.webkitgetusermedia({ video: true }, resolve, reject); }); } } } i go browser console , try instance new camera. var c = new camera() vm1898:2 uncaught referenceerror: camera not defined @ <anonymous>:2:13 @ object.injectedscript._evaluateon (<anonymous>:905:140) @ object.injectedscript._evaluateandwrap (<anonymous>:838:34) @ object.injectedscript.evaluate (<anonymous>:694:21) shouldn't camera available? babel seems should translate function-like structure make work in es5. tried run in babel's repl and translated fine how access classes meteor , es6? i suppose babel wrap code closure, unable reach camera console. try window.camera = camera

android - Fill layout with color with exception of some child view -

i want show overlay on layout, overlay has translucent color fills view exception. these exception shape transparent color highlight background view overlay covering. my question how set translucent color fill parent view color exception area inside parent view. answer use "canvas.clippath()", here example code public class circularclipview implements view { final path path = new path(); public circularclipview(final context context, final attributeset attrs, final int defstyleattr) { super(context, attrs, defstyleattr); } @override protected void ondraw(final canvas canvas) { super.ondraw(canvas); canvas.save(); final int viewwidthhalf = 300; final int viewheighthalf = 300; final int radius = 100; path.addcircle(viewwidthhalf, viewheighthalf, radius, path.direction.cw); canvas.clippath(path, region.op.difference); canvas.drawcolor(r.color.transparen); //#c500

agile - Jira Release Notes - -

we use jira @ work our software development tickets. i'd able to, on release of version - email our team email address report on release, fixed, improved. basic email containing: tickets type; order, prio, name, link, status. i've tried searching over, nothing fits bill. pdf view plugin » doesn't work jira cloud (also expensive hell) maven changes plugin » use jenkins building, want jira release trigger email - not deployment to. any ideas? triggered (or @ least compiled) via rest / webhooks? far teh internetz has come empty. thanks :) i haven't seen want except plugin mentioned write jira event listener plugin goes off versionreleaseevent can send email fetching issues version. (least should possible) however question make reference jira cloud means custom plugin not option. you use rest api monitor projects release versions: /rest/api/2/project/{projectidorkey}/versions and poll on fixed interval (1/2 hour example) see if have moved

visual studio - Microsoft C# command line compiler not finding .dll in external directory -

i compile c# program command line in linux terminal. csc.exe added path , works correctly. directory layout follows: |-- program.cs |-- otherfiles.cs |-- bin | |-- debug | | |-- newtonsoft.json.dll from top directory, use following command compile: csc *.cs /r:./bin/debug/newtonsoft.json.dll --> error cs2001: source file 'r:bin/debug/newtonsoft.json.dll' not found is there better way i'm trying here, or have copy .dll files want same directory program.cs , done in this question ? the /reference argument used indicate name of assembly. to specify additional directories search assembly files use /lib argument: csc *.cs /r:newtonsoft.json.dll /lib:"./dir spaces/need quotes", ./bin/debug use /lib specify directory in 1 or more of assembly references located. /lib topic discusses directories in compiler searches assemblies.

wmi - How refresh ManagementObject result c# -

Image
i need read information ms queue timeout (bytesinqueue, messagesinqueue), data not refresh. var path = string.format(@"\\{0}\root\cimv2", machine); var scope = new managementscope(path); scope.connect(); string querystring = string.format(@"select * win32_perfrawdata_msmq_msmqqueue name '%{0}%'", queuepath.remove(0, queuepath.lastindexof('\\') + 1)); var query = new objectquery(querystring); var searcher = new managementobjectsearcher(scope, query); var moitems = managementobject x in searcher.get() select x; var moitem = moitems.firstordefault(); if (moitem != null) { bytesinqueue = (uint64)moitem.getpropertyvalue("bytesinqueue"); messagesinqueue = (uint64)moitem.getpropertyvalue("messagesinqueue"); } if use windows management instrumentation tester, data not refreshed, there button "refresh object", need. how can actual data, or refresh it? you not able actual data, because have query i

java - Optaplanner solving failed "illegal state exception" -

i new optaplanner , trying better learn how use changing around dinner party example solve different type of problem. added new score rule called samesleepingpreference, uses new enum created called sleepingpreference property of guest. people have same sleeping preference put next each other. rule "samesleepingpreference" when $leftdesignation : seatdesignation($leftguest : guest) $rightdesignation : seatdesignation(isrightof($leftdesignation), $rightguest : guest) eval($leftguest.sleepingpreference.equals($rightguest.sleepingpreference)) scoreholder.addconstraintmatch(kcontext, +1); end when try run optaplanner using data sheet of 4 people, example works fine. however, made longer list of 144 people changing around 1 of original data sheets dinner party example, , gives me error: 2015-07-23 10:41:59,414 [awt-eventqueue-0] info opened: data\dinnerparty\unsolved\hannahweddingtest.xml 2015-07-23 10:42:01,012 [swingworker-pool

Counting the number of unique formulas in an excel sheet -

i have big workbook 50+ worksheets , count number of unique formulas in workbook. used inbuilt find option find '=' returns duplicate formulas due drag option in excel. ideas appreciated. thanks. this sliiightly different answer may expecting, if go formulas ribbon, -->formula auditing section --->show formulas, change cells display what's in formula bar, instead of simplification of formula is. using simplest way check formulas present in workbook. as counting 'unique' formulas using, that's possible, clarify why want it? using information for? if explain needs little more provide more useful solution.

java - How to Add Sequence to Names(If Duplicated) Stored in a List -

given following code: import java.util.arraylist; import java.util.arrays; import java.util.collections; import java.util.linkedhashset; import java.util.list; public class filenameseq { public static void main(string[] args) { //list containing duplicate names list<string> al = new arraylist<string>(arrays.aslist("java", "java", "java", "cpp", "java", "cpp" ,"c")); arraylist<string> filenamelist = new arraylist<>(); (int = 0; al.size() > 0;) { int freq = collections.frequency(al, al.get(i)); string filename = al.get(i); filenamelist.add(filename.concat("-").concat("" + freq)); al.remove(i); /* removing element */ } system.out.println(filenamelist); } } i have developed piece of code generate sequence if there similar names stored in list, first occurr

python - How to format the name of the logging level -

when start ipython, see logs this: [i 17:03:59.993 notebookapp] using mathjax cdn: https://cdn.mathjax.org/mathjax/latest/mathjax.js [w 17:04:00.292 notebookapp] terminals not available (error no module named terminado) [i 17:04:00.293 notebookapp] serving notebooks local directory: /home/oleg [i 17:04:00.293 notebookapp] 0 active kernels [i 17:04:00.293 notebookapp] ipython notebook running at: http://localhost:8888/ [i 17:04:00.293 notebookapp] use control-c stop server , shut down kernels (twice skip confirmation). here levels of messages formatted, is, see i instead of info , w instead of warning etc. in addition, brackets colored. find cool , write logs way too. however, ipython uses tornado logging system. i use colorlog module color messages. in order formatting, subclassed streamhandler class, described here: how level of logging record in custom logging.handler in python? class formatlevelhandler(logging.streamhandler): def emit(self, record):

Regex - Special Character After 1 or more digits -

i'm rough regex , need have special character after number. if there multiple numbers special character have after entire group. special characters include !@#$%^&*() abcd1 not valid abcd1# valid abcd11# valid what have checks if string between 5 , 30 characters , contains number ^(?=.*\d)(?=.*[a-za-z]).{5,30}$ try this: '\d+[!@#$%^&*()]'

c# - OData, method get with key not found -

with code below, can hit (using fiddler): getcustomers via get: odata/customers post(customermodel customer) via post: odata/customers delete via delete: odata/customers(5) the delete method : public ihttpactionresult delete([fromodatauri] int key) { console.writeline(key); } i hit method , key, no problem. but don't hit method key (no problem method without key, full list) : // get: odata/customers(5) public ihttpactionresult getcustomer([fromodatauri] int key) { console.writeline(key); } i error (response headers via fiddler): http/1.1 404 not found the webapiconfig : public static class webapiconfig { public static void register(httpconfiguration config) { odatamodelbuilder builder = new odataconventionmodelbuilder(); builder.entityset<customermodel>("customers"); builder.entityset<employeemodel>("employees"); config.mapodataserviceroute( routename: "odataro

orientdb - How to insert a vertex with link type property with the orientjs query builder? -

i trying insert vertex orientjs(previously oriento) query builder. class has link type property pointing class. i know can work raw query string love use query builder. here i've tried far : db.insert() .into('vertexclassname') .set({"prop":"value", "linkproperty":"33:1289287"}) db.insert() .into('vertexclassname') .set({"prop":"value", "linkproperty":"#33:1289287"}) i following error : error on saving record in cluster #13 am setting properties in right way ? error related somtehing else ? have sucessfully ran insert query in cluster #13 raw query string in studio... according official documentation seems problem might @ end of statement db.insert().into('vertexclassname') .set({"prop":"value", "linkproperty":"33:1289287"}).one() .then(function (data) { // callback }); check if code works addin

javascript - Div show auto generated inline style -

i have taken 'div' element , @ run time 'div' shows auto generated inline style. how should stop such inline style? <div class="radius_div_square" id="usernoteexpand" style="overflow-x: auto; overflow-y: auto; height:4px;" sizcache="3" sizset="339;"> in code sample can see height:4px; have stop. that inline styling must added other library or framework. you must find out causing that. or can overwrite height attribute (external) stylesheet #usernoteexpand { height: 100px !important; } however, latter quite dirty...

html - White screen of death on dynamic sql php page -

i learning php creation of web pages mysql. wanted to run script, fails. white screen of death. can @ code , tell me , in direction should go. time. <?php include 'include.php'; // php class bracket // bracket builder gotgames // author benjamin thomas // october 2009 class bracket { //bring in database details include.php var $username = db_user; var $password = db_pass; var $database = db_name; //init class variables var $tournament_name; var $tournament_size; var $tournament_format; var $tournament_id; var $result_servers; var $result_stvs; var $result_matches; var $result_teams; //************************************************************************************* // schedule bracket // input - tournament id used identify tournament scheduling // operation - constructor reads required information databas , assigns following class values: // tournament_name; // tournament_size; // tournament_format; // tournament_id; // result_servers; // result_stvs; // result

javascript - Call automatically JS function with parameters inside <div> element -

i've tried find answers on internet this.. didn't find :( i'm trying call automatically javascript function passing parameters inside < div > element when page loaded. know "onload" doesn't work on < div > elements. don't have idea how that. note..: parameters dynamics because it's inside foreach loop. each loop have 2 different parameters send function. @foreach(var in something) { <div onload="myfunction(i.param1, i.param2);"> </div> } you can use script block @ end of <div> : <div> ... <script type="text/javascript"> myfunction(dynam_param1, dynam_param2); </script> </div>

mysql - Get all current joins to a query in yii2 ActiveQuery -

is there way joined table query? for example: query = account::find()->joinwith(['gallery'])->joinwith(['articles'])->etc... is there integrated method in yii2 return above joined tables (or event on hook them manually)? solution suggested @beowulfenator shows joins relations (which added joinwith() method. to show joins need prepare query this: $query = account::find() ->join('...', '...') ->joinwith(['gallery', 'articles']); // way, can reduce code $query->prepare(); this transform yii\db\activequery simple yii\db\query doesn't have joinwith property has join property show joins. you can var_dump , see it: var_dump($query->join); exit(); first element stores type of join, second - table name (note can either string or array depending on used relation), third - on condition.

python - What is the main difference between Numba Pro and Theano/pyautodiff for GPU calculations? -

both numba pro , pyautodiff based on theano supports conversion of python code gpu machine code. theano allow symbolic derivation of resulted syntax tree, outside scope of question. my question whether there technical limitations in 1 or other framework, make code less efficient.

sql - How to convert dollar money to Indian currency without function -

i have convert money comma separated select convert(varchar, cast(250233870.06 money), 1) result : money 250,233,870.06 but want in indian rupee format like desired output : money 25,02,33,870.06 you can use format if have sql server 2012 or above this. select format(cast(250233870.06 money),'n','en-in') output 25,02,33,870.06

c++ - Load class from shared library without header file -

i have my_program loads shared libraries. basicaly user can create 1 project , project can executed my_program . want load class shared library. i've found example: c++ dynamic shared library on linux this example great, have problem. don't have header file. so, there possible way load class don't have header file? suppose there isn't. if not mistaken don't think there way load header file dynamically? if user write class child : public parent in main program must replace myclass (from example provided) child. know methods in child class, becase provide baseparent class pure virtual methods. include baseparent in main program. still need know class name of project. what if project class name must my_project? help? know must replace myclass (from example above) my_project wouldn't trigger error because main program wouldn't know nothing class my_project ? i'm open suggestions because literally stuck. edit: if have class in main progra