Posts

Showing posts from June, 2011

r - How to solve the issue of fread txt with EOF? -

i trying read climate station info ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-stations.txt . however, since first row not populated (last 2 cols missing) , 5th column contains spaces, unable complete reading with: fread('ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-stations.txt',sep=) it returns error message: expected sep (' ') new line, eof (or other non printing character) ends field 5 when detecting types point 0: age00135039 35.7297 0.6500 50.0 oran-hopital militaire how apply fread correctly on reading txt file? thank you!

javascript - C++ server require ajax call to connect twice -

i have created simple c++ http server accept post request , parses data. #pragma comment (lib, "ws2_32.lib") // #pragma comment (lib, "mswsock.lib") #define default_buflen 4096 #define default_port "8080" class chttp { public: chttp() { recvbuflen = default_buflen; iresult = wsastartup(makeword(2, 2), &wsadata); if (iresult != 0) { printf("wsastartup failed error: %d\n", iresult); } zeromemory(&hints, sizeof(hints)); hints.ai_family = af_inet; hints.ai_socktype = sock_stream; hints.ai_protocol = ipproto_tcp; hints.ai_flags = ai_passive; iresult = getaddrinfo(null, default_port, &hints, &result); if (iresult != 0) { printf("getaddrinfo failed error: %d\n", iresult); wsacleanup(); } } int init() { listensocket = socket(result->ai_family, result->ai_so

html - Github Pages website favicon not showing -

i'm hosting website using github pages. connected cloudflare website because of ssl. when added favicon.ico website , following code in <head> make favicon show up, still doesn't show up. can do? <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"> (english not native language) edit: seems other people can see favicon, except me. why?

java - Get a object's list from a store procedure with MyBatis -

i list procedure using object list argument this: estado.java public class estado{ private string code; private string name; ... } estadolist.java public class estadolist{ private list<estado> estados; ... } query.xml ... <resultmap type="estado" id="resultestado"> <result property="code" column="c_code" /> <result property="name" column="c_name" /> </resultmap> <parametermap type="estadolist" id="paramestadolist"> <parameter property="estados" jdbctype="cursor" mode="out" resultmap="resultestado"/> </parametermap> <select id="getestados" parametermap="paramestadolist" statementtype="callable"> {call pkg.pr_estados(?)} </select> ... estadodao @override public list<e

Make text appear above background in HTML + CSS -

hi first webpage i've made , i'm trying display gif backrgound , make text appear above that.. works fine except can't seem display text above gif background.. can see in source code have 1 heading , 3 paragraphs, knows how fix this? <!doctype html> <html> <head> <link rel="icon" href="http://www.iconarchive.com/download/i91751/icons8/windows-8/systems-linux.ico" type="image/x-icon"/> <title>firstwebpage</title> <style> body{ /* use gif background */ background-image: url('http://images.eurogamer.net/2015/articles/1/8/7/1/5/3/2/san-francisco-subway-system-hacked-passengers-get-free-rides-148033947612.gif'); background-position: relative; background-size: cover; } </style> <audio autoplay loop> <source src="seffelinie.mp3" type="audio/mp3"> </head> <body> <div align="

XCode Multithreading does not work in Visual Studio 2015 -

i have written c++ opencv trackers multi threads. on building program xcode find 3 cpu cores being used , speed of tld tracked increases 50 %. however when build same project in visual studio using same code multi threads 1 cpu core utilized , tracker speed doesn't increase. there ain't difference between multi threads , single thread sequential program. i don't know why happens , how initialize threads in visual studio 2015.

ios - How to format text like a blockquote within a UITextView -

Image
i trying familiarize myself coretext , started making own note taking application. i have regex in place in conjunction attributedstrings , trying mimic functionality of stackoverflow text box typing in now. i have of common things like: bold italics headers emphasis blocks but struggling make block quote / code block. something breaks own line , creates box goes edge no matter how long text is. and changes background color is possible strictly using attributedstrings? i've seen old examples html / css injected hoping accomplish using special nsattributedstringkey combination. yes, it's possible. here's sample playground in swift 3: import uikit import playgroundsupport let richtext = nsmutableattributedstring() let chunk0 = nsattributedstring(string: "but struggling make block quote / code block.\n\n") richtext.append(chunk0) let paragraphstyle = nsmutableparagraphstyle() paragraphstyle.headindent = 20 // note settin

debugging - Debug DLL function parameters without a source code -

