Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-09-23T21:24:57Z
Updated: 2 hours 4 min ago

Does dict.values() returns in an ordered sequence?

Fri, 09/22/2017 - 08:46
dict_mark = {'Wang': 'C', 'Li': 'B', 'Ma': 'A'} s = '' for c in dict_mark.values(): s += c print(s)

dictionary is unordered,so why does dict_mark.values() always return this value sequence like 'C' 'B' 'A'?Why not 'B' 'A' 'C' or 'A' 'B' 'C'?

Same properties in one class

Fri, 09/22/2017 - 08:44

Is there any disadvantage in this example?

.class { max-height: 500px; max-height: 50vh; }

I want to do this because if vh is not supported in some browser, that browser will apply max-height: 500px; and ignore the line of vh.

How to create a bag of words from a pandas dataframe

Fri, 09/22/2017 - 08:42

Here's my dataframe

CATEGORY BRAND 0 Noodle Anak Mas 1 Noodle Anak Mas 2 Noodle Indomie 3 Noodle Indomie 4 Noodle Indomie 23 Noodle Indomie 24 Noodle Mi Telor Cap 3 25 Noodle Mi Telor Cap 3 26 Noodle Pop Mie 27 Noodle Pop Mie ...

I already make sure that df type is string, my code is

df = data[['CATEGORY', 'BRAND']].astype(str) import collections, re texts = df bagsofwords = [ collections.Counter(re.findall(r'\w+', txt)) for txt in texts] sumbags = sum(bagsofwords, collections.Counter())

When I call

sumbags

The output is

Counter({'BRAND': 1, 'CATEGORY': 1})

I want all of the data count in sumbags, except the title, to make it clear something like

Counter({'Noodle': 10, 'Indomie': 4, 'Anak': 2, ....}) # because it is bag of words

I need every 1 word counts

how can i let my workstation to visit k8s cluster?

Fri, 09/22/2017 - 08:38

I am trying reach my k8s master from my workstation. I can access the master from the LAN fine but not from my workstation. The error message is:

% kubectl --context=employee-context get pods Unable to connect to the server: x509: certificate is valid for 10.96.0.1, 10.161.233.80, not 114.215.201.87

How can I do to add 114.215.201.87 to the certificate? Do I need to remove my old cluster ca.crt, recreate it, restart whole cluster and then resign client certificate? I have deployed my cluster with kubeadm and I am not sure how to do these steps manually.

chat in multi window from to reciver and reciver to from

Fri, 09/22/2017 - 08:21
I Want To create live Chat in struts2 farmework using jquery for multiple chats at a time .

here below code for reference . want to chat with from to reciver aftr reciver get msg want to reply reciver to whose sended(from) ..

here i creating some code using jquery. if once one id: "BFI01" chat window open it could not allow another id :"BFI02" chat window seperately .

here i given code for available user but it not allow to open chat box for selected id .

