Posts

Featured post

javascript - Microsoft Bot Framework - how to send responses from a 3rd party API -

using microsoft bot framework, how can proxy api between incoming , outgoing bot messages? i've replaced: server.post('/api/messages', connector.listen()); with own implementation takes req.body.text , sends separate endpoint. how can send endpoints response chat? server.post('/api/messages', (req, res, next) => { request.post('endpoint', { json: {"text": req.body.text}, }, (error, response, body) => { // how send body outgoing chat message? }) }) update: to point out why ezequiel jadib's answer won't work, i've added complete code. req not defined within bot's callback function. const restify = require('restify') const builder = require('botbuilder') const request = require('request') // setup restify server const server = restify.createserver() server.use(restify.plugins.bodyparser()) server.listen(process.env.port || process.env.port || 3978, function () { cons...

java - Mock final method in inner class with PowerMockito -

i'm having trouble stubbing final method, used inside of class i'm trying test. problematic line in test class here: powermockito.when(connectionmock.authuser("fake-user", "fake-password")).thenreturn("random string"); which throws nullpointerexception. test class looks this: @runwith(powermockrunner.class) @preparefortest({myclass.class, apiclientconnection.class}) public class myclasstest { @test public void apiconnect() throws exception { myclass c = new myclass(); apiclientconnection connectionmock = powermockito.mock(apiclientconnection.class); powermockito.whennew(apiclientconnection.class).withanyarguments().thenreturn(connectionmock); powermockito.when(connectionmock.authuser("fake-user", "fake-password")).thenreturn("random string"); c.apiconnect("fake-host", 80, "fake-user", "fake-password"); } } the class i'm ...

c++ - Output is either 6.9531e-308 or 0 (noob) -

i'm trying write program give cost of phone call based on when starts/ends , how long takes. works fine, except when tries display cost of each call , total cost @ end. every cost listed $6.9531e-308. similar issue resolved issue initializing variable in question 0 when program starts listing every cost $0. the way i'm calculating total doesn't seem working either, since when cost $6.9531e-308, total comes out $7.64841e-307 instead of $4.17186e-307. it's either multiplying 1 of costs 11 or thinks there's 11 costs need added up. here code: #include <fstream> #include <sstream> #include <iostream> #include <iomanip> #include <string> #include <cstring> using namespace std; ifstream fin("call_history.txt"); //read file //int main int main() { string temp; double total = 0.0; while (getline(fin, temp)) { istringstream s(temp); string token[3]; int = 0; while(getl...

asp.net mvc - how to pass 'true'/'false' data from Controller to View using jquery for bootstrap validator in MVC -

view $('#frmcreatenewadminpanelmenu').bootstrapvalidator({ message: '.......', feedbackicons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { txtmenuname_create: { validators: { notempty: { message: '......' }, stringlength: { min: 6, max: 100, message: '.......' }, remote: { type: 'post', url: '/adminpanelmenu/menunameremote', ...

graph - Recursive self-join in HANA SQLSCRIPT procedure -

according academical literature http://pi3.informatik.uni-mannheim.de/~norman/hana_sqlscript_btw2013.pdf hana support recursive calls on hierarchical tree following: create procedure browse_set_top_bt (in depth integer, in currdepth integer, in current tt_from_to, out hull tt_from_to) language sqlscript reads sql data begin relevant = select frm , customerconnections weight >= 2; temp = select c.frm , r.to :current c, :relevant r c.to = r.frm ; currdepth = currdepth + 1; if( currdepth < depth ) call browse_set_top_bt ( depth, currdepth, temp, temp2 ) hull = :temp union :temp2; else hull = :temp; end; end; any further support in eventual manner browse parent-child tree in recursive self-join way welcome. sorry, mistook academic test implementation of query processing feature part of delivered standard product functionality. sap hana not support recursive queries described in paper. what support graph-oriented queries (maybe suitable use case here) , ...

c++ - Application of socket() from sys/socket.h -

i'm writing program in c++ establish communication dlp lightcrafter (texas instruments) without provided gui, , i've used these instructions establish connection: #include <stdlib.h> #include <string.h> #include <iostream> /* cout */ #include <sys/types.h> #include <netinet/in.h> #include <sys/socket.h> /* socket struct */ #include <arpa/inet.h> /* ip, etc */ #include <unistd.h> /* read() write() socket */ #include <cstdint> #include "pkt.h" /* calcchecksum() */ using namespace std; /* packet format * ------------------------------------------------------------------------------------ * | header | data | checksum | * ------------------------------------------------------------------------------------ * | byte 0 | byte 1 | byte 2 | byte 3 | byte 4 | byte 5 | byte 6...byte n | byte n+1 | * ------------------------------------------------------------...

google cloud dataflow - How can I improve performance of TextIO or AvroIO when reading a very large number of files? -

textio.read() , avroio.read() (as other beam io's) default don't perform in current apache beam runners when reading filepattern expands large number of files - example, 1m files. how can read such large number of files efficiently? when know in advance filepattern being read textio or avroio going expand large number of files, can use recently added feature .withhintmatchesmanyfiles() , implemented on textio , avroio . for example: pcollection<string> lines = p.apply(textio.read() .from("gs://some-bucket/many/files/*") .withhintmatchesmanyfiles()); using hint causes transforms execute in way optimized reading large number of files: number of files can read in case practically unlimited, , pipeline run faster, cheaper , more reliably without hint. however, may perform worse without hint if filepattern matches small number of files (for example, few dozen or few hundred files). under hood, hint causes transforms execute via ...