Posts

Showing posts from January, 2011

android - Firebase onMessageReceived is triggering twice -

i scheduling notification launched when message received firebase service problem notification triggering twice(once on time , second time after maybe 30 min) here code: sharedpreferences = preferencemanager .getdefaultsharedpreferences(getapplicationcontext()); // check if message contains data payload. if (remotemessage.getdata().size() > 0) { intent myintent = new intent(myfirebasemessagingservice.this, myalarmservice.class); pendingintent = pendingintent.getservice(myfirebasemessagingservice.this, 0, myintent, 0); alarmmanager alarmmanager = (alarmmanager)getsystemservice(alarm_service); long currenttime = system.currenttimemillis(); int hour=sharedpreferences.getint("hour",9); int min=sharedpreferences.getint("min",0); calendar calendar = calendar.getinstance(); calendar.set(calendar.hour_of_day,hour); calendar.set(calendar.minute,min); alarmmanage...

How to send checkbox checked data using jquery and ajax to struts action class -

below jquery here how checkbox checked data in struts action class using jquery , ajax please tell me <script> $(document).ready(function() { $('#datatables-example').datatable({ responsive : true, "order":[], "columndefs": [ { "targets": 0, "orderable": false, "classname": "dt-center" }] }); $("#selectall").click(function() { $('.case').prop('checked', this.checked); if ($('.case').prop('checked', this.checked)) { count = this.checked ? $(".case").length : 0; smscount.innerhtml = count; } }); $(".case").click(function() { count = $(".case:checked").length; if ($(".case").length == $(".case:checked").length) { ...

protocol buffers - Reading a protobuf3 custom option from C# -

tl;dr according doc, if doing c++, read value of custom option using string value = mymessage::descriptor()->options().getextension(my_option); . there similar examples java , python. i'm doing c# , find equivalent. can it, , if yes, how? more details i'm manipulating classes generated protobuf3 . schemas declaring custom option . looks this: import "google/protobuf/descriptor.proto"; extend google.protobuf.messageoptions { string my_option = 51234; } message mymessage { option (my_option) = "hello world!"; } my code being provided object generated mymessage , , i'd read value of option (here hello world! ) update: i'm not using protobuf-net. c# natively supported protobuf, i'm using google's protobuf3 c# library. looks feature hasn't been implemented yet: https://github.com/google/protobuf/issues/1603 it looks it's matter of time , they're open pull requests. depending on how need it, 1 doing...

datetime - r: How to print a histogram of daytimes with times in Format e.g. 13:00 in ggvis -

Image
i have data.frame datetime objects, read in csv file , turned datetime objects dmy_hm() lubridate package. want print histogram distribution of times, independent of date. here example, looks pretty good: library(dplyr) library(ggvis) library(lubridate) # create example gespeichert <- c(rep("01/05/2016 15:26",times=10), rep("13/05/2016 00:17",times=5), rep("01/08/2016 12:05",times=10), rep("17/04/1983 23:39",times=5), rep("06/07/2015 09:36",times=10)) info <- c(rep("bla",times=30),rep("bla bla",times=10)) df_time <- cbind.data.frame(gespeichert,info,stringsasfactors=false) df_time %>% mutate(gespeichert = dmy_hm(gespeichert)) -> df_time # trying reduce datetime object time df_time %>% mutate(uhrz_num = hour(gespeichert) * 60 + minute(gespeichert)) %>% # time in minute numbers, not necessary mutate(gesp_...

java - HttpsUrlConnection. setInstanceFollowRedirects(false) seems not effective -

everybody.i'm using web crawler query user's integral in web sites.but trouble.first of ,let's focus on picture: enter image description here as can see,the first request ,it's response code 302,that page redirected page.now ,look @ code,the login method: private juneyresults login(string url, string param) { juneyresults results = new juneyresults(); httpsurlconnection connection = null; int contentlength = param.getbytes().length; try { url requested = new url(url); connection = (httpsurlconnection) requested.openconnection(); connection.setinstancefollowredirects(false); connection.setdooutput(true); connection.setrequestmethod("post"); connection.setrequestproperty("user-agent", ua); connection.setrequestproperty("content-type", "application/x-www-form-urlencoded"); connection.setrequestproperty("cookie", map2string(mcookies)); ...

python - How to get Disk type information from VMware using pyvmomi? -

i have disktype information using python pyvmomi library, able same through c# vmware sdk via "get-vm | get-harddisk -disktype "flat" | select parent,name,disktype,scsicanonicalname,devicename,diskmode | fl" command, output disk in vsphere/esx flat disktype. in respective command, have searched "flat" disktype can "rawphysical, rawvirtual, or unknown" . have gone through vmware mob properties wasn't able search disktype property. thanks

sql server - Package error after adding web reference to script component in SSIS -

Image
i'm following instructions find online try generating ssrs reports via ssis package. but whenever add ssrs report web services reference, pack throw me package validation error. something "microsoft.sqlserver.dts.pipeline.cannotcreateusercomponentexception: cannot create user component class. make sure there 1 class marked ssisscriptcomponententrypointattribute in script." any idea?

How to retain soft keyboard state after invalidateOptionsMenu android -

hi have used searchview below, @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { super.oncreateoptionsmenu(menu, inflater); menu.clear(); inflater.inflate(r.menu.all_menu, menu); searchmanager manager = (searchmanager) getactivity().getsystemservice(context.search_service); searchview searchview = (searchview) menu.finditem(r.id.menu_search).getactionview(); searchview.setsearchableinfo(manager.getsearchableinfo(getactivity().getcomponentname())); searchtextview = (autocompletetextview) searchview.findviewbyid(android.support.v7.appcompat.r.id.search_src_text); try { field mcursordrawableres = textview.class.getdeclaredfield("mcursordrawableres"); mcursordrawableres.setaccessible(true); mcursordrawableres.set(searchtextview, r.drawable.cursor); //this sets cursor resource id 0 or @null make visible on white background } catch (excep...

c++ - My OCX file is not regisrter on other system except mine -

Image
i made ocx file (mfc active x c++) guide: link simple ocx add tow numbers , show result. build in release mood , platforms(x86 , x64). when wrote: regsvr32 d:\mathocx.ocx , registering on pc . guide website has simple html file work mathocx , not worked me. when copy ocx system shows error : when searched in google, 1 said should use c:\windows\syswow64\regsvr32 register ocx, error occurred again, 1 said should install dependencywalker.exe check dll not near file. download , put dll near ocx file. not changed , error shows again. can now? i used visual studio 2013. have 64b os.

javascript api restful name functions, good practices -

i need advise name functions inside service calls restful api (i know there not standards); let's see how used in 2 ways on angular.io site: on tutorial , http section : https://angular.io/docs/ts/latest/guide/server-communication.html save () delete () put () post () on developper guide http, hero.services.ts : https://angular.io/docs/ts/latest/guide/server-communication.html#!#http- client getheroes () addhero () search() in file: search.services.ts on tutorial on web: http://offering.solutions/articles/angular/consuming-a-rest-api-with-angular-2-http-service-in-typescript/ getall getsingle add update delete (i don't not camelcase ) names clear my question is: a. when functions's name have no object's name , addhero (), use simple add () on service , component consumed ? b. search service can joined on same file service? c. there advise api restful?

angularjs - Json Object in ng-repeat -

response object like $scope.list= [ object { cid=74, date="2016-08-25t00:00:00.000+0530", optkey="key", optvalue="{ value:{ 'name':test, 'gender':male } }" }, object { cid=75, date="2016-08-25t00:00:00.000+0530", optkey="key", optvalue="{ value:{ 'name':test2, 'gender':female } }" }}, object { cid=77, date="2016-08-26t00:00:00.000+0530", optkey="key", optvalue="{ value:{ 'name':test1, 'gender':female } }" }] and in html page used ng-repeat <div ng-repeat="item in list"> {{item.date}} -- works fine </div> here how display json value in object optvalue, done code like. <div ng-repeat="item in list"> {{item.optvalue.value}} -- undefined </div> but not working can 1 give hint this just because optvalue...

sql - How to calculate the percentage in Mysql? -

i have table laborder column account, orderno, createddate, table 1 account contains multiple orderno. requirement want fetch records particular account based on createddate of comparing current week 1 previous week. let's suppose account created 100 orders in previous week , created orders in current week 50 want notify particular account current week order less or equal previous week orders. our business requirement send email particular account current week order count less 50% previous week orders. have notify account. calculate difference current week orders count or previous week orders ? how achieve requirement 1 better fetch records. using simple query create view create stored procedure i have following table data : table name : laborder account orderno createddate -------------------------------------- 101 13 2016-08-2 102 56 2016-08-9 103 79 2016-08-24 i want data below. store...

java - Jenkins Octopus Integration -

i using jenkins ci tool , using octopus deploy java application. when surfed, solutions deploy .net application using octopack. how pack java application , automatically deploy octopus server jenkins instance? you can pack nuget (with nuget pack command, documented here ). that's octopack does. create .nuspec file, , in <files> section, include files want empty target. example, include files in package: ... <files> <file src="path/to/output/**" target="" /> </files> ... you can push octopus deploy system using nuget push . instructions on octopus deploy package library page.

vb.net - DataGridView, Change cell of a typed Column to another type -

i'm trying mix column on datagridview 2 control types (checkbox & textbox), data coming stored procedure i'm writing have little flexability. in stored procedure i'm returning blank column act 'selection' column in gridview, encountering problems when trying convert cells other type based on criteria...... i keep problem datatypes when converting between control types, have tried alsort of diferent ways convert value first, controls first, etc etc nothing working 100%..... currently have sp returning string 'false' in column in using criteria create checkbox..... works fine value remains sstring after converting boolean, datatype boolean on checkbox value 'string'..... has gone on head , i'm @ loss...... newcntrl2 = new datagridviewcheckboxcell newcntrl2.value = convert.toboolean(dgv.cells(0).value) newcntrl2.valuetype = gettype(system.boolean) dgv.cells(0) = newcntrl2 this code converting textboxcolumncell checkbox cell any i...

angular - QuillJS editor loads correctly, but fails to find CSS files during pasting -

Image
i have angular2 (rc5) , primeng (beta 13) app uses primeng editor component (p-editor) based on quilljs editor (v1.0.0-rc.2). project based on angular 2 seed project. the page editor component loads fine, , able basic text editing. however, when try paste text editor, chrome dev tools reports number 404 errors: the strange thing if hover on clipboard.js:122 link in dev tools, address show webpack:///./modules/clipboard.js don't believe using webpack. here tools/config/project.config.ts file import { join } 'path'; import { seedconfig } './seed.config'; /** * class extends basic seed configuration, allowing project specific overrides. few examples can found * below. */ export class projectconfig extends seedconfig { project_tasks_dir = join(process.cwd(), this.tools_dir, 'tasks', 'project'); fonts_dest = `${this.app_dest}/fonts`; fonts_src = [ 'node_modules/font-awesome/fonts/**' ]; constructor() { s...

Regex group is matching quotes when I don't want it to -

Image
i have regular expression: "([^"\\]|\\.)*"|(\s+) debuggex demo but problem is, when have input "foo" , use matcher go through groups, first group finds "foo" when want foo . doing wrong? edit: i'm using java , fixed it "((?:[^"\\]|\\.)*)"|(\s+) debuggex demo the first capturing group wasn't including * whole string. enclosed within capturing group , made inner existing 1 non capturing group. edit: no... it's working in online regex debuggers not in program... capture contents of double quoted literal pattern (branch 1) , if matched grab it. also, consider unrolling pattern:  "([^"\\]*(?:\\.[^\\"]*)*)"|(\s+) in java: string pat = "\"([^\"\\\\]*(?:\\\\.[^\\\\\"]*)*)\"|(\\s+)"; note patterns (a|b)* cause stack overflow issue in java, that's why unrolled version preferable.

angularjs - Side Menu issue in ionic -

in ionic menu, if click page menu list, side menu appears. on button click if load page side menu not appear untill refresh i face same type of problem,i think you. i forgot use option enable-menu-with-back-views="true" on <ion-side-menus>

javascript - Iterating through all selected checkboxes and get the value of input boxes in jquery -

this question has answer here: best way selected checkboxes values in jquery [duplicate] 1 answer i have code whereby in table row there checkboxes , input boxes, values of input boxes checkboxes checked this html <table> <tr> <td><input type="checkbox" name="new" value="37"></td> <td><input type="text" name="new" id="quantity" class="37"></td> </tr> <tr> <td><input type="checkbox" name="new" value="38"></td> <td><input type="text" name="new" id="quantity" class="38"></td> </tr> .....#this continue </table> note class of input boxes same value of checkboxes currently using code check checked checkboxes ...

Codeigniter Dompdf : Call to a member function isHtml5ParserEnabled() on null -

i placed 'dompdf' @ '/system/libraries/', , create class file 'dompdf.php' @ same dir, code below: <?php defined('basepath') or exit('no direct script access allowed'); require_once("dompdf/autoload.inc.php"); use dompdf\dompdf; use dompdf\options; class ci_dompdf extends dompdf { /** * set template table config file if exists * * @param array $config (default: array()) * @return void */ public function __construct($config = array()) { log_message('info', 'dompdf class initialized'); } } below part of controller function using dompdf library: public function pdf_create($html, $filename='', $stream=true){ $this->load->library('dompdf','dompdf'); $this->dompdf->load_html($html); $this->dompdf->render(); if ($stream) { $this->dompdf->stream($filename.".pdf"); } else { ...

javascript - I want to make the icon spin back when click on outside -

this code used spin arrow head upward direction on click on icon .i want spin when click on out side of icon , want repeat processes when click on icon , click outside of icon. <html> <head> <link rel="stylesheet" type="text/css" href="troll.css"> <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="../project/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" href="../project/style.css" /> <link rel="stylesheet" type="text/css" href="../project/font-awesome-4.2.0/css/font-awesome.min.css" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> function rotate(){ document.g...

cron - cronjob not executed on docker swarm deployment -

i using docker swarm control deployment several containers used machine learning application. i have bash script sends commands executed containers. when execute script manually in console, works fine, commands sent containers , run when added same script executed cron, doesn't work (i using crontab -e command script executed user) here's 1 example of scripts need run: eval $(docker-machine env --swarm director) docker exec -d container_luigi-worker_1 luigi --module etl alltasks and cron line is: 16 * * * * sh /path/script.sh as using swarm, first need env of director, execute command using docker exec (in case command start job using spotify's luigi tool) what missing? thanks

android - Large screen scale genymotion -

Image
i'm facing annoying bug oracle virtual machine , genymotion. yesterday, strange scale in amulator started happen. does know how fix it? in desktop works fine.

c - Compile and link a source file containing object files to another data structure -

this current makefile: cc=gcc include=./structures/ cflags=-wall -i$(include) objs=rlmain.o rlist.o queue.o .phony: clean all: rlmain queue.o: $(include)queue.c $(include)queue.h $(cc) $(cflags) -c $(include)queue.c -o queue.o rlist.o: $(include)rlist.c $(include)rlist.h $(cc) $(cflags) -c $(include)rlist.c -o rlist.o rlmain: main.c rlist.o queue.o $(cc) $(cflags) main.c rlist.o queue.o -o rlmain clean: rm -f *.o rlmain makefile in top directory. in lower directory called "structures" collection of files data structures. data structures implement ready list - linked list of queues. i managed queue.o working using '-c' cannot rlist.o make because rlist.c not contain main method, , must link queue.o functions. i'm using command make everything else working except command. want write command tell compiler link queue.o functions rlist.c compilation not compile functions require main(). do in order make happen? ...

How do I check if my dates have a certain year, after retrieving all dates via php? -

i retrieving date in php query: date_format(items.r_date, '%m %d, %y') r_date and displaying this, example: january 1st, 1934 however, if year 1111, make date custom. such (i know isn't real code, trying explain want do: if ($row['r_date'] contains '*1111*') { $r_date = "my custom message"; } else $r_date = $row['r_date']; could me solve this? thank time. a literal implementation of pseudo-code uses strpos : if (false !== strpos($row['r_date'], '1111')) { $r_date = "my custom message"; } else { $r_date = $row['r_date']; } however, "only check last 4 digits" answer dagon , or alternate 1 below using substr_compare , may yield fewer false positives: if (0 === substr_compare(rtrim($row['r_date']), '1111')) $r_date = "my custom message"; } else { $r_date = $row['r_date']; } note i've used trim here in event d...

mysql - How to set global and session mode in my.cnf -

following thread , have set global , session followings when restart mysql, how can set in my.cnf? mysql> set global sql_mode='strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution'; mysql> set session sql_mode='strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution'; mysql> exit; from mysql docs : [mysqld] sql_mode = strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution

python 2.7 - tensorflow group or collect fetches ops or tensors into single fetch -

i general case tf.merge_all_summaries tf.get_collection('summaries'). as example, find tf.contrib.metrics.streaming* suite introduces set of "update_op" operations must run once each. find following syntax cumbersome, _,_,_,_,_,summary,_=sess.run( tf.get_collection('updates')+[merged_summaries]+[train_op]) and looking workaround not require knowing number of updates in collection. using tensorflow-0.10 of writing. tensorflow supports (since version 0.10) passing nested structures session.run() . example, can pass list of lists of tf.tensor objects session.run() , result similarly-nested list of lists of numpy arrays. can pass mixed list (or tuple) containing lists, tensors, , operations. in case, write following: updates = tf.get_collection('updates') _, summary, _ = sess.run([updates, merged_summaries, train_op]) in case, return value sess.run() list 3 elements, first (ignored) element list same length updates .

oauth 2.0 - Make the User.Identity include the email address from the access token payload -

Image
we using oauth via introspection validate access tokens. app.useoauthintrospection(options => { options.automaticauthenticate = true; options.automaticchallenge = true; options.authority = "http://localhost:12345/"; options.audiences.add("resourceserver01"); options.clientid = "resourceserver01"; options.clientsecret = "secret_secret_secret"; }); this works, mostly. the authorization server response @ connect/introspect good. { "active": true, "iss": "http://localhost:12345/", "sub": "797264b3-194c-483f-08fb-08d3cbab9158", "scope": "openid email roles", "iat": 1471998289, "nbf": 1471998289, "exp": 1472000089, "jti": "274cbb7f-9412-4d69-8c02-ca6a500b4a36", "token_type": "bearer", "aud": [ "resourceserver01", "resources...

javascript - react function not being called -

i rendering react class using node js so... var express = require('express'); var router = express.router(); var react = require('react'); var reactdom = require('react-dom/server'); var app = react.createfactory(require('../components/index')); router.get('/', function(req,res) { var reacthtml = reactdom.rendertostring(app({})); res.render('../../tutorhub/views/index.jade', {reactoutput: reacthtml}); }); module.exports = router; the page gets rendered fine, no function add gets called. example, in app class... class app extends react.component { constructor(props) { super(props); } getclass() { return "a_class"; } render() { return ( <div classname={this.getclass}></div> ); } } module.exports = app; the getclass function not called. instead classname becomes code class = getclass() { return "a_class"; } ...

sql - How to find dependent materialized query table -

is there simple way find out materialized query tables use table mytable. as not alter table because base table materialized query table. this queried via system catalog this: select tabschema, tabname syscat.tabdep dtype = 's' , bschema = 'db2inst1' , bname = 'employee' more details columns can found here .

unit testing - httptest.ResponseRecorder has no field or method Result -

so 1 weird, i'm trying mock response renders json. test looks this: import ( "fmt" "net/http" "net/http/httptest" "reflect" "strings" "testing" ) ... func testmessagefromresponse(t *testing.t) { mc := mycontroller{} body := "{ \"message\":\"kthxbai\" }" w := httptest.newrecorder() w.write([]byte(body)) resp := w.result() msg := mc.messagefromresponse(resp) if msg != "kthxbai" { t.errorf("expected response body kthxbai %s", msg) } } i'm testing method messagefromresponse on mycontroller but not building. when run go test in project directory, following error: ./my_controller_test.go:115: w.result undefined (type *httptest.responserecorder has no field or method result) i should mention using httptest.responserecorder writer stub elsewhere in same file, it's failing when try access result(...

bash - Count multiple occurrences of some text for each file under a directory -

i trying count multiple occurrences of text each file under directory. following script close want not count multiple occurrences on same line: grep -rc 'blah' /some/path --include \*.txt for example given 2 files: foo.txt blah, hey blah more text bar.txt blah the above script produces: foo.txt:1 bar.txt:1 but output looking is*: foo.txt:2 bar.txt:1 i know total number of occurrences can found in 1 file using grep , piping results word count: grep -oh 'blah' foo.txt|wc -l how multiple files achieve output in example* above? update the best solution come follows: find /some/path -name '*.txt'|awk '{print "echo -n '\''" $0 "\: '\'' && grep -oh '\''blah'\'' " $0 "|wc -l"}'|bash grep -o prints each match on new line - count em up dir=$1 grep -hor --include '*.txt' 'blah' $dir| uniq -c| # output after uniq # ...

python 3.x - sqlalchemy insert - string argument without an encoding -

the code below worked when using python 2.7, raises statementerror when using python 3.5. haven't found explanation online yet. why doesn't sqlalchemy accept simple python 3 string objects in situation? there better way insert rows table? from sqlalchemy import table, metadata, create_engine import json def add_site(site_id): engine = create_engine('mysql+pymysql://root:password@localhost/database_name', encoding='utf8', convert_unicode=true) metadata = metadata() conn = engine.connect() table_name = table('table_name', metadata, autoload=true, autoload_with=engine) site_name = 'buffalo, ny' p_profile = {"0": 300, "1": 500, "2": 100} conn.execute(table_name.insert().values(updated=true, site_name=site_name, site_id=site_id, p_profile=json.dumps(p_profile))) add_site(1...

Can I read a CSV represented as a string into Apache Spark using spark-csv -

i know how read csv file spark using spark-csv ( https://github.com/databricks/spark-csv ), have csv file represented string , convert string directly dataframe. possible? actually can, though it's using library internals , not advertised. create , use own csvparser instance. example works me on spark 1.6.0 , spark-csv_2.10-1.4.0 below import com.databricks.spark.csv.csvparser val csvdata = """ |userid,organizationid,userfirstname,usermiddlename,userlastname,usertitle |1,1,user1,m1,l1,mr |2,2,user2,m2,l2,mr |3,3,user3,m3,l3,mr |""".stripmargin val rdd = sc.parallelize(csvdata.lines.tolist) val csvparser = new csvparser() .withuseheader(true) .withinferschema(true) val csvdataframe: dataframe = csvparser.csvrdd(sqlcontext, rdd)

python - How do you serve a dynamically downloaded image to a browser using flask? -

i'm working ip camera. can use url such 1 grab static image off camera: http://username:password@ip_of_camera:port/streaming/channels/1/picture what want have python/flask download image url when client loads page, , embed image page using img tag. if have template looks this: <html> <head> <title>test</title> </head> <body> <img src="{{ image }}"> </body> </html> how replace {{ image }} downloaded image? would use urllib/requests download image flask's static folder, replace {{ image }} {{ url_for('static', filename="temp_image.png") }} , , delete image static folder when page loads? download someplace else instead (other static folder)? or there other way keeps image in memory? ps. know it's possible replace {{ image }} url directly, reveals username/password/ip/port of camera client. i add masking route on flask fetches , serves ima...

java - Game with server and multiple client, make sure only one game object is created -

i'm trying write poker server , client program, create game in server class , client class takes output , displays them. however, when ever this, there seem 2 game objects created, first player gets input consistent object shown in console, second player displays cards not shown in sysout method, , can not seem find created second game object. server class: import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.io.printwriter; import java.net.inetaddress; import java.net.serversocket; import java.net.socket; import java.net.unknownhostexception; import java.util.arraylist; import java.util.hashset; public class pokerserver { /** * port server listens on. */ private static final int port = 9050; // keeps track of names private static arraylist<string> names = new arraylist<string>(); // broadcast messages private static arraylist<printwriter> writers = new arraylist<printwriter>(); private boolea...

asp.net - Trying to get SELECT SCOPE_IDENTITY() as c# variable -

i inserting row 1 table want new id can add in variable have email address stored. var db = database.open("mydb"); var insertcommand1 = "insert mydb (firstname, lastname) values(@0, @1)"; db.execute(insertcommand1, first, last); var lastinsertedid = db.queryvalue("select scope_identity()"); var insertcommand2 = "insert email (id_person, email) values(@0, @1)"; db.execute(insertcommand2, lastinsertid, email); where id_person id created in first table. when run code lastinsertedid = {}. reason why not grabbing value id_person primary key, int , not null first table? --tim from the documentation of scope_identity() , emphasis mine: returns last identity value inserted identity column in same scope. scope module: stored procedure, trigger, function, or batch. therefore, 2 statements in same scope if in same stored procedure, function, or batch . because using 2 queries considered 2 batches. need ...

c++ - "Assert and return" macro in Google Test? -

is there assert_and_return macro in google test test something, , if it's false, raises assertion , returns value? actually every assert_xxx returns function - not return value - assumed function (in cases functions created testxx macros) void function. this issue when use assert_xxx within function called function. check if function failed on assert - need use assert_no_fatal_failure see example void assertnotnull(int *p) { assert_that(p, notnull(p)); } void assertsizeis(int actual, int expected) { assert_eq(actual, expected); } test(a, b) { std::pair<int*,int> p = createarray(7); assert_no_fatal_failure(assertnotnull(p.first)); assert_no_fatal_failure(assertsizeis(p.second, 7)); for( int = 0; < 7; ++i) assert_eq(0, p.first[i]); }

mysql - Returning additional lines of data based on a where clause in a union query -

i have single table of sales information. sale can credited 2 sales people causing value of .5 when happens need have half sale reported in 2 places. report this salesman salesman 2 unit no unit cnt. date ==================================================== dave s. n/a htu88 1 8/2/16 dave s. phil n. nc88y .5 8/5/16 total sales.....................: 1.5 phil n. n/a jki98u 1 8/1/16 phil n. n/a ji98u1 1 8/3/16 phil n. dave s. nc88y .5 8/5/16 total sales.....................: 2.5 store total.....................: 4.0

javascript - TypeError while trying to connect to mongoDB using meteor.js -

i have new meteor project, every time execute meteor mongo following: c:\users\edtho\appdata\local\.meteor\packages\meteor-tool\1.4.1\mt-os.windows.x86_32\dev_bundle\lib\node_modules\meteor-promise\promise_server.js:165 throw error; ^ typeerror: port should number or string: null @ lookupandconnect (net.js:942:13) @ socket.connect (net.js:921:5) @ object.exports.conn...

php/mysql remove part of string and echo -

i've got simple set of strings: abc_def abc_1_def i'm trying remove 1_ second string. 1 may character a-z0-9. suggestions or assistance? something php: function sup($string){ $string = explode("_", $string); return count($string) > 2 ? $string[0]."_".$string[2] : $string; } or function sup($string){ return preg_replace("/_.+_/", "_", $string); }

opencv - Homography from 3D plane to plane parallel to image plane -

i have image in there calibration target (known geometry) in scene (let's simple 2" x 2" square lying on table). perform perspective transformation (using warpperspective() ) resulting image orthogonal view of table (as if camera axis parallel table normal). standard procedure computing homography general plane different general plane @ least 4 correspondences known in 2 images of same scene (using getperspectivetransform() ). in case have 1 image, correct thing "make up" plane , force correspondences arbitrary position on plane? example, in this situation make correspondences between 4 detected corners (a,b,c,d) in image , 4 points of choosing (which define pixel->real world scale. example, choose a' = (0,0), b' = (20,20), c' = (0,20), d' = (20,0) indicate in resulting image there 10 pixels per inch. of course choose scale here, , choose position square target land in output (i.e. a' = (100,100), b' = (120,120), c' = (100,120)...

jquery - Creating n number of buttons (or variable number of buttons) in JavaScript -

i new javascript , having difficulty task. writing code paginate table have. right logic related buttons hard coded , want make more dynamic. meaning, have 5 buttons have separate code same thing , want refactor code have n buttons , 1 script controls them. i want code generate (total records/number of records per page) number of buttons, want take value of button , pass existing code grab right section of data table. how do though? of documentation i've found jquery libraries datatables (which spent hour working , did not display anything). i appreciate tips, tricks, or tutorials. edit $(document).ready(function () { $('#b1').click(function () { var data = $("#isgeo").serializearray(); data.push({ name: "page", value: '1' }) $.ajax({ type: 'get', url: '@url.action("gettable", "subsidencepoints")', data...

Empty file when reading contents - Google Drive API Android -

i´ve read lot google drive api android in last 5 days , didn't find single piece of information use project. i´ve decided come here, hoping of brillant guys me out. i using android studio 2.1.3 , play-services:9.4.0 , i'm able upload .txt file root folder on google drive without problems. however, when try file content copy .txt, final file turns out empty. tried verify, after query, file's size on metadata buffer , it's empty too. don´t know else do. follow code: googleapiclient: api = new googleapiclient.builder(this) .addapi(drive.api) .addscope(drive.scope_appfolder) .addscope(drive.scope_file) .addconnectioncallbacks(this) .addonconnectionfailedlistener(this) .build(); api.connect(); function create files: public void createfiles() { sendfolder = new file(environment.getexternalstoragedirectory(), "sendtest"); receivefolder = new file(environment.getexternal...

c# - My program is not updating mongo db -

i new in mvc. doing program edits existing records in mongodb. program not updating record. this edit method: [httppost] public async task<actionresult> edit(biocardmodel model) { await _biocardservices.updatebiocard( model.cardid ,model); return redirecttoaction("index"); } this method updates record in mongo db public async task updatebiocard(guid value, [frombody]biocardmodel card) { var db = connecttomongo(); var collection = db.getcollection<biocardmodel>(_collection); var filter = builders<biocardmodel>.filter.eq("cardid", value); var update = builders<biocardmodel>.update .set(b => b.name, card.name) .set(b => b.firstname, card.firstname) .set(b => b.lastname, card.lastname) .set(b => b.title, card.title) .set(b => b.lifespan, card.lifespan) .set(b => b.bio, card.bio) .set(b => b.bio, card.anecdote) .set(b =>...

sockets - Python program terminating unexpectedly -

i have program scrapes website , downloads files when finds it. runs fine @ other times flat out terminates operation of program before finishing searching sequence. i'm stumped. never quits while downloading while searching. i'm guessing socket error problem said above i'm stumped. i've put in httperror checking , nothing gets displayed http error code. i'm trying right insert socket error checking , gets crazier. prior adding socket error checking works fine. once add in socket error checking program won't run. brings idle display , shows cursor, idle ready , waiting next command. otherwise without socket error checking indicates program running until either tkinter window shuts down(err program terminates unexpectedly). if tkinter window shuts downs doesn't give error on idle. what have find out why program terminating @ times , able trap out won't terminate , go , rerun same web address again. think have rerunning same web address t...