Posts

Showing posts from May, 2015

csv - Assigning multiple variables in matlab from one matrix -

i need write csv have more 1 output not know how either or assign each number separate variable , have print in list csv file. x=rand(10); rows=[1:10]; cols=[1:10] j=x(rows,cols) end end csvwrite('weikle_list1.csv',j); y=csvread('weikle_list1.csv') cols=[1:10] rows=[1:10] k=x(cols,rows) end end csvwrite('weikle_list2.csv',k); w=csvread('weikle_list2.csv') formatspec='k=%1.4f'; fprintf(formatspec,x);

c++ - Ambiguous constructor -

well, i'm newbie c++ , practicing constructors. i'm creating bad version of string class , have been asked next task: a) create constructor can make conversion const char* string . b) create constructor 'n' first letters const char* . if 'n' longer const char* , copy of const char* written string . if 'n == 0', program write empty string . i think had no problems implementing them; have: cadena::cadena(const char* cad){ tam_ = strlen(cad); s_ = new char[tam_ + 1]; strcpy(s_,cad); } cadena::cadena(const char* cad, unsigned lon){ tam_ = lon; s_ = new char[tam_ + 1]; for(unsigned = 0; < tam_; i++){ s_[i] = cad[i]; } s_[tam_] = '\0'; } my problem comes when try test them in main method, error: "c1 ambiguous". i tried making dummy parameter (declaring unsigned parameter int no name in header) initizialite second parameter 0 , can't make using dummy parameter. i know

YouTube and FancyBox Video Functionality -

i trying embed youtube video in actual page, , have video in lightbox using fancybox plugin. when this, get: refused display 'youtube video url' in frame because set 'x-frame-options' 'sameorigin'. i video on page autoplay, , video in lightbox play when clicked , pause video embedded on page. appreciated in solving this, haven't worked youtube api or fancybox. edit: i able embed 2 videos, 1 on page , 1 in lightbox of this: embed youtube video - refused display in frame because set 'x-frame-options' 'sameorigin' in case, needs question answered in future. changing url watch embed allows this. anyone able on play/stop functionality using fancybox? thanks! i able embed 2 videos, 1 on page , 1 in lightbox of this: embed youtube video - refused display in frame because set 'x-frame-options' 'sameorigin' in case, needs question answered in future. changing url watch embed allows this.

makefile - How should I link libraries in automake normally linked with pkg-config? -

i'm trying project buildable automake. while using allegro5. i can build code using following command fine g++ -std=c++0x *.cpp -o mygame $(pkg-config --libs allegro-5.0 \ allegro_acodec-5.0 allegro_audio-5.0 allegro_color-5.0 allegro_dialog-5.0 \ allegro_font-5.0 allegro_image-5.0 allegro_main-5.0 allegro_memfile-5.0 \ allegro_physfs-5.0 allegro_primitives-5.0 allegro_ttf-5.0) but makefile not work. here src/makefile.am bin_programs = mygame am_cxxflags = "-std=c++0x" mygame_sources = animation.cpp body.cpp gameobject.cpp menu.cpp vector3.cpp \ arena.cpp button.cpp keyboard.cpp mesh.cpp assets.cpp character.cpp \ main.cpp mouse.cpp barrier.cpp environment.cpp manager.cpp titlemenu.cpp mygame_ldadd = allegro-5.0 allegro_acodec-5.0 allegro_audio-5.0 \ allegro_color-5.0 allegro_dialog-5.0 allegro_font-5.0 allegro_image-5.0 \ allegro_main-5.0 allegro_memfile-5.0 allegro_physfs-5.0 \ allegro_primitives-5.0 allegro_ttf-5.0 cleanfiles = myg

Java Collections Binary Search : The method binarySearch in the type Collections is not applicable for the arguments -