i have dll without source code. know program (again, have binary file, no source code) runs dll perform task. viewed dll dependency walker (depends.exe) see names of functions. see parameters sent function program. possible? i assume you're talking native dll? if so, answer perhaps. if dll compiled using c++ name mangling, it's possible depends original prototype back. if function names ?_foo@adbde instead of foo, they're decorated. in dependency walker use "undecorate c++ functions" command. otherwise, need module address of function , use disassembler work out parameters used , do. can frustrating , time consuming task.

if statement - Excel advanced multiple conditions formula -

i need write if in excel multiple conditions. basically, need excel return me this: if cr2=>2 , ci2=>2 , ch2=>2 should return 1 if cr2=>2 , ci2=>2 , ch2=1 should return 2; if cr2=>2 , ci2=1 , ch2=>2) should return 2; if cr2=>2 , ci2=1 , ch2=>1 should return 3; if cr2=1 , ci2=1 , ch2=1 should return 4. i've been trying right no success , think problem due fact don't know how can right false statements in case. any appreciated. thank you! you make big, ugly, nested-if-and statement , figure out how want deal other possible scenarios (unless don't happen in data). =if(and(cr2>=2,ci2>=2,ch2>=2), 1, if(and(cr2>=2,ci2>=2,ch2=1), 2, if(and(cr2>=2,ci2=1,ch2>=2), 2, if(and(cr2>=2,ci2=1,ch2>=1), 3, if(and(cr2=1,ci2=1,ch2=1), 4, "some other thing happened"))))))

python - Replicate identical tuples to N -

this question has answer here: how create list of repeated tuples in python? 2 answers i have identical tuples of (0, 1) assigned define limits 3 input values: bounds = ((0, 1), (0, 1), (0, 1)) is there pythonic way assign same tuples n inputs? example: bounds = ((0, 1), (0, 1), (0, 1), (0, 1), (0, 1), ...nth(0, 1)) you can multiply sequence n shallow copies of contents: bounds = ((0, 1),) * n this fine tuples of ints or other immutable data structures containing immutable types, cause surprising behavior if use mutable data structures lists - sequence of n references same list, because it's shallow copy. in case, comprehension idiomatic way create n independent objects: mutable_bounds = [[0, 1] _ in range(n)]

entity framework - How to use IdentityDbContext with SQLite database in EF Core? -

i cannot use identitydbcontext sqlite in ef core because unable apply migrations. have error: sqlite not support migration operation ('addforeignkeyoperation'). i know have rewrite migration manually ( https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations ). how? db context class empty class inheriting after identitydbcontext

react native - Watchman crawl failed when run npm start in Mac -

Image
i created project run react-native run-ios , build successful , shows no-bundle url present run npm start here error message. can please help? thank you. react-native-cli: 2.0.1 react-native: 0.47.2 watchman -v 4.9.0 try adding sudo before command. might not right way deal issue may going.

ios - Swift BLE "didDiscoverServices" not executing. Am I missing something? -

i've been reading tutorial use nrf8001 adafruit , connecting ios device via arduino. far i've set correctly , works fine in app. i'm trying write own app (for now) exact same thing, read tutorial , understand copied code close could, far can connection , things seem working (ui-wise), can't seem past connecting device: here's code after connecting: func centralmanager(_ central: cbcentralmanager, diddiscover peripheral: cbperipheral, advertisementdata: [string : any], rssi rssi: nsnumber) { //what when discovers peripheral, add array list print("peripheral found: " + (peripheral.name ?? "unknown name")) peripheralsfoundnames.append((peripheral.name ?? "unknown name")) peripheralsfounddata.append((advertisementdata.description )) peripheralsfoundcb.append(peripheral) peripheralsfoundrssis.append(rssi) } func centralmanager(_ central: cbcentralmanager, didconnect peripheral: cb

ionic2 - center align radio option for iOS in ionic 3 app -

i have following code in ionic 3. have yes/no type radio button horizontally aligned. in android coming in center in ios thery coming right aligned. want make them center aligned ios well. following code: <ion-card center> <ion-card-header > <ion-label >q1. programming geek?</ion-label> </ion-card-header> <ion-row radio-group> <ion-col width-30> <ion-item> <ion-label>yes</ion-label> <ion-radio value="1"></ion-radio> </ion-item> </ion-col> <ion-col width-30> <ion-item> <ion-label>no</ion-label> <ion-radio value="0"></ion-radio> </ion-item> </ion-col> </ion-row> </ion-card> following css have modified: .input-wrapper{ flex: initial; } .card-md .item-md.item

c - Header files and functions, is my function, parameters, or header prototype? -

i started c , tasked using header house prototype function. problem nothing happens when i'm expecting prompt input. didn't error , know @ first solve problem. have far. lab2.c #include <stdio.h> #include "lab2header.h" int main(){ double *p; double array [10]; p = array; const int size = 10; void input(p,size); return 0; } lab2header.h #ifndef lab2header_h_ #define lab2header_h_ void input (double *array,const int size); #endif lab2header.c #include <stdio.h> #include "lab2header.h" void input (double *array,const int size){ (int = 0; < size ; i++) { printf("input value"); scanf("%lf", &array[i]); } } a lot of notes @ seem either use int parameter or have function no needed parameters, mistake in array pointer problem way made function? void input(p,size); this line makes no sense. if supposed function call, need remove void .

angular - Cannot create routes on Ionic 3 -

i want see actual route on url can't figure out need change exactly. i'm following docs here: https://ionicframework.com/docs/api/navigation/ionicpage/ but error: ...home.ts has @ionicpage decorator, not have corresponding "ngmodule" at... have on top of page: @ionicpage({ name: 'sums-home', segment: 'sums-home' }) i created home.module.ts file code: import { ngmodule } '@angular/core'; import { sumshomepage} './home'; import { ionicpagemodule } 'ionic-angular'; import { ngmodule } '@angular/core'; import { sumshomepage} './home'; import { ionicpagemodule } 'ionic-angular'; @ngmodule({ declarations: [ sumshomepage ], imports: [ ionicpagemodule.forchild(sumshomepage), ], exports: [ sumshomepage ] }) export class sumshomepagemodule { } and go page doing: this.navctrl.push('sums-home'); but think should have else. does arch

matlab - How to recover files that were moved to a single file? -

Image
i tried move multiple files folder, there mistake in matlab code didn't create folder. files moved single file cannot opened or edited. how recover these files? example of mistake: a=strcat('c:\users\foldername'); % name , directory of folder fname=a; % mkdir(fname); % command wasn't executed... movefile('file1',fname); movefile('file2',fname); so file1 , file2 merged in file 'fname', instead of in folder named 'fname'. how file1 , file2 back? thanks in advance! unfortunately, odds may stacked against getting of files, except last one. reason why because movefile doesn't append existing destination file, overwrites it. following give last file (by renaming fname ): movefile(fname, 'file2'); if you're lucky, operating system have options restore previous versions of files/folders . best bet may check , see if folder containing original files has previous versions can open/restore previo

Angular 4 - managing state -

i developing angular 4 app need save navigation state such when user navigates away app non-angular web app , again should re-display last place left off. i looking @ established pattern follow this. far investigating redux angular, best solution above?

mysql - How to achieve redundancy between 2 tables of different databases? -

first of i'd start saying i've checked these 2 questions: sync 2 tables of different databases - mysql how synchronize 2 tables of different databases on same machine (mysql) but while similar not need. i have 2 databases in same server. db1 , db2 both databases have exact copy of single table called "user": userid login name lastname password level how can achieve sort of redundancy between these 2 tables in different databases? if db1.user gets new record db2.user has have record, if record modified other 1 modified , if deleted other 1 gets deleted too. to more specific, db2.user needs reflection of db1.user using triggers. edit: there question: mysql replication on single server , not remotely close want do. updated little bit @ end of posted how i'd achieve suggestion. as proposed can use triggers stated in this standard documentation . define after insert,after update , after delete triggers on db1.user , within trigg

swift - How to connect UITableViewCell button to perform UITableView functions? -

i have app utilizes tableview contains prototype cell. prototype cell contains few labels , button (connected cell's uitableviewcell file). if that's not clear, mean: class contactscell: uitableviewcell { //this custom cell used prototype cell tableview @iboutlet weak var firstnamelabel: uilabel! @iboutlet weak var lastnamelabel: uilabel! @iboutlet weak var numberlabel: uilabel! @iboutlet weak var indexpathrowlabel: uilabel! @iboutlet weak var replacecontactbuttonui: uibutton! @ibaction func replacecontactbuttontapped(_ sender: any) { //this button in question } the reason because i'd each cell in tableview have of labels (and button), each row having different values in labels. these values handled cellforrowat tableview function, via system follows: pressing button ( not button in cells talking about... different button @ top of vc, outside of tableview) brings contact picker: func selectcontact(){//allows user bri

python - Finding elapsed time across midnight without dates -

how compute elapsed time between time1 = 23:30:00 , time2 = 01:30:00 ? not have dates associated them, python attaches date 1900-01-01 when make them datetime objects, become time1 = 1900-01-01 23:30:00 , time2 = 1900-01-01 01:30:00 . desired outcome 2 hours. you can subtract 2 datetime objects , difference between them from datetime import datetime # d = datetime(year, month, day, hour, min, sec) d1 = datetime(2017, 9, 1, 23, 30, 00) d2 = datetime(2017, 9, 2, 1, 30, 00) print d2 - d1 2:00:00

python - When I create list A and then separate it with list C, then I cannot add list D -

a=11 b=21 a=[] n=10 y in range (11,b): x in range (1,a): a.append(x*y) in range (a-1): c=a[i*n:(i+1)*n] d=a[i*n] print(d+c) as far can see: c list, while d element list unless list of lists. you can d=[a[i*n]] that make d list of single element

python - Pycharm Debug mode syntax error -

all of sudden when running pycharm community edition i've started syntax error when running debug mode. tried reinstalling pycharm had no luck error. see before? traceback (most recent call last): file "/applications/pycharm ce.app/contents/helpers/pydev/pydevd.py", line 26, in <module> _pydevd_bundle.pydevd_additional_thread_info import pydbadditionalthreadinfo file "/applications/pycharm ce.app/contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info.py", line 19, in <module> _pydevd_bundle.pydevd_additional_thread_info_regular import pydbadditionalthreadinfo # @unusedimport file "/applications/pycharm ce.app/contents/helpers/pydev/_pydevd_bundle/pydevd_additional_thread_info_regular.py", line 5, in <module> _pydevd_bundle.pydevd_frame import pydbframe file "/applications/pycharm ce.app/contents/helpers/pydev/_pydevd_bundle/pydevd_frame.py", line 10, in <module> _pydevd_bun

mysql - Query works in SQL Fiddle but not on local DB -

i have sql fiddle here: http://sqlfiddle.com/#!9/cb017b/2 this works fine , returns expected data in sql fiddle when running query on local db following error: #1055 - expression #2 of select list not in group clause , contains nonaggregated column 'x.var_value' not functionally dependent on columns in group clause; incompatible sql_mode=only_full_group_by i trying group by text column named var_name , not seem work on local db. try this: select x.* ( select var_name, var_value subscribers_vars subscriber = 35 order created desc ) x group x.var_name can take out order by it's hard use in sub select subsequent group by. that's show. whole query can re-written without sub select (if not exercise) select var_name, var_value subscribers_vars subscriber = 35 group var_name

sprite kit - Moving Background Swift SKSpriteKit -

i'm working on application i'm trying set moving background. have transparent image full of clouds i'm using. problem is, how can make move more smoother? i've tried play speeds still looks laggy. blessing. here's video of got going. http://sendvid.com/78ggkzcj and here's picture of cloud image. cloud image here's code. think should change or differently? class gamescene: skscene { // background let background = skspritenode(texture:sktexture(imagenamed: "background")) // clouds var maincloud = skspritenode() var cloud1next = skspritenode() // time of last frame var lastframetime : timeinterval = 0 // time since last frame var deltatime : timeinterval = 0 override func didmove(to view: skview) { background.position = cgpoint(x: 0, y: 0) // prepare clouds sprites maincloud = skspritenode(texture: sktexture(imagenamed: "cloudbg1")) mainclo

java - HttpClientErrorException: 404 null -

i try call address in controller using resttemplate , result want ok or not found status in controller @getmapping(value = "/thanks") public modelandview confirmaccount( @requestparam string token, uricomponentsbuilder uricomponentsbuilder ) { resttemplate resttemplate = new resttemplate(); httpentity<object> entity = new httpentity<>(new httpheaders()); uricomponents uricomponents = uricomponentsbuilder.path("/register/token/{token}").buildandexpand(token); responseentity<boolean> response = resttemplate .exchange(uricomponents.touri(), httpmethod.put, entity, boolean.class); return response.getstatuscode().tostring().equals("200") ? new modelandview("redirect:/signin") : new modelandview("tokennotfound"); } i call address of controller. @requestmapping(value = "/

svg - use d3.js to animate a gauge needle -

i trying use d3.js animate gauge needle, end weird animation. have done search internet, couldn't figure out solution can use fix problem. codepen function createneedle(sampleangle){ topx = centerx - math.cos(sampleangle) * trilength topy = centery - math.sin(sampleangle) * trilength leftx = centerx - 10 * math.cos(sampleangle - math.pi / 2) lefty = centery - 10 * math.sin(sampleangle - math.pi / 2) rightx = centerx - 10 * math.cos(sampleangle + math.pi / 2) righty = centery - 10 * math.sin(sampleangle + math.pi / 2) return " m " + leftx + " " + lefty + " l " + topx + " " + topy + " l " + rightx + " " + righty; } //animate needle d3.select('.moveneedle') .attr('d', createneedle(sampleangle1)) .transition() .duration(2000) .attr('d', createneedle(sampleangle2)); you can make life easier if apply transform="rotate()" instead

c# - ReportViewer report in ASP.NET MVC5 not Displaying Data -

i’m working on first reportviewer report in asp.net mvc5 application, , i’m having trouble displaying data on report. have searched , found similar problems on site, none of solutions seems me solve issues. initially, received following error message: data source instance has not been supplied data source ‘dataset1’ in response, changed dataset name “reportdataset” “dataset1”, i’m not using “dataset1” anywhere. think default name of dataset when created dataset using report wizard, renamed “reportdataset” @ time. i have checked content of reportdatasource before adding reportviewer1.localreport.datasources, , has data in it. i believe i’m close showing report, missing perhaps obvious may have created report using reportviewer before, first-timer, think i’m missing that. appreciate if point out i’m missing. thank you. for rdlc report, used report wizard create report1.rdlc, has following dataset properties: name: reportdataset data source: reportdataset available datasets:

lua - Parse Headers in OpenResty? -

i have script in lua implementing google oauth. i working on adding branch of logic bypasses oauth: local auth_header = ngx.header["authorization"] or "unset" -- if valid api key exists, use rather oauth login flow ngx.log(ngx.err, "debug: " .. auth_header) if api_key ~= "unset" , auth_header == api_key return end however, appears header set blank: 2017/09/12 01:33:28 [error] 16494#16494: *109 [lua] google_oauth.lua:57: debug: unset, client: 1.2.3.4, server: resty, request: "get /images/favicon.ico?1487269154 http/1.1", host: "resty", referrer: "https://resty/sessions/new" am missing something? there way access headers in openresty i'm unaware of?

R: display vector in input format -

this question has answer here: output vector in r in same format used inputting r 2 answers is there r function displays vector in 'input' format? for example if x <- sprintf("%s",seq(1:3)) then function produce >unknown_function(x) [1] c("1", "2", "3") as per d.b's comment unknown_function <- function(x){cat(deparse(x))}

json - INT more than 2147483647 always turn to 2147483647 in PHP -

my db id more 2147483647 (integer), if id turns 2147483647 when convert data json. this json result [ {"id":2147483647, "district_id":7171051, "name":"karame"}, {"id":2147483647, "district_id":7171051, "name":"ketang baru"}, {"id":2147483647, "district_id":7171051, "name":"wawonasa"}, {"id":2147483647, "district_id":7171051, "name":"ternate baru"}, {"id":2147483647, "district_id":7171051, "name":"ternate tanjung"}, {"id":2147483647, "district_id":7171051, "name":"kombos barat"}, {"id":2147483647, "district_id":7171051, "name":"kombos timur"}, {"id":2147483647, "district_id":7171051, "name":"singkil satu"}, {"id":214748

python - Sort List of strings aternately -

so have list of strings : ['cbad','hfig','qspr','uyxz'] i want sort these strings in alternate fashion without changing relative position : ['abcd' ,'ihgf', 'pqrs', 'zyxu'] i.e. 'abcd' sorted in ascending order, 'ihgf' sorted in 'descending order, 'pqrs' sorted in ascending , on alternately. so, instead of sorting these list of strings looping through list element wise, there other efficient way in python ? (keeping in mind list may contain large number of elements). also, possible in such can define sort of custom order sorting, if want every third element sorted in descending order. : ['abcd' ,'fghi', 'srqp', 'uxyz'] this 1 liner works: mylist = ['cbad','hfig','qspr','uyxz'] ["".join(sorted(s, reverse=i%2)) i,s in enumerate(mylist)]

r - adding a comma and "" to a specific text -

i don't know category question falls into. have text has pattern below. 1 merrill lynch 33 2 lehman brothers hldgs. 82 3 salomon 149 4 paine webber group 248 5 bear stearns 328 6 charles schwab 621 7 a.g. edwards & sons 823 the pattern (sequence 1, company name (consists of characters or numbers), number (maximum 1000)) repeated i want (build function) turns text vector; c("1 merrill lynch 33", "2 lehman brothers hldgs. 82", "3 salomon 149", "4 paine webber group 248", "5 bear stearns 328", "6 charles schwab 621", "7 a.g. edwards & sons 823") would possible? there's no regularity in company name or number follows. there's space after first increasing sequence, space after company name. can provide more information if necessary. using stringr package, library(stringr) str_extract_all(txt, "[0-9]+\\d+[0-9]+") the regular expression reads 'any n

scala - Why don't Akka Streams application terminate normally? -

i wrote simple application using alpakka cassandra library package com.abhi import akka.actor.actorsystem import akka.stream.{actormaterializer, closedshape} import akka.stream.alpakka.cassandra.scaladsl.cassandrasource import akka.stream.scaladsl.{flow, graphdsl, runnablegraph, sink} import com.datastax.driver.core.{cluster, row, simplestatement} import scala.concurrent.await import scala.concurrent.duration._ object myapp extends app { implicit val actorsystem = actorsystem() implicit val actormaterializer = actormaterializer() implicit val session = cluster .builder .addcontactpoints(list("localhost") :_*) .withport(9042) .withcredentials("foo", "bar") .build .connect("foobar") val stmt = new simplestatement("select col1, col2 foo").setfetchsize(20) val source = cassandrasource(stmt) val tofoo = flow[row].map(row => foo(row.getlong(0), row.long(1))) val sink = sink.f

html - Z-Index is not working -

https://codepen.io/anon/pen/vebqyy?editors=1100 i have div class filter. div make background image lighter. trying make div class inner go on top of filter. put z index: 9999 on inner div not going top html, body { height: 100%; } .outer { display: table; height: 100%; width: 100%; background: url('https://static.pexels.com/photos/56875/tree-dawn-nature-bucovina-56875.jpeg'); background-size: cover; } .middle { display: table-cell; width: 100%; vertical-align: middle; text-align: center; // center in div } /* dim background */ .filter { position: absolute; width: 100%; height: 100%; top: 0; background-color: black; opacity: 0.5; } /* not working. z index not bringing top */ .inner { z-index: 9999; } h1 { color: white; } <section class="outer"> <div class="middle"> <div class="filter"></div> &l

python - Keras Cost Function Error when trying to round predicted tensor to nearest integer -

Image
i using sigmoid activation in second-last layer , resizing using tf.images.resize_images() in last layer. the target tensor has maximum value of 1.0. in dice error cost function. def dice(y_true, y_pred): return 1.0-dice_coef(y_true, y_pred, 1e-5, 0.5) def dice_coef(y_true, y_pred, smooth, thresh, axis = [1,2,3]): y_pred = k.round(y_pred) inse = k.sum(k.dot(y_true, k.transpose(y_pred)), axis=axis) l = k.sum(y_pred, axis=axis) r = k.sum(y_true, axis=axis) hard_dice = (2. * inse + smooth) / (l + r + smooth) hard_dice = k.mean(hard_dice) return hard_dice when run code error below. however, error goes away when remove k.round(y_pred) . idea on how solve problem? loss,acc,err = final_model.train_on_batch(train_image,label) file "c:\local\anaconda3-4.1.1-windows-x86_64\envs\tensorflow-cpu\lib\site-packages\keras\engine\training.py", line 1761, in train_on_batch self._make_train_function() file "c:\local\anaconda3-4.1.1-windows-x8

webpack - angular-cli 3rd Party Library - jquery.floatThead 2.0.3 -

i want use floatthead in angular2 app. have install jquery global library. in angular-cli.json "scripts": ["../node_modules/jquery/dist/jquery.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js", "../node_modules/ngx-rating/ngx-rating.pure.amd.js", "../node_modules/bootstrap-select/dist/js/bootstrap-select.min.js", "../node_modules/floatthead/dist/jquery.floatthead.min.js" ], in component have imported both jquery , floatthead follows import * $ 'jquery'; import * floatthead 'floatthead'; ... $('card-list-table').floatthead({top:110, responsivecontainer: function($table){ return $table.closest(".table-responsive"); } }); there no complitaion issue getting runtime error , plugin doesn't work error typeerror: __webpack_imported_module_5_jquery__(...

c++ text file redirection getline infinite loop -

so i'm having issue reading in text file using cin. here basic idea of code: while(getline(cin,line) { cout << line << endl; } //do task return 0; the problem i'm running loop not terminate , //do task never run. solution i've found directly @ text file, see how many lines of text there are, , hard code conditional break out of it. have text file 5 lines , variable int row. this: while(getline(cin,line) { cout << line << endl; if(row == 5) { break; } //do task return 0; i tried googling can't seem find answer anywhere. ideas? , libraries i'm allowed use iostream. you can use rdbuf redirect cin output following link you. http://www.cplusplus.com/reference/ios/ios/rdbuf/

Why android build system is working in a strange way? -

so have xml file has following structure: <relativelayout> <scrollview above="@id/bottom">...</scrollview> <linearlayout id="@+id/bottom">...</linearlayout> </relativelayout> i referenced linear layout in scroll view above. @ first project compiles no errors , gave desired results. when clean project gave errors linear layout reference. error:(16, 31) no resource found matches given name (at 'layout_above' value '@id/bottom'). i know, should put linear layout above scroll view why errors didnt show @ first, why happening ? change like <relativelayout> <linearlayout id="@+id/bottom">...</linearlayout> <scrollview above="@id/bottom">...</scrollview> </relativelayout> or <relativelayout> <scrollview above="@+id/bottom">...</scrollview> <!-- notice + --> <linearlayout id="@+id/bottom"&g

java - my viewpager have bad performance in android 6 -

i create slider adapter , activity , code works fine in android 4.4 kitkat in android 6 have crash or don't show me images , .... have problem appcompact ? don't know how fix problem. adapter public class screenshootsadapter extends pageradapter { private int[] image_resources={ r.drawable.walkthrough1, r.drawable.walkthrough2, r.drawable.walkthrough3, r.drawable.walkthrough4, r.drawable.walkthrough5, r.drawable.walkthrough6, }; private context ctx; private layoutinflater layoutinflater; public screenshootsadapter(context ctx){ this.ctx=ctx; } @override public int getcount() { return image_resources.length; } @override public boolean isviewfromobject(view view, object object) { return (view==(linearlayout) object); } @override public object instantiateitem(viewgroup container, int position){ layoutinflater

sql - Fetch data from table based on common value present in joining table -

i have 2 tables table1 , table2 , joining table table_1_2 holds primary key of both table1 , table2 tables. table diagram i want fetch records table2 based on values of table1.suppose if user selects t1 , t2 record table1 p1 should fetched table2 p1 has got record both t1 , t2 seen in joining table. if user selects t1 record table1 both p1 , p2 value should fetched table2 t1 has associated record both p1 , p2. what query can used fetch record condition?it helpful if can provide rails query same.

jQuery preventDefault() is not working after each function -

i'm trying input form using each function. preventdefault not working after each function. $("#my-form").on('submit', function(e){ var masterarray = array(); var stringify = ''; $(".input-class").each(function(){ $id = $(this).attr('id'); $data = $(this).val(); $myarray = array(); if ($eamount == 0) { myarray = { scheme_code:$id, amount:0 }; }else{ myarray = { scheme_code:$id, amount:$data }; } masterarray.push(myarray); }); stringify = json.stringify(investmentarray); e.preventdefault(); )}; you should use e.preventdefault() after event binding $("#my-form").on('submit', function(e){ e.preventdefault(); // rest stuff });

understanding subroutines in perl -

sub bat { ($abc) = @_; @gcol ; { $rec = {}; $rec->{name} = "batid"; $rec->{type} = "varchar2"; $rec->{length} = "14"; $rec->{scale} = "0"; $rec->{label} = "id"; $rec->{ref_comment} = "shows bat type"; $rec->{ref_link} ="$appl_home/bat.cgioptions=status&options=mfgdate&options=details&options=refreshauto"; $rec->{ref_col} = [ ("bat_id") ]; $rec->{nullable} = "y"; $rec->{pk} = "n"; $rec->{print} = undef; $rec->{visible} = "yes"; push (@gcol, $rec); } } can explain subroutine being done in each line ? , hash used in or not? $rec= {};? happens using push? you ask explanation of happening on every line , don't think you've got yet. sub bat { # take first par

javascript - Map zooming with D3 and Datamaps -

i need help. i'm using datamaps , want implement zoom on country. can find loads of examples how can achieve this, difference is, want able external button. let's outside of <div id="worldmap"></div> map being rendered have button: <button data-location="aus"> . how able zoom using these values? know datamaps uses these short names (aus = australia) notate name. can provide long lat coordinates if way it. can me issue? i'm new d3 , datamaps. one way translate , scale region of choice using translate scale shown below. function gotoaustralia(){ map.svg.selectall(".datamaps-subunits").transition().duration(750).attr("transform", "scale(1.5)translate(-400,-100)"); } function gotosouthamerica(){ map.svg.selectall(".datamaps-subunits").transition().duration(750).attr("transform", "scale(1.5)translate(-50,-300)"); } function reset(){ map.svg.selectall(&qu

php - Function to revert mysql statement -

how can implement undo changes function in php application, if user example added new member group, or deleted item notification message appear: selected item have been deleted, undo delete action(link trigger undo function). the following working code: public function deleterecord($id) { $group = $this->query('set autocommit=0'); $group = $this->query('delete `members` memberid = '.$id.''); } public function undo_delete() { $member = $this->query('rollback'); if($member) { trigger_error('undo action has been completed. ', e_user_notice); return true; } } the problem code transaction has not been submitted, rollback or log out undo changes has been done during user session, not sure if best approach create redo function, suggestions? you not able undo 2 different requests .because when call undo . undo delete happened members . solve sugg

c++ - UDP server consumes all processor time in multithreaded program -

i'm developing client/server application. client , server run on 2 different machines running ubuntu 16.04. client sends 2 variables influence flow of server part, therefore, want decrease packet loss rate as possible. application thread-based. in 1 thread udp server running. project has gui implemented using qt. when tried implement udp server blocking, whole program , gui froze until packet received. , when packet received program didn't response. therefore, thought non-blocking udp best way it. managed make udp non-blocking using select() . comes problem. if set timeout of recvfrom 10ms , thread allowed run every 10ms, no packet lost but, apparently, udp thread consumes processor time program freezes. if increased interval of calling thread or reduced timeout interval, around 80% of packets lost. know udp connectionless protocol , tcp may better option, have use udp client side sends packets on udp. the question is: how can reduce packet loss rate without blockin

indexing - Best Postgresql index type to be used with not equal (<>) where condition -

i need query 2 identical huge tables (more milion records). besides other conditions, there not equal condition on columns pair of varchar type. is standard btree type index suitable or other index type more suitable not equal (<>) condition? why not try different indexes , let postgres tell effective explain command? unless data contains sort of rare edge case breaks indexing functionality, can test real , see actual results without having guess.

sql server - SQL Merge Replication Error-1 -

i'm facing problem in sql merge replication: error message: the merge process unable verify existence of generation @ 'publisher'. ÃŽf failure persists, reintilialize subscription. tcp provider: semaphore timeout period has expired. (source: mssqlserver, error number:121) communication link failure (source: mssqlserver: error number: 121) help: while i'm not in position reintialize subscription due production database environment.

recordrtc - Record WebRTC audio chunks -

i want record audio of webrtc call , have problems these 2 issues: the sample rate of audio should 16 khz. i want send small chunks (eg. 2s long) server. i'm using recordrtc library. when use stereoaudiorecorder can solve issue 1. because it's recording .wav , offers parameter change sample rate 16 khz. can't find way blob of recorder while i'm recording. my second approach use mediastreamrecorder . it's recording webm/opus sample rate of 48 khz , can't find way change this. mediastreamrecorder offers method getinternalrecorder().getarrayofblobs() blobs while recording. the solution doesn't have recordrtc . library , file format fine.

build system - libmod error in yocto krogoth 2.1.2 -

i compiling libmad in yocto-2.1.2 giving below error. nothing provides 'libmad'libmad skipped: because has restricted license not whitelisted in license_flags_whitelist how resove error. in advance. i'm compiling libmad python-pygame recipe in yocto(toaster). in libmad recipe, there's line license_flags = "commercial" which means might require commercial license (depending on jurisdiction etc. can case eg media encoders / decoders). if / when have solved issue (either obtaining commercial license, or deemed don't need one), should add: license_flags_whitelist += "commercial_libmad" in local.conf or in distro config.

datetime - Sql server update zero value existing date -

i have date value 2017-09-18 11:27:59.547 table. how can l update 2017-09-18 00:00:00.000 on records? can give me sql script? this should trick update table set field = cast(field date);

python - How to separate Flask-Admin (auth example) into different files with imports -

i tried separating codes sample flask-admin: https://github.com/flask-admin/flask-admin/blob/master/examples/auth/app.py however, becomes messy add more codes tried structure them i'm getting errors think because of circular dependencies. can run homepage , admin page, errors when tried sign in (e.g. admin:admin). __init__.py from flask import flask flask_sqlalchemy import sqlalchemy # create flask application app = flask(__name__) app.config.from_pyfile('config.py') db = sqlalchemy(app) headers = {'content-type': 'application/json'} myapp import app app. py import os flask import flask, url_for, request, render_template, json, jsonify flask_security import security, sqlalchemyuserdatastore flask_security.utils import hash_password import flask_admin, requests flask_admin import helpers admin_helpers myapp import app, db, headers myapp.models import user, role, mymodelview flask_script import manager flask_migrate import migrate, migratecom