Posts

c++ - How can you specify carriage return and newline character match when using boost::regex? -

i having problem boost::regex behaviour when comes matching \r , \n characters in string. communicating on serial port modem linux c++ application , receiving following message it ati3\r\nv3.244\r\nok\r\n i know string correct check ascii hex values of each character returned. problem application needs strip out version number specified vx.xyz part of string. end using following boost::regex based code: string str_modem_fw_version_number = ""; string str_regex("ati3\r\nv(\d+[.]\d+)\r\nok\r\n"); boost::regex patt; try { patt.assign(str_regex); boost::cmatch what; if (boost::regex_match(str_reply.c_str(), sc_what, patt)) { str_modem_fw_version_number = string(sc_what[1].first,sc_what[1].second); } } catch (const boost::regex_error& e) { cout << e.what() << endl; } the above not work - can see string correct sure making obvious error cr , nl characters in regex. have tried following not ...

c# - How can i check if the file size is larger then it was in the beginning? -

this code: private void timer2_tick(object sender, eventargs e) { timercount += 1; timercount.text = timespan.fromseconds(timercount).tostring(); timercount.visible = true; if (file.exists(path.combine(contentdirectory, "msinfo.nfo"))) { string filename = path.combine(contentdirectory, "msinfo.nfo"); fileinfo f = new fileinfo(filename); long s1 = f.length; if (f.length > s1) { timer2.enabled = false; timer1.enabled = true; } } } once file exist 1.5mb size after minutes file updating 23mb. want check if file larger before stop timer2 , start timer1. but line: if (f.length > s1) not logical since im doing time long s1 = f.length; how can check if file larger ? you can rely on global variable (like 1 using contentdirectory...

Passing a list of arguments to plot in R -

i use same arguments several calls plot . tried use list (which can serve dictionary) : a <- list(type="o",ylab="") plot(x,y, a) but not work : error in plot.xy(xy, type, ...) : invalid plot type any suggestion ? extending @baptiste's answer, can use do.call this: x <- 1:10 # data y <- 10:1 do.call("plot", list(x,y, type="o", ylab="")) or setting arguments in list , call a a <- list(x,y, type="o", ylab="") do.call(plot, a)

c# 4.0 - how to generate dynamic parametrized unit test cases for c# application in vs 2012 -

i explored pex , code digger generation of unit test cases exploring code found limitations in them .code digger requires portable class libraries whereas pex requires vs 2010 . need know there tool generate unit test cases automatically c# applications pex or better that can used vs 2012 . regards priya

c# - Check that VPN ports are open -

is there way check udp ports 500 , 4500 of vpn server responding ? goal check if firewall or blocking these ports. thanks in advance so, udp doesn't acks or connections tcp does; way sure port responding send data , response (there no requirement respond though). since these specific ports, assume there specific application/protocol looking at. need open port , either send garbage data or form of identification payload (depending on protocol). this previous question outlines need handle that.

emulation - ANDROID: How to show the system navigation bar in an emulator -

how can enable system navigationbar(the 1 including home/back/menu) on jellybean emulator? googling this, said can done changing property qemu.hw.mainkeys, can't find set constant. can me? i know old question. but, trick following: navigate .android/avd/virtual-device.avd , , change following values in following files: config.ini : hw.mainkeys=no, hw.keyboard=no hardware-quemu.ini : hw.mainkeys = no, hw.keyboard = no that should disable navigation bar on virtual device. note: enable use of keyboard, have set these parameters yes.

node.js - Catching HTTP response event -

i building node web application (using express) , keep dry possible, automatically acquire database connection each request need release (back pool). i manually in every route polluting code. figured should listen server events , release once response either finished generating or sending. options have? events (and inside object (app, request or whatever) triggered when response complete? res inherited eventemitter, , can use default events can emit own ones. 1 of common finish (in node.0.8.12 , older end ) event: res.on('finish', function() { // request processing finished }); you can attach event requests if want, or specific in roots. additionally can create middleware, db connection, , attach finish event , possibly timeouts. , need add middleware routes, minimum of repetitive coding. in mean time, recommend not create db connection each request, big overhead , unnecessary use of sockets io handlers. can freely use onse single connection, , effic...