function get_fb_complete(){ /* $('#log_complete').append('<li>get_fb() ran</li>'); */ var feedback = $.ajax({ data :{"fromval": '<%=fromuser%>'}, type: "POST", url: "chatload1", sync: true, success : function(res) { // alert("haiii"); var b=JSON.parse(res.result); console.log("b VALUE--"+b); //alert(b.length); for(var l=0; l<b.length; l++){ // alert("HAIfdsdafI"); // alert($(".username").text()); // alert(b[l].toid); // alert(b[l].inbox); /* var user2 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">'+ b[l].toid + '</span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body" style="text-align:right;"> <div class="col-xs-10"><div class="msg-text" ><div class="receiver" style="background: #ffffff;" ><p >'+b[l].inbox+'</p></div></div> <span class="partner"> Your partner is typing...</span><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn " ><button class="btn btn-primary btn-sm" id="btnchat">Send</button></span></div></div></div></div>'; */ /* alert("1--"+user2); $('#chat').append(user2); */ /* $('.receiver').show(); $('#inner').html("gfvu"); */ //$('#log_complete').append('<li>'+b[l].toid+'+'+b[l].inbox+'</li>'); /* if($(".username").text()==$("#tarid").val){ $('.receiver').show(); $('#inner').html(b[l].inbox); } -------*/ } /* if (b) { $("#tab").show() drawChart(b,c); } */ } }).complete(function(){ setTimeout(function(){get_fb_complete();}, 10000); }).responseText; } $(function(){ get_fb_complete(); }); function toChat(b,c) { alert("yes"); } $( document ).ready(function(){ $('#BFI0008').click(function(e) { e.preventDefault(); alert("HAI BFI0008"); var user1 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">BFI0008 </span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body" style="text-align:right;"> <div class="col-xs-10"><div class="msg-text" ><div class="receiver" style="background: #ffffff;" ><p id="inner"></p></div></div> <span class="partner"> Your partner is typing...</span><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn " ><button class="btn btn-primary btn-sm" id="btnchat">Send</button></span></div></div></div></div>'; alert("1--"+user1); $('#chat').append(user1); $(".msg-text").show(); $('.receiver').hide(); $('.partner').show(); /* $(".chat-body").show(); $(".chat-header").show(); */ }); $('#BFI0006').click(function(e) { e.preventDefault(); alert("HAI BFI0006"); var user1 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">BFI0006 </span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body" style="text-align:right;"> <div class="col-xs-10"><div class="msg-text" ><div class="receiver" style="background: #ffffff;" ><p id="inner"></p></div></div> <span class="partner"> Your partner is typing...</span><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn " ><button class="btn btn-primary btn-sm" id="btnchat">Send</button></span></div></div></div></div>'; alert("1--"+user1); $('#chat').append(user1); $(".msg-text").show(); $('.receiver').hide(); $('.partner').show(); /* $(".chat-body").show(); $(".chat-header").show(); */ }); <%-- var fromval={ "fromval": '<%=fromuser%>' } $.ajax({ url : "chatload", data : fromval, dataType : 'json', type : 'POST', async : true, success : function(res) { alert("haiii"); var b=JSON.parse(res.result); console.log("b VALUE--"+b); alert(b.length); for(var l=0; l<b.length; l++){ alert(b[l].toid); alert(b[l].inbox); var user2 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">'+ b[l].toid + '</span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body" style="text-align:right;"> <div class="col-xs-10"><div class="msg-text" ><div class="receiver" style="background: #ffffff;" ><p >'+b[l].inbox+'</p></div></div> <span class="partner"> Your partner is typing...</span><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn " ><button class="btn btn-primary btn-sm" id="btnchat">Send</button></span></div></div></div></div>'; alert("1--"+user2); $('#chat').append(user2); } /* if (b) { $("#tab").show() drawChart(b,c); } */ } }); $("#emojionearea1").emojioneArea({ pickerPosition: "right", tonesStyle: "bullet", events: { keyup: function (editor, event) { console.log(editor.html()); console.log(this.getText()); } } }); /* $("#testt").hide(); $(".chat-body").hide(); $(".chat-header").hide(); $(".msg-text").hide(); */ /* $('a').click(function(e) { e.preventDefault(); alert("HAIII"); var targetUser = ($(this).html()); $(document).data('chat.targetUser', targetUser); var user1 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">'+ targetUser + '</span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body"> <div class="row msg msg-sent" id="testt"><div class="col-xs-10"><div class="msg-text" ><p></p></div></div></div><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><span class="partner"> Your partner is typing...</span><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn"><button class="btn btn-primary btn-sm" id="btn-chat">Send</button></span></div></div></div></div>'; alert(user1); $('#chat').append(user1); }); */ $('a').click(function(e) { e.preventDefault(); alert("HAIII"); var targetUser = ($(this).html()); alert(targetUser); alert($("#tarid").val(targetUser)); $('.username').append(targetUser); $(document).data('chat.targetUser', targetUser); /* var user = '<div class="user open" id="' + targetUser + '"><header><div class="status"></div><div class="header-text">' + targetUser + '</div><div class="close" >&times;</div></header><div class="message-area"></div><div class="input-area"><input type="text" id="input" /></div></div>'; */ //var user1 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">'+ targetUser + '</span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body"> <div class="row msg msg-sent" id="testt"><div class="col-xs-10"><div class="msg-text" ><p></p></div></div></div><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><span class="partner"> Your partner is typing...</span><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn"><button class="btn btn-primary btn-sm" id="btn-chat">Send</button></span></div></div></div></div>'; var user1 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">'+ targetUser + '</span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body" style="text-align:right;"> <div class="col-xs-10"><div class="msg-text" ><div class="receiver" style="background: #ffffff;" ><p id="inner"></p></div></div> <span class="partner"> Your partner is typing...</span><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn " ><button class="btn btn-primary btn-sm" id="btnchat">Send</button></span></div></div></div></div>'; alert("1--"+user1); $('#chat').append(user1); $(".msg-text").show(); $('.receiver').hide(); $('.partner').show(); /* $(".chat-body").show(); $(".chat-header").show(); */ }); }); $(document).on('click', '.icon_close', function (e) { //$( this ).closest(".chat-window").remove(); $("#logid").val(); alert($(".username").text()); var values = { "logid" : $("#logid").val(), "toid" : $(".username").text() }; $.ajax({ url : "chatmsgclose" , data : JSON.stringify(values), dataType : 'json', contentType : 'application/json', type : 'POST', async : true, success : function(res) { alert("sucess"); } }); $( this ).closest(".chat-window").remove(); }); /* $(".icon_close").click(function(){ $( this ).closest(".chat-window").remove(); }); */ /* $("#btnchat").click(function(e) { e.preventDefault(); alert("JHAII"); }); */ $(document).on('click', '#btnchat', function (e) { alert("BTNSUB"); alert($("#logid").val()); alert($(".username").text()); alert($("#btn-input").val()); var a=$("#btn-input").val(); alert("textvalue==="+a); /* $('.chat-body').append($("#btn-input").val() '<br/>'); */ $('.receiver').show(); $(".chat-body .receiver").append( a +'<br/>'); $("#btn-input").val(''); alert("testt=="+$("#testt")); var values = { "logid" : $("#logid").val(), "toid" : $(".username").text(), "chatmsg" : a }; $.ajax({ url : "chatmsg" , data : JSON.stringify(values), dataType : 'json', contentType : 'application/json', type : 'POST', async : true, success : function(res) { alert("sucess btnclcik"); alert($("#logid").val()); alert($(".username").text()); toChat($("#logid").val(),$(".username").text()); <%-- if($("#logid").val() != '<%=fromuser%>'){ alert("if"); var user1 = '<div id="chats" class="container"><div class="chat-window col-xs-5 col-md-3" id="chat_window_1"><div class="chat-header col-xs-12"><div class="col-xs-8" ><span class="glyphicon glyphicon-comment"></span><span class="username">'+ targetUser + '</span></div><div class="col-xs-4 text-right"> <a><span class="glyphicon glyphicon-minus icon_minim"></span></a> <a><span class="glyphicon glyphicon-remove icon_close" data-id="chat_window_1"></span></a> </div></div> <div class="toHide"> <div class="chat-body" style="text-align:right;"> <div class="col-xs-10"><div class="msg-text" ><div class="receiver" style="background: #ffffff;" ><p ></p></div></div> <span class="partner"> Your partner is typing...</span><div class="col-xs-2"><div class="profile-pic"><img class="img-responsive img-rounded" src="http://www.bitrebels.com/wp-content/uploads/2011/02/Original-Facebook-Geek-Profile-Avatar-1.jpg"> </div></div></div><div class="chat-footer"><div class="input-group"><input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." /><span class="input-group-btn " ><button class="btn btn-primary btn-sm" id="btnchat">Send</button></span></div></div></div></div>'; alert("1--"+user1); $('#chat').append(user1); }else{ alert("ELSE"); } --%> /* var b=JSON.parse(res.result); console.log("b VALUE--"+b); alert(b.length); */ $("#testt").show(); } }); /* $("#testt").show(); */ return false; }); $(document).on('click', '.icon_minim', function (e) { var toHide = $( this ).closest(".chat-window").find(".chat-body"); if (toHide.hasClass("panel-hidden")){ alert("if"); $("#chats .chat-header").attr('style', 'top: 148px'); //toHide: styletop: 460px; toHide.removeClass("panel-hidden"); toHide.slideDown(); }else{ alert("else"); $("#chats .chat-header").attr('style', 'top: 460px'); /* toHide.addStlye("top: 460px;"); */ toHide.addClass("panel-hidden"); toHide.slideUp(); } }); <style> html, body{ height: 100%; } #chats{ position: fixed; bottom: 0; width: 100%; /* background: gray; */ background: white; height: 506px; margin-left: -500px; } #chats .chat-window{ position: relative; height: 97%; padding: 0; } #chats .chat-header{ position: absolute; top: 148px; padding: 5px; width: 100%; height: 50px; background: #2F2F2F; color: white; font-weight: bold; border-radius: 5px 5px 0 0; margin-left: 0px; } #chats .chat-header a{ text-decoration: none; cursor: pointer; color: white; } #chats .toHide{ } #chats .chat-body{ position: absolute; width: 100%; top: 198px; /* bottom: 50px; */ bottom: 3px; padding: 10px 10px 0 10px; background: #dedede; /* overflow-y:hidden; */ font-size: 13px; } #chats .msg{ padding: 10px 0; margin: 0; } #chats .msg div{ padding: 0; height: 100%; min-height: 50px; } #chats .msg .msg-text{ /* background: white; */ background-color: #34a1ef; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); /* border-radius: 3px; */ border-radius: 10px 2px 2px 10px; padding: 10px; margin: 0 5px; } #chats .msg-text p{ overflow-wrap: break-word; word-wrap: break-word; } #chats .profile-pic img{ width: 10px; height: 10px; } #chats .chat-footer{ position: absolute; height: 50px; width: 100%; bottom: 0; padding: 10px 20px 0 20px; border-top: #cccccc solid 1px; background: #f5f5f5; margin-left: -4%; } /* #chats .msg-text { min-height: 20px; float:right; clear: both; background-color: #34a1ef; border-radius: 10px 2px 2px 10px; } */ #chats .partner{ top: 414px; position: absolute; color: #34a1ef; } /* NEW STYLE CONTACT */ * { -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */ } body{margin:0;padding:0;} #contact { /* height: auto; */ background: #ececec; position: relative; /* right: -774px; */ bottom: -200px; /* margin-right: 17px; */ width: 100%; margin-left: 294%; } #contact header { padding: 10px; background: #333; color: #FFF; } #contact main { padding: 10px } #chat { position: fixed; bottom: 0; left: 0; right: 100px; height: auto; } #chat .user { border: 1px solid #333; background: #fff; width: 200px; height: 100%; float: left; margin-right: 5px; } .user header { position: relative; background: #4b67a8; border: 1px solid #2e4588; } .user header .status { position: absolute; top: 36%; left: 10px; width: 8px; height: 8px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; background: green; } .user header .header-text { color: #fff; font-weight: bold; padding: 8px; margin: 0 0 0 15px; font-size: 12px; text-shadow: 0 -1px rgba(0, 0, 0, .25); } .user header .close { position: absolute; right: 5px; top: 7px; color: #fff; } .message-area { background: #fff; height: 120px; padding: 5px; color: #333; overflow: scroll; } .user .input-area { border-top: 1px solid #333; padding: 3px; } .user .input-area input { padding: 5px; width: 100%; font-size: 12px; border: none; outline: none; } .receiver { width: auto !important; padding: 4px 10px 7px !important; border-radius: 10px 10px 10px 0; /* background: #ffffff; */ font-size: 12px; text-shadow: 0 1px 1px rgba(0, 0, 0, .2); word-wrap: break-word; display: block; float: right; margin-right: -55px; } </style> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="../css/bootstrap.min.css" rel="stylesheet"> <link href="../css/bootstrap.css" rel="stylesheet"> <script src="../jQuery/jQuery-2.2.0.min.js"></script> <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <link href="../css/emojionearea.min.css" rel="stylesheet"> <script src="../jQuery/jquery.min.js"></script> <script src="../jQuery/emojionearea.js"></script> <title>Insert title here</title> </head> <body> <div class="container"> <form class="form-horizontal" method="post" name="ChatMess1" enctype="multipart/form-data"> <input type="hidden" id="logid" name="logid" value="BFI0008"/> <input type="hidden" id="tarid" name="tarid" value=""/> <div id="chats" class="container"> <div class="chat-window col-xs-5 col-md-3" id="chat_window_1"> <div id="contact"> <header>Users</header> <main> <ul> <li id="touser" value="BFI0008"><a href="#" id="BFI0008">BFI0008</a></li> <li id="touser" value="BFI0006"><a href="#" id="BFI0006">BFI0006</a></li> </ul> </main> </div> <div id="chat" style="left: 1061px;"></div> <div id="chat11" style="left: 1061px;"></div> </div> </div> </div> <div class="row" style=" width: 195px; height:30px; /* float: right; */ margin-left: 1%;"> <!-- <div class="span6" > <input type="text" id="emojionearea1"> </div> --> <h4>Log (complete)</h4> <ol id="log_complete"></ol> </div> </body> </html>

(#100) Tried accessing nonexisting field (instant_articles) on node type (User) -fb api [on hold]

Fri, 09/22/2017 - 08:08

I am passing correct pageid and page access token by using below url in browser. https://graph.facebook.com/{page_id}/instant_articles?access_token={page access token}

But I am getting error like

(#100) Tried accessing nonexisting field (instant_articles) on node type (User).Please help me to fix it

kindly find my below code

DataSet dtset = new DataSet();

var ss = objVer.VideoID.ToString().Replace("<br /><br />", "</p><p>").Replace("<p style=\"font-family: Latha; line-height: 23px; font-size: 0.9em !important; background-color: #ffffff;\">", " ").Replace("<span style=\"font-family: Latha; font-size: 12.96px; line-height: 23px; background-color: #ffffff;\">", ""); var sss = ss.Replace("</span><br style=\"clear: left; font-family: Latha; line-height: 23px; font-size: 0.9em !important; background-color: #ffffff;\">", "").Replace("<br style=\"clear: left; font-family: Latha; line-height: 23px; font-size: 0.9em !important; background-color: #ffffff;\">", ""); var ssss = sss.Replace("src=\"/uploads/", "src=\"http://xxxx/uploads/").Replace("height=\"350\" width=\"615\"", " "); var sssss = ssss.Replace(" </br></br>", "</p><p>") + "</p><figure class=\"op-ad\"><iframe width=\"300\" height=\"250\" style=\"border:0; margin:0;\" src=\"https://www.facebook.com/adnw_request?placement=ad_placement_id&adtype=banner300x250\"></iframe></figure>"; var a = sssss.Replace("</div><div><br /></div><div>", "</p><p>").Replace("</p></p><figure class=\"op-ad\">", "</p><figure class=\"op-ad\">"); var a1 = a.Replace("<br><figure><img", "</p><figure><img"); var a2 = a1.Replace("</figure><br>", "</figure>"); StringBuilder sb = new StringBuilder(); sb.Append("<!doctype html>"); sb.Append("<html lang=\"en\">"); sb.Append("<head>"); // sb.Append("<meta property=\"fb:pages\" content=\"id\" />"); sb.Append("<meta charset=\"utf-8\">"); sb.Append("<link rel=\"canonical\" href=\"" + ConfigurationManager.AppSettings["VideoBaseUrl"] + objVer.StoryURL.ToString() + ".vid" + "\">"); sb.Append("<meta property=\"op:markup_version\" content=\"v1.0\">"); sb.Append("<meta property=\"fb:likes_and_comments\" content=\"enable\">"); sb.Append("<meta property=\"fb:use_automatic_ad_placement\"content=\"enable=true ad_density=default\">"); sb.Append("<meta property=\"og:title\" content=\"" + objVer.Title.ToString() + "\">"); sb.Append("<meta property=\"og:description\" content=\"" + objVer.Description.ToString() + "\">"); sb.Append("<meta property=\"og:image\" content=\"" + objVer.LargeImageUrl.ToString() + "\">"); sb.Append("</head>"); sb.Append("<body>"); sb.Append("<article>"); sb.Append("<header>"); if (objVer.VideoStory.ToString() == "") { //writer.WriteElementString("video", ConfigurationManager.AppSettings["BaseUrl"] + articleData.Rows[i]["VideoLink"].ToString()); } else { sb.Append("<figure data-feedback=\"fb:likes, fb:comments\">"); sb.Append("<Video>"); sb.Append("<source src=\"baseurl/MP4/" + objVer.VideoStory.ToString() + "\" type=\"video/mp4\"/>"); sb.Append("</Video>"); sb.Append("</figure>"); } sb.Append("<h1 style=\"font-size:1.6em !important;\" >"); sb.Append(objVer.Title.ToString()); sb.Append("</h1>"); sb.Append("<address>"); sb.Append("<a>" + "" + "</a>"); sb.Append("</address>"); sb.Append("<time class=\"op-published\" datetime=\"" + DateTime.Now.ToString() + "\">" + DateTime.Now.ToString() + "</time>"); sb.Append("<time class=\"op-modified\" datetime=\"" + DateTime.Now.ToString() + "\">" + DateTime.Now.ToString() + "</time>"); sb.Append("<figure class=\"op-ad\"><iframe width=\"300\" height=\"250\" style=\"border:0; margin:0;\" src=\"https://www.facebook.com/adnw_request?placement=placement_id&amp;adtype=banner300x250\"></iframe>"); sb.Append("</figure>"); sb.Append("</header>"); sb.Append("<figure data-feedback=\"fb:likes, fb:comments\">"); sb.Append("<img src=\"" +objVer.LargeImageUrl.ToString() + "\"/>"); sb.Append("</figure>"); //sb.Append("<h2>"); //sb.Append(dtset.Tables[0].Rows[i]["Description"].ToString()); //sb.Append("</h2>"); // sb.Append(a2); sb.Append("<figure class=\"op-tracker\"><iframe src=\"m\"></iframe></figure>"); //sb.Append("<footer>"); //sb.Append("<small>Ltd.</small>"); //sb.Append("</footer>"); sb.Append("<h2>/h2>"); sb.Append("<ul>"); foreach (DataTable table in dtset1.Tables) { foreach (DataRow dr in table.Rows) { sb.Append("<li><p><a href=\"" + ConfigurationManager.AppSettings["BaseUrl"] + dr["ParentName"].ToString() + "/" + dr["ChildName"].ToString() + "/" + dr["URL"].ToString() + "\">" + dr["HeadLine"].ToString() + "</a></p></li>"); //sb.Append("<li><p><a href=\"" + ConfigurationManager.AppSettings["BaseUrl"] + dr["Url"].ToString() + "\">" + dr["Description"].ToString() + "</a></p></li>"); } } sb.Append("</ul>"); sb.Append("</article>"); sb.Append("</body>"); sb.Append("</html>"); string PageAccessToken =ConfigurationSettings.AppSettings.Get("FBPageAccessToken").ToString(); string id =ConfigurationSettings.AppSettings.Get("FBPageID").ToString(); string Published = "true"; string development_mode = "true"; string path = String.Format("https://graph.facebook.com/{0}", id); var url = path + "/instant_articles?" + AppendKeyvalueWithoutAmbression("access_token", PageAccessToken); // The POST body is just a collection of key=value pairs, // the same way a URL GET string might be formatted var parameters = "" + AppendKeyvalue("html_source", sb.ToString()) + AppendKeyvalue("published", Published) + AppendKeyvalueWithoutAmbression("development_mode", development_mode); var webRequest = System.Net.WebRequest.Create(url); webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.Method = "POST"; byte[] bytes = System.Text.Encoding.ASCII.GetBytes(parameters); webRequest.ContentLength = bytes.Length; System.IO.Stream os = webRequest.GetRequestStream(); os.Write(bytes, 0, bytes.Length); os.Close(); DbCommand FBIAInsert; // Send the request to Facebook, and query the result to get the confirmation code var webResponse = webRequest.GetResponse(); StreamReader sr = null; try { sr = new StreamReader(webResponse.GetResponseStream()); string PostID = sr.ReadToEnd().Replace("{\"", " ").Replace("id\"", " ").Replace(":\"", " ").Replace("\"}", " ").Trim(); } catch (Exception ex) { //strValidationError = strMethdName + " : " + ex.Message.ToString() + strStoryID; } finally { if (sr != null) sr.Close(); } }

public static string AppendKeyvalue(string key, string value) { return string.Format("{0}={1}&", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(value)); }

Thanks

The maximum recursion 100 has been exhausted before statement completion (SQL Server)

Fri, 09/22/2017 - 08:06

In SQL Server, I have this simplified table and I'm trying to get a list of all employees with their domain manager:

IF OBJECT_ID('tempdb.dbo.#employees') IS NOT NULL DROP TABLE #employees CREATE TABLE #employees ( empid int, empname varchar(50), mgrid int, func varchar(50) ) INSERT INTO #employees VALUES(1, 'Jeff', 2, 'Designer') INSERT INTO #employees VALUES(2, 'Luke', 4, 'Head of designers') INSERT INTO #employees VALUES(3, 'Vera', 2, 'Designer') INSERT INTO #employees VALUES(4, 'Peter', 5, 'Domain Manager') INSERT INTO #employees VALUES(5, 'Olivia', NULL, 'CEO') ; WITH Emp_CTE AS ( SELECT empid, empname, func, mgrid AS dommgr FROM #employees UNION ALL SELECT e.empid, e.empname, e.func, e.mgrid AS dommgr FROM #employees e INNER JOIN Emp_CTE ecte ON ecte.empid = e.mgrid WHERE ecte.func <> 'Domain Manager' ) SELECT * FROM Emp_CTE

So the output I want is:

empid empname func dommgr 1 Jeff Designer 4 2 Luke Head of designers 4 3 Vera Designer 4

Instead I get this error:
Msg 530, Level 16, State 1, Line 17 The statement terminated. The maximum recursion 100 has been exhausted before statement completion.

What am I doing wrong? Is it actually possible with CTE?

Edit: There was indeed an error in the data, the error has gone now, but the result isn't what I want:

empid empname func dommgr 1 Jeff Designer 2 2 Luke Head of designers 4 3 Vera Designer 2 4 Peter Domain Manager 5 5 Olivia CEO NULL 4 Peter Domain Manager 5 1 Jeff Designer 2 3 Vera Designer 2

Loop through Pivot Table fields in VBA

Fri, 09/22/2017 - 07:43

I have made some automation in VBA that takes pivot table fields and does a calculation. I would like this set of code to repeat for the pivot table fields that i specify and importantly it should filter out neutral and blank value which i added in the code but i am not sure if its global enough for all the fields. I tried also using different pivot caches but i kept having errors.

Here is the VBA code that i already coded [The pivot field i have used is Dryness + Absorbency in column AP]:

Sub create() 'PURPOSE: Creates a brand new Pivot table on a new worksheet from data in the ActiveSheet Dim sht As Worksheet Dim pvtCache As PivotCache Dim pvt As PivotTable Dim StartPvt As String Dim SrcData As String Dim cht As Object 'Determine the data range you want to pivot SrcData = ActiveSheet.Name & "!" & Range("A1").CurrentRegion.Address(ReferenceStyle:=xlR1C1) 'Create a new worksheet Set sht = Sheets.Add 'Where do you want Pivot Table to start? StartPvt = sht.Name & "!" & sht.Range("A3").Address(ReferenceStyle:=xlR1C1) 'Create Pivot Cache from Source Data Set pvtCache = ActiveWorkbook.PivotCaches.create( _ SourceType:=xlDatabase, _ SourceData:=SrcData) 'Create Pivot table from Pivot Cache Set pvt = pvtCache.CreatePivotTable( _ TableDestination:=StartPvt, _ TableName:="PivotTable") ActiveSheet.PivotTables("PivotTable").AddDataField ActiveSheet.PivotTables( _ "PivotTable").PivotFields("Dryness + Absorbency"), _ "Count of Dryness + Absorbency", xlCount With ActiveSheet.PivotTables("PivotTable").PivotFields("Dryness + Absorbency") .PivotItems("NEUTRAL").Visible = False .PivotItems("(blank)").Visible = False End With With ActiveSheet.PivotTables("PivotTable").PivotFields("Subject Name") .Orientation = xlColumnField .Position = 1 End With With ActiveSheet.PivotTables("PivotTable").PivotFields("Dryness + Absorbency") .Orientation = xlRowField .Position = 1 End With Range("A4").Select Dim LR As Long, LC As Long LR = ActiveCell.End(xlDown).Row LC = ActiveCell.End(xlToRight).Column Range(ActiveCell, Cells(LR, LC)).Select Selection.Copy Range("A5").End(xlDown).Offset(2, 0).Select Selection.PasteSpecial xlPasteAll Range("A" & Rows.Count).End(xlUp).Offset(1).Select ActiveCell.FormulaR1C1 = "DIFFERENCE%" Range("B13").Select ActiveCell.FormulaR1C1 = "=ABS(R[-2]C-R[-3]C)/R[-1]C*100" Selection.Copy Dim lngLastColumn As Long lngLastColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column Range(ActiveCell, Cells(ActiveCell.Row, lngLastColumn)).FillRight End Sub

Here is the Snippet of the excel columns or pivot table fields i need to loop through:

Expected output (Example with 2 pivot fields):

I have been stuck for awhile. Any help or ways to make it simpler is appreciated.

Inline styling font-family not working on gmail and outlook

Fri, 09/22/2017 - 07:19

I have create a template and have use a google font family 'Ubuntu' as follow:. However when viewing on gmail or outlook, it is display the text in Arial. Can anyone help me on this. Thanks you.

<td align="center" style="color: #fff;font-size: 29px;padding: 30px 0 15px 0;font-weight:500;font-family:'Ubuntu', sans-serif;">Text</td>

In the head, I have added the link to call the font as follow:

<link href="https://fonts.googleapis.com/css?family=Ubuntu:400,500,700" rel="stylesheet">

JavaFX Application Thread exception to the rule

Fri, 09/22/2017 - 07:11

The JavaFX Application Thread. Sources I can find says all updates on nodes must happen in this thread.

I am trying to find the documentation for this and if there are any exceptions to this rule. https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/concurrency.htm As it says:

The JavaFX scene graph, which represents the graphical user interface of a JavaFX application, is not thread-safe and can only be accessed and modified from the UI thread also known as the JavaFX Application thread.

https://docs.oracle.com/javase/8/javafx/get-started-tutorial/jfx-architecture.htm#A1107438

Any ”live” scene, which is a scene that is part of a window, must be accessed from this thread. A scene graph can be created and manipulated in a background thread, but when its root node is attached to any live object in the scene, that scene graph must be accessed from the JavaFX application thread.

I have experienced that not all updates on a node must be done on the JavaFX AT. Some calls to update the node works fine outside this thread. For instance updating Text textProperty does not require running within the JavaFX AT. Nor thus it looks like setting tooltip does either, or changing visibility/disable/managed.

Updates on Label textProperty outside of the JavaFX AT will throw an

IllegalStateException: Not on FX application thread; currentThread = Task

How is Jmockit different from EasyMock? Which is better to use?

Fri, 09/22/2017 - 05:56

I have for long worked on EasyMocking in JUnits. I am pretty much comfortable with this but now I want to know how EasyMocks are different from Jmockits. I tried going through their documentation and I found out that the syntax is a bit different. But yet I could not figure out if there is any difference in their performances. Can anyone help me figure out what are the points that make either of them better than the other? Is there any special element in JMockit that is not found in the other? Thanks in advance...

What should i do to assign values from input stream to 3D array?

Fri, 09/22/2017 - 02:41

I got several inputs data with ifstream, it looks like:

ifstream Input1, Input2, Input3; Input1.open(arg[1]); Input2.open(arg[2]); Input3.open(arg[3]);

And I have a 3D array which I plan to use for these three streams, Depth is three (each layer stores one input). The dynamic 3D array is created array[Depth][Rows][Colons]. I plan to do something similar to the scenario 'one input in 2D array': operator >> in the 2D for loops, now code block looks like:

for(int h = 0; h < Depth; h ++){ for(int i = 0; i < Rows; i++){ for(int j = 0; j < Colons; j++){ //assign the values array[h][i][j] = vector[i]; //what i did in my assignment, vector is the merged three vectors for three input stream } } }

I have no clue now, what shall i do/think now?

Edit: It's a programming homework that I've already submitted. It requires me to use dynamic 3D array to store the stream data and do the computation.

What I did is, using three separate vectors to store three streams, then using the insertmethod to merge three vectors. Then array[h][i][j] = vector[i] in the loop. I'm wondering if there are some more effective and right ways to do this by directly using operator >> .

in tcl with sqlite binding, "eval" command didn't do anything for "ATTACH DATABASE"

Thu, 09/21/2017 - 21:08

I am trying to perform database connection automatically using tcl since its what was recommended for sqlite

I tried "eval" for CREATE TABLE, INSERT INTO, and SELECT FROM. They all worked as expected, but it didn't work with ATTACH DATABASE. The following script did not do anything

#!/user/bin/tclsh load /usr/lib/sqlite3.20.1/libsqlite3.20.1.so Sqlite3 sqlite3 main_db /location1/dbfile.sqlite main_db eval { ATTACH DATABASE "/home/location2/dbfile2.sqlite3" AS db; }

After execution I did not see the database attached

Thanks!

Spark structured streaming integration with Kafka

Thu, 09/21/2017 - 21:08

I'm writing a Spark structured streaming app that reads from and writes to Kafka. I've been trying to create a fat jar (using sbt assembly) for my spark application, that I can then submit to the spark cluster using the spark-submit script.

However, the application keeps failing with the following error:

Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.worker.DriverWrapper$.main(DriverWrapper.scala:58) at org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala) Caused by: java.lang.ClassNotFoundException: Failed to find data source: kafka. Please find packages at http://spark.apache.org/third-party-projects.html at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:549) at org.apache.spark.sql.execution.datasources.DataSource.providingClass$lzycompute(DataSource.scala:86) at org.apache.spark.sql.execution.datasources.DataSource.providingClass(DataSource.scala:86) at org.apache.spark.sql.execution.datasources.DataSource.sourceSchema(DataSource.scala:195) at org.apache.spark.sql.execution.datasources.DataSource.sourceInfo$lzycompute(DataSource.scala:87) at org.apache.spark.sql.execution.datasources.DataSource.sourceInfo(DataSource.scala:87) at org.apache.spark.sql.execution.streaming.StreamingRelation$.apply(StreamingRelation.scala:30) at org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:150) ... 6 more Caused by: java.lang.ClassNotFoundException: kafka.DefaultSource at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$21$$anonfun$apply$12.apply(DataSource.scala:533) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$21$$anonfun$apply$12.apply(DataSource.scala:533) at scala.util.Try$.apply(Try.scala:192) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$21.apply(DataSource.scala:533) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$21.apply(DataSource.scala:533) at scala.util.Try.orElse(Try.scala:84) at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:533)

Questions

  1. In the documentation, I saw that the spark-submit script needs to be called with the --packages parameter. What does this parameter do?

  2. As far as I could understand, the --packages parameter downloads the specified package and its associated dependencies from the maven repo. If this is correct, is there a way to avoid this submission-time dependency on a remote repo and to a create a far jar that has all the dependencies embedded in it?

Following are the relevant portions of the build.sbt file:

..... "org.apache.kafka" %% "kafka" % "0.10.1.0", "org.apache.kafka" % "kafka-clients" % "0.10.1.0", "org.apache.spark" %% "spark-core" % SPARK_VERSION % "provided", "org.apache.spark" %% "spark-mllib" % SPARK_VERSION, "org.apache.spark" %% "spark-sql" % SPARK_VERSION % "provided", "org.apache.spark" %% "spark-sql-kafka-0-10" % SPARK_VERSION, "org.apache.spark" % "spark-streaming_2.10" % SPARK_VERSION % "provided", ("org.apache.spark" %% "spark-streaming-kafka-0-10" % SPARK_VERSION).exclude("org.spark-project.spark","unused"), ......

Thanks in advance.

Can i Render React Components with import/require through mvc views on the client side?

Thu, 09/21/2017 - 21:08

I have spent the past few days trying to make react work with mvc. I have finally achieved this but by rendering on the client side. While doing research I have found that the require and import keywords do not work within the browser so i have figured that i must render server side.

The only function i have found to render server side is the @Html.React() function. however this does not seem to work when i insert my component name.

The reason i need import/require is because i am trying to implement the Flux architecture so need to import my Actions, Store and Constants.

What would be the best way of going about this?

Override of unset a variable set with SetEnvIfNoCase

Thu, 09/21/2017 - 21:08

I use the following code in my httpd.conf to block some unwanted old browsers

SetEnvIfNoCase User-Agent (msie\s7) blocked=old Order Allow,Deny Allow from all Deny from env=blocked

The following useragent however should not be blocked (Microsoft Office uses this useragent):

mozilla/4.0 (compatible; msie 7.0; windows nt 6.1; win64; x64; trident/7.0; .net clr 2.0.50727; slcc2; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; .net4.0e; ms-office; msoffice 16)

Question: How do I override of unset a variable set with SetEnvIfNoCase?

Will this work?

SetEnvIfNoCase User-Agent (msoffice) blocked=0

Getting blank web page in IE but working in Chrome and Firefox

Thu, 09/21/2017 - 21:08

enter image description here I'm working on a Node Js and Angular Application. Suddenly i'm Getting an error in jQuery saying "Unable to get property 'push' of undefined or null reference" only in IE. From the console i felt that the error is in Jquey. I might be wrong. No page is rendering in my local and some pages are rendering in production in Internet Explorer.

Mongo DB - Only Let Documents that match a certain condition get analyzed by the next stage of the aggregation pipeline

Thu, 09/21/2017 - 21:07

I have a collection with various documents but i am trying to match and group only a certain subset of documents that match a certain condition:

scanned: true

{ "_id" : "uqtkoew8fxkqhif7t2im1geb", "_class" : "mz.co.crunchtech.vtchill.domain.tickets.PrivateWithTablesTicket", "tableId" : "59bba43c77c82a7d95b2bef2", "scanNumber" : 2, "maxScans" : 2, "scanDate" : ISODate("2017-09-18T19:36:37.045Z"), "creationDate" : ISODate("2017-09-15T11:37:20.411Z"), "type" : "pwtbday", "numberOfPeople" : 2, "eventId" : "59bba42d77c82a7d95b2bef1", "client" : { "email" : "", "phoneNumber" : "258849901374", "name" : "Rui Cossa" }, "smsState" : false, "rsvp" : 0, "scanned" : true } { "_id" : "wklyuxdkljjccoqymc5xee58", "_class" : "mz.co.crunchtech.vtchill.domain.tickets.PrivateWithTablesTicket", "tableId" : "None", "scanNumber" : 1, "maxScans" : 1, "scanDate" : ISODate("2017-09-21T20:14:42.383Z"), "creationDate" : ISODate("2017-09-18T23:17:47.681Z"), "type" : "pwtbday", "numberOfPeople" : 1, "eventId" : "59bba42d77c82a7d95b2bef1", "client" : { "email" : "", "phoneNumber" : "", "name" : "Gildo zefanias" }, "smsState" : false, "rsvp" : 0, "scanned" : true } { "_id" : "fu6dblxi3zcotnxtqhiqik28", "_class" : "mz.co.crunchtech.vtchill.domain.tickets.PrivateWithTablesTicket", "tableId" : "None", "scanNumber" : 0, "maxScans" : 1, "creationDate" : ISODate("2017-09-18T23:17:47.988Z"), "type" : "pwtbday", "numberOfPeople" : 1, "eventId" : "59bba42d77c82a7d95b2bef1", "client" : { "email" : "", "phoneNumber" : "", "name" : "Rogerio Zandamela" }, "smsState" : false, "rsvp" : 0, "scanned" : true } { "_id" : "2veawo9d0vya7jegdiuv5yl0", "_class" : "mz.co.crunchtech.vtchill.domain.tickets.PrivateWithTablesTicket", "tableId" : "None", "scanNumber" : 1, "maxScans" : 1, "scanDate" : ISODate("2017-09-21T20:14:42.383Z"), "creationDate" : ISODate("2017-09-18T23:17:48.015Z"), "type" : "pwtbday", "numberOfPeople" : 1, "eventId" : "59bba42d77c82a7d95b2bef1", "client" : { "email" : "", "phoneNumber" : "", "name" : "Yuka" }, "smsState" : false, "rsvp" : 0, "scanned" : true }

Even though all of the documents above have a scanDate the aggregation below returns an error:

db.ticket.aggregate( [ {$match: {"scanned": true}}, { $group : { _id : { day: {$dayOfMonth: "$scanDate"},hour: {$hour: "$scanDate"}}, totalScans: { $sum: "$scanNumber"}, count: { $sum: 1 } } } ] );

ERROR:

assert: command failed: { "ok" : 0, "errmsg" : "can't convert from BSON type null to Date", "code" : 16006, "codeName" : "Location16006" } : aggregate failed

How to limit the aggregation only to documents that match the condition of the match portion

Npm save and package json relationship

Thu, 09/21/2017 - 21:07

Case 1: I read in this link (What is the --save option for npm install?) that npm --save basically updating your dependencies in package.json

Case 2: However I read in some articles that package.json would influence what you install when you execute npm install. for instance if your existing "@angular/common": "~4.0.0" and you want to upgrade it 4.4.2, you just need to change it to 4.4.2 in package.json and run npm install. It will update your dependencies of angular to 4.4.2. is this correct?

Therefore in case 1, it seems that "npm save" controls package.json dependencies version. however in case 2, it seems that package.json controls what you install when you execute npm install.

Which one is correct? If they both controlling each other, when you execute npm install how would it know which version to be installed? Thanks

find average interval dates from the date colum in mysql server

Thu, 09/21/2017 - 21:07

This is the date column from where I am trying to get average interval from top to bottom. For example First interval would be different between '2008-03-29' and '2009-04-04' and next interval would be the difference between '2009-04-04' and '2010-05-18' in days and list goes on. List of Dates

Here is the part of stored procedure I have written.

SELECT Cow_ID, Cow_Age, Cow_Breed, count(animal_id) as Numb_calves_born, count(Calf_ID) as numb_calves_weaned, calve_interval, Cow_Sire_Breed FROM( SELECT @cow_id:=cattle_info_tbl.dam_ID as Cow_ID, cattle_info_tbl.cow_age as Cow_Age, @cow_breed:=(select breed from cattle_info_tbl where animal_id=@cow_id) as Cow_Breed, animal_id IN (select animal_id from cattle_info_tbl where dam_id=@cow_id) as animal_id, #cattle_info_tbl.animal_id as Calf_ID, @cow_sire_id:=(select sire_id from cattle_info_tbl where animal_id=@cow_id) as Cow_Sire_Breed, #Where goes the problem (MAX(cattle_info_tbl.birth_date)-MIN(cattle_info_tbl.birth_date)/(SUM(CASE WHEN weaning_tbl.manage_code='T' Then 0.5 ELSE 1 END))) as calve_interval FROM cattle_info_tbl INNER JOIN measurement_tbl ON (cattle_info_tbl.chaps_id = measurement_tbl.chaps_id) AND entry_type='W' INNER JOIN weaning_tbl ON weaning_tbl.chaps_id=cattle_info_tbl.chaps_id where cattle_info_tbl.herd_id = input_herd_id AND dam_id!='' AND manage_code=0 order by dam_id

Pages