i trying design ride sharing system. here base object package rider; import java.util.treemap; public class uber{ string driver; treemap<float,string> destination; public uber(string d) { driver=d; destination = new treemap<float,string>(); } private void addtimedest(float tm, string dest) { destination.put(tm, dest); } float gettsum() { float tsum=0; (float f : this.destination.keyset()) tsum+=f; return tsum; } } so, each object has driver , associated time<->destination map driver. ultimately, want sort list of such objects time field i.e. key of treemap. and here iterator class created above package rider; import java.util.arraylist; import java.util.collections; import java.util.comparator; import java.util.iterator; public class uberiterator implements iterator<uber> { int currindex=0; arraylist<uber> ulist; comparato

r - Extract time from timestamp? -

essentially, want hour, minute, , seconds column of timestamps have in r, because want view how different data points occur throughout different times of day , day , date irrelevant. however, how timestamps structured in dataset: 2008-08-07t17:07:36z and i'm unsure how time timestamp. thank can provide , please let me know if can provide more information! we can use strptime convert datetime class , format extract hour:min:sec. dtime <- strptime(str1, "%y-%m-%dt%h:%m:%sz") format(dtime, "%h:%m:%s") #[1] "17:07:36" if op wants have hour, min, sec separate columns read.table(text=format(dtime, "%h:%m:%s"), sep=":", header=false) # v1 v2 v3 #1 17 7 36 another option using lubridate library(lubridate) format(ymd_hms(str1), "%h:%m:%s") #[1] "17:07:36" data str1 <- "2008-08-07t17:07:36z"

xaml - Select a different grid based on a converter's value for a UWP app -

in uwp app, have property returns 3 values. want show different grid based on value using converter. best way achieve this? direction think going head towards create 3 different grid templates, , set style 1 of these 3 templates based on converter returns. know if work? grid doesn have grid, can contentcontrol or that. want show different section of ui based on property thanks i use windowsstatetriggers nuget package. once installed can reference @ top of xaml xmlns:triggers="using:windowsstatetriggers" and had property in backend class called isbusy public bool isbusy { get; set; } = false; and example had 2 simple grids in xaml. <stackpanel x:name="root"> <grid x:name="redgrid" background="red" width="200" height="100" /> <grid x:name="greengrid" background="green" width="200" height="100" visibility="collapsed"/> </sta

swift - Splitting Audio Channels iOS -

i've been working on ios project attempting split audio file each individual channel can played separately. right opening audio file , copying data avaudiopcmbuffer separate data. right testing on mp3 file , far when copy audio data buffer of buffer's contents initialized 0 . supposed happening? let fileurl = nsurl(string: path!) let audiofile = try! avaudiofile(forreading: fileurl!) let framecount = uint32(audiofile.length) let buffer = avaudiopcmbuffer(pcmformat: audiofile.processingformat, framecapacity: framecount) { try audiofile.readintobuffer(buffer, framecount: framecount) } catch { print("no data") } i still new working ios , know may going wrong, appreciate help. the values returned in buffer small. if round them zero. to see if it's working correctly, multiply them large integer.

java - Why wont my calculations show in my app? -

i trying make simple ballistic app calculates bullet drop , time target. have in place need it, when test , wait results doesn't seems calculations have in there. suggestions me? package com.example.koryhershock.testapp; import android.app.activity; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class mainactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.content_main); button btn = (button)findviewbyid(r.id.button1); final edittext et1 = (edittext)findviewbyid(r.id.muzzlevelocity); final edittext et2 = (edittext)findviewbyid(r.id.targetrange); final textview time = (textview)findviewbyid(r.id.textview1); final textview bulletdrop = (textview)findviewbyid(r.id.textview2); btn.setonclicklistener(new on

artificial intelligence - Replacements for Neural Networks -

i learning artificial neural networks , usefulness intrigued me. tried make 1 play simple game (2048, done many times before seemed place start.)however, have found 2 problems along way. the first way programming it, there no training data set. appears able worked around, haven't found way it. the second neural networks, appear able minimize error, , game trying maximize score. @ given time there no optimal setup neural net check against. i ability create ai , let learn best strategies without me directly teaching it, why decided try format in first place. question is, there type of nn can overcome these short fallings, or way program 1 without these issues, or have switch different algorithm/program. if have switch please give recommendation of switch to. thank input also, if belongs in different place in stack exchange please where first, brief answer direct questions. read after recommendation :) the first way programming it, there no training da

What are fail-safe & fail-fast Iterators in Java -

there 2 types of iterators in java: fail-safe , fail-fast. what mean, , difference between them? what difference between them ... "fail safe" means: won't fail. strictly speaking, there no such thing in java fail-safe iterator. correct term "weakly consistent". javadoc says: "most concurrent collection implementations (including queues) differ usual java.util conventions in iterators , spliterators provide weakly consistent rather fast-fail traversal." typically, weak consistency means if collection modified concurrently iteration, guarantees of iteration sees weaker. (the details specified in each conncurrent collection classes javadocs.) "fail fast" means: may fail ... , failure condition checked aggressively failure condition (where possible 1 ) detected before damage can done. in java, fail-fast iterator fails throwing concurrentmodificationexception . the alternative "fail-fast" , "

External IP column is empty in the kubectl get services result set -

i have created service following config file: { "kind":"service", "apiversion":"v1", "metadata":{ "name":"my-service", "labels":{ "app":"my-service" } }, "spec":{ "ports": [ { "port":8080, "targetport":"http-server" } ], "selector":{ "app":"my-service" }, "type": "loadbalancer" } } executed following command: $ kubectl create -f my-service.json service "my-service" created then want see external address of service: $ kubectl services name cluster-ip external-ip port(s) age my-service 10.0.203.169 8080/tcp 3m kubernetes 10.0.0.1 <none> 443/tcp 32m in examples of

Qlikview Export Screenshot To Email -

i'm trying write script button in app named export. main idea button take screenshot of current active sheet, , attach email in outlook. here it's supposed do: open outlook (done) attach image in email (done) however, script works on local machine. not work once deploy onto qlikview server. suspect is because save local c drive. how work once deploy on server? here's code: sub sendmail() set appoutlook = createobject("outlook.application") 'create new message set message = appoutlook.createitem(olmailitem) message .subject = "testing daily report" .htmlbody = "<span lang=en>" _ & "<p class=style2><span lang=en><font face=calibri size=3>" _ & "hello,<br ><br >the weekly dashboard available. " _ & "<br>the main overview attached below:<br>&qu

javascript - Request to Php file from node js and i am getting the error 404 not found and i tried every possible path but not getting it -

Image
error in browser : my request code in js file : $http.post('php/db-r-distinct.php', zd) .then(function (response) { console.log('constructor, partners response : ' + json.stringify(response.data)); _this.$scope.dem = response.data; // on récupère ici les données du php }); my php file placed in folder src/php/db-r-distinct.php <?php include 'gs.php'; try { $mysql = new pdo("mysql:dbname=".sql_dbase.";host=".sql_host, sql_user, sql_pass); $mysql->setattribute( pdo::attr_errmode, pdo::errmode_exception ); $mysql->exec("set character set utf8"); // sets encoding utf-8 } catch (pdoexception $e) {echo 'error :' . $e->getmessage();} $dd = json_decode(file_get_contents("php://input")); $tab = $dd ->tab; $distct = $dd ->distinctv; $sql = "select t1.* $tab t1 join ( select $distct, max(du) latest $tab group

javascript - how to find table tag td values useing jQuery filter selecter -

<table> <tr> <td>calories </td> <td>targetvalue1</td> </tr> <tr> <td>protein</td> <td>targetvalue2</td> </tr> <tr> <td>protein</td> <td>targetvalue3</td> </tr> hi how can select second td values?? i tried $.each($("#nutritab tbody tr td:eq(1)"),function(i , item){ alert($(item).text()); }); but return first values .... use nth-child selector instead of :eq(index) the :nth-child(n) selector matches every element nth child() ( index starts 1 ) the :eq(index) selector selects element @ index n within matched set.( zero-based index ) $.each($("#nutritab tr td:nth-child(2)"), function(i, item) { alert($(item).text()); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"><

vb.net - Visual Studio 2010 insets code snippet code on new line -

assuming want create code snippet tostring(), have created following snippet: <?xml version="1.0" encoding="utf-8"?> <codesnippets xmlns="http://schemas.microsoft.com/visualstudio/2005/codesnippet"> <codesnippet format="1.0.0"> <header> <title>to string vb</title> <author>john doe</author> <description>shortcut tostring()</description> <shortcut>ts</shortcut> </header> <snippet> <code language="vb"> <![cdata[tostring()]]> </code> </snippet> </codesnippet> </codesnippets> when write code myobject.ts , press tab invoke code snippet, visual studio this: myobject. tostring() instead of this: myobject.tostring() how can keep snippet completion on same line invoked from? came ac

c# - ArgumentOutOfRangeException (The UTC time represented when the offset is applied must be between year 0 and 10,000.) with OData / SC Orchestrator -

i'm writing small web interface goes on front of system center orchestrator setup. supposed hit runbook , data - part largely unimportant. the code attempting start runbook job data using sample code (and subbing in requirements) https://msdn.microsoft.com/en-us/library/hh921685.aspx the lines have changed references own orchestrator, runbook guid, , runbook parameters. this line throws exception in title: context.savechanges(); which has stack trace showing error seems originating somewhere in odata realm of things beyond code: [argumentoutofrangeexception: utc time represented when offset applied must between year 0 , 10,000. parameter name: offset] system.datetimeoffset.validatedate(datetime datetime, timespan offset) +14215620 system.datetimeoffset..ctor(datetime datetime) +56 microsoft.data.odata.atom.epmsyndicationwriter.createdatetimestringvalue(object propertyvalue, odatawriterbehavior writerbehavior) +144 microsoft.data.odata.atom.epmsyndication

c++ - “class::data member is private” error -

who can check “class::data member private” error. #include <iostream> using namespace std; class marks { private: char * name; char * grade; float gpa; public: char* set_name(char * n) { name=n; cout<<"enter name :"; cin>>name; return name; } float set_gpa(float g) { gpa=g; cout<<"enter cgpa :"; cin>>gpa; return gpa; } char set_grade() { if(gpa>=3.00&&gpa<=4.00) { grade[1]='a'; } else if(gpa>=2.00&&gpa<=2.99) { grade[1]='b'; } else if(gpa>=0.00&&gpa<

javascript - DataTable How to prevent row click in columns containing hyperlinks -

i dealing javascript datatable clickable rows. each row when clicked forwards browser different page. column of row contains hyperlink. when hyperlin clicked don't want row click event fired or managed. here how have implemented row click event $(tableid+' tbody').on( 'click', 'tr', function (e) { window.location.href = $(this).attr('url'); }); when add event listener parent, event default "bubbles" downwards , attaches event children. in case setting event on tr (parent) , event bubble down , attach td (children). 1 of these td understand contains href (hyperlink) , block click event set on parent, have set event listener of event type click within function event need state event.stoppropagation() , override tr click event bubbled down. document.addeventlistener('domcontentloaded',()=>{ //set event on parent(tr), event bubbles default downwards therefore td's inherit do

javascript - Inline CKEditor with toolbar on generated code -

i'm building backend cms @ moment. i've been asked create module generates different blocks make page (picture text below, picture text right etc.) that bit working editing text i'm trying use ckeditor. using follwing code text editable i'm not getting toolbar : <div id="editable" contenteditable="true"> <h4>{{title}}</h4> {{text}} </div> to try , solve tried using javascript ckeditor's guide : ckeditor.disableautoinline = true; ckeditor.inline( 'editable' ); this code creating error : uncaught typeerror: cannot call method 'geteditor' of undefined i suppose it's because before text has been generated editor has nothing link to. can please me make generated code editable toolbar? also, possible ckeditor working class names instead of ids? thanks in advance during initialization phase ckeditor checks whether there's editor instance already bound element . erro

java - TestNG - running specific tests programically -

i trying create testng.xml programmatically. use below java code public static createtestsuit(string testclass){ xmlsuite suite = new xmlsuite(); suite.setname("my suite"); xmltest test = new xmltest(suite); test.setname("my test"); list<xmlclass> classes = new arraylist<xmlclass>(); classes.add(new xmlclass(testclass)); test.setxmlclasses(classes) ; list<xmlsuite> suites = new arraylist<xmlsuite>(); suites.add(suite); testng tng = new testng(); tng.setxmlsuites(suites); tng.run(); } the class 'testclass' contains several test methods. don't want run these methods. how can specify test method names want run in above code, above method should like public static createtestsuit(string testclass, list<string> testcasesid){ //code } note: test methods in form @test(testname="testcaseid") public void test1(){ } use xmlinclude include

javascript - ng repeat on click of a button -

i'm working on customized multiselection field according client's requirement. have implemented filter ng-repeat linked text box. typing text ng-repeat triggers , filtered values respectively typed alphabet, should appear in div. tough part is, on click of arrow button need ng-repeated list should appeared without filter applied it. user can select list item manually without being alphabet specific. i think need box can select 1 item list filter on typing, please try use https://ghiden.github.io/angucomplete-alt autocomplete directive angularjs

jenkins - Unable to connect a windows system as slave using JNLP -

Image
i have jenkins master running on suse linux. want connect windows 8.1 system slave using jnlp. followed link here https://wiki.jenkins-ci.org/display/jenkins/jenkins+cli#jenkinscli-connectionmechanism , changed jenkins global security configuration. under tcp-port jnlp-slave, selected static , entered port 49187. when launch jnlp connection on slave system, after while "read timeout" error. could suggest me doing wrong?

c# - 500 internal server error when : (colon) is at the end of WebApi Url. Accepting ipv6 as param -

i have action method receives ip parameter. [httpget] [route("lookup/{ipaddress}")] public string get(string ipaddress) { return ipaddress; } problem when api called ipv6 compact in parameter ending : (colon), call doesn't reach action , getting 500 internal server error no detail. works fine local machine using vs 2013 when deploy azure appservice ipv6 gives internal server error. already added requestpathinvalidcharacters <system.web> <compilation debug="true" targetframework="4.5" /> <customerrors mode="off" /> <httpruntime targetframework="4.5" requestpathinvalidcharacters="&lt;,&gt;,*,%,&amp;,\,?" /> </system.web> and set the <modules runallmanagedmodulesforallrequests="true"> works fine on local iis , iis express when deployed azure website api not working. could try: change config string <... requestval

character encoding - difference between NLS_NCHAR_CHARACTERSET abd NLS_CHARACTERSET for Oracle -

i have quick question here, know difference between nls_nchar_characterset , nls_characterset setting in oracle ?? from understanding nls_nchar_characterset nvarchar data types , nls_characterset varchar2 data types. i tried test on development server current settings characterset following :- parameter value ------------------------------ ---------------------------------------- nls_nchar_characterset al16utf16 nls_numeric_characters ., nls_characterset us7ascii then inserted chinese character values database. inserted characters table called data_ , updated column address , address_2 varchar2 columns. right understanding current setting nls_characterset us7ascii , chinese characters should not supported still showing in database ?? nls_nchar_characterset take precedence on ?? thank you. in general points correct. nls_nchar_characterset defines character set nvarchar2 , et. al. columns whereas nls_characterse

priority queue - java huffman tree precedence -

i have 2 questions following code have been researching on past couple of days. how can implement following rules if there multiple ties (meaning same number of frequencies) give single letter groups precedence on multiple letters , alphabetically? second question is, point me in write direction regards code encode/decode? should implement through main statement or go ahead , write new class? little stuck on start. import java.util.*; //the following code hardcoded 2 separate arrays consisting of //characters , corresponding frequency. application takes in these 2 //arrays , constructs huffman encoding tree. begins showing user //letters, frequency, , huffman code assigned letter. //the application takes in .txt file various strings , encodes them. //this result shown. [still working on part-- question above] abstract class huffmantree implements comparable<huffmantree> { public final int frequency; // frequency of tree public huffmantree(int freq) { frequency = freq;

ajax - ASP.NET : ImageButton Image Doesn't Update inside UpdatePanel -

i have imagebutton inside updatepanal , onclick event, process preformed on same image. image save on same location. problem is, code behind executes successfully, result doesn't show on webpage asp code: <asp:scriptmanager id="scriptmanager1" runat="server" /> <asp:updatepanel id="updatepanel1" childrenastriggers="true" updatemode="always" runat="server"> <contenttemplate> <asp:imagebutton id="imagebutton1" runat="server" autopostback="true" imageurl="~/sel_img/test.jpg" onclick="imagebutton1_click" /> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="imagebutton1" /> </triggers> </asp:updatepanel> code behind protected void imagebutton1_click(object sender, imageclickeventargs e) { using (bitmap bitmap =

php - Use "RewriteEngine on" in .htaccess only if the visitor is in a session -

so user not logged see same link user logged, difference logged user see different page after following link. please note link stay intact, meaning don't want replace final url one. also, avoid playing cookies. if can't done using rewriteengine, there way involving .htaccess / php? no need related .htaccess. combine both pages 1 , wrap content logged in users should see if logged_in() {...} or whatever can use check if user logged in. that should enough.

powershell - Use Out-gridview to display Log -

i'm pretty new powershell scripts. i'd display log file in gridview using out-gridview. let's have simple script $logfile = "logs\mycoollogfile.log"; gc -wait $logfile | out-gridview -wait this displays each row in single cell. log formated this: level timestamp loggername [thread]: message each entry separated 1 or more spaces (but can change separated 1 tab character if more suitable). message may contain additional spaces. previous entries never contain spaces. i'd have different columns level , timestamp etc. i'm not sure how achieve this. appreciated. edit: @jisaak requested, here example of log multi line message: warn 09:53:49.938 n.s.e.cachemanager [startstop-thread] creating new instance of cachemanager using diskstorepath "c:\temp" used existing cachemanager. source of configuration net.sf.ehcache.config.generator.configurationsource$defaultconfigurationsource@48666bf4. diskstore path cachemanager set c:\t

firebase - '.info/connected' takes very long to respond -

i long wait between going offline , '.info/connected' handler being called. in tests average wait 30 seconds long example notify user. is configurable somewhere or there way reduce ? (fb web interface on chrome) the firebase client uses websockets connect servers. value of .info/connected becomes false when underlying socket signals it's been closed, depends on socket provider (chrome in case). there no api in firebase sdk allows control this.

javascript - jQuery Class is not adding after division refresh -

i have jquery code when button-refresh clicked, table-data table refreshed. when refreshed, class negative not adding td below code $("#button-refresh").click(function(){ $("#table-data").load("index.php #table-data"); $("td[name=td-total").each(function() { var text = $(this).text(); var num = parsefloat(text); if (num < 0) { $(this).addclass("negative"); } }); }); use callback method of .load() $("#button-refresh").click(function(){ $("#table-data").load("index.php #table-data", function() { $("td[name=td-total").each(function() { var text = $(this).text(); var num = parsefloat(text); if (num < 0) { $(this).addclass("negative"); } }); }); });

excel - Issue with making chart dynamic, using formula name -

Image
i wanted make bar chart dynamic. purpose have used =a1:index(a2:a60;counta(a2:a60)) formula. gave name formula using name manager. when use formula in x-axis label range (in bar chart -> select data), getting error the formula typed contain error . formula working in cell. please suggest, doing wrong. thank you. when enter named range chart series dialog or label dialog, must precede range name either sheet name or file name. consider following screenshot: see how formula x axis labels entered =sheet1!chtlabels the formula range name is =sheet1!$a$1:index(sheet1!$a$2:$a$60,counta(sheet1!$a$2:$a$60)) similar series definitions. range name alone not sufficient. has preceded sheet name (or file name).

Gradle How to build several versions of a jar with different dependencies -

if tried solve similar problem before, please share solution. in gradle file have different subproject. of right able build rest-client core, there situation when rest-client should build db-client subproject. idea need able build rest-client different dependency. let 1 task builds rest-client dependency 1 project , task build rest-client dependency on 2 subproject. project(':core') { apply plugin: "groovy" repositories { mavencentral() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.5' testcompile "org.testng:testng:6.8.21" } } //rest-client project specific stuff project(':rest-client') { apply plugin: "groovy" repositories { mavencentral() } dependencies { compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' compile project(':core') compile 'org.codehaus.groovy:groovy-all:2.4.5' testcomp

mysql - Solr query doesn't show all the fields -

i learning solr (5.5.0) , running in standalone mode. here solr-data-config.xml: <dataconfig> <datasource type="jdbcdatasource" driver="com.mysql.jdbc.driver" url="jdbc:mysql://127.0.0.1/dbn" user="root" password="root"/> <document> <entity name="planexample" query="select * plan userid=60 limit 3"> <field column="planid" name="id" /> <field column="userid" name="userid" /> <field column="planname" name="planname" /> <field column="del" name="del" /> </entity> </document> </dataconfig> and add fields accordingly managed-schema: <field name="userid" type="int" indexed="true" stored="true" required="true" multivalued="true"/&g

java - maven-jaxb2-plugin: How to use my own EqualsStrategy -

i'm using maven-jaxb2-plugin generate equals , hashcode methods. i have implemented own strategies, derived jaxbequalsstrategy , jaxbhashcodestrategy . is there way tell plugin use strategies instead of default ones? e.g. via configuration like <arg>-xequals=my.own.equalsstrategy</arg> you correct: <build> <defaultgoal>test</defaultgoal> <plugins> <plugin> <groupid>org.jvnet.jaxb2.maven2</groupid> <artifactid>maven-jaxb2-plugin</artifactid> <configuration> <extension>true</extension> <args> <arg>-xtostring</arg> <arg>-xequals</arg> <arg>-xequals-equalsstrategyclass=my.own.equalsstrategy</arg> <arg>-xhashcode</arg> <arg>-xhashcode-has

How to initialize Google protocol buffers Timestamp in Java? -

google protocol buffers (3.0.0-beta2) offers well-known type timestamp . the documentation describes initialization in java using system.currenttimemillis() following: long millis = system.currenttimemillis(); timestamp timestamp = timestamp.newbuilder().setseconds(millis / 1000) .setnanos((int) ((millis % 1000) * 1000000)).build(); is there alternative way in recent java 8 ? starting java 8 , there new date/time-api makes more appealing reader using java.time.instant instant time = instant.now(); timestamp timestamp = timestamp.newbuilder().setseconds(time.getepochsecond()) .setnanos(time.getnano()).build(); the result should same concerning precision.

c# - How to prevent HttpListener from aborting pending requests on stoppage? HttpListener.Stop is not working -

i have problem here. in below code async/await pattern used httplistener. when request sent via http "delay" query string argument expected , value causes server delay mentioned request processing given period. need server process pending requests after server stopped receiving new requests. static void main(string[] args) { httplistener httplistener = new httplistener(); countdownevent sessions = new countdownevent(1); bool stoprequested = false; httplistener.prefixes.add("http://+:9000/getdata/"); httplistener.start(); task listenertask = task.run(async () => { while (true) { try { var context = await httplistener.getcontextasync(); sessions.addcount(); task childtask = task.run(async () => { try { console.writeline($"request accepted: {context.requ

Purpose of %w in ruby on rails -

i see in routes.rb this %w( mission path standard getting_started welcome infection instruction implementation ).each |page| page, to: "pages##{page}" end and when see home controller , doesn't have nay actions list above. link works properly. i want know these lines of codes do? %w( mission path standard getting_started welcome infection instruction implementation ).each |page| page, to: "pages##{page}" end the code works like: %w(foo bar) is shortcut array ["foo", "bar"] .each |page| it loops each element such in 1st loop value of page = "foo" get page, to: "pages##{page}" this line become get foo, to: "pages#foo" when user hits /foo redirected foo action of pages controller, same other elements too. thus, makes easy define routes elements in %w( )

java - Indeterminate Progress bar wont show -

i have application copies files (via adb) android tablet. takes time want display popup indeterminate progress bar on it. when copy task complete want able stop progress bar , let user close dialog. at moment have not added dialog box , trying progress bar working. problem have progress bar not showing @ start of task, dont know why. progressbar shows when dialog box saying sync complete appears. code is: progress = new jprogressbar(0, 100); progress.setforeground(new color(255, 99, 71)); progress.setindeterminate(true); progress.setvalue(0); progress.setpreferredsize( new dimension( 300, 20 ) ); progress.setbounds( 278, 12, 260, 20 ); progress.setvisible(false); progress.setstring("sync in progress"); progress.setstringpainted(true); contentpane.add(progress); pushtotab = new jbutton(""); pushtotab.addactionlistener(new actionlistener() { public void actio

Convert B to KiB, MiB calling a bash function -

in script i'm using check size of given mailbox, size returned in byte. more easy in "human readable" format. this question great starting old , not able modify answers needs. having: mailbox="/var/mail/$1 good=471859200 #450mb actualsize=$(wc -c <"$mailbox") mailboxdim=$(grep "mailbox_size_limit" /etc/postfix/main.cf | awk -f" " '{print $3}') i need print value in kb / mb if [ ! -f $mailbox ]; echo "can't check size of $mailbox | size=0; total=$mailboxdim" exit 3 else if [ $actualsize -lt $good ]; echo "size of mailbox $actualsize | size=$actualsize; total=$mailboxdim" exit 0 fi fi well, code longer more or less same. i'd need like echo "size of mailbox convert($actualsize) | size=convert($actualsize); total=convert($mailboxdim)" and i'm not able write correct function edit: everybody! if or in future wondering why need 2 variables achieve sam

java - Same value from database gives different long when code run locally and on server -

i have field in db name updation_date , save data in datetime/ timestamp , saving utc datetime. when retrieve long values this rs.gettimestamp("updation_date").gettime() now when run code on local machine right utc time (the same 1 saved in db) when run same code on server (it's in netharlands) long value having 3 hours utc time. don't know why difference because converting time db long. updation: tried using function utc date still no effect private static string dateformat = "yyyy-mm-dd't'hh:mm:ssz"; public static long getutctime(timestamp datetime) throws parseexception{ simpledateformat sdf = new simpledateformat(dateformat); sdf.settimezone(timezone.gettimezone("utc")); date date = sdf.parse(getstringdate(datetime)); return date.gettime(); } public static string getstringdate(timestamp datetime) throws parseexception { simpledateformat sdf = new simpledateformat(dateformat); return sdf.for

string - Display a substring in c++ program -

here question: write program allows input integer represents month number (1 – 12) , program should display abbreviation corresponding month. example: if input 3, output should mar, march. hint: store month abbreviations in big string months = “janfebmaraprmayjunjulaugsepoctnovdec” here codes far: #include <iostream> using namespace std; int main() { int x; string months = "janfebmaraprmayjunjulaugsepoctnovdec"; cout << "enter integer between (1-12): " << endl; cin>>x; cout<<"\n"<<months.substr(x,3); return 0; } problem: cannot figure out how corresponding abbreviations. #include <iostream> using namespace std; int main() { int x; string months = "janfebmaraprmayjunjulaugsepoctnovdec"; cout << "enter integer between (1-12): " << endl; cin >> x; cout << months.substr((x-1)*3, 3); return 0; } se

grails - Diacritic Letters are mistreated by Rest Client -

i'm using rest:0.8 connect main grails project grails project serves report generator using line of code: map<string, string> adminconfigservice = [ weburl: "http://192.168.20.21:8080/oracle-report-service/generate", ... ] map params = [ ... name: "iñigo", ... ] withhttp(uri: adminconfigservice.weburl) { html = get(query: params) } and receiving rest client process data. running 2 projects in local machine works fine. although when deploy war file of report generator our tomcat server, converts letter "ñ" "├â┬æ" , name "iñigo" treated "i├â┬æigo" . since report generator project works fine when run on local machine, means need change conf files on tomcat server? setting file need change? it seems encoding issue. check config.groovy : grails.converters.encoding = "utf-8" check file's encoding of controllers , services use rest:0.8. check ur

node.js - How can I check given date is between two dates in mongodb? -

{ "_id": { "$oid": "asdf976" }, "categories": [{ "mainmodels": [{ "submodels": [{ "price": "2000", "submodelname": "lumia021", }, { "price": "2000", "submodelname": "lumia341", } ], "status": "active", "modelname": "lumia", "fromdate": "15/04/2016", "todate": "29/04/2016" }], "brand": "nokia" }], "rank": "1", "name": "first mobile station" } { "_id": { "$oid": "asdf976" }, "categories": [{ "mainmodels": [{ "submodels": [{ "price": "2000", "submodelname": &qu

javascript - How to dynamically add script which will be executed right now? -

there simple page: <html> <head> <script type="text/javascript" src="scripts/x.js"></script> </head> <body> <script type="text/javascript"> console.log($); </script> </body> </html> 'scripts.x.js': var script = document.createelement('script'); script.type = 'text/javascript'; script.src = 'https://code.jquery.com/jquery-1.12.3.min.js'; script.async = false; script.defer = false; document.currentscript.parentnode.insertbefore(script, document.currentscript.nextsibling); this script adds new external script tag right after current script, doesn't work, because 'console.log' writes error 'index.html:8 uncaught referenceerror: $ not defined'. doing wrong? in advance! the problem because of asynchronous i/o model of javascript script doesn't expect. think script stop executing while jquery loading, c

javascript - Why does Angular ng-message 'when="required"' fire even though the input field has input? -

i have plunker here . when type in input in input field , click elsewhere on page message "this field required." gets displayed. why message being displayed despite input field having value? here code: <form name="reportform" novalidate > <input name="startdate" placeholder="enter start date" ng-model="startdatevalue" required> <ng-messages ng-if='reportform.startdate.$touched' for="reportform.startdate.$error"> <ng-message when="required"> field required. </ng-message> </ng-messages> <button ng-disabled="reportform.$invalid" type="submit"> submit query </button> </form> you missing import ngmessages module: example: https://plnkr.co/edit/vwhrtizrjkqbgfjaj5zb?p=preview var app = angular.module('plunker', ['ngmessages']); app.controller('mainctrl', function($sc

ios - How to set the identifier of the segue to “sw_front”? -

i'm using swreveal creating slide out menu. don't have storyboard. deleted it. have set identifier segue "sw_front" , "sw_rear". how can without storyboard? please, don't ask me why deleted storyboard. if don't have storyboard can't set segue...!!

c# - element not visible Target invocation exception -

i trying automate login on dropbox https://www.dropbox.com/chooser ,but still facing issues element not visible, weird, though if page loaded successfully. here code filling password: protected virtual void fillpassword(string password) { //password.clear(); password.sendkeys(password); } the last line fails on target invocation exception. wanted use password.clear();, failing. here locator password: [cachelookup, findsby(how = how.name, using = "login_password")] protected override iwebelement password { get; set; } what going on? tried use wait methods page,but has not helped. know why crashes? i changed html locator to: [cachelookup, findsby(how = how.cssselector, using = ".text-input-wrapper [name=\"login_password\"]")] protected override iwebelement password { get; set; } and works fine. not sure why name selector cannot find it. misunderstanding me. both approaches should work. here page sou