Posts

c++ - Strange behavior when static casting from a big double to an integer -

here 's simple code: int main() { double d1 = 10000000000.0; const double d2 = 10000000000.0; cout << static_cast<int>(d1) << endl; cout << static_cast<int>(d2) << endl; cout << static_cast<int>(10000000000.0) << endl; } the output is: -2147483648 2147483647 2147483647 this surprised me grealy. why positive double casted negative int? i'm using g++ : gcc version 4.4.3 (ubuntu 4.4.3-4ubuntu5). casting double int when int isn't big enough hold value yields undefined behaviour . [n3290: 4.9/1]: prvalue of floating point type can converted prvalue of integer type. conversion truncates; is, fractional part discarded. the behavior undefined if truncated value cannot represented in destination type. this behaviour derived c: [c99: 6.3.1.4/1]: when finite value of real floating type converted integer type other _bool , fractional part discarded (i.e., value truncated ...

jquery - How to click on a primary key and have that data sent to another page? -

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#stuff").on("click",function(){ //var thing=$(this).text("td:first"); var tag=$(this).find("td:first").html(); var thing=$("tag").text(); alert(thing); //var thing=$(this).parent().siblings(":first").text(); window.location.href='thing.jsp?thing=' + thing; }); }); </script> <form action="relay" method="get"> <table border="2" id="stuff"> <tr> <td>id</td> <td>lion</td> <td>tiger</td> <td>libra</td> <td>ox</td> ...

Why are some datetime values being deleted when I round the time in R? -

i importing series of csv files r. these contain date/time column, id, , 2 columns of temperature values. this give example of data looks like: id<-c(1,2,3,4) date.time<-as.character(c("12/03/17 00:21:28", "12/03/17 02:21:28", "12/03/17 04:21:28", "12/03/17 06:21:28")) temp1<-c(-3.568,-3.568,-3.598,-3.598) temp2<-c(-11.577,-11.577,-11.541,-11.433) df<-data.frame(id,date.time,temp1,temp2) because date/time not in format want, i've been using strptime , formatting them posixlt. like: df$date.time<-strptime(df$date.time, "%d/%m/%y %h:%m:%s") df$date.time<- as.posixlt(df$date.time, "%y/%m/%d %h:%m:%s", tz="gmt0") this works fine , gives data looks like: id date.time temp1 temp2 1 2017-03-12 0:21:28 -3.568 -11.577 2 2017-03-12 2:21:28 -3.568 -11.577 3 2017-03-12 4:21:28 -3.598 -11.541 4 2017-03-12 6:21:28 -3.598 -11.433 however, want round time par...

jquery - Place Sub-Div in New Parent for Mobile/Narrow Width, 3-Col Bootstrap Otherwise -

jsfiddle: https://jsfiddle.net/lukeu3f8/4/ i have 3-column boostrap layout. selecting in col 1 activates 2, 2 activates 3 (like step-by-step wizard). the issue when browser resized (and in mobile) columns 2 , 3 wrap around column 1 @ bottom . can see if resize jsfiddle window. initially when page opened, no big deal because no selection has been made. it's ok show 1,2,3 sequentially in single column. once col 1 menu selected, in mobile (or desktop if $(window).width() < 1000 in experience) col 2 , later col 3 must detached/prepended under menuitem li (in front) clicked. think have scroll active li, can come later. other scenarios ok, can keep 3-col layout is. i need function both on startup , resizing like function resizesec2and3() { var limit = 1000; // perform detachment if (1) window width < limit, (2) menu selection has been made if ($(window).width() < limit && currmenuitemindex != -1) { var col2element...

How to grab data from plain text response of API Calls in PHP? -

i'm getting api response in plain text. need grab data text response , need store them variables. api calling: $url="http://91.101.61.111:99/sendrequest/?mobile=9999999999&id=11011&reqref=501"; $request_timeout = 60; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_timeout, $request_timeout); curl_setopt($ch, curlopt_connecttimeout, $request_timeout); curl_setopt($ch, curlopt_returntransfer, 1); $output = curl_exec($ch); $curl_error = curl_errno($ch); curl_close($ch); api response in plain text: request accepted ref=501 system_reference=ba01562 i need grab data above plain text response variables, below: $status = "request accepted"; $myref = "501"; $sysref = "ba01562"; i have tried: $explode1 = explode(" ", $output); $explode2 = explode("=", $explode1[3]); $explode3 = explode("=", $explode1[4]); $status = $exp...

How to write SortedSet of cassandra data type as json in python? -

i trying dump cassandra data in csv format using python. far, developed following script: from cassandra.cluster import cluster cassandra.auth import plaintextauthprovider cassandra.query import tuple_factory cassandra.query import dict_factory import csv auth_provider = plaintextauthprovider(username='cassandra', password='std123') cluster = cluster(['127.0.0.1'],auth_provider=auth_provider) session = cluster.connect('killrvideo') session.row_factory = tuple_factory rows = session.execute("select * videos videoid = 873ff430-9c23-4e60-be5f-278ea2bb21bd") row = cursor.fetchall() open('data.csv', 'w') fp: = csv.writer(fp, delimiter=',') a.writerows(rows) cluster.shutdown() and giving me output like: 873ff430-9c23-4e60-be5f-278ea2bb21bd, 2013-05-16 23:50:00, second in 3 part series cassandra data modeling, http://www.youtube.com/watch?v=qphhxujn5es,1, "sortedset([video_metadata(height=480, widt...

html - width of the width and height not working -

hi trying change width , height of .content class. giving me 100px of width , 100% of height if don't mention. have tried removing float stil not working.what reason? <!doctype html> <html> <head> <style> body{margin:0} #navbar{ width:100%; background-color:black; height:50px; padding: 0 150px 0 150px; position:relitive; } #logo{height:60px; width:90px; } #container{ background-color:#e6e6e6; width:78%; margin: auto; height:1000px; text-align:center; } #navtable{ color:white; position:absolute; top:10px; left:300px; font-size:1.5em; } #navtable td{padding:0 10px 0 10px; border-right:1px solid wh...