Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
54,575,426
What is the purpose of marking the set function (setter) as constexpr?
<p>I cannot understand the purpose of marking the setter function as <code>constexpr</code>, that is allowed since C++14. My misunderstanding comes from the next situation: I declare a class with a constexpr c-tor, and I am about to use it in a constexpr context, by creating a constexpr instance of that class <code>constexpr Point p1</code>. An object <code>p1</code> now is constant and its value could not be changed, so the <code>constexpr</code> setter could not be called. On the other hand, when I create an instance of my <code>class Point</code> in a non-constexpr context <code>Point p</code>, I can call the setter for that object, but now setter will not execute at compile-time, because the object is not constexpr!</p> <p>As a result, I do not understand how can I enhance the performance of my code using <code>constexpr</code> for setters.</p> <p>This is the code that demonstrates calling a constexpr setter on an non-constexpr object, that means run-time computation, instead of the compile-time:</p> <pre><code>class Point { public: constexpr Point(int a, int b) : x(a), y(b) {} constexpr int getX() const noexcept { return x; } constexpr int getY() const noexcept { return y; } constexpr void setX(int newX) noexcept { x = newX; } constexpr void setY(int newY) noexcept { y = newY; } private: int x; int y; }; int main() { Point p{4, 2}; constexpr Point p1{4, 2}; p.setX(2); } </code></pre> <p>Could anyone help me to understand what is the purpose of marking the setter function as <code>constexpr</code>?</p>
<c++><c++14><constexpr>
2019-02-07 14:20:45
HQ
54,576,441
How to extract a specific list of files from a folder in Windows?
<p>I have a folder of around 3,000 music files of all the same type (.flac).</p> <p>I made an excel (and .txt) list of around 1,000 files in that folder that I want to move to a different folder.</p> <p>Is there a way to accomplish this without having to manually move each file by referencing the list?</p> <p>Thank you!</p>
<windows><file><explorer>
2019-02-07 15:13:26
LQ_CLOSE
54,576,507
How a dbms server sends a ResultSet to a client?
<p>I know that ResultSet cannot be serializable due to the connection details present in it. How a database server is able to send a ResultSet which has a connection in it? Can anyone explain this process? I am not able to understand this concept properly. I searched on the internet, and I could not find the relevant details.</p>
<java><jdbc><resultset>
2019-02-07 15:16:47
LQ_CLOSE
54,577,095
Reactjs: How to open a multiple message box with reactjs
How to open a multiple message box with reactjs Am building a multiple chatbox like facebook. At the moment, User can call up a chatbox, can close it, minimize it etc. **Here is the issue.** when I click on different users for example three users, am supposed to have three chatbox pop up that corresponds to those three different users but its showing just one chatbox. Any help will be appreciated. **Here is the full code** import React, { Component, Fragment } from "react"; import { render } from "react-dom"; import axios from 'axios'; import './style.css'; class MessageBox extends Component { constructor() { super(); this.state = { showBox: false, shownToggle: true, data: [ { id: "1", name: "Tony" }, { id: "2", name: "Mark"}, { id: "3", name: "Joy"} ], currentRec: undefined, }; this.showBox = this.showBox.bind(this); this.closeBox = this.closeBox.bind(this); this.toggle = this.toggle.bind(this); } showBox = (i, pid, name) => { // showBox(pid, name) { this.setState({ currentRec: i }); console.log(`Selected record index: ${i}`); alert(pid); alert(name); //event.preventDefault(); this.setState({ showBox: true }, () => { document.addEventListener('click', this.closeBox); }); } closeBox(event) { if (this.dropdownBox.contains(event.target)) { this.setState({ showBox: false }, () => { document.removeEventListener('click', this.closeBox); }); } } toggle() { this.setState({ shownToggle: !this.state.shownToggle }); } /* handleChat(id, name) { alert(id); alert(name); } */ render() { var hidden = { display: this.state.shownToggle ? "block" : "none" } return ( <div> <ul style={{float: "right"}}> {this.state.data.map((person, i) => ( <div className="chat-sidebar" key={i}> <button onClick={ () => this.showBox(i, person.id, person.name)}> Chat with {person.name}</button> {this.state.showBox ? ( <div className="msg_box" style={{right: '270px'}}> <div onClick={this.toggle.bind(this)} class="msg_head"> (<b style={{color: 'orange'}}> {this.state.currentRec !== undefined && <div className="modal-body"> {this.state.data[this.state.currentRec].name} ({this.state.data[this.state.currentRec].id}) </div>} </b>) Minimize <div className="close" ref={(element) => {this.dropdownBox = element;}} style={{color: 'white'}}>Close</div> </div> <div style={ hidden } className="msg_wrap"> <div className="msg_body">Message will appear here</div> </div> </div> ): ( null )} </div> ))} </ul> </div> ); } } **Here is the css** /**** Chat Popup Layout******/ body{ background:#e5e5e5; font-family: sans-serif; } .msg_box{ position:fixed; bottom:-5px; width:250px; background:white; border-radius:5px 5px 0px 0px; } .msg_head{ background:black; color:white; padding:8px; font-weight:bold; cursor:pointer; border-radius:5px 5px 0px 0px; } .msg_body{ background:white; height:200px; font-size:12px; padding:15px; overflow:auto; overflow-x: hidden; } .close{ float:right; cursor:pointer; } .minimize{ float:right; cursor:pointer; padding-right:5px; } /**** Slider Layout Popup *********/ .chat-sidebar { width: 250px; //position: fixed; height: 100%; right: 0px; top: 0px; padding-top: 10px; padding-bottom: 10px; border: 1px solid #b2b2b2; }
<reactjs>
2019-02-07 15:46:49
LQ_EDIT
54,577,475
AzureDevOps - Link git commit or branch to work item via command line
<p>I've worked on projects with a Jira integration where I simply had to include the ticket number in the commit or branch name and that work would automatically link with the ticket in Jira. Exe:</p> <blockquote> <p><code>git commit -am '123 some commit'</code></p> </blockquote> <p>And on the ticket you'd see a link to the commit.</p> <p><strong>How can I do that with Azure Dev Ops?</strong></p> <p>I know how to manually do it via Visual Studio or in the ticket itself, but I want to do it through the command line only.</p>
<git><azure-devops>
2019-02-07 16:06:34
HQ
54,577,531
My Application keeps stopping, help me find the problem please
I'm having a problem with my application, the thing that it is supposed to do is send a message using volume key buttons on the phone. The problem now is that it keeps stopping and I do not know if it works. Here is the code guys, I also added some wake lock in order for my app to stay active even when phone is locked public class MainActivity extends Activity { private final static int SEND_SMS_PERMISSION_REQUEST_CODE = 111; private Button sendMessage; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag"); wl.acquire(); setContentView(R.layout.activity_main); sendMessage = findViewById(R.id.send_message); final EditText phone = findViewById(R.id.phone_no); final EditText message = findViewById(R.id.message); sendMessage.setEnabled(false); if (checkPermission(Manifest.permission.SEND_SMS)) { sendMessage.setEnabled(true); } else { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, SEND_SMS_PERMISSION_REQUEST_CODE); } sendMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String msg = message.getText().toString(); String phonenumber = phone.getText().toString(); if (!TextUtils.isEmpty(msg) && !TextUtils.isEmpty(phonenumber)) { if (checkPermission(Manifest.permission.SEND_SMS)) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(String.valueOf(phone), null, msg, null, null); } else { Toast.makeText(MainActivity.this, "Permission denied", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(MainActivity.this, "Enter a message and a phone number", Toast.LENGTH_SHORT).show(); } } }); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { sendMessage.setEnabled(true); return true; } else if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { sendMessage.setEnabled(true); return true; } else return super.onKeyDown(keyCode, event); } private boolean checkPermission(String permission) { int checkPermission = ContextCompat.checkSelfPermission(this, permission); return checkPermission == PackageManager.PERMISSION_GRANTED; } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case SEND_SMS_PERMISSION_REQUEST_CODE: if (grantResults.length > 0 && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) { sendMessage.setEnabled(true); } break; } } }
<java><android>
2019-02-07 16:09:58
LQ_EDIT
54,577,548
Java error while launching JMeter bat file
<p>I am trying to launch JMeter through the BAT file on a windows machine but I am getting the following error:</p> <pre><code>Not able to find Java executable or version. Please check your Java installation. errorlevel=2 Press any key to continue . . . </code></pre> <p>I have set the java path earlier and this was working perfectly fine earlier. can anyone suggest me how to fix this issue?</p>
<java><windows><batch-file><jmeter>
2019-02-07 16:10:49
LQ_CLOSE
54,577,567
Replace last comma in character with " &"
<p>I have many different characters which have the following structure:</p> <pre><code># Example x &lt;- "char1, char2, char3" </code></pre> <p>I want to remove the last comma of this character with " &amp;", i.e. the desired output should look as follows:</p> <pre><code># Desired output "char1, char2 &amp; char3" </code></pre> <p>How could I replace the last comma of a character with " &amp;"?</p>
<r><replace><character>
2019-02-07 16:11:45
HQ
54,578,053
Is it ok to send to token from frontend to backend?
<p>If I have an application in which a user can connect to facebook from the frontend, it is ok to send the access token to the backend?</p> <p>If there are security risks, what are them?</p>
<javascript><frontend><backend>
2019-02-07 16:36:03
LQ_CLOSE
54,578,141
Implementing a dynamic typed language with LLVM IR
<p>I'm trying to build a JIT compiler for a dynamic language using LLVM C API but I'm stuck at implementing dynamic types, for example in function definition, LLVM needs types for each argument but the type is unknown until runtime based on what the user passes, i googled this for a while but no any good resources about it anywhere, I also tried looking at Julia's source code to see how they did it, unfortunetely the code is big and complex and i have to eye jump everywhere to find such a small detail, from what i seen so far in it is they represent their types as an empty LLVM struct pointers and a func sig type that holds some extra data, but I'm very unsure of how that works or even if I'm explaining it right, any resources can be helpful, an example code is most appreciated, the example doesn't have to be in C API, C++ is also fine I'll convert it myself one way or the other.</p> <p>Thanks in advance.</p>
<c++><c><compiler-construction><llvm><language-design>
2019-02-07 16:40:23
LQ_CLOSE
54,579,730
React Hooks with React Router v4 - how do I redirect to another route?
<p>I have a simple react hooks application - a list of Todos - with react router v4</p> <p>On the List of Todos, when a Todo is clicked I need to:</p> <ol> <li>Dispatch the current todo in context</li> <li>Redirect to another route (from /todos to /todos/:id)</li> </ol> <p>In the previous React Class based implementation I could use this.context.history.push to redirect to another route. </p> <p>How would I handle that using React Hooks in combination of React Router v4 (in code below see my comment in function editRow())?</p> <p>Code below:</p> <p>=====index.js=====</p> <pre><code>import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter} from "react-router-dom" import App from './App'; ReactDOM.render( &lt;BrowserRouter&gt; &lt;App /&gt; &lt;/BrowserRouter&gt;, document.getElementById('root')); </code></pre> <p>=====main.js=====</p> <pre><code>import React from 'react' import { Switch, Route } from 'react-router-dom' import TodosList from './todoslist' import TodosEdit from './todosedit' const Main = () =&gt; ( &lt;main&gt; &lt;Switch&gt; &lt;Route exact path="/todos" component={TodosList}/&gt; &lt;Route exact path="/todos/:id" component={TodosEdit} /&gt; &lt;/Switch&gt; &lt;/main&gt; ) export default Main </code></pre> <p>=====app.js=====</p> <pre><code>import React, {useContext, useReducer} from 'react'; import Main from './main' import TodosContext from './context' import todosReducer from './reducer' const App = () =&gt; { const initialState = useContext(TodosContext); const [state, dispatch] = useReducer(todosReducer, initialState); return ( &lt;div&gt; &lt;TodosContext.Provider value={{state, dispatch}}&gt; &lt;Main/&gt; &lt;/TodosContext.Provider&gt; &lt;/div&gt; ) } export default App; </code></pre> <p>=====TodosContext.js=====</p> <pre><code>import React from 'react' const TodosContext = React.createContext({ todos: [ {id:1, text:'Get Grocery', complete:false}, {id:2, text:'Excercise', complete:false}, {id:3, text:'Drink Water', complete:true}, ], currentTodo: {} }) export default TodosContext </code></pre> <p>=====reducer.js=====</p> <pre><code>import React from 'react' export default function reducer(state, action){ switch(action.type){ case "GET_TODOS": return { ...state, todos: action.payload } case "SET_CURRENT_TODO": return { ...state, currentTodo: action.payload } default: return state } } </code></pre> <p>=====Todos.js=====</p> <pre><code>import React, {useState, useContext, useEffect} from 'react'; import TodosContext from './context' function Todos(){ const [todo, setTodo] = useState("") const {state, dispatch} = useContext(TodosContext) useEffect(()=&gt;{ if(state.currentTodo.text){ setTodo(state.currentTodo.text) } else { setTodo("") } dispatch({ type: "GET_TODOS", payload: state.todos }) }, [state.currentTodo.id]) const editRow = event =&gt;{ let destUrlEdit = `/todos/${event.id}` let obj = {} obj.id = event.id obj.text = event.text dispatch({type:"SET_CURRENT_TODO", payload: obj}) //after dispatch I would like to redirect to another route to do the actual edit //destUrlEdit } return( &lt;div&gt; &lt;h1&gt;List of ToDos&lt;/h1&gt; &lt;h4&gt;{title}&lt;/h4&gt; &lt;ul&gt; {state.todos.map(todo =&gt; ( &lt;li key={todo.id}&gt;{todo.text} &amp;nbsp; &lt;button onClick={()=&gt;{ editRow(todo)}}&gt; &lt;/button&gt; &lt;/li&gt; ))} &lt;/ul&gt; &lt;/div&gt; ) } export default Todos; </code></pre>
<javascript><reactjs><react-router><react-router-v4><react-hooks>
2019-02-07 18:12:23
HQ
54,580,583
Error java.lang.ArrayIndexOutOfBoundsException:2
<p>I am facing java.lang.ArrayIndexOutOfBoundsException.... But my String includes more than 2 values </p> <pre><code> String[] elements = { "Allama Iqbal","born","in","Sailkot"}; String str = String.join(",", elements); String str = String.join(",", elements); String[] strArray = new String[] {str}; if(strArray[2].equals("NNP") ) { } The POS are...Allama//NNP The POS are...Iqbal//NNP The POS are...,//, The POS are...born//VBN The POS are...,//, The POS are...in//IN The POS are...,//, The POS are...Sailkot//NNP Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 </code></pre>
<java>
2019-02-07 19:09:40
LQ_CLOSE
54,582,123
Output offset when using std::cout
<p><strong>Hello dear Community,</strong></p> <p>I discovered weird behaviour when using std::cout. At line 75 I invoke the function "<strong>traverse(...)</strong>". <strong>traverse(...)</strong> will invoke "<strong>visit(int)</strong>". <strong>visit(int)</strong> will just print the int-parameter that is applied to the function.</p> <p>I created a breakpoint on line 75 to investigate how the preorder on an binary-tree is working and discovered weird behaviour when it comes to the console-output of <strong>visit(int)</strong>.</p> <p>If I'm using at line 101, within the <strong>visit(int)</strong>-function:</p> <pre><code>std::cout &lt;&lt; std::endl &lt;&lt; "Node: " &lt;&lt; i &lt;&lt; std::endl; </code></pre> <p>It's normally printed. But if I will use:</p> <pre><code>std::cout &lt;&lt; std::endl &lt;&lt; "Node: " &lt;&lt; i; </code></pre> <p>The zero (0) will not be printed if the <strong>visit(int)</strong>-function is executed first. Whilst examining the the debugger I observed the variable <strong>i</strong> that is applied to <strong>visit(i)</strong>. From the beginning: i = 0, <strong>NO</strong> console output is printed, then the second run of visit(i) is executed with i = 2. But instead printing the 2, the 0 will be printed.</p> <p>It seems that the missing</p> <pre><code>&lt;&lt; std::endl </code></pre> <p>will lead to weird behavior of the whole line.</p> <p>Does anybody expected same issues? Just try it.</p> <pre><code>/* * Project: Traversing of a binary-tree with the preorder (recursive). * Author: https://github.com/OtenMoten * * A binary-tree is suitable for managing efficient data. * "Preorder" means the algorithm will first check the root, then * the left sub-tree and finally the right sub-tree. * * Just check out https://stackoverflow.com/questions/2130416/what-are-the-applications-of-binary-trees * to read about the use-cases of binary-trees. * * Coding Standard: * "a" = address variable (i.e. int&amp; aTest;) * "i" = normal variable (i.e. int iTest;) * "p" = pointer variable (i.e. int* pTest;) * "x" = array (i.e. int xTest[10][5];) * * Created on 6. Februar 2019, 23:05 */ #include &lt;cstdlib&gt; #include &lt;stdio.h&gt; #include &lt;iostream&gt; using namespace std; constexpr int MAX_COLUMNS(4); void print(int, int[][MAX_COLUMNS]); void visit(int); void height(int, int[][MAX_COLUMNS], int&amp;, int&amp;); void traverse(int, int[][MAX_COLUMNS], int[]); void out(int[]); int main(int argc, char** argv) { constexpr int iCoutRows_Alpha = 9; constexpr int iCoutRows_Beta = 11; int aCurrentHeight = 0; int aFinalHeight = 1; int xDataFromTree[100] = {0}; // Father - Left Son - Right Son - Data int xTreeAlpha[iCoutRows_Alpha][MAX_COLUMNS] = { {0, 5, 3, 0}, // Node 0 {4, 0, 0, 101}, // Node 1 {7, 0, 0, 102}, // Node 2 {0, 0, 0, 103}, // Node 3 {5, 1, 7, 0}, // Node 4 {0, 6, 4, 0}, // Node 5 {5, 0, 0, 104}, // Node 6 {4, 8, 2, 0}, // Node 7 {7, 0, 0, 105} // Node 8 }; int xTreeBeta[iCoutRows_Beta][MAX_COLUMNS] = { {0, 2, 1, 0}, // Node 0 {0, 4, 8, 0}, // Node 1 {0, 5, 3, 0}, // Node 2 {2, 9, 6, 0}, // Node 3 {1, 10, 7, 0}, // Node 4 {2, 0, 0, 107}, // Node 5 {3, 0, 0, 102}, // Node 6 {4, 0, 0, 104}, // Node 7 {1, 0, 0, 101}, // Node 8 {3, 0, 0, 105}, // Node 9 {4, 0, 0, 103} // Node 10 }; std::cout &lt;&lt; std::endl; std::cout &lt;&lt; "Preorder-Traversing" &lt;&lt; std::endl; print(iCoutRows_Beta, xTreeBeta); std::cout &lt;&lt; std::endl; traverse(0, xTreeBeta, xDataFromTree); // Start with the root, node 0. std::cout &lt;&lt; std::endl &lt;&lt; std::endl; height(0, xTreeBeta, aCurrentHeight, aFinalHeight); std::cout &lt;&lt; "Height of the binary-tree = " &lt;&lt; aFinalHeight; out(xDataFromTree); return 0; }; void print(int iCountRows, int b[][MAX_COLUMNS]) { int iColumnA = 0; int iColumnB = 1; int iColumnC = 2; int iColumnD = 3; std::cout &lt;&lt; std::endl; std::cout &lt;&lt; "Binary-tree:"; for (int iii = 0; iii &lt; iCountRows; iii++) { std::cout &lt;&lt; std::endl; std::cout &lt;&lt; "Father - Left - Right - Data"; printf("\n%3d %7d %7d %7d ", b[iii][iColumnA], b[iii][iColumnB], b[iii][iColumnC], b[iii][iColumnD]); }; }; void visit(int i) { std::cout &lt;&lt; std::endl &lt;&lt; "Node: " &lt;&lt; i &lt;&lt; std::endl; }; void height(int root, int xBinaryTree[][4], int &amp;aCurrentHeight, int &amp;aFinalHeight) { aCurrentHeight++; // "aCurrentHeight" is the current layer of the node. if (aCurrentHeight &gt; aFinalHeight) aFinalHeight = aCurrentHeight; // The final height is &gt;= the current height. if (xBinaryTree[root][1] != 0) // The current node is NOT a leaf! { height(xBinaryTree[root][1], xBinaryTree, aCurrentHeight, aFinalHeight); // Get the height of the left sub-tree. height(xBinaryTree[root][2], xBinaryTree, aCurrentHeight, aFinalHeight); // Get the height of the right sub-tree. }; aCurrentHeight--; }; void traverse(int i, int baum[][4], int inhalt[]) { int az; visit(i); if (baum[i][1] != 0) // aktueller Knoten ist kein Blatt { traverse(baum[i][1], baum, inhalt); //linken Sohn traverse(baum[i][2], baum, inhalt); //rechten Sohn } else { az = inhalt[0]; // aktueller Knoten ist Blatt inhalt[az + 1] = baum[i][3]; inhalt[0] = az + 1; }; }; void out(int xInputArray[]) { std::cout &lt;&lt; std::endl; std::cout &lt;&lt; "Count of leafs with data = " &lt;&lt; xInputArray[0]; std::cout &lt;&lt; std::endl &lt;&lt; std::endl; std::cout &lt;&lt; "Data is:"; for (int i = 1; i &lt; xInputArray[0] + 1; i++) { std::cout &lt;&lt; std::endl; std::cout &lt;&lt; xInputArray[i]; }; }; </code></pre> <p><strong>Kind regards Oten</strong></p>
<c++><c++14><binary-tree><preorder>
2019-02-07 20:54:53
LQ_CLOSE
54,582,642
How to create cookies in website rather then browser?
<p>I want to store the cookies in website rather then browser to access the same content on cross browser. Please conclude your suggestion.</p>
<php><cookies>
2019-02-07 21:33:25
LQ_CLOSE
54,583,231
Java : If inside method is throwing error, shouldn't the outside method also throw error?
<p>Say,</p> <pre><code>public String testing() { caller.call(); } Class Caller { public void call() throws Exception1 { } } </code></pre> <p>that is, is say, call() can throw Exception1, do I have to add same throws in testing() method definition also? Or its not needed? I am not getting any compile time error in Intellij IDE when I don't throws in testing() method definition. Shouldn't I have the compile time error?</p>
<java><exception>
2019-02-07 22:23:53
LQ_CLOSE
54,583,289
Get variable from javascript array
<p>I'm want to get variable "priceWithVatMin" and "priceWithVatMax" from Javascript "array"</p> <pre><code> &lt;script&gt; dataLayer = []; dataLayer.push({'shoptet' : { "pageType": "productDetail", "product": { "id": 2148, "name": "iPhone 7 Plus 32GB Black", "currency": "CZK", "priceWithVatMin": 12899, "priceWithVatMax": 13599 } </code></pre> <p>i want some like write in console this variable e.g -> <code>console.log(?)</code> Thanks lot :-) </p>
<javascript>
2019-02-07 22:29:03
LQ_CLOSE
54,583,981
How to make the values in a list equal to 1st, 2nd, 3rd, etc
<p>I'm not trying to find the highest value or rank them in a certain order. I need the first value to be the 1st place, second value the 2nd place, you get it. Honestly, I couldn't find it done in the simplest way nor done in the way I'm describing. I'm sure it's be done but I haven't found anything. </p> <p>Example: <code>['10','11','12','13,'14']</code></p> <p>'10' = 1 or 1st</p> <p>'11' = 2 or 2nd</p> <p>'12' = 3 or 3rd</p> <p>'13' = 4 or 4th</p> <p>'14' = 5 or 5th</p>
<python>
2019-02-07 23:36:36
LQ_CLOSE
54,586,137
How do I combine multiple OpenAPI 3 specification files together?
<p>I want to combine an API specification written using the OpenAPI 3 spec, that is currently divided into multiple files that reference each other using <code>$ref</code>. How can I do that?</p>
<api><swagger><openapi>
2019-02-08 04:52:53
HQ
54,586,621
What's the correct way to implement login page in Xamarin Shell?
<p>My app has structure like this.</p> <p>Splash page => Login page => Main page</p> <p>After login, user cannot go back to login/splash page. There are several pages in flyout menu that user can go to. However, login/splash items should not be showed in these flyout menu items.</p> <p>Some project may try to load main page first before show login page as a modal page. I think this way doesn't work because it should take so much time to load complex main page before send user back to login.</p>
<xamarin.forms>
2019-02-08 05:42:50
HQ
54,587,348
I WANT TO KNOW HOW TO MAKE A FLOATING BUTTON IN ANDROID STUDIO THAT REMAINS ON THE SCREEN EVEN AFTER CLOSING ACTIVITY
I WANT TO KNOW HOW TO MAKE A FLOATING BUTTON OR ANYTHING EXTRA. IN ANDROID STUDIO THAT REMAINS ON THE SCREEN EVEN AFTER CLOSING ACTIVITY
<android-studio>
2019-02-08 06:52:36
LQ_EDIT
54,587,455
python3: make a list unique in-place
How can one make a list contain only unique items while preserving order AND updating it in-place? PS - I know that a set can be used, but it will not guarantee ordering.
<python><python-3.x><list><unique>
2019-02-08 07:02:19
LQ_EDIT
54,588,784
how to change backgound color for edittext(android) if input is filled or present in that editbox
[I want to apply same yellow color background as their in second input box for the first input box where input is already given inshort how to give same input colour when editbox is focused or input present here is my code i did it for if focused ][1] [1]: https://i.stack.imgur.com/FoDNB.jpg
<android>
2019-02-08 08:51:44
LQ_EDIT
54,589,765
Can't get data from JSON status undefined?
<p>I am trying to get the <code>status</code> of <code>de.zip-code</code> but get a error <code>Cannot read property 'status' of undefined</code>. In my js file I have this </p> <p><code>$.getJSON("link", function(json) { let creditcheck = json.de_zip_code.status;</code> and more.</p> <pre><code>{ de.zip-code: { status: "RED", link: "link", text: "text" }, glasvezel-availability: { status: "RED", link: "link", text: "text" } } </code></pre>
<javascript><json>
2019-02-08 09:52:03
LQ_CLOSE
54,590,135
How do I fix this script (Powershell)
Hi I am trying to get this short script to work and I dont understand why, Powershell gives somewhat garbled and useless error messages! Script:- $us = Read-Host 'Enter Your User Group Name:' |Get-ADGroup -Filter {name -like "*$us*"} -Properties Description,info | Select Name | Sort Name Error:- Get-ADGroup : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. At line:1 char:42 + ... ser Name:' |Get-ADGroup -Filter {name -like "*$us*"} -Properties Desc ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (River:PSObject) [Get-ADGroup], ParameterBindingException + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADGroup
<powershell>
2019-02-08 10:13:14
LQ_EDIT
54,590,275
How to convert 8pm to 20 hrs in plsql?
<p>Can anyone help me to convert <code>08-MAR-16 08.15.41.000000 PM</code> so I need <code>08-MAR-16 20.15.41.000000</code> ?</p>
<datetime><plsql>
2019-02-08 10:21:26
LQ_CLOSE
54,591,336
unable to push value in an Array in ionic
i am trying to push a value into an array but i am getting error **Cannot read property 'push' of undefined** my html code is <ion-item *ngFor="let item of items" (click)="clicked(item.title)"> {{item.title}} </ion-item> </ion-list> and my ts code is clicked(item){ this.addedtags.push(item); console.log(this.addedtags); }
<angular><typescript><ionic-framework><ionic2><ionic3>
2019-02-08 11:21:40
LQ_EDIT
54,592,702
How can i receive sms from india to Us twilio number
<p>I am Sending sms to twilio usa number from india but it is not delivered.Can you please tell me why my messages are not delivered.</p>
<php><twilio>
2019-02-08 12:40:54
LQ_CLOSE
54,592,778
How fix attr/colorError in Android studio
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'. Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed C:\Users\Jarup\.gradle\caches\transforms-1\files-1.1\card-form-3.5.0.aar\cb262b69320916545281c54ceaa4ba26\res\values\values.xml:57:5-60:13: AAPT: error: style attribute 'attr/colorError (aka com.example.lun.pocket_health_advisor:attr/colorError)' not found. Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed C:\Users\Jarup\AndroidStudioProjects\healthcare\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2493: error: style attribute 'attr/colorError (aka com.example.lun.pocket_health_advisor:attr/colorError)' not found. error: failed linking references.
<java><android>
2019-02-08 12:45:08
LQ_EDIT
54,593,210
C# Prevent process from turning inactive
I want to improve my c# skills a bit and made a little programm with some heavy calculation. <br><br> The Problem that occours is, that the whole process turns inactive after a few seconds in cause of the calculation (up to 531.441.000.000 char arrays are created by calculation). <br> My CPU usage is somewhere around 20% and the memory usage around 100MB while the process is being executed. The whole code is written in c# with c# froms. <br><br> **My Question**: Is there a general way to prevent it from turning inactive? I can imagine, that I could use more of my hardware capacities, but I don't know where to start.
<c#><winforms>
2019-02-08 13:13:13
LQ_EDIT
54,594,026
replace CR LF in SED
I have a 1.5 GB Windows text file with some lines ending with LF and most of lines ending with CR+LF Can you please help with SED script which - a. will replace all CR+LF with $|$ - replace all LF with CR+LF - replace back all $|$ with CR+LF
<windows><text><sed><character-replacement>
2019-02-08 14:01:20
LQ_EDIT
54,594,582
How to read json file in jupyter notebook?
import numpy as np import pandas as pd import seaborn as sns import matplotlib as plt from ast import literal_eval import json %matplotlib inline with open('today.json') as f: data = literal_eval(f.read()) df = pd.DataFrame(data) print(df) Error: File "<ipython-input-16-6c3ee58610d7>", line 10 data = literal_eval(f.read()) ^ IndentationError: expected an indented block
<python><json><python-3.x><pandas>
2019-02-08 14:32:29
LQ_EDIT
54,595,285
How to use R with Google Colaboratory?
<p>Google Colaboratory supports Python version 2.7 and 3.6</p> <p>I see an example how to use Swift in Colab a while ago.</p> <p>Today, I happened to run</p> <pre><code>!jupyter-kernelspec list </code></pre> <p>And found a new kernel: IRkernel</p> <pre><code>Available kernels: ir /usr/local/share/jupyter/kernels/ir python2 /usr/local/share/jupyter/kernels/python2 python3 /usr/local/share/jupyter/kernels/python3 swift /usr/local/share/jupyter/kernels/swift </code></pre> <p>Is it now possible to use R in Colab as well? No hassle in installing R kernel?</p>
<r><jupyter-notebook><google-colaboratory>
2019-02-08 15:10:33
HQ
54,595,333
Need help debugging this SQL Procedure for MSSQL
Hi I've been trying to create the Procedure as below but after queriing it kept giving me these errors sg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 164 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 165 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 166 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 167 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 168 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 169 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 170 Must declare the scalar variable "@V_ERR_REC". Msg 137, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 171 Must declare the scalar variable "@V_ERR_REC". Msg 102, Level 15, State 1, Procedure PKG_BNLX5_INSERT_DMBATCHERRLOG, Line 172 Incorrect syntax near '@V_ERR_REC'. CREATE PROCEDURE "PKG_BNLX5_INSERT_DMBATCHERRLOG"(@IN_PROCNAME VARCHAR(4000), @IN_TARNAME VARCHAR(4000), @IN_CURSOR VARCHAR(4000), @IN_UNIQUE_NUMBER FLOAT, @IN_SQLCODE VARCHAR(4000), @IN_SQLERRM VARCHAR(4000), @IN_REMARK VARCHAR(4000)) AS BEGIN SET NOCOUNT ON; SET @V_ERR_REC.PROCNAME = @IN_PROCNAME; SET @V_ERR_REC.TARNAME = @IN_TARNAME; SET @V_ERR_REC.CURSOR = @IN_CURSOR; SET @V_ERR_REC.UNIQUE_NUMBER = @IN_UNIQUE_NUMBER; SET @V_ERR_REC.DATIME = GETDATE(); SET @V_ERR_REC.ERRCODE = @IN_SQLCODE; SET @V_ERR_REC.ERRDESC = @IN_SQLERRM; SET @V_ERR_REC.REMARK = @IN_REMARK; INSERT INTO VM1DTA.DMBATCHERRLOG VALUES @V_ERR_REC; COMMIT; END;
<sql><sql-server><stored-procedures>
2019-02-08 15:13:33
LQ_EDIT
54,595,859
Webapp with Python back-end. Should I use AWS Lambda?
<p>I want to build a webapp with Python back-end. The front-end of the webapp will just have a simple input box where the user puts an address. Then, on the back-end I want to scrape content from the webpage in that address and then process that data. This data processing might become quite heavy.</p> <p>I'm quite experienced with Python, although with webapps, hosting, and so on, I have zero experience. I bought a domain name and hosting on namecheap, even though I just found out that maybe I won't be needing to use their hosting, as someone in /r/webhosting recommended me to use AWS instead. This was the methodology I was recommended to follow:</p> <blockquote> <ul> <li>switch to AWS (or Azure)</li> <li>create python lambda/function to do whatever you want to do with this request...</li> <li>put lambda behind api-gateway</li> <li>put Cloudfront in front of api-gateway (optional but hey..)</li> </ul> </blockquote> <p>I have seen tutorials to point the namecheap domain into an EC2 instance. But how do I go about doing this with Lambda? Is it the same principle? Can you point me to any tutorials that might teach me how to handle this? Is Lambda actually the optimal solution for this?</p> <p>Thanks!</p>
<python><amazon-web-services><amazon-ec2><aws-lambda>
2019-02-08 15:44:09
LQ_CLOSE
54,596,430
NetFramework app referencing NetFramework library in same solution referencing NetStandard library in another soln.: could not load file or assembly
<p>There are many similar questions about problems referencing a .NET Standard class library from a .NET Framework project where a NuGet package dependency in the netstandard library doesn't flow to the netframework app, and the <code>Could not load file or assembly</code> error occurs at runtime:</p> <p><a href="https://i.stack.imgur.com/lUGdX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lUGdX.png" alt="enter image description here"></a></p> <p>Many sources exist, like the one below, that indicate this can be resolved by adding the missing dependency on the netframework project:</p> <ul> <li><a href="https://stackoverflow.com/a/46015829/2704659">https://stackoverflow.com/a/46015829/2704659</a></li> </ul> <p>This is unfavorable, however, because I don't want to have projects have to carry around direct references that they shouldn't require; the dependencies should flow naturally so future added/removed dependencies just work.</p> <p>Other sources indicate that it can be resolved by adding <code>&lt;RestoreProjectStyle&gt;PackageReference&lt;/RestoreProjectStyle&gt;</code> and <code>&lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt;</code> to the netframework project file:</p> <ul> <li><a href="https://stackoverflow.com/a/53654690/2704659">https://stackoverflow.com/a/53654690/2704659</a></li> <li><a href="https://stackoverflow.com/a/53732075/2704659">https://stackoverflow.com/a/53732075/2704659</a></li> <li><a href="https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx" rel="noreferrer">https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx</a></li> </ul> <p>I've tested both of the above fixes with projects <em>that reside within the same Visual Studio solution</em> and had success, but I prefer the second approach because it's a "set it and forget it" solution. </p> <p>The problem I've found is when I try to reference a netstandard class library from a netframework project <em>in another VS solution</em> and I use the <code>&lt;RestoreProjectStyle&gt;PackageReference&lt;/RestoreProjectStyle&gt;</code> and <code>&lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt;</code>approach in the latter project. In my specific case, I have a .NET Framework executable project that references a .NET Framework class library in the same solution, and that class library references a .NET Standard class library in another solution.</p> <p>I've created <a href="https://github.com/roryap/Multi-Solution-NetStandard-from-NetFramework-Dependency-Issue" rel="noreferrer">an MCVE on GitHub that demonstrates this behavior</a>. I'm using VS 2017 v15.9.4.</p> <p>Other than always adding the packages directly on the netframework project, is there a way to get this working?</p> <hr> <p>(Note: it sounds similar to the problem here, but I'm not using "click once": <a href="https://stackoverflow.com/a/47839628/2704659">https://stackoverflow.com/a/47839628/2704659</a>)</p>
<c#><.net><visual-studio><visual-studio-2017><.net-standard>
2019-02-08 16:19:38
HQ
54,597,292
Ping send with PHP
<p>I have an application to develop for the university. Something simple. But I'm inexperienced on how to do it. It's exactly what I want to do; If I send ping 50 IP addresses at 3 minute intervals, I would like the IP address to write on the admin panel off if it is turned off and open if it is turned on. (red and green button maybe ) How ı can do it exactly? Since the servers belong to us, I want the commands to work correctly. What exactly do I want to show on the screen if Ping is successful?</p>
<javascript><php><css><html><ping>
2019-02-08 17:12:31
LQ_CLOSE
54,597,811
Why is variable not always null?
<p>Within the selectMarkerIfHover method, the if statement allows for a case when "lastSelected" is not null. </p> <p>For the life of me I cannot see a situation when this could ever happen, because it appears to always be either null to begin with, or set as null in the mouseMoved method. I need to understand how lastSelected could ever be null when the selectMarkerIfHover method is called. I have looked everywhere for help to solve this, but it is so specific, I could not find an answer.</p> <pre><code>public class EarthquakeCityMap extends PApplet { // You can ignore this. It's to get rid of eclipse warnings private static final long serialVersionUID = 1L; // IF YOU ARE WORKING OFFILINE, change the value of this variable to true private static final boolean offline = false; /** This is where to find the local tiles, for working without an Internet connection */ public static String mbTilesString = "blankLight-1-3.mbtiles"; //feed with magnitude 2.5+ Earthquakes private String earthquakesURL = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.atom"; // The files containing city names and info and country names and info private String cityFile = "city-data.json"; private String countryFile = "countries.geo.json"; // The map private UnfoldingMap map; // Markers for each city private List&lt;Marker&gt; cityMarkers; // Markers for each earthquake private List&lt;Marker&gt; quakeMarkers; // A List of country markers private List&lt;Marker&gt; countryMarkers; // NEW IN MODULE 5 private CommonMarker lastSelected; private CommonMarker lastClicked; public void setup() { // (1) Initializing canvas and map tiles size(900, 700, OPENGL); if (offline) { map = new UnfoldingMap(this, 200, 50, 650, 600, new MBTilesMapProvider(mbTilesString)); earthquakesURL = "2.5_week.atom"; // The same feed, but saved August 7, 2015 } else { map = new UnfoldingMap(this, 200, 50, 650, 600, new Google.GoogleMapProvider()); // IF YOU WANT TO TEST WITH A LOCAL FILE, uncomment the next line //earthquakesURL = "2.5_week.atom"; } MapUtils.createDefaultEventDispatcher(this, map); // (2) Reading in earthquake data and geometric properties // STEP 1: load country features and markers List&lt;Feature&gt; countries = GeoJSONReader.loadData(this, countryFile); countryMarkers = MapUtils.createSimpleMarkers(countries); // STEP 2: read in city data List&lt;Feature&gt; cities = GeoJSONReader.loadData(this, cityFile); cityMarkers = new ArrayList&lt;Marker&gt;(); for(Feature city : cities) { cityMarkers.add(new CityMarker(city)); } // STEP 3: read in earthquake RSS feed List&lt;PointFeature&gt; earthquakes = ParseFeed.parseEarthquake(this, earthquakesURL); quakeMarkers = new ArrayList&lt;Marker&gt;(); for(PointFeature feature : earthquakes) { //check if LandQuake if(isLand(feature)) { quakeMarkers.add(new LandQuakeMarker(feature)); } // OceanQuakes else { quakeMarkers.add(new OceanQuakeMarker(feature)); } } // could be used for debugging printQuakes(); // (3) Add markers to map // NOTE: Country markers are not added to the map. They are used // for their geometric properties map.addMarkers(quakeMarkers); map.addMarkers(cityMarkers); } // End setup public void draw() { background(0); map.draw(); addKey(); } /** Event handler that gets called automatically when the * mouse moves. */ @Override public void mouseMoved() { // clear the last selection if (lastSelected != null) { lastSelected.setSelected(false); lastSelected = null; } selectMarkerIfHover(quakeMarkers); selectMarkerIfHover(cityMarkers); } // If there is a marker under the cursor, and lastSelected is null // set the lastSelected to be the first marker found under the cursor // Make sure you do not select two markers. // private void selectMarkerIfHover(List&lt;Marker&gt; markers) { // TODO: Implement this method // Abort if there's already a marker selected if (lastSelected != null) { return; } for(Marker m : markers) { CommonMarker marker = (CommonMarker)m; if(marker.isInside(map,mouseX,mouseY)) { lastSelected = marker; marker.setSelected(true); return; } } } /** The event handler for mouse clicks * It will display an earthquake and its threat circle of cities * Or if a city is clicked, it will display all the earthquakes * where the city is in the threat circle */ @Override public void mouseClicked() { // TODO: Implement this method // Hint: You probably want a helper method or two to keep this code // from getting too long/disorganized if(lastClicked != null) { unhideMarkers(); lastClicked = null; } else if(lastClicked == null) { checkEarthquakes(); if(lastClicked == null) { checkCities(); } } } // Helper method that will check if an earthquake marker was clicked on // and respond appropriately private void checkEarthquakes() { if (lastClicked != null) return; // Loop over the earthquake markers to see if one of them is selected for (Marker m : quakeMarkers) { EarthquakeMarker marker = (EarthquakeMarker)m; if (!marker.isHidden() &amp;&amp; marker.isInside(map, mouseX, mouseY)) { lastClicked = marker; // Hide all the other earthquakes and hide for (Marker mhide : quakeMarkers) { if (mhide != lastClicked) { mhide.setHidden(true); } } for (Marker mhide : cityMarkers) { if (mhide.getDistanceTo(marker.getLocation()) &gt; marker.threatCircle()) { mhide.setHidden(true); } } return; } } } // Helper method that will check if a city marker was clicked on // and respond appropriately private void checkCities() { if (lastClicked != null) return; // Loop over the earthquake markers to see if one of them is selected for (Marker marker : cityMarkers) { if (!marker.isHidden() &amp;&amp; marker.isInside(map, mouseX, mouseY)) { lastClicked = (CommonMarker)marker; // Hide all the other earthquakes and hide for (Marker mhide : cityMarkers) { if (mhide != lastClicked) { mhide.setHidden(true); } } for (Marker mhide : quakeMarkers) { EarthquakeMarker quakeMarker = (EarthquakeMarker)mhide; if (quakeMarker.getDistanceTo(marker.getLocation()) &gt; quakeMarker.threatCircle()) { quakeMarker.setHidden(true); } } return; } } } // loop over and unhide all markers private void unhideMarkers() { for(Marker marker : quakeMarkers) { marker.setHidden(false); } for(Marker marker : cityMarkers) { marker.setHidden(false); } } // helper method to draw key in GUI private void addKey() { // Remember you can use Processing's graphics methods here fill(255, 250, 240); int xbase = 25; int ybase = 50; rect(xbase, ybase, 150, 250); fill(0); textAlign(LEFT, CENTER); textSize(12); text("Earthquake Key", xbase+25, ybase+25); fill(150, 30, 30); int tri_xbase = xbase + 35; int tri_ybase = ybase + 50; triangle(tri_xbase, tri_ybase-CityMarker.TRI_SIZE, tri_xbase-CityMarker.TRI_SIZE, tri_ybase+CityMarker.TRI_SIZE, tri_xbase+CityMarker.TRI_SIZE, tri_ybase+CityMarker.TRI_SIZE); fill(0, 0, 0); textAlign(LEFT, CENTER); text("City Marker", tri_xbase + 15, tri_ybase); text("Land Quake", xbase+50, ybase+70); text("Ocean Quake", xbase+50, ybase+90); text("Size ~ Magnitude", xbase+25, ybase+110); fill(255, 255, 255); ellipse(xbase+35, ybase+70, 10, 10); rect(xbase+35-5, ybase+90-5, 10, 10); fill(color(255, 255, 0)); ellipse(xbase+35, ybase+140, 12, 12); fill(color(0, 0, 255)); ellipse(xbase+35, ybase+160, 12, 12); fill(color(255, 0, 0)); ellipse(xbase+35, ybase+180, 12, 12); textAlign(LEFT, CENTER); fill(0, 0, 0); text("Shallow", xbase+50, ybase+140); text("Intermediate", xbase+50, ybase+160); text("Deep", xbase+50, ybase+180); text("Past hour", xbase+50, ybase+200); fill(255, 255, 255); int centerx = xbase+35; int centery = ybase+200; ellipse(centerx, centery, 12, 12); strokeWeight(2); line(centerx-8, centery-8, centerx+8, centery+8); line(centerx-8, centery+8, centerx+8, centery-8); } // Checks whether this quake occurred on land. If it did, it sets the // "country" property of its PointFeature to the country where it occurred // and returns true. Notice that the helper method isInCountry will // set this "country" property already. Otherwise it returns false. private boolean isLand(PointFeature earthquake) { // IMPLEMENT THIS: loop over all countries to check if location is in any of them // If it is, add 1 to the entry in countryQuakes corresponding to this country. for (Marker country : countryMarkers) { if (isInCountry(earthquake, country)) { return true; } } // not inside any country return false; } // prints countries with number of earthquakes private void printQuakes() { int totalWaterQuakes = quakeMarkers.size(); for (Marker country : countryMarkers) { String countryName = country.getStringProperty("name"); int numQuakes = 0; for (Marker marker : quakeMarkers) { EarthquakeMarker eqMarker = (EarthquakeMarker)marker; if (eqMarker.isOnLand()) { if (countryName.equals(eqMarker.getStringProperty("country"))) { numQuakes++; } } } if (numQuakes &gt; 0) { totalWaterQuakes -= numQuakes; System.out.println(countryName + ": " + numQuakes); } } System.out.println("OCEAN QUAKES: " + totalWaterQuakes); } // helper method to test whether a given earthquake is in a given country // This will also add the country property to the properties of the earthquake feature if // it's in one of the countries. // You should not have to modify this code private boolean isInCountry(PointFeature earthquake, Marker country) { // getting location of feature Location checkLoc = earthquake.getLocation(); // some countries represented it as MultiMarker // looping over SimplePolygonMarkers which make them up to use isInsideByLoc if(country.getClass() == MultiMarker.class) { // looping over markers making up MultiMarker for(Marker marker : ((MultiMarker)country).getMarkers()) { // checking if inside if(((AbstractShapeMarker)marker).isInsideByLocation(checkLoc)) { earthquake.addProperty("country", country.getProperty("name")); // return if is inside one return true; } } } // check if inside country represented by SimplePolygonMarker else if(((AbstractShapeMarker)country).isInsideByLocation(checkLoc)) { earthquake.addProperty("country", country.getProperty("name")); return true; } return false; } } </code></pre>
<java><oop>
2019-02-08 17:50:42
LQ_CLOSE
54,598,085
Ionic 4 ion-title in toolbar is not centered on android
<p>I am wondering if this a common problem. My <code>ion-title</code> is not centered in the toolbar on android. </p> <p>I googled it but I couldn't find anything for ionic 4, what I did found was a pretty good solution in ionic 3.</p> <p>here it is: <a href="https://stackoverflow.com/a/30021395/4983589">https://stackoverflow.com/a/30021395/4983589</a></p> <p>I am wondering if somebody know how to do this in ionic4?</p> <p>Here an image how it looks on android:</p> <p><a href="https://i.stack.imgur.com/Yaxq8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Yaxq8.png" alt="enter image description here"></a></p>
<ionic-framework><ionic4>
2019-02-08 18:10:39
HQ
54,598,322
How to make Typescript infer the keys of an object but define type of its value?
<p>I want to define the type of an object but let typescript infer the keys and don't have as much overhead to make and maintain a UnionType of all keys.</p> <p>Typing an object will allow all strings as keys:</p> <pre><code>const elementsTyped: { [key: string]: { nodes: number, symmetric?: boolean } } = { square: { nodes: 4, symmetric: true }, triangle: { nodes: 3 } } function isSymmetric(elementType: keyof typeof elementsTyped): boolean { return elementsTyped[elementType].symmetric; } isSymmetric('asdf'); // works but shouldn't </code></pre> <p>Inferring the whole object will show an error and allows all kind of values:</p> <pre><code>const elementsInferred = { square: { nodes: 4, symmetric: true }, triangle: { nodes: 3 }, line: { nodes: 2, notSymmetric: false /* don't want that to be possible */ } } function isSymmetric(elementType: keyof typeof elementsInferred): boolean { return elementsInferred[elementType].symmetric; // Property 'symmetric' does not exist on type '{ nodes: number; }'. } </code></pre> <p>The closest I got was this, but it don't want to maintain the set of keys like that:</p> <pre><code>type ElementTypes = 'square' | 'triangle'; // don't want to maintain that :( const elementsTyped: { [key in ElementTypes]: { nodes: number, symmetric?: boolean } } = { square: { nodes: 4, symmetric: true }, triangle: { nodes: 3 }, lines: { nodes: 2, notSymmetric: false } // 'lines' does not exist in type ... // if I add lines to the ElementTypes as expected =&gt; 'notSymmetric' does not exist in type { nodes: number, symmetric?: boolean } } function isSymmetric(elementType: keyof typeof elementsTyped): boolean { return elementsTyped[elementType].symmetric; } isSymmetric('asdf'); // Error: Argument of type '"asdf"' is not assignable to parameter of type '"square" | "triangle"'. </code></pre> <p>Is there a better way to define the object without maintaining the set of keys?</p>
<typescript>
2019-02-08 18:31:38
HQ
54,598,689
scp fails with "protocol error: filename does not match request"
<p>I have a script that uses SCP to pull a file from a remote Linux host on AWS. After running the same code nightly for about 6 months without issue, it started failing today with <code>protocol error: filename does not match request</code>. I reproduced the issue on some simpler filenames below:</p> <pre><code>$ scp -i $IDENT $HOST_AND_DIR/"foobar" . # the file is copied successfully $ scp -i $IDENT $HOST_AND_DIR/"'foobar'" . protocol error: filename does not match request # used to work, i swear... $ scp -i $IDENT $HOST_AND_DIR/"'foobarbaz'" . scp: /home/user_redacted/foobarbaz: No such file or directory # less surprising... </code></pre> <p>The reason for my single quotes was that I was grabbing a file with spaces in the name originally. To deal with the spaces, I had done <code>$HOST_AND_DIR/"'foo bar'"</code> for many months, but starting today, it would only accept <code>$HOST_AND_DIR/"foo\ bar"</code>. So, my issue <em>is</em> fixed, but I'm still curious about what's going on.</p> <p>I Googled the error message, but I don't see any real mentions of it, which surprises me.</p> <p>Both hosts involved have <code>OpenSSL 1.0.2g</code> in the output of <code>ssh -v localhost</code>, and <code>bash --version</code> says <code>GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)</code> Any ideas?</p>
<ssh><scp>
2019-02-08 18:59:42
HQ
54,598,783
CS50 Speller Help: I'm going crazy over these valgrind errors
Please help me with this. My code compiles and does what I want it to, but valgrind keeps spitting out errors that I don't understand in the slightest. It's saying that i'm trying to us uninitialized variables but they're very clearly initialized? Even if I define the variable it says it's uninitialized? It's clear my code works so I don't understand what the hell the actual problem is. I've even looked at other people's solutions online and my code seems to match. Does valgrind just hate me? What is going on? GAAAAAAAH my code: #include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "dictionary.h" // Represents number of buckets in a hash table #define N 26 // Represents a node in a hash table typedef struct node { char word[LENGTH + 1]; struct node *next; } node; // Represents a hash table, AKA an array of nodes node *hashtable[N]; // Number of Words loaded into memory int wordnum = 0; // Initialize custom functions to be defined later unsigned int hash(const char *word); bool load(const char *dictionary); unsigned int size(void); bool check(const char *word); bool unload(void); // Hashes word to a number between 0 and 25, inclusive, based on its first letter unsigned int hash(const char *word) { return tolower(word[0]) - 'a'; } // Loads dictionary into memory, returning true if successful else false bool load(const char *dictionary) { // Open dictionary FILE *file = fopen(dictionary, "r"); if (file == NULL) { unload(); return false; } // Buffer for a word char word[LENGTH + 1]; // Insert words into hash table while (fscanf(file, "%s", word) != EOF) { int index = hash(word) % N; if (hashtable[index] == NULL) { hashtable[index] = malloc(sizeof(node)); for (int i = 0, n = strlen(word); i < n; i ++) { hashtable[index]->word[i] = word[i]; } hashtable[index]->next = NULL; wordnum++; } else { node *new_node = malloc(sizeof(node)); for (int i = 0, n = strlen(word); i < n; i ++) { new_node->word[i] = word[i]; } new_node->next = hashtable[index]; hashtable[index] = new_node; wordnum++; } } // Close dictionary fclose(file); // Indicate success return true; } // Returns number of words in dictionary if loaded else 0 if not yet loaded unsigned int size(void) { return wordnum; } // Returns true if word is in dictionary else false bool check(const char *word) { int index = hash(word); node *current = hashtable[index]; while (current != NULL) { char tempword [LENGTH + 1]; strcpy(tempword, word); for (int i = 0, n = strlen(tempword); i < n; i ++) { tempword[i] = tolower(tempword[i]); } if (strcmp(tempword, current->word) == 0) { return true; } current = current->next; } return false; } // Unloads dictionary from memory, returning true if successful else false bool unload(void) { for (int i = 0; i < N; i ++) { while (hashtable[i] != NULL) { node *buffer = hashtable[i]; hashtable[i] = hashtable[i]->next; free(buffer); } } for (int i = 0; i < N; i ++) { if (hashtable[i] != NULL) { return false; } } return true; }
<c><valgrind><cs50>
2019-02-08 19:06:38
LQ_EDIT
54,598,920
Cannot concatenate 'str' and 'list' objects (Basic list indexing Python 2)
I have a program that asks for the user how many names they have and then prints them depending on the category the fall in (first, middle, and last). names = int(input("Number of names: ")) name_list = [] for i in range(names): name_list.append(input("Name: ")) print "First name: " + name_list[0] print "Middle names: " + name_list[0:len(name_list) - 1] print "Last name: " + name_list[-1] But I'm getting a TypeError: cannot concatenate 'str' and 'list' objects on line 9 and I'm not really sure why. I look for the error but I only found way more complex programs and I didn't really get the explanation
<python><python-2.x>
2019-02-08 19:19:16
LQ_EDIT
54,599,765
how do you write a function which doesn't hang when u read from a channel and u are pushing to another channel
consider a function like this func (sc *saramaConsumer) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { for msg := range claim.Messages() { sc.messages <- msg //this would hang the call if no one is reading from sc.messages and u can never exit consume cliam } }
<go>
2019-02-08 20:30:40
LQ_EDIT
54,601,529
Efficiently mapping one-to-many many-to-many database to struct in Golang
<h1>Question</h1> <p>When dealing with a one-to-many or many-to-many SQL relationship in Golang, what is the best (efficient, recommended, "Go-like") way of mapping the rows to a struct?</p> <p>Taking the example setup below I have tried to detail some approaches with Pros and Cons of each but was wondering what the community recommends.</p> <h1>Requirements</h1> <ul> <li>Works with PostgreSQL (can be generic but not include MySQL/Oracle specific features)</li> <li>Efficiency - No brute forcing every combination</li> <li>No ORM - Ideally using only <code>database/sql</code> and <code>jmoiron/sqlx</code></li> </ul> <h1>Example</h1> <p><em>For sake of clarity I have removed error handling</em></p> <p><strong>Models</strong></p> <pre class="lang-golang prettyprint-override"><code>type Tag struct { ID int Name string } type Item struct { ID int Tags []Tag } </code></pre> <p><strong>Database</strong></p> <pre class="lang-sql prettyprint-override"><code>CREATE TABLE item ( id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ); CREATE TABLE tag ( id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(160), item_id INT REFERENCES item(id) ); </code></pre> <p><strong>Approach 1 - Select all Items, then select tags per item</strong></p> <pre class="lang-golang prettyprint-override"><code>var items []Item sqlxdb.Select(&amp;items, "SELECT * FROM item") for i, item := range items { var tags []Tag sqlxdb.Select(&amp;tags, "SELECT * FROM tag WHERE item_id = $1", item.ID) items[i].Tags = tags } </code></pre> <p><em>Pros</em></p> <ul> <li>Simple</li> <li>Easy to understand</li> </ul> <p><em>Cons</em></p> <ul> <li>Inefficient with the number of database queries increasing proportional with number of items</li> </ul> <p><strong>Approach 2 - Construct SQL join and loop through rows manually</strong></p> <pre class="lang-golang prettyprint-override"><code>var itemTags = make(map[int][]Tag) var items = []Item{} rows, _ := sqlxdb.Queryx("SELECT i.id, t.id, t.name FROM item AS i JOIN tag AS t ON t.item_id = i.id") for rows.Next() { var ( itemID int tagID int tagName string ) rows.Scan(&amp;itemID, &amp;tagID, &amp;tagName) if tags, ok := itemTags[itemID]; ok { itemTags[itemID] = append(tags, Tag{ID: tagID, Name: tagName,}) } else { itemTags[itemID] = []Tag{Tag{ID: tagID, Name: tagName,}} } } for itemID, tags := range itemTags { items = append(Item{ ID: itemID, Tags: tags, }) } </code></pre> <p><em>Pros</em></p> <ul> <li>A single database call and cursor that can be looped through without eating too much memory</li> </ul> <p><em>Cons</em></p> <ul> <li>Complicated and harder to develop with multiple joins and many attributes on the struct</li> <li>Not too performant; more memory usage and processing time vs. more network calls</li> </ul> <p><strong>Failed approach 3 - sqlx struct scanning</strong></p> <p>Despite failing I want to include this approach as I find it to be my current aim of efficiency paired with development simplicity. My hope was by explicitly setting the <code>db</code> tag on each struct field <code>sqlx</code> could do some advanced struct scanning </p> <pre class="lang-golang prettyprint-override"><code>var items []Item sqlxdb.Select(&amp;items, "SELECT i.id AS item_id, t.id AS tag_id, t.name AS tag_name FROM item AS i JOIN tag AS t ON t.item_id = i.id") </code></pre> <p>Unfortunately this errors out as <code>missing destination name tag_id in *[]Item</code> leading me to believe the <code>StructScan</code> is not advanced enough to recursively loop through rows (no criticism - it is a complicated scenario)</p> <p><strong>Possible approach 4 - PostgreSQL array aggregators and <code>GROUP BY</code></strong></p> <p>While I am sure this will <em>not</em> work I have included this untested option to see if it could be improved upon so it <em>may</em> work.</p> <pre class="lang-golang prettyprint-override"><code>var items = []Item{} sqlxdb.Select(&amp;items, "SELECT i.id as item_id, array_agg(t.*) as tags FROM item AS i JOIN tag AS t ON t.item_id = i.id GROUP BY i.id") </code></pre> <p>When I have some time I will try and run some experiments here. </p>
<sql><go><struct><sqlx>
2019-02-08 23:17:41
HQ
54,601,696
Background and foreground bash/zsh jobs without adding newlines in "continued/suspended" messages
<p>I have a process that goes something like this:</p> <ul> <li>Run a command that generates a bunch of results in a bunch of files</li> <li>Open a file in vim</li> <li>Edit one of the results</li> <li>Background vim, get the next result, foreground vim</li> <li>Repeat until the list is complete</li> </ul> <p>Each time I background and foreground vim, though, bash/zsh prints two messages that look like this:</p> <pre><code>[1] + 4321 continued nvim [1] + 4321 suspended nvim </code></pre> <p>These are annoying because they eat screen space and eventually the results filter off the screen. I have to rerun the command or continually scroll up and down to find it.</p> <p>Is there a way to get the "continued/suspended" messages to avoid adding so many newlines? Alternatively, can I suppress them altogether.</p>
<bash><vim><zsh><foreground><job-control>
2019-02-08 23:38:36
HQ
54,602,205
SQL How do I pull data from events that happen on a single day? EX. List all engagements that start and end on the same day?
SQL How do I pull data from events that happen on a single day? EX. List all engagements that start and end on the same day?
<sql><sql-server>
2019-02-09 01:04:32
LQ_EDIT
54,602,291
Using for loop to make multiple drawLine shapes
<p>I am making a star using a draw line. I want to run a for loop to expand a star into multiple stars in a grid-like pattern. I am fairly new to java and could use some help with my code. The gride pattern that I would like the stars to open up too isn't too specific as far as columns x rows go. even making 6 stars or 9 stars is fine, as long as they are in a grid-like pattern. </p> <p>So far, I have the star drawn with drawLine. At one point I got two stars but they were to close to each other. When I run the code it looks like I have a whole bunch of stars sort of staggered on top of each other and being able to get two stars on Star Field, I would like to get more in such 5x6 pattern or something close. I believe I might be having a hard time computing the math in the for loops to get this to happen.</p> <p>Should I run, multiple nested for loops or is there a way to do this with using a minimal amount of for loops?</p> <pre><code>public static void drawFlag(int stars, int stripes, java.awt.Graphics g, int x, int y, int width, int height) { // Sets backround rectangle color to white g.setColor(Color.WHITE); g.fillRect(x, y, width, height); // Draw filled red rectangles *stripes* int stripeHeight = height/stripes; g.setColor(Color.RED); int lastStripeDrawnY = 0; // For loop runs red stripes for (int i = y; i &lt; y + height - 2*stripeHeight; i = i + 2*stripeHeight) { g.fillRect(x, i, width, stripeHeight); lastStripeDrawnY = i; } // expands strips across the rectangle int lastStripeY = lastStripeDrawnY+2*stripeHeight; int lastStripeHeight = y + height - lastStripeY; if (stripes%2 != 0) { g.fillRect(x, lastStripeY, width, lastStripeHeight); } int stars1 = 15; for (int cols = 1; cols &lt;= stars1; cols++) { int rows = stars1/cols; if (cols &gt; rows &amp;&amp; cols &lt;2*rows &amp;&amp; cols*rows == stars1) { } } // Draws the starField int numberOfRedStripes = (int)Math.ceil(stripes/2.0); int starFieldHeight = numberOfRedStripes*stripeHeight; int starFieldWidth = starFieldHeight*width/height; g.setColor(Color.BLUE); g.fillRect(x, y, starFieldWidth, starFieldHeight); for (int x1 = 0; x1+100 &lt;+ starFieldWidth-5; x1++) { if(x1/5*4 == stars) { drawStar(g,x1,y,50); for(int y1 = 0; y1 &lt;=starFieldHeight-5;y1++) { if(y1/4*2 == stars) { drawStar(g,x,y1,50); } } } } } // drawLine the star public static void drawStar(java.awt.Graphics g, int x, int y, int size) { g.setColor(Color.WHITE); g.drawLine(x+size/2, y+size/6, x+4*size/5, y+5*size/6); g.drawLine(x+4*size/5,y+5*size/6, x+size/6, y+2*size/5); g.drawLine(x+size/6, y+2*size/5, x+5*size/6, y+2*size/5); g.drawLine(x+5*size/6, y+2*size/5, x+size/5, y+5*size/6); g.drawLine(x+size/5, y+5*size/6, x+size/2, y+size/6); } } </code></pre> <p>Expand one star into a checkered grid-like pattern.</p>
<java><graphics>
2019-02-09 01:21:33
LQ_CLOSE
54,602,307
Using Javascript, how I compare to values to see if they are divisible by each other?
I am trying to write a event handler here so that when users enter a number in the first text box and the second text box, and click "Compare Values" button, a function executes and it checks if either of the number is ZERO, it prints out on "box5", "You have entered zero" if the two numbers are the same, it prints out on "box5", "The numbers are the same" If the first number is evenly divisible by the second, it prints out on "box5", "The first is divisible by the second" if the second number is evenly divisible by the first, it prints out on "box5", "The second is divisible by the first" else-if the numbers do not divide into each other, it prints out on "box5", "They are not divisible" I've already created the HTML page for this but I do not know how I should approach this. A few users have told me to use the "keyup" method and I was hoping if someone could show me an example of the way they would approach this using the "keyup" method if that is possible. Thanks in advance <p> Enter two numbers and we will tell you if they are evenly divisble <p> Enter your first number:</p> <input type="text" id="box3"> <p> Enter your second number: </p> <input type="text" id="box4"> <button id="compareValue">Compare Values</button> <p> Output will appear here: </p> <input text="type" id="box5" disabled> I am just trying to create a simple tool to compare 2 numbers entered by a user, and check to see if they are divisible, and if they are, which number is divisible by which one, and to make sure that no ZERO is entered in the input, and else-if nothing is divisible by each other, then it tells you they are not divisible.
<javascript><jquery><html><object><webpage>
2019-02-09 01:24:54
LQ_EDIT
54,602,476
Removing one letter from a word
<p>So Is it possible to remove one letter from a string? For example</p> <p>String Word = "Hello";</p> <p>I want to create a function where decrementation happens like if you clicked it it will be Hell then Hel then He then H and "" is it possible? </p>
<c#><unity3d>
2019-02-09 02:03:10
LQ_CLOSE
54,602,527
How to make auto hyperlink regex ignore img tags with src?
<p>I have the following regex which replaces all plain-text hyperlinks into actual anchor tags.</p> <pre><code>$acturl = '~(?:(https?)://([^\s&lt;]+)|(www\.[^\s&lt;]+?\.[^\s&lt;]+))(?&lt;![\.,:])~i'; $content = preg_replace($acturl, '&lt;a href="$0"&gt;$0&lt;/a&gt;', $content); </code></pre> <p>However, the problem with this code is that it also converts img tags into anchors too.</p> <p>For example, <code>&lt;img src="https://link.com"&gt;</code> will become <code>&lt;img src="&lt;a href='https://link.com'&gt;https://link.com&lt;/a&gt;"&gt;</code>.</p> <p>Is there a way to have this regex ignore images and only operate on plain-text URLs?</p>
<php><regex>
2019-02-09 02:15:28
LQ_CLOSE
54,602,566
Can i generate a .exe with a WPF application?
<p>Is possible to generate a .exe from another .exe? using visual studio and net framework ? for example the application grab a .dll and convert into a standalone .exe app</p>
<c#><.net><wpf>
2019-02-09 02:23:13
LQ_CLOSE
54,602,859
Flutter Bug in Andriod Studio
[Console][1] Error while Building Flutter Project i have upgraded gradle version as well reinstall andriod studio [1]: https://i.stack.imgur.com/jTdep.png
<flutter><build.gradle>
2019-02-09 03:26:32
LQ_EDIT
54,604,121
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib in VSCode Terminal
<p>For my case, i only get the error when opening accessing terminal (zsh) via VS Code. </p> <p>Upon opening VS Code terminal OR running <code>node</code> command, i get this error:</p> <pre><code>dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib Referenced from: /usr/local/bin/node Reason: image not found [1] 4506 abort node </code></pre> <p>However, it runs fine when running via iTerm. Tried running <code>brew update</code> and <code>brew upgrade</code> and a few other recommended answers.</p> <p>Anything am i missing?</p>
<node.js><terminal><visual-studio-code>
2019-02-09 07:22:13
HQ
54,605,307
Android Studio - Check if row exists in table and update it
Unfortunately all the solutions I could find, would not help me with my problem. With a button click I want to add some value to my database table, but first it should check if the row already exists in my table, if so it just should update the row. Here are my Codes: **MAIN ACTIVITY: (Just the Button Click)** incredient= new Incredient(); btnAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for(int i = 0; i < dataSource.size();i++){ tvname = (TextView) shoppingList.getChildAt(i).findViewById(R.id.tvName); tvamount = (TextView) shoppingList.getChildAt(i).findViewById(R.id.tvAmount); String nameTV = tvname.getText().toString(); String amountTV = tvamount.getText().toString(); incredient.setName(nameTV); incredient.setAmount(amountTV); incredient.setId(i); TableIncredient.getInstance(IncredientShopping.this).checkRow(incredient); } **DATABASE TABLE:** public class TableIncredient extends SQLiteOpenHelper { public static TableZutaten INSTANCE = null; public static final String DB_NAME = "INCREDIENT_TABLE"; public static final int VERSION = 1; public static final String TABLE_NAME = "incredient_table"; public static final String KEY_ID = "ID"; public static final String COL_NAME = "Name"; public static final String COL_AMOUNT = "AMOUNT"; public TableIncredient (Context context) { super(context, DB_NAME, null, VERSION); } @Override public void onCreate(SQLiteDatabase db) { String createQuerry = "CREATE TABLE " + TABLE_NAME + "(" + KEY_ID + " INTEGER PRIMARY KEY, " + COL_NAME + " TEXT NOT NULL, " + COL_AMOUNT + " INTEGER DEFAULT NULL)"; db.execSQL(createQuerry); } public boolean checkRow(Incredient incredient){ SQLiteDatabase db = this.getReadableDatabase(); Cursor c = db.query(TABLE_NAME, new String[]{KEY_ID, COL_NAME, COL_AMOUUNT}, KEY_ID + " =? AND " + COL_NAME + " =? AND " + COL_AMOUNT + " =?" , new String[]{String.valueOf(incredient)}, null, null, null, null); ContentValues values = new ContentValues(); values.put(COL_NAME, incredient.getName()); values.put(COL_AMOUNT, incredient.getAmount()); if (c.moveToFirst()){ increseIncredient(incredient); return true; } else { long newID = db.insert(TABLE_NAME, null, values); db.close(); getIncredient(newID); return false; } } } With this code it always uses the else statement and I do not know why this happens. I hope someone can help me to create a new row if it not exists and update the row if it exists.
<java><android><sqlite>
2019-02-09 10:22:42
LQ_EDIT
54,607,320
How do i check <p> element is empty using class? #javascript
How do i check if the element is p is empty using class. for e.g. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> n=1 while (n<4) { if (checks if p element class(n) is empty){ //Replaces the p element with variable } else { n++} <!-- end snippet --> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <p id="working" class="machine1"></p> <p id="working" class="machine2"></p> <p id="working" class="machine3"></p> <!-- end snippet -->
<javascript>
2019-02-09 14:45:51
LQ_EDIT
54,608,321
Can i access device files using Android NDK?
Can i write to device files (/dev/...) using Android NDK. If yes, to all of them? Which permissions are needed? Unfortunately i found nothing about this case.
<android><android-ndk>
2019-02-09 16:43:07
LQ_EDIT
54,608,403
Pycharm: How to focus on Editor when hit a debug point
<p>I am using a mac, with Pycharm version 2018.2.4 Community version.</p> <p>When I run a debugging session using the debugger and hit a debug point, I have to click on my editor using my mouse to be able to type code on the editor. If I don't do this and hit my keyboard directly, Mac will complain with some "bing" sound, signaling the keyboard input is not valid to any application (my opinion).</p> <p>How to make my Pycharm auto focus on the editor when hitting the debug point? Or at least focus on the debugger so that I can hit ESC to focus on the editor?</p> <p>I have selected "Focus application on breakpoint" in the setting. <a href="https://i.stack.imgur.com/yKOjy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yKOjy.png" alt="enter image description here"></a></p>
<python><pycharm>
2019-02-09 16:51:17
HQ
54,608,509
Regular expression
I have this context free grammar : S -> aSb S -> aSa S -> bSa S -> bSb S -> epsilon I want to show that this grammar describes a regular language ( namely can be represented as a regular expression) but I'm not sure how to do that and get the confident I'm not missing any pattern. I did not see this exact question and that why I don't think it is duplicate. I'd like an explanation on this relative simple example. It was hard for me to follow more complicated examples.
<regex>
2019-02-09 17:04:43
LQ_EDIT
54,609,804
How to write a block of text(multiple lines text) to a file in windows via batch file without using multiple echo call?
I have been trying to write multiple lines of text to a text file in windows but don't know how to do this. Also, search on the internet a lot about this but all solutions use echo command multiple times. Is there any way to do this without using echo command multiple times like "cat" in Linux.
<batch-file><cmd><echo>
2019-02-09 19:14:40
LQ_EDIT
54,610,138
count elements with specific data using ES6 concatenation
<p>trying to use <code>ecmascript 6</code> variable concatenation.</p> <p>Expecting <code>exists</code> in console but getting error. Please help: </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let path = 'abc'; if($('.title[data-path=${path}]').length &gt; 0){ console.log('exists'); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div class='title' data-path = 'abc'&gt;lorem&lt;/div&gt; &lt;div class='title' data-path = 'def'&gt;ipsum&lt;/div&gt; &lt;div class='title' data-path = 'abc'&gt;lorem&lt;/div&gt;</code></pre> </div> </div> </p>
<javascript><jquery>
2019-02-09 19:52:46
LQ_CLOSE
54,610,214
How to code a countdown timer always countdown to tomorrow?
I would like to have a countdown timer always show a countdown until tomorrow to a new client id. Thinking of using the js variable code functions to define new client's timezone together with if statement comment. and make it a repeat loop ? Anyone have down this before? A new client id will always see the countdown timer counting down to tomorrow no matter when does the client loading the page.
<javascript><html><countdowntimer>
2019-02-09 20:02:21
LQ_EDIT
54,610,872
How to use (for loop) and (if conditionals) when I have float numbers in string
we have a string called (A) contain float numbers : A="1.65, 1.46, 2.05, 3.03, 3.35, 3.46, 2.83, 3.23, 3.5, 2.52, 2.8, 1.85" How can I compute the the number of items with values >3.0 please?
<python>
2019-02-09 21:21:18
LQ_EDIT
54,611,471
Typescript optional chaining error: Expression expected.ts(1109)
<p>I am trying to do optional chaining in Typescript + React Native.</p> <p>Let's say I have the following interfaces:</p> <pre><code>interface Bar { y: number } interface Foo { x?: Bar } </code></pre> <p>and I try to run the following:</p> <pre><code> const test: Foo = {x: {y: 3}}; console.log(test.x?.y); </code></pre> <p>VSCode will show an error under the <code>?.</code> saying the following: <em>Expression expected.ts(1109)</em> </p> <p>Do you have any idea why this is happening or how should I fix it? Thanks.</p>
<typescript><react-native><visual-studio-code>
2019-02-09 22:32:20
HQ
54,612,064
Array of structs with new[] doesn't seem to work if said struct have constructor
<p>For an assignment I have a struct with constructor defined and wish to create array of these using new[] operator. I can't understand why this doesn't work. The code is like so (pseudo code):</p> <pre><code>struct Structname { int x; int y; Structname(int a,int b) { x=a; y=b; } } </code></pre> <p>Now trying to do:</p> <pre><code>Structname *Array = new Structname[size] </code></pre> <p>Results in error "No function matching call Structname::Structname() on Structname[size]" (not exact citation). The error doesn't occur when there is no constructor in my struct just as if the compiler expects me to use the constructor in Structname* Array = new Structname[size]. I cannot delete the constructor because I need it in other parts of the code. Also I cannot use std::vector due to assignment rules.</p>
<c++><struct><new-operator>
2019-02-09 23:59:58
LQ_CLOSE
54,612,984
how can i solve this "Cannot subscript a value of type '[[String]]' with an index of type 'UInt32'"
[enter image description here][1]i'm having a problem about this UInt32 thingy the "answer" in my button is having an error about this "Cannot subscript a value of type '[[String]]' with an index of type 'UInt32'" let answers = [["1. After the exam, I felt too exhausted and famished to eat my foods.","2. I could eat a horse, I am a famish now.","3. I famished my stomach next time you treat me to a meal out.","4. I will bring lots of pizza, that's famish."],["Would","Has to","Must","Could"]] var rightanswerplacement:UInt32 = 0 rightanswerplacement = arc4random_uniform(2)+1 var button:UIButton = UIButton() var x = 1 for i in 1...3{ button = view.viewWithTag(i) as! UIButton if (i == Int(rightanswerplacement)){ button.setTitle(answers[rightanswerplacement][0], for: UIControlState.normal) } else{ button.setTitle(answers[rightanswerplacement][x], for: UIControlState.normal) x = 2 } currentquestions += 1 } [1]: https://i.stack.imgur.com/g554J.png
<swift><xcode9>
2019-02-10 03:10:21
LQ_EDIT
54,613,467
How to cast a quotient
<p>I'm making a simple calculator that lists everything when someone inputs two integers. Everything seems to be working well except for the quotient I just can't seem to find that casts.</p> <pre><code>#define _CRT_SECURE_NO_WARNINGS #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #define SUM a + b #define AVG (SUM) /(float) 2 #define SUBTRACTION a - b #define MULTIPLICATION a * b #define QUOTIENT #define MODULUS a % b void main() { int a, b; printf("Enter two integers: "); scanf("%d%d", &amp;a, &amp;b); printf("\n\nThe Sum is %d\n", SUM); printf("The Difference is %d\n", SUBTRACTION); printf("The Multiplication is %d\n", MULTIPLICATION); printf("The Quotient is %d\n", QUOTIENT); printf("The Average is %0.2f\n", AVG); printf("The Modulus is %d\n", MODULUS); system("PAUSE"); } </code></pre>
<c++><casting><division>
2019-02-10 04:54:39
LQ_CLOSE
54,614,198
Is there any other way to print mysql table in html like a matrix from?
i am currently working on a college project.The requirement is to print the data(subject ,class,section) to the corresponding day and hour in html table.I tried my best to achieve the requirement but the html table just prints again and prints the next value where i want all my data to be printed in a single table to corresponding day and hour . here is the image of my database : https://imgur.com/a/G4ylbV5 And here is my output which am not satisfied with: https://imgur.com/a/oa8OLyT Here is my code: https://imgur.com/a/2rAT1Ax i expect the output to be a single table with all the respected data in the corresponding place.
<php><css><mysql><html><xampp>
2019-02-10 07:10:12
LQ_EDIT
54,614,868
Using an interrupt service routine for a PIC24 microcontroller
<p>Need help in writing an interrupt service routine to implement this flow chart for a PIC24FJ64GA102 microcontroller!</p> <p>Thanks in advance for your help!</p> <p>PHOTO LINK FOR THE FLOWCHART ---> <a href="https://ibb.co/j43K149" rel="nofollow noreferrer">https://ibb.co/j43K149</a></p>
<c><isr><pic24>
2019-02-10 08:59:06
LQ_CLOSE
54,616,663
VB.Net MS ACCESS .Object Reference Not Set to an instanceof an object
'Sql = "Select ItemName,Count(itemID) from tblItem where Item ='" & "A" & "' AND ExpireDate < '" & Now().Date() & "' Group By ItemName" Im FACING Datatype miss match in this querry in DATE Field.... how could i make this ? DB-MS ACCESS
<vb.net><ms-access>
2019-02-10 13:01:38
LQ_EDIT
54,617,101
Zero-cost properties with data member syntax
<p>I have (re?)invented this approach to zero-cost properties with data member syntax. By this I mean that the user can write:</p> <pre><code>some_struct.some_member = var; var = some_struct.some_member; </code></pre> <p>and these member accesses redirect to member functions with zero overhead.</p> <p>While initial tests show that the approach does work in practice, I'm far from sure that it is free from undefined behaviour. Here's the simplified code that illustrates the approach:</p> <pre><code>template &lt;class Owner, class Type, Type&amp; (Owner::*accessor)()&gt; struct property { operator Type&amp;() { Owner* optr = reinterpret_cast&lt;Owner*&gt;(this); return (optr-&gt;*accessor)(); } Type&amp; operator= (const Type&amp; t) { Owner* optr = reinterpret_cast&lt;Owner*&gt;(this); return (optr-&gt;*accessor)() = t; } }; union Point { int&amp; get_x() { return xy[0]; } int&amp; get_y() { return xy[1]; } std::array&lt;int, 2&gt; xy; property&lt;Point, int, &amp;Point::get_x&gt; x; property&lt;Point, int, &amp;Point::get_y&gt; y; }; </code></pre> <p>The test driver demonstrates that the approach works and it is indeed zero-cost (properties occupy no additional memory):</p> <pre><code>int main() { Point m; m.x = 42; m.y = -1; std::cout &lt;&lt; m.xy[0] &lt;&lt; " " &lt;&lt; m.xy[1] &lt;&lt; "\n"; std::cout &lt;&lt; sizeof(m) &lt;&lt; " " &lt;&lt; sizeof(m.x) &lt;&lt; "\n"; } </code></pre> <p>Real code is a bit more complicated but the gist of the approach is here. It is based on using a union of real data (<code>xy</code> in this example) and empty property objects. (Real data must be a standard layout class for this to work).</p> <p>The union is needed because otherwise properties needlessly occupy memory, despite being empty.</p> <p>Why do I think there's no UB here? The standard permits accessing the common initial sequence of standard-layout union members. Here, the common initial sequence is empty. Data members of <code>x</code> and <code>y</code> are not accessed at all, as there are no data members. My reading of the standard indicate that this is allowed. <code>reinterpret_cast</code> should be OK because we are casting a union member to its containing union, and these are pointer-interconvertible.</p> <p>Is this indeed allowed by the standard, or I'm missing some UB here?</p>
<c++><language-lawyer><union><undefined-behavior>
2019-02-10 13:55:55
HQ
54,618,322
Remove Grey Box
I'm very new to learning very basic HTML. I can't figure out how to remove the grey lines around my follow buttons. Any help is appreciated. Thank you! [Here's a screenshot of the grey boxes][1] <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <html> <head> <title>social follow bar</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body bgcolor="#00FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <!-- Save for Web Slices (social follow bar.psd) --> <table id="Table_01" width="250" height="40" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td rowspan="2"> <a href="https://www.pinterest.com/wherefoodtakesus/pins/"> <img src="https://wherefoodtakesus.com/wp-content/uploads/Home-Page/Buttons/Social-Sharing-Buttons/Pinterest_button.png" width="40" height="40" border="0" alt="Pinterest-Follow_button"></a></td> <td rowspan="2"> <a href="https://www.instagram.com/wherefoodtakesusblog/"> <img src="https://wherefoodtakesus.com/wp-content/uploads/Home-Page/Buttons/Social-Sharing-Buttons/Instagram_button.png" width="40" height="40" border="0" alt="Instagram-Follow_button"></a></td> <td rowspan="2"> <a href="https://wherefoodtakesus.com/feed/"> <img src="https://wherefoodtakesus.com/wp-content/uploads/Home-Page/Buttons/Social-Sharing-Buttons/RSS_button.png" width="40" height="40" border="0" alt="RSS-Follow_button"></a></td> <td rowspan="2"> <a href="https://mix.com/wherefoodtakesus"> <img src="https://wherefoodtakesus.com/wp-content/uploads/Home-Page/Buttons/Social-Sharing-Buttons/Mix_button.png" width="40" height="40" border="0" alt="Mix-Follow_button"></a></td> <td rowspan="2"> <a href="mailto:wherefoodtakesus@gmail.com"> <img src="https://wherefoodtakesus.com/wp-content/uploads/Home-Page/Buttons/Social-Sharing-Buttons/Email_button.png" width="40" height="40" border="0" alt="Email_button"></a></td> </tr> </table> <!-- End Save for Web Slices --> </body> </html> <!-- end snippet --> [1]: https://i.stack.imgur.com/Kp9Kx.png
<javascript><html>
2019-02-10 16:09:41
LQ_EDIT
54,618,413
How can i solved this problem in laravel?
[![Result][1]][1] [enter image description here][2] [![enter image description here][3]][3] [enter image description here][4] [![enter image description here][5]][5] [1]: https://i.stack.imgur.com/hKpQa.png [2]: https://i.stack.imgur.com/QBVJ0.png [3]: https://i.stack.imgur.com/oQhju.png [4]: https://i.stack.imgur.com/jltK7.png [5]: https://i.stack.imgur.com/smaSR.png
<php><laravel><validation><null><laravel-5.7>
2019-02-10 16:19:10
LQ_EDIT
54,618,645
Object with rows to nested object
**Before** This is an object with multiple rows: { "functions": [ { "package_id": "2", "module_id": "2", "data_id": "2" }, { "package_id": "1", "module_id": "1", "data_id": "2" }, { "package_id": "2", "module_id": "3", "data_id": "3" } ] } **Desired result** I want this to return into a "nested" Object like below, without duplicates: { "packages": [ { "package_id": "2", "modules": [ { "module_id": "2", "data": [ { "data_id": "2" } ] }, { "module_id": "3", "data": [ { "data_id": "3" } ] } ] },{ "package_id": "1", "modules": [ { "module_id": "1", "data": [ { "data_id": "2" } ] } ] } ] } I've already tried loops inside loops, with constructing multiple arrays and objects. Which causes duplicates or overriding objects into single ones. Is there a more generic way to generate this with JavaScript? (It's for an Angular (6) project.
<javascript><json><angular-cli>
2019-02-10 16:43:32
LQ_EDIT
54,618,995
can i use symfony nodeJS and angular in one application
<p><em>hello,</em> <em>I am doing an audit platform for applications develop in angular node and symfony, my question is that I can use the 3 technology at the same time here is my project thank you in advance</em></p> <p><a href="https://i.stack.imgur.com/PrcJS.png" rel="nofollow noreferrer">projet</a></p>
<node.js><angular><symfony>
2019-02-10 17:24:22
LQ_CLOSE
54,619,817
How to fix 'Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.'
<p>I recently uninstalled and reinstalled Postgres10. I then went to run a Node/Express/React application that relies on connecting to a Postgres database (and communicating with it using Sequelize). </p> <p>Initially it could not connect to the database. I realized the uninstall process removed my old databases, so then I went and re-created a new one with the name that this application connects to. Then when I restarted the app (both server and client), front-end interaction with the database was working again like normal - writing new users and reading them for authentication etc.</p> <p>However, I now have the following error in the Chrome Dev Tools console on every page-load of the app:</p> <blockquote> <p>Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist</p> </blockquote> <p>This error makes a reference to localhost/:1. When I hover over this, it shows <a href="http://localhost:3000/" rel="noreferrer">http://localhost:3000/</a>, the address I'm viewing the app at in the browser.</p> <p>Anyone have an idea what is going on? Most of the other threads I've found that bring up this error seem to be related to someone trying to develop a Chrome Extension, and even then they tend to have very few responses.</p>
<node.js><linux><postgresql><google-chrome-devtools><sequelize.js>
2019-02-10 18:49:42
HQ
54,620,595
Noob explanation of ++x
<p>Please explain ++x in layman's terms</p> <p>I tried searching for this here, youtube, Google, Chegg, and a programming community on discord. I'm pretty desperate now because I I still don't understand this. haha I know that it's a prefix which means that it increments the value then does the expression, but I don't exactly understand what that means. I also know what y -= 3 means which is y-3.</p> <pre><code>int x = 8; int y = ++x; if (x &gt; 5) y -= 3; else y = 9; Console.WriteLine(y); </code></pre> <p>I don't know what the answer is.</p>
<c#>
2019-02-10 20:16:40
LQ_CLOSE
54,620,698
What's the difference between `useRef` and `createRef`?
<p>I was going through the hooks documentation when I stumbled upon <a href="https://reactjs.org/docs/hooks-reference.html#useref" rel="noreferrer"><code>useRef</code></a>.</p> <p>Looking at their example…</p> <pre><code>function TextInputWithFocusButton() { const inputEl = useRef(null); const onButtonClick = () =&gt; { // `current` points to the mounted text input element inputEl.current.focus(); }; return ( &lt;&gt; &lt;input ref={inputEl} type="text" /&gt; &lt;button onClick={onButtonClick}&gt;Focus the input&lt;/button&gt; &lt;/&gt; ); } </code></pre> <p>…it seems like <code>useRef</code> can be replaced with <code>createRef</code>.</p> <pre><code>function TextInputWithFocusButton() { const inputRef = createRef(); // what's the diff? const onButtonClick = () =&gt; { // `current` points to the mounted text input element inputRef.current.focus(); }; return ( &lt;&gt; &lt;input ref={inputRef} type="text" /&gt; &lt;button onClick={onButtonClick}&gt;Focus the input&lt;/button&gt; &lt;/&gt; ); } </code></pre> <p>Why do I need a hook for refs? Why does <code>useRef</code> exist?</p>
<javascript><reactjs><react-hooks>
2019-02-10 20:27:16
HQ
54,622,053
Beginner question - passing strings to a React function
I have a background in C# and am just starting to learn React. My question is I'm sure very basic, but for some reason I'm struggling to figure out what I'm doing wrong. I expect someone on here will be able to answer this in a flash. I have created a simple function to accept the parameters name and email, and display them on screen. This is my first piece of React code. Once I conquer this, I'll learn how to loop through the same function to build a list, and then work on getting data from an external source into that list. Here is my code: ``` import React from "react"; import ReactDOM from "react-dom"; import "./styles.css"; const datarow = props => <div><b>Name:{props.myname}</b><br></br><b>Email:{props.email}</b></div>; function App() { return <datarow myname='James' email='james@place.org' />; } const rootElement = document.getElementById("root"); ReactDOM.render(<App />, rootElement); ``` When I execute this within CodeSandbox however, the resulting page is blank. No compile errors are occurring however. What am I doing wrong? My expectation is I should be able to pass name and email into this function and get a result on-screen.
<reactjs>
2019-02-10 23:08:47
LQ_EDIT
54,622,056
Django vs JS Frameworks
<p>How powerful are the frontend features of Django compared to heavy JS frameworks like React and Vue.js? If I plan to develop a bold web app with including a CRM module, and for an example with a Kanban Board, is that something achievable with Django alone or would I need another JS framework to back it up?</p>
<javascript><django>
2019-02-10 23:08:51
LQ_CLOSE
54,622,377
Issue in converting to specific Date format in JAVA
<p>i am receiving following date in form of String : "Wed Feb 06 2019 16:07:03 PM" which i need to convert it in form "02/06/2019 at 04:17 PM ET"</p> <p>Please advise</p>
<java><string><date><date-conversion>
2019-02-10 23:57:57
LQ_CLOSE
54,622,846
Remove Bootstrap's validation icons
<h2>Explanation</h2> <p>I'm trying to remove these <a href="https://getbootstrap.com/docs/4.2/components/forms/#validation" rel="noreferrer">Bootstrap's validation</a> icons ("x" and "check"), but I've look into everything and can't find where it is.</p> <h2>Code</h2> <p>You can also see in it this <a href="https://jsfiddle.net/at9enbmo/" rel="noreferrer">JSFiddle</a>.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet" /&gt; &lt;script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"&gt;&lt;/script&gt; &lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;form class="was-validated"&gt; &lt;div class="form-group"&gt; &lt;select class="custom-select" required&gt; &lt;option value=""&gt;Open this select menu&lt;/option&gt; &lt;option value="1"&gt;One&lt;/option&gt; &lt;option value="2"&gt;Two&lt;/option&gt; &lt;option value="3"&gt;Three&lt;/option&gt; &lt;/select&gt; &lt;div class="invalid-feedback"&gt;Example invalid custom select feedback&lt;/div&gt; &lt;/div&gt; &lt;/form&gt;</code></pre> </div> </div> </p> <p>Thanks in advance,<br> Luiz.</p>
<javascript><html><css><bootstrap-4>
2019-02-11 01:22:29
HQ
54,622,984
What js module has currency formatting/ calculation?
<p>I am using react and looking for a module that can convert amounts based on currency symbol? What would be a good module for this?</p>
<reactjs>
2019-02-11 01:47:57
LQ_CLOSE
54,623,431
Find the biggest number in array by using javascript loops
create a function called biggestNumberInArray() that takes an array as a parameter and returns the biggest number. Here is an array const array = [-1,0,3,100, 99, 2, 99] What i try in my JS: function biggestNumberInArray(arr) { for (let i = 0; i < array.length; i++) { for(let j=1;j<array.length;j++){ for(let k =2;k<array.length;k++){ if(array[i]>array[j] && array[i]>array[k]){ console.log(array[i]); } } } } } it returns 3 100 99. I want to return just 100 because it is the biggest number. Is there any improve ways to use loops to get the biggest value?
<javascript><arrays><for-loop>
2019-02-11 03:04:20
LQ_EDIT
54,624,745
how can I cache ID tokens from cognito for subsequent hits to API gateway?
how to implement this scenario in AWS? the user hits a API endpoint in API gateway, Cognito is used for verification. the user passes access id (after successful Cognito verification) to API gateway, then once the access token is exchanged with id token, can the id token be cached in API gateway or elastic cache for subsequent API hits to avoid the overhead of token exchange for each call?
<amazon-web-services><jwt><aws-api-gateway><amazon-cognito><amazon-elasticache>
2019-02-11 06:02:36
LQ_EDIT
54,625,867
why after I connection to sql server with library golang go-mssqldb , they print <nil>?
I have problem , after I connection to sql server , they print `<nil>` , what wrong with my code or problem with my connection to sql server because they just print `<nil>`? error can see in here [enter image description here][1] package main import ( "database/sql" "fmt" _ "github.com/denisenkom/go-mssqldb" "github.com/gin-gonic/gin" "net/http" ) func main() { db, err := sql.Open("sqlserver","sqlserver://sa:@localhost:1433?database=CONFINS&connection+timeout=30") if err != nil{ fmt.Print(err.Error()) } err = db.Ping() if err != nil { fmt.Print(err.Error()) } defer db.Close() type SMSBlast struct { SequenceID string MobilePhone string Output string WillBeSentDate string SentDate string Status string DtmUpd string } router := gin.Default() //Get a SMSBlast detail router.GET("/SMSBlast2/:SequenceID", func(context *gin.Context) { var( smsblast SMSBlast result gin.H ) SequenceID := context.Param("SequenceID") fmt.Println(db.Ping()) row := db.QueryRow("select SequenceID, MobilePhone, Output, WillBeSentDate, SentDate, Status, DtmUpd from SMSBlast2 = ?;",SequenceID) err = row.Scan(&smsblast.SequenceID, &smsblast.MobilePhone, &smsblast.Output, &smsblast.WillBeSentDate, &smsblast.SentDate, &smsblast.Status, &smsblast.DtmUpd) if err != nil{ //if no results send null result = gin.H{ "result": nil, "count": 0, } }else{ result = gin.H{ "result" : smsblast, "count" : 1, } } context.JSON(http.StatusOK, result) }) router.Run(":8080") } [1]: https://i.stack.imgur.com/OUSJc.png
<go><go-gin>
2019-02-11 07:38:10
LQ_EDIT
54,627,594
Remove everything from string after the second - with a single line in Javascript
<p>I want to ensure the language is always extracted from a string, only before the 2nd dash (-)</p> <p>So</p> <p><code>en-AU-Option-A</code></p> <p>becomes</p> <p><code>en-AU</code></p> <p>Is this possible with a single line of Javascript?</p>
<javascript><node.js><regex>
2019-02-11 09:40:21
LQ_CLOSE
54,628,606
How to fix problem close drpdown when i click outside it
I am developping an angular 5 project. My home page is composed by many components. In navbarComponent i have a dropdown list. I want when the dropdown list is open if i click outside it,it will close automatically. This is my code: ngOnInit() { this.showMenu = false;} toggle() { this.showMenu = !this.showMenu; } <div *ngIf="isConnect" class=" userStyle dropdown-toggle " (click)="toggle()"> <ul class="dropdown-menu subMenu" role="menu" *ngIf="showMenu"> <li (click)="profile()" class="subMenuItem"> PROFILE</li> <li (click)="administration()" class="subMenuItem subMenuItem-last">ADMINISTRATION</li> <li class="subMenuItem subMenuItem-last"><button class="btn blue-btn" (click)="logout()" ><mat-icon mat-list-icon fontIcon="icon-logout"></mat-icon>LOGOUT</button></li> </ul> </div>
<javascript><angular><typescript>
2019-02-11 10:36:32
LQ_EDIT
54,628,799
WPF Path disappears at some size
<p>I have encountered this problem while scaling graph, which is drawn over GIS control Greatmap. But a simple experiment persuades me that problems is somewhere deeper in WPF.</p> <p>Consider simple WPF application:</p> <p>This is MainWindow.xaml</p> <pre><code>&lt;Grid&gt; &lt;StackPanel&gt; &lt;Slider ValueChanged="Size_Changed" Minimum="0" Maximum="300000"/&gt; &lt;TextBox x:Name="Value"&gt;&lt;/TextBox&gt; &lt;/StackPanel&gt; &lt;Canvas&gt; &lt;Path x:Name="MyPath" Stroke="Black" StrokeThickness="2" /&gt; &lt;/Canvas&gt; &lt;/Grid&gt; </code></pre> <p>And this is its code behind</p> <pre><code>private void Size_Changed(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e) { if (MyPath == null) return; var g = new StreamGeometry(); using (var s = g.Open()) { var pointA = new Point(0, 200); s.BeginFigure(pointA, false, false); var pointB = new Point(e.NewValue, 200); s.PolyLineTo(new[] {pointB}, true, true); Value.Text = $"zoom = {e.NewValue:0.0} ; pointA = {pointA.X:#,0} ; pointB = {pointB.X:#,0}"; } g.Freeze(); MyPath.Data = g; } </code></pre> <p>While I drag slider from 0 to 249999 it’s all right. I can see line on my view. But at the very moment slider’s value becomes 250000 – line disappears.</p> <p>Is there any limitations in WPF ?</p>
<c#><wpf>
2019-02-11 10:45:54
HQ
54,629,756
ow can I create an access data base that delete entries after a specific dates
How can I create an access data base that delete entries after a specific dates For example, the expiry date of a medicine in my stock is today. The entry of that medicine must be automatically deleted from my database after today. ** > what macro programming must I do????? **
<ms-access>
2019-02-11 11:38:11
LQ_EDIT
54,630,215
Run opencv scripts as a part of a python program
I wish to run scripts from the OpenCV repository (Specifically from [https://github.com/opencv/opencv/tree/master/samples/dnn][1] ), as a part of a Python program. What is the best way doing so? Can I import the relevant files as a part of the cv package? thanks [1]: https://github.com/opencv/opencv/tree/master/samples/dnn
<python><opencv>
2019-02-11 12:03:35
LQ_EDIT
54,630,728
Combining MVC + Blazor in the same project
<p>Our current application is now running on ASP.NET Core (MVC) and I was wondering is there will be an offical way to use MVC and Blazor (client side) in the same project?</p> <p>The reason why I want to do that is because we won't be able to migrated from MVC to Blazor in one big bang since, the application is just too big. I was thinking on a step by step transition from MVC to Blazor. Just not sure if this will be possible?</p>
<.net><asp.net-core><blazor>
2019-02-11 12:33:48
HQ
54,630,920
FirebaseFirestoreException: FAILED_PRECONDITION
<p>To get the data from the firestore collection for instance update I tried the below query.</p> <p>docRef.whereArrayContains().orderBy().limit()</p> <p>com.google.firebase.firestore.FirebaseFirestoreException: FAILED_PRECONDITION: The query requires an index. You can create it here:</p>
<android><google-cloud-firestore>
2019-02-11 12:45:20
LQ_CLOSE
54,631,144
How you generate create query from existing table using java?
<p>I have few tables I want to generate create query(ddl) from existing tables , and convert to postgres compatible one from oracle .</p>
<java><sql><oracle>
2019-02-11 12:57:06
LQ_CLOSE
54,633,075
c# read block of lines in text file
I am writing a program to read a log file. each entry starts with a time-stamp, except when there is an error, which in this case, I would have multiple lines for the error message and without time-stamp. the file looks like this: 20190207 14:23:10.123 info Read input 20190207 14:23:11.001 info connecting to database 20190207 14:23:17.101 error truncating the table customer. Error code XXXX the file was blocked. I would like to store every entry with its time-stamp, event type, and message in a table that has three columns, one column for the time-stamp (datetime) and another column for the evens(info/warning/error), and a column for the text (data type text). how do I iterate through the file and read all the entries including the error message which sometimes be in multiple lines?
<c#><loops><text-files><logfile>
2019-02-11 14:46:01
LQ_EDIT
54,633,690
How can I use multiple refs for an array of elements with hooks?
<p>As far as I understood I can use refs for a single element like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const { useRef, useState, useEffect } = React; const App = () =&gt; { const elRef = useRef(); const [elWidth, setElWidth] = useState(); useEffect(() =&gt; { setElWidth(elRef.current.offsetWidth); }, []); return ( &lt;div&gt; &lt;div ref={elRef} style={{ width: "100px" }}&gt; Width is: {elWidth} &lt;/div&gt; &lt;/div&gt; ); }; ReactDOM.render( &lt;App /&gt;, document.getElementById("root") );</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/react@16/umd/react.production.min.js"&gt;&lt;/script&gt; &lt;script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"&gt;&lt;/script&gt; &lt;div id="root"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>How can I implement this for an array of elements? Obviously not like that: (I knew it even I did not try it:)</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const { useRef, useState, useEffect } = React; const App = () =&gt; { const elRef = useRef(); const [elWidth, setElWidth] = useState(); useEffect(() =&gt; { setElWidth(elRef.current.offsetWidth); }, []); return ( &lt;div&gt; {[1, 2, 3].map(el =&gt; ( &lt;div ref={elRef} style={{ width: `${el * 100}px` }}&gt; Width is: {elWidth} &lt;/div&gt; ))} &lt;/div&gt; ); }; ReactDOM.render( &lt;App /&gt;, document.getElementById("root") );</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/react@16/umd/react.production.min.js"&gt;&lt;/script&gt; &lt;script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"&gt;&lt;/script&gt; &lt;div id="root"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>I have seen <a href="https://github.com/facebook/react/issues/14072" rel="noreferrer">this</a> and hence <a href="https://github.com/facebook/react/issues/14490#issuecomment-454973512" rel="noreferrer">this</a>. But, I'm still confused about how to implement that suggestion for this simple case. </p>
<javascript><reactjs><react-hooks>
2019-02-11 15:18:46
HQ
54,634,090
Matching line items for bank reconcilition
I am preparing bank reconciliation file to match the negative value with a positive one. in below table there are negative values which need to be reconciled/match with the positive one. for example A4 (5076) is the sum of negative value A2+A6+A8 (-5076) which are reconciling each other and making zero. i want a excel coding which reconcile all the positive values with the negative values. please help A B 1 -5425 2 -4125 3 -2632 4 5076 5 -222 6 -906 7 8279 8 -45 9 -254 10 -542
<excel><vba>
2019-02-11 15:40:34
LQ_EDIT
54,634,093
flutter wrap text instead of overflow
<p>When creating a Text widget with a long string in Flutter, it wraps its text when put directly in a Column. However, when it is inside Column-Row-Column, the text overflows the side of the screen.</p> <p>How do I wrap text inside a Column-Row-Column? And what is the reason for this difference? It would seem logical to me that any child of the upper column would have the same width? Why is the width unbounded?</p> <p>I tried putting the text in Expanded, Flexible, Container and FittedBox, based on other answers, but it leads to new errors I don't understand.</p> <p>Example:</p> <pre><code>MaterialApp( title: 'Text overflow', home: Scaffold( appBar: AppBar(title: Text("MyApp"),), body: Column( children: &lt;Widget&gt;[ Row( children: &lt;Widget&gt;[ // The long text inside this column overflows. Remove the row and column above this comment and the text wraps. Column( children: &lt;Widget&gt;[ Text("Short text"), Text("Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. ") ], ), ], ), ], ), ), ) </code></pre>
<flutter><flutter-layout>
2019-02-11 15:40:53
HQ
54,634,685
Remove background-color from string in c#
<p>I want to remove background-color attribute from string (html) example :</p> <pre><code>&lt;p style=\"background-color:#eeeeee\"&gt;Hellow world&lt;/p&gt; </code></pre> <p>will be </p> <pre><code>&lt;p &gt;Hellow world&lt;/p&gt; </code></pre> <p>or </p> <pre><code>&lt;p style=\"\"&gt;Hellow world&lt;/p&gt; </code></pre> <p>in c#</p>
<c#><regex>
2019-02-11 16:14:37
LQ_CLOSE
54,636,137
How to add info from textbox to SQL
<p>How to insert every line in HTML texbox to new row in MySQL database using PHP.</p>
<php><html><mysql><sql>
2019-02-11 17:37:20
LQ_CLOSE
54,636,248
How do I convert a String that looks like an int to the correct format?
<p>Let's say I have a String variable that looks like this. <code>String milli = "2728462"</code> is there a way to convert it to look something like this <code>2,252,251</code> which I guess I want as a long.</p> <p>The thing is it will be passing strings in this format <code>1512</code> <code>52</code> <code>15010</code> <code>1622274628</code></p> <p>and I want it to place the <code>,</code> character where it needs, so if the number is <code>1000</code> then place it like so <code>1,000</code> and <code>100000</code> then <code>100,000</code> etc.</p> <p>How do I properly convert a String variable like that?</p> <p>Because this</p> <pre><code>String s="9990449935"; long l=Long.parseLong(s); System.out.println(l); </code></pre> <p>Will output <code>9990449935</code> and not <code>9,990,449,935</code></p>
<java>
2019-02-11 17:45:32
LQ_CLOSE