title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
JavaScript Safari - SyntaxError: Unexpected token '>'
<p>I have the problem that this JavaScript snippet runs in Firefox / Chrome without any problem, and Safari I get error: "SyntaxError: Unexpected token '>'".</p> <p>Here's the code:</p> <pre><code>window.onclick = (test) =&gt; { const googleWindow = window.open(); fakeAjax(response =&gt; { googleWindow.location.replace(`https://google.com?q=${response}`); }); }; function fakeAjax(callback) { setTimeout(() =&gt; { callback('example'); }, 1); } </code></pre> <p>I've googled and have already seen here in the forum, the problem there appears often, unfortunately I have not found a suitable solution.</p> <p>Thank you in advance Best regards</p>
0
Margin-bottom not working in flexbox
<p>I have an issue where I have a flexbox, but I don't exactly want every single element to be spaced according to the properties given, so I want to play with margins.</p> <p>I have a header at the top of the box but I want spacing between it and the rest of the elements.</p> <p>So I want my list of <code>p</code> elements to be grouped together but spaced farther away from the heading.</p> <p>However, when I do <code>margin-bottom</code> it isn't having an effect (when I increase or decrease <code>margin-bottom</code> nothing changes).</p> <p>I was originally doing it in percents and changed it to pixels but that doesn't seem to be the issue either.</p> <p>In the snippet I would have no problem with how it looks but on a bigger browser there's hardly any space between the heading and the <code>p</code> elements which is the issue. </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-css lang-css prettyprint-override"><code>.container { display: flex; position: relative; flex-wrap: wrap; justify-content: flex-start; align-items: stretch; min-height: 70vh; width: 70%; margin: 5% auto 8% auto; background-color: white; } .container p { margin-bottom: 2%; } .container h2 { color: orange; font-size: 34px; } .middle p:first-child { margin-top: 8%; } .bspace { margin-bottom: 50px; } .box h2 { color: orange; text-align: center; } .left { display: flex; flex-flow: row wrap; align-items: center; justify-content: space-around; order: 1; width: 30%; } .middle { display: flex; flex-flow: column wrap; order: 2; width: 45%; height: 100%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;div class="left"&gt; &lt;img src="home.jpg" alt="Picture of kid"&gt; &lt;img src="catering.jpg" alt="Picture of kid"&gt; &lt;/div&gt; &lt;div class="middle"&gt; &lt;h2 class="bspace"&gt; Some Text &lt;/h2&gt; &lt;p&gt;Sample&lt;/p&gt; &lt;p&gt;Sample&lt;/p&gt; &lt;p&gt;Sample&lt;/p&gt; &lt;p&gt;Sample&lt;/p&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
0
Running Jupyter with multiple Python and IPython paths
<p>I'd like to work with Jupyter notebooks, but have had difficulty doing basic imports (such as import matplotlib). I think this was because I have several user-managed python installations. For instance: </p> <pre><code>&gt; which -a python /usr/bin/python /usr/local/bin/python &gt; which -a ipython /Library/Frameworks/Python.framework/Versions/3.5/bin/ipython /usr/local/bin/ipython &gt; which -a jupyter /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter /usr/local/bin/jupyter </code></pre> <p>I used to have anaconda, but removed if from the ~/anaconda directory. Now, when I start a Jupyter Notebook, I get a Kernel Error:</p> <pre><code>File "/Library/Frameworks/Python.framework/Versions/3.5/lib/pytho‌n3.5/subprocess.py", line 947, in init restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/pytho‌n3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: '/Users/npr1/anaconda/envs/py27/bin/python' </code></pre> <p>What should I do?!</p>
0
How do I import a Groovy class into a Jenkinfile?
<p>How do I import a Groovy class within a Jenkinsfile? I've tried several approaches but none have worked.</p> <p>This is the class I want to import:</p> <p><strong>Thing.groovy</strong></p> <pre><code>class Thing { void doStuff() { ... } } </code></pre> <p>These are things that don't work:</p> <p><strong>Jenkinsfile-1</strong></p> <pre><code>node { load "./Thing.groovy" def thing = new Thing() } </code></pre> <p><strong>Jenkinsfile-2</strong></p> <pre><code>import Thing node { def thing = new Thing() } </code></pre> <p><strong>Jenkinsfile-3</strong></p> <pre><code>node { evaluate(new File("./Thing.groovy")) def thing = new Thing() } </code></pre>
0
react native - requiring unknown module
<p>I have been trying to load local image files in ListView. </p> <p>It does work when I hard code:</p> <p><code>return &lt;Image source={require('./public/image1.png')} style={{width: 60, height: 60}}/&gt;</code></p> <p>However, it doesn't work when I read the path of the image like this:</p> <pre><code>var path = rowData.thumbnail; console.log(path); // './public/image1.png' return &lt;Image source={require(path)} style={{width: 60, height: 60}}/&gt; </code></pre> <p>or like this:</p> <pre><code>return &lt;Image source={require(rowData.thumbnail)} style={{width: 60, height: 60}}/&gt; </code></pre> <p>with this error message,</p> <blockquote> <p>Requiring unknown module"'./public/image1.png'". If you are sure the module is there, try restarting the packager or running "npm install".</p> </blockquote> <p>Could you please give me an advice to read the path from the object? I attached the full code below. Thank you in advance.</p> <pre><code>class MyClass extends Component { constructor(props) { super(props); const ds = new ListView.DataSource({rowHasChanged: (r1, r2) =&gt; r1 !== r2}); let data = importedData.map(function(d) { return { thumbnail: "'./public" + d.thumbnail + "'" } }); this.state = { dataSource: ds.cloneWithRows(data) }; } renderRow(rowData) { var path = rowData.thumbnail; return &lt;View style={{flex: 1, flexDirection: 'row'}}&gt; &lt;Image source={require(path)} style={{width: 60, height: 60}}/&gt; &lt;/View&gt; } render() { return ( &lt;View style={{paddingTop: 22}}&gt; &lt;ListView dataSource={this.state.dataSource} renderRow={this.renderRow} /&gt; &lt;/View&gt; ); } } </code></pre>
0
WebAPI [FromBody] always null
<p>I received a request like this.</p> <pre><code>POST /API/Event?EventID=15&amp;UserID=1&amp;Severity=5&amp;DeptID=1&amp;FlowTag=CE HTTP/1.1 Content-Type: application/x-www-form-urlencoded Host: localhost:8088 Content-Length: 9 Expect: 100-continue Connection: Keep-Alive HTTP/1.1 100 Continue Desc=test </code></pre> <p>And my WebAPI interface is like this:</p> <pre><code>[Route("API/Event"), HttpPost] public IHttpActionResult StationCreateWorkItem(long EventID, long UserID, int Severity, long DeptID, string FlowTag, [FromBody] string Desc) </code></pre> <p>However, my Desc parameter is always NULL. May I know how can I retrieve the body content if there is no way for me to use [FromBody] in WebAPI (OWIN)</p> <p>Sorry, I can't change the incoming message, because it was developed by another company.</p>
0
Trying to understand Python loop using underscore and input
<p>One more tip - if anyone is learning Python on HackerRank, knowing this is critical for starting out.</p> <p>I'm trying to understand this code:</p> <pre><code> stamps = set() for _ in range(int(input())): print('underscore is', _) stamps.add(raw_input().strip()) print(stamps) </code></pre> <p>Output:</p> <pre><code> &gt;&gt;&gt;2 underscore is 0 &gt;&gt;&gt;first set(['first']) underscore is 1 &gt;&gt;&gt;second set(['second', 'first']) </code></pre> <ol> <li><p>I put 2 as the first raw input. How does the function know that I'm only looping twice? This is throwing me off because it isn't the typical...for i in xrange(0,2) structure. </p></li> <li><p>At first my thinking was the underscore repeats the last command in shell. So I added print statements in the code to see the value of underscore...but the values just show the 0 and 1, like the typical loop structure.</p></li> </ol> <p>I read through this post already and I still can't understand which of those 3 usages of underscore is being used. </p> <p><a href="https://stackoverflow.com/questions/5893163/what-is-the-purpose-of-the-single-underscore-variable-in-python">What is the purpose of the single underscore &quot;_&quot; variable in Python?</a></p> <p>I'm just starting to learn Python so easy explanations would be much appreciated!</p>
0
Perfect scrollbar not working
<p>what am i missing in the following code? Why is <a href="http://noraesae.github.io/perfect-scrollbar/" rel="nofollow">Perfect scrollbar</a> horribly crashing?</p> <p>It seems it's messing up myDiv scrollbar with browser main scrollbar... any help is appreciated.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;meta charset="utf-8" /&gt; &lt;link href="perfect-scrollbar.min.css" type="text/css" rel="stylesheet"&gt; &lt;style&gt; #myDiv { width: 400px; height: 400px; overflow: auto; background-color: #eeeeee; margin: auto; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="myDiv"&gt; &lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt;&lt;p&gt;Test perfect scrollbar&lt;/p&gt; &lt;/div&gt; &lt;script type="text/javascript" src="jquery-3.1.0.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="perfect-scrollbar.jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#myDiv').perfectScrollbar(); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thank you</p>
0
Updating NPM with Nodist
<p>I'm unable to update <code>npm</code>, and get it to use with <a href="https://github.com/marcelklehr/nodist" rel="nofollow noreferrer">Nodist</a>.</p> <p>Whenever I try to update <code>npm</code> with the command</p> <pre><code>npm install -g npm </code></pre> <p>the following message comes right after executing it:</p> <blockquote> <p>(node:5304) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.</p> <p>C:\Program Files (x86)\Nodist\v\nodev6.5.0\npm -> C:\Program Files (x86)\Nodist\v\nodev6.5.0\node_modules\npm\bin\npm-cli.js</p> <p>[email protected] C:\Program Files (x86)\Nodist\v\nodev6.5.0\node_modules\npm</p> </blockquote> <p>Doing an <code>npm -v</code> right after, gives me the previous version:</p> <pre><code>...&gt; npm -v 2.14.10 </code></pre> <p>However, if you noticed the last line in the message above, there is <code>[email protected]</code> which means it is somehow trying to install <em>that</em> version of <code>npm</code>.</p> <p>I also followed instructions from <a href="https://askubuntu.com/questions/562417/how-do-you-update-npm-to-the-latest-version"><em>this</em></a> post for Ubuntu users and <a href="https://stackoverflow.com/questions/18412129/how-do-i-update-node-and-npm-on-windows"><em>this</em></a> for Windows users, but they seem to address issues with standalone <code>NodeJS</code> installations and <em>NOT</em> <code>NodeJS</code> + Nodist combo.</p> <p>Meanwhile, I was wondering if Nodist itself enables us to update <code>npm</code>, or in other words, does it have any version management feature for <code>npm</code> as well, just as it does for <code>node</code>.</p> <p>Thanks for any help in advance.</p> <hr> <h3>Additional Info</h3> <p>I am using Nodist <code>v0.7.1</code> on Windows 7.</p>
0
How to install openjdk "1.8.0_20-b26" on amazon Linux?
<p>I'm pretty new to Linux and I need to install openjdk <strong>1.8.0_20-b26</strong> (that specific version) on a machine in AWS. I'll appreciate if you could give some tips because it seems like using <code>yum</code> always install the latest one and trying to use <code>--showduplicates</code>yields nothing.</p> <p>I'll appreciate your help.</p>
0
How to fetch and reuse the CSRF token using Postman Rest Client
<p>I am using Postman Rest client for hitting the rest services. I am getting the following error when I try to execute the rest service from Postman client.</p> <pre><code>HTTP Status 403 - Cross-site request forgery verification failed. Request aborted. </code></pre> <p><a href="https://i.stack.imgur.com/ynwWL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ynwWL.png" alt="enter image description here"></a></p> <p>It appears that the rest services are secured by the implementation of CSRF token. Does anybody has any idea about how to fetch the CSRF token and reuse it for future requests?</p>
0
JPA insert object if not exists, do nothing if exists
<pre><code>@Entity @Table(name="PROPERTY_VALUES") public class PropertyValuesData extends AbstractData { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="VAL_ID") private Long id; @OneToOne(fetch = FetchType.EAGER, cascade= {CascadeType.PERSIST} ) @JoinColumn(name = "VAL_PROP_ID") private PropertyData property; } </code></pre> <p>Persist object:</p> <pre><code> public void createItem(TYPE item){ try{ em=EMFactory.createEntityManager(); em.getTransaction().begin(); em.persist(item); em.getTransaction().commit(); }catch(Exception e){ logger.error("Error while createItem", e); System.err.println(e.getMessage()); }finally { if(em!=null) em.close(); } } </code></pre> <p>I have 2 situation: 1) I create new object <code>PropertyValuesData</code>, which contain existing property (with id) -> then I want to ONLY add new <code>PropertyValuesData</code> 2) I create new object <code>PropertyValuesData</code>, with new property -> then I want to insert also new <code>PropertyData</code>.</p> <p>If I add <code>CascadeType.PERSIST</code>, then I can save new property, but for existing property it try insert it again. What should I do to avoid insert again the same property?</p>
0
RecyclerView creating margins between items
<p>first of all, sorry if this a stupid question. I'm not being lazy. So, the problem is, im trying to implement CardView/RecyclerView in an Android app. I made it, but the problem is that the cards are spaced one from another, and i don't know how to fix it. I explored the code but everything seems to be fine.</p> <p>The code : </p> <p>RecyclerView</p> <pre><code>&lt;android.support.v7.widget.RecyclerView android:id="@+id/collapsing_recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" android:padding="@dimen/activity_horizontal_margin"&gt; &lt;/android.support.v7.widget.RecyclerView&gt; </code></pre> <p>CardView item</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;android.support.v7.widget.CardView android:id="@+id/card_view" card_view:cardBackgroundColor="@color/colorAccent" android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="100dp" android:layout_margin="5dp" card_view:cardCornerRadius="2dp"&gt; &lt;TextView android:gravity="center" android:layout_width="match_parent" android:layout_height="match_parent" android:text="New Text" android:id="@+id/cardview.name" /&gt; &lt;/android.support.v7.widget.CardView&gt; &lt;/LinearLayout&gt; </code></pre> <p>Adapter :</p> <pre><code>public class MyRecyclerViewAdapter extends RecyclerView .Adapter&lt;MyRecyclerViewAdapter .DataObjectHolder&gt; { private static String LOG_TAG = "MyRecyclerViewAdapter"; private ArrayList&lt;CardViewItem&gt; mDataset; private static MyClickListener myClickListener; public static class DataObjectHolder extends RecyclerView.ViewHolder implements View .OnClickListener { TextView label; public DataObjectHolder(View itemView) { super(itemView); label = (TextView) itemView.findViewById(R.id.cardview_name); Log.i(LOG_TAG, "Adding Listener"); itemView.setOnClickListener(this); } @Override public void onClick(View v) { myClickListener.onItemClick(getAdapterPosition(), v); } } public void setOnItemClickListener(MyClickListener myClickListener) { this.myClickListener = myClickListener; } public MyRecyclerViewAdapter(ArrayList&lt;CardViewItem&gt; myDataset) { mDataset = myDataset; } @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.example_card_view, parent, false); DataObjectHolder dataObjectHolder = new DataObjectHolder(view); return dataObjectHolder; } @Override public void onBindViewHolder(DataObjectHolder holder, int position) { holder.label.setText(mDataset.get(position).getName());; } public void addItem(CardViewItem dataObj, int index) { mDataset.add(index, dataObj); notifyItemInserted(index); } public void deleteItem(int index) { mDataset.remove(index); notifyItemRemoved(index); } @Override public int getItemCount() { return mDataset.size(); } public interface MyClickListener { public void onItemClick(int position, View v); } } </code></pre> <p>Hope you guys can help me. Thanks!</p> <p>EDIT: So, i found the answer. The coulprit was the android:layout_height="match_parent" in my cardview item. I change it for "wrap_content" and fixed the problem. Thanks for the help guys! :)</p>
0
Angular2 - TypeError: this.http.get(...).toPromise is not a function
<p>i try to follow tutorial on angular.io (<a href="https://angular.io/docs/ts/latest/tutorial/toh-pt6.html" rel="noreferrer">Tour the Heroes</a>) But instead of tutorial I try to make real GET request on some JSON.</p> <p>My code looks like:</p> <pre><code> private userUrl = 'https://jsonplaceholder.typicode.com/users'; constructor(private http: Http) {} getUsersHttp(): Promise&lt;User[]&gt; { return this.http.get(this.userUrl) .toPromise() .then(response =&gt; response.json().data as User[]) .catch(this.handleError); } </code></pre> <p>To service I import just few basic things:</p> <pre><code>import { Injectable } from '@angular/core'; import { Headers, Http, Response } from '@angular/http'; import { User } from './user'; </code></pre> <p>Where <code>user.ts</code> is basicly copy of <code>heroe.ts</code> in TOH so:</p> <pre><code>export class User { id: number; name: string; } </code></pre> <p>How I call this specific method in service: First I try multiple things but while debugging i try just console.log it so:</p> <pre><code> console.log(this.userService.getUsersHttp()); </code></pre> <p>When page is loading in console i found multiple errors: First one is:</p> <blockquote> <p>EXCEPTION: TypeError: this.http.get(...).toPromise is not a function</p> </blockquote> <p>Second one is:</p> <blockquote> <p>EXCEPTION: TypeError: this.http.get(...).toPromise is not a functionBrowserDomAdapter.logError @</p> </blockquote> <p>Service it self looks fine. I added my service to <code>app.module.ts</code> in this line:</p> <pre><code>providers: [ HTTP_PROVIDERS, UserService ] </code></pre> <p>and it works if I directly return data with some function like (and comment out calling <code>getUsertHttp</code> function):</p> <pre><code> getUsers() { return [{'id': 1, 'name': 'User1'}, {'id': 2, 'name': 'User2'}]; } </code></pre> <p>I try to describe everything which may be important so sorry if question is kind long a bit. <strong>Please guys can you give me hint what i am doing wrong?</strong></p>
0
Error when resample dataframe with python
<p>I create a dataframe </p> <pre><code>df5 = pd.read_csv('C:/Users/Demonstrator/Downloads/Listeequipement.csv',delimiter=';', parse_dates=[0], infer_datetime_format = True) df5['TIMESTAMP'] = pd.to_datetime(df5['TIMESTAMP'], '%d/%m/%y %H:%M') df5['date'] = df5['TIMESTAMP'].dt.date df5['time'] = df5['TIMESTAMP'].dt.time date_debut = pd.to_datetime('2015-08-01 23:10:00') date_fin = pd.to_datetime('2015-10-01 00:00:00') df5 = df5[(df5['TIMESTAMP'] &gt;= date_debut) &amp; (df5['TIMESTAMP'] &lt; date_fin)] df5.info() &lt;class 'pandas.core.frame.DataFrame'&gt; Int64Index: 8645 entries, 145 to 8789 Data columns (total 9 columns): TIMESTAMP 8645 non-null datetime64[ns] ACT_TIME_AERATEUR_1_F1 8645 non-null float64 ACT_TIME_AERATEUR_1_F3 8645 non-null float64 ACT_TIME_AERATEUR_1_F5 8645 non-null float64 ACT_TIME_AERATEUR_1_F6 8645 non-null float64 ACT_TIME_AERATEUR_1_F7 8645 non-null float64 ACT_TIME_AERATEUR_1_F8 8645 non-null float64 date 8645 non-null object time 8645 non-null object dtypes: datetime64[ns](1), float64(6), object(2) memory usage: 675.4+ KB </code></pre> <p>I try to resample it per day like this : </p> <pre><code>df5.index = pd.to_datetime(df5.index) df5 = df5.set_index('TIMESTAMP') df5 = df5.resample('1d').mean() </code></pre> <p>But I get a problem : </p> <blockquote> <pre><code>KeyError Traceback (most recent call last) C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\indexes\base.py </code></pre> <p>in get_loc(self, key, method, tolerance) 1944 try: -> 1945 return self._engine.get_loc(key) 1946 except KeyError:</p> <pre><code>pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4154)() pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4018)() pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item </code></pre> <p>(pandas\hashtable.c:12368)()</p> <pre><code>pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item </code></pre> <p>(pandas\hashtable.c:12322)()</p> <pre><code>KeyError: 'TIMESTAMP' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) &lt;ipython-input-109-bf3238788c3e&gt; in &lt;module&gt;() 1 df5.index = pd.to_datetime(df5.index) ----&gt; 2 df5 = df5.set_index('TIMESTAMP') 3 df5 = df5.resample('1d').mean() C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\core\frame.py </code></pre> <p>in set_index(self, keys, drop, append, inplace, verify_integrity) 2835 names.append(None) 2836 else: -> 2837 level = frame[col]._values 2838 names.append(col) 2839 if drop:</p> <pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\core\frame.py </code></pre> <p>in <strong>getitem</strong>(self, key) 1995 return self._getitem_multilevel(key) 1996 else: -> 1997 return self._getitem_column(key) 1998 1999 def _getitem_column(self, key):</p> <pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\core\frame.py </code></pre> <p>in _getitem_column(self, key) 2002 # get column 2003 if self.columns.is_unique: -> 2004 return self._get_item_cache(key) 2005 2006 # duplicate columns &amp; possible reduce dimensionality</p> <pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\core\generic.py </code></pre> <p>in _get_item_cache(self, item) 1348 res = cache.get(item) 1349 if res is None: -> 1350 values = self._data.get(item) 1351 res = self._box_item_values(item, values) 1352 cache[item] = res</p> <pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\core\internals.py </code></pre> <p>in get(self, item, fastpath) 3288 3289 if not isnull(item): -> 3290 loc = self.items.get_loc(item) 3291 else: 3292 indexer = np.arange(len(self.items))[isnull(self.items)]</p> <pre><code>C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\indexes\base.py </code></pre> <p>in get_loc(self, key, method, tolerance) 1945 return self._engine.get_loc(key) 1946 except KeyError: -> 1947 return self._engine.get_loc(self._maybe_cast_indexer(key)) 1948 1949 indexer = self.get_indexer([key], method=method, tolerance=tolerance)</p> <pre><code>pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4154)() pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4018)() pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item </code></pre> <p>(pandas\hashtable.c:12368)()</p> <pre><code>pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item </code></pre> <p>(pandas\hashtable.c:12322)()</p> <pre><code>KeyError: 'TIMESTAMP' </code></pre> </blockquote> <p>Any idea please to help me to resolve this problem?</p> <p>Kind regards</p>
0
What is the variable $(MAKE) in a makefile?
<p>I am currently learning how to write makefiles. I've got the following makefile (which was automatically generated for a C-project that should run on an ARM chip), and I'm trying to understand it:</p> <pre><code> RM := rm -rf # All of the sources participating in the build are defined here -include sources.mk -include FreeRTOS/Supp_Components/subdir.mk -include FreeRTOS/MemMang/subdir.mk -... -include subdir.mk -include objects.mk ifneq ($(MAKECMDGOALS),clean) ifneq ($(strip $(S_UPPER_DEPS)),) -include $(S_UPPER_DEPS) endif ifneq ($(strip $(C_DEPS)),) -include $(C_DEPS) endif endif -include ../makefile.defs # Add inputs and outputs from these tool invocations to the build variables # All Target all: FreeRTOS_T02.elf # Tool invocations FreeRTOS_T02.elf: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' @echo 'Invoking: MCU GCC Linker' arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -specs=nosys.specs -specs=nano.specs -T LinkerScript.ld -Wl,-Map=output.map -Wl,--gc-sections -lm -o "FreeRTOS_T02.elf" @"objects.list" $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' $(MAKE) --no-print-directory post-build # Other Targets clean: -$(RM) * -@echo ' ' post-build: -@echo 'Generating binary and Printing size information:' arm-none-eabi-objcopy -O binary "FreeRTOS_T02.elf" "FreeRTOS_T02.bin" arm-none-eabi-size "FreeRTOS_T02.elf" -@echo ' ' .PHONY: all clean dependents .SECONDARY: post-build -include ../makefile.targets </code></pre> <p>I'm trying to wrap my head around the line <code>$(MAKE) --no-print-directory post-build</code> in the rule for making the <code>.elf</code> file.</p> <p>I cannot find a definition for the variable <code>$(MAKE)</code>, so I assume that it is something built-in. What is this line actually doing?</p>
0
Change popup menu style - not working
<p>I'm trying to apply style to Android popup menu. Menu is shown on button click. In my example I want to set black menu background.</p> <p>So, my menu layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:title="Item 1" android:id="@+id/menu1"&gt; &lt;/item&gt; &lt;item android:title="Item 2" android:id="@+id/menu2"&gt; &lt;/item&gt; &lt;/menu&gt; </code></pre> <p>Next, my activity layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.michal.popupmenu.MainActivity"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!"/&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:onClick="btnClick" android:nestedScrollingEnabled="true"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Code to show menu on button click:</p> <pre><code>public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void btnClick(View view) { showMenu(view); } public void showMenu(View v) { PopupMenu popup = new PopupMenu(this, v); popup.inflate(R.menu.popup_menu); popup.show(); } } </code></pre> <p>Styles xmle was generated automatically. I have only added menu style to set black menu background, here it is: </p> <pre><code>&lt;style name="PopupMenu" parent="Widget.AppCompat.PopupMenu"&gt; &lt;item name="android:popupBackground"&gt;@android:color/black&lt;/item&gt; &lt;/style&gt; &lt;!-- Base application theme. --&gt; &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt; &lt;!-- Customize your theme here. --&gt; &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt; &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt; &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt; &lt;item name="popupMenuStyle"&gt;@style/PopupMenu&lt;/item&gt; &lt;/style&gt; </code></pre> <p></p> <p>But still menu background is white and it should be black. Any ideas what's wrong?</p> <p>[edit] According to comments, updated code:</p> <pre><code>&lt;resources&gt; &lt;style name="PopupMenu" parent="@style/Widget.AppCompat.Light.PopupMenu"&gt; &lt;item name="android:popupBackground"&gt;#FF4081&lt;/item&gt; &lt;/style&gt; &lt;!-- Base application theme. --&gt; &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt; &lt;!-- Customize your theme here. --&gt; &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt; &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt; &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>Main activity:</p> <pre><code>public void showMenu(View v) { Context wrapper = new ContextThemeWrapper(getApplicationContext(), R.style.PopupMenu); PopupMenu popup = new PopupMenu(wrapper, v); // This activity implements OnMenuItemClickListener //popup.setOnMenuItemClickListener((PopupMenu.OnMenuItemClickListener) this); popup.inflate(R.menu.popup_menu); popup.show(); } </code></pre> <p>Result is not what I expect</p> <p><a href="https://i.stack.imgur.com/uepk1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uepk1.png" alt="result"></a></p> <p>Menu background is still black, not a color I want to set.</p>
0
Make padding responsive
<p>I just started using Bootstrap, and I'm new in front-end development in general. I'm having a problem with padding, since it remains the same size in desktop and mobile devices.</p> <p>HTML code:</p> <pre><code> &lt;div class="container" id="i-container"&gt; &lt;h3&gt;We possess high quality products &amp;mdash; therefore our customers are always loyal&lt;/h3&gt; &lt;/div&gt; </code></pre> <p>CSS code:</p> <pre><code> #i-container{ border: solid; border-color: rosybrown; padding-left: 150px padding-top: 10px; } </code></pre> <p>As I mentioned above, in mobile devices the padding remains the same (it doesn't seem to be responsive). I tried using <em>em</em> too, by the way. It doesn't help either.</p>
0
Drop specific rows from multiindex Dataframe
<p>I have a multi-index dataframe that looks like this:</p> <pre><code> start grad 1995-96 1995-96 15 15 1996-97 6 6 2002-03 1 1 2007-08 1 1 </code></pre> <p>I'd like to drop by the specific values for the first level (level=0). In this case, I'd like to drop everything that has 1995-96 in the first index.</p>
0
Change Window.print() paper orientation
<p>I want to change paper mode (orientation) on the window print. I want to change it programatically but i could not find anything.</p> <blockquote> <p>window.print()</p> </blockquote> <p>But i do not know , how can i do it.</p> <pre><code>@media print{@page {size: landscape}} </code></pre> <p>I dont need it.</p> <pre><code> function printWindow() { window.print({ /* some code here? */ }); } </code></pre>
0
how to inspect element for xcode ui test like appium inspector
<p>I am doing xcode ui test forl an app. Previously i used</p> <pre><code>appium </code></pre> <p>by which i can know the detail path of any element. Through its inspector, i can know the element name or xpath or anything.</p> <p>But as per request, recently i switched to xcode ui test.</p> <p>I am facing issue in this new technology. I can't get the element details.</p> <p>It gives details through record but this does not work all time. </p> <p>Sometimes it's too much long.</p> <pre><code>Is there any way to inspect the element like appium inspector so that i can write my element path accordingly by myself without recording? </code></pre>
0
How can I add an assembly binding redirect to a .net core unit test project?
<p>I'm trying to create a .net core unit test project against framework 4.6.1 which tests an project dependent on Microsoft.SqlServer.Types (10.0.0.0). Prior to .net core I'd add an app.config file with the binding redirect. I've tried this but the binding redirect does not seem to be picked up when I run from visual studio. What can I do to fix the binding redirect?</p>
0
ASP.Net Core localization
<p>ASP.Net core features <a href="https://docs.asp.net/en/latest/fundamentals/localization.html" rel="noreferrer">new support for localization</a>.</p> <p>In my project I need only one language. For most of the text and annotations I can specify things in my language, but for text coming from ASP.Net Core itself the language is English.</p> <p>Examples:</p> <ul> <li>Passwords must have at least one uppercase ('A'-'Z').</li> <li>Passwords must have at least one digit ('0'-'9').</li> <li>User name '[email protected]' is already taken.</li> <li>The E-post field is not a valid e-mail address.</li> <li>The value '' is invalid.</li> </ul> <p>I've tried setting the culture manually, but the language is still English. </p> <pre><code>app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("nb-NO"), SupportedCultures = new List&lt;CultureInfo&gt; { new CultureInfo("nb-NO") }, SupportedUICultures = new List&lt;CultureInfo&gt; { new CultureInfo("nb-NO") } }); </code></pre> <p>How can I change the language of ASP.Net Core, or override its default text?</p>
0
How to debug angular app using angular-cli webpack?
<p>I used [email protected] before and now I updated to angular-cli@webpack beta.11. After a lot of custom changes I got it to work.</p> <p>The only thing is that now I can not debug my angular app using webstorm and chrome debugger because I don't get any ts files using ng serve. With [email protected] it was very easy to debug my app using the Jetbrains Plugin.</p> <p>How can I debug my angular app with Webstorm and the Chrome Debugger using ng serve?</p>
0
How to display Table in README.md file in Github?
<p>I want to display a table in readme.md file. I read <a href="https://help.github.com/enterprise/11.10.340/user/articles/github-flavored-markdown/" rel="noreferrer">GitHub Flavored Markdown</a> and followed what it said. So this is my table:</p> <pre><code>| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 | </code></pre> <p>However, I don't see any table and result looks like:</p> <p><a href="https://i.stack.imgur.com/xZVYe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xZVYe.png" alt="enter image description here"></a></p>
0
Replace all error values of all columns after importing datas (while keeping the rows)
<p>An Excel table as data source may contain error values (#NA, #DIV/0), which could disturbe later some steps during the transformation process in <a href="https://support.office.com/en-us/article/Introduction-to-Microsoft-Power-Query-for-Excel-6e92e2f4-2079-4e1f-bad5-89f6269cd605" rel="noreferrer">Power Query</a>.<br> Depending of the following steps, we may get no output but an error. So how to handle this cases?</p> <p>I found two standard steps in Power Query to catch them:</p> <ul> <li><a href="https://msdn.microsoft.com/en-us/library/mt260807.aspx" rel="noreferrer">Remove errors</a> (UI: Home/Remove Rows/Remove Errors) -> all rows with an error will be removed </li> <li><a href="https://msdn.microsoft.com/en-us/library/mt260833.aspx" rel="noreferrer">Replace error values </a>(UI: Transform/Replace Errors) -> the columns have first to be selected for performing this operations.</li> </ul> <p>The first possibility is not a solution for me, since I want to keep the rows and just replace the error values. </p> <p>In my case, my data table will change over the time, means the column name may change (e.g. years), or new columns appear. So the second possibility is too static, since I do not want to change the script each time.</p> <p>So I've tried to get a dynamic way to clean all columns, indepent from the column names (and number of columns). It replaces the errors by a null value.</p> <pre><code>let Source = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content], //Remove errors of all columns of the data source. ColumnName doesn't play any role Cols = Table.ColumnNames(Source), ColumnListWithParameter = Table.FromColumns({Cols, List.Repeat({""}, List.Count(Cols))}, {"ColName" as text, "ErrorHandling" as text}), ParameterList = Table.ToRows(ColumnListWithParameter ), ReplaceErrorSource = Table.ReplaceErrorValues(Source, ParameterList) in ReplaceErrorSource </code></pre> <p>Here the different three queries messages, after I've added two new column (with errors) to the source:<br> <a href="https://i.stack.imgur.com/F0nIC.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/F0nIC.jpg" alt=""></a></p> <p>If anybody has another solution to make this kind of data cleaning, please write your post here.</p>
0
How to call an AJAX function on page load
<p>I need to call GetAllProperties() function during page loading instead of calling the GetAllProperties() function after page is fully loaded.</p> <p>I tried window.onload = GetAllProperties; but it didn't work</p> <p>My code looks like this:</p> <pre><code>&lt;script type="text/javascript"&gt; window.onload = GetAllProperties; function GetAllProperties() { $.ajax({ cache: false, url: '/Home/GetAllProperties', type: 'GET', contentType: "application/json; charset=utf-8", success: function (response) { if (response.list.length &gt; 0) { console.log(response.list) var $data = $('&lt;table id="mytable" class="table table-striped"&gt; &lt;/table&gt;'); var header = "&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Property Name&lt;/th&gt;&lt;th&gt;Edit&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;"; $data.append(header); $.each(response.list, function (i, row) { var $row = $('&lt;tr/&gt;'); $row.append($('&lt;td/&gt;').html(row.PropertyName)); $hidden = $(' &lt;input type="hidden" name="hid" value= "' + row.PropertyId + '"&gt;'); $row.append($hidden); $editButton = $("&lt;button class='editbtn' id='mybtn'&gt;Edit&lt;/button&gt;"); $row.append($editButton); $deleteButton = $("&lt;button class='deletebtn' id='delbtn'&gt;Delete&lt;/button&gt;"); $row.append($deleteButton); $data.append($row); }); $("#MyDiv").empty(); $("#MyDiv").append($data); } else { } }, error: function (r) { alert('Error! Please try again.' + r.responseText); console.log(r); } }); } &lt;/script&gt; </code></pre>
0
How to get device IMEI number programmatically using swift
<p>Is there any way to find device IMEI using swift code and any framework like (coreTelephone)? </p>
0
Spring boot @CachePut, how it works
<p>I'm trying to update values in spring cache, however @CachePut does not replace actual value, but put another value with the same key:</p> <p>Cachename: noTimeCache:</p> <ul> <li>Key: SYSTEM_STATUS, val: ON</li> <li>Key: SYSTEM_STATUS, val: OFF</li> </ul> <p>1.Why?</p> <p>My cache service:</p> <pre><code>@CachePut(value = "noTimeCache", key = "#setting.getSetting().name()") public String updateGlobalCacheValue(GlobalSettings setting) { System.out.println("Setting: " + setting.getSetting().name() + ", val: " + setting.getValue()); return setting.getValue(); } </code></pre> <p>I know it's looks funny but i need to work with jpa repositories. Maybe someone have better solution.</p> <p>2.Why can't I use function argument as @Cacheable key like this?</p> <pre><code>@Cacheable(value = "noTimeCache", key = "#setting.name()", unless = "#result == null") @Query("SELECT gs.value FROM GlobalSettings gs WHERE gs.setting = ?1") String getGlobalSettingValue(Settings setting); </code></pre> <p>It tells me setting is null.</p> <p>3.Is the way to override @Repositository interface methods, for example save() to add annotation @Cacheable to them?</p>
0
When using JavaScript's reduce, how do I skip an iteration?
<p>I am trying to figure out a way to conditionally break out of an iteration when using JavaScript's <code>reduce</code> function. </p> <p>Given the following code sums an array of integers and will return the number <code>10</code>: </p> <pre><code>[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, currentIndex, array) { return previousValue + currentValue; }); </code></pre> <p>How can I do something like this: </p> <pre><code>[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, currentIndex, array) { if(currentValue === "WHATEVER") { // SKIP or NEXT -- don't include it in the sum } return previousValue + currentValue; }); </code></pre>
0
get file content of google docs using google drive API v3
<p>Is there any way to get the content of native files (Google Docs) using Google Drive API v3? I know API v2 supports this with the exportLinks property, but it doesn't work anymore or has been removed.</p>
0
How do I change the border lines COLOUR on the table view
<p>I have already tried the following code from <a href="https://stackoverflow.com/questions/17403875/remove-grid-line-in-tableview">Remove grid line in tableView</a> , but that only allows me to change the vertical line colour and not the horizontal line colour. </p> <p>So, I am trying to change the white border line colour which you can see in the image below, how would I change this colour? I am using JavaFX with CSS.</p> <p><a href="https://i.stack.imgur.com/o60Ih.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o60Ih.png" alt="TableView"></a></p> <p>Here is my CSS:</p> <pre class="lang-css prettyprint-override"><code>.table-view{ -fx-background-color: transparent; } .table-view:focused{ -fx-background-color: transparent; } .table-view .column-header-background{ -fx-background-color: #262626; } .table-view .column-header-background .label{ -fx-background-color: transparent; -fx-text-fill: #0ed9e0; } .table-view .column-header { -fx-background-color: transparent; } .table-view .table-cell{ -fx-text-fill: #0ed9e0; -fx-alignment: center; } .table-row-cell{ -fx-background-color: -fx-table-cell-border-color, #2b2a2a; -fx-background-insets: 0, 0 0 1 0; -fx-padding: 0.0em; /* 0 */ } .table-row-cell:odd{ -fx-background-color: -fx-table-cell-border-color, #262626; -fx-background-insets: 0, 0 0 1 0; -fx-padding: 0.0em; /* 0 */ } .table-row-cell:selected { -fx-background-color: #005797; -fx-background-insets: 0; -fx-background-radius: 1; } </code></pre>
0
How to check Port 1433 is working for Sql Server or not?
<p>How can I check whether port 1433 is open for Sql Server or not? I have set in bound and out bound rules, checked in SQL config manager but not sure whether it is working.</p>
0
Two-Way databinding in EditText
<p>I have this object </p> <pre><code>ObservableInt someNumber; public ObservableInt getSomeNumber() { return someNumber; } public void setSomeNumber(ObservableInt number) { this.someNumber = number; } </code></pre> <p>and my AppCompatEditText is like this in xml code:</p> <pre><code>&lt;android.support.v7.widget.AppCompatEditText android:layout_width="0dp" android:layout_height="@dimen/agro_item_height" android:layout_weight="1" android:inputType="numberDecimal" android:text="@={String.valueOf(myObject.someNumber)}" android:gravity="center_horizontal"/&gt; </code></pre> <p>I'm having this error:</p> <pre><code>Error:Execution failed for task ':app:compileDebugJavaWithJavac'. java.lang.RuntimeException: failure, see logs for details. cannot generate view binders java.lang.NullPointerException at android.databinding.tool.expr.MethodCallExpr.generateCode(MethodCallExpr.java:69) at android.databinding.tool.expr.Expr.toFullCode(Expr.java:745) at android.databinding.tool.expr.Expr.assertIsInvertible(Expr.java:767) at android.databinding.tool.BindingTarget.addInverseBinding(BindingTarget.java:68) at android.databinding.tool.LayoutBinder.&lt;init&gt;(LayoutBinder.java:228) at android.databinding.tool.DataBinder.&lt;init&gt;(DataBinder.java:52) at android.databinding.tool.CompilerChef.ensureDataBinder(CompilerChef.java:83) at android.databinding.tool.CompilerChef.sealModels(CompilerChef.java:168) at android.databinding.annotationprocessor.ProcessExpressions.writeResourceBundle(ProcessExpressions.java:149) at android.databinding.annotationprocessor.ProcessExpressions.onHandleStep(ProcessExpressions.java:82) at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.runStep(ProcessDataBinding.java:154) at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.access$000(ProcessDataBinding.java:139) at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:66) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856) at com.sun.tools.javac.main.Main.compile(Main.java:523) at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129) at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138) at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:46) at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:104) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:53) at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38) at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35) at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25) at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:163) at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:145) at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:93) at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99) at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:237) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) </code></pre> <p>I already have tried just with </p> <pre><code>android:text="@={myObject.someNumber}" </code></pre> <p>but I'm having this error:</p> <pre><code>Error:Execution failed for task ':app:compileDebugJavaWithJavac'. java.lang.RuntimeException: Found data binding errors. ****/ data binding error ****msg:Cannot find the getter for attribute 'android:text' with value type int on android.support.v7.widget.AppCompatEditText. file:C:\Users\Moviit\AndroidStudioProjects\pbbchile-android\app\src\main\res\layout\row_agro_tab.xml loc:51:8 - 60:48 ****\ data binding error **** </code></pre> <p>Anybody has an example of how to do this?</p>
0
How conditional join if first matching has no row, use second matching
<p>My client table has some special rows that work this way. There are multiple customer records that belongs to the same customer but with slightly different column value. The tables belong to them and I can't change anything in their table, so I have to work on a script to deal with this.</p> <p>Now I need to compare customer data from main table and get the data from client table. The condition is as below:</p> <ol> <li><p>If the main table Id exists in client table, get the only record matching with main table Id column</p></li> <li><p>If the main table Id not exists in client table, use main table Idnumber to find and match Idnumber in client table. </p></li> </ol> <p>Below is an example of what I'm trying to achieve:</p> <p>Let's say this data exist in the main table and client table below:</p> <p><a href="https://i.stack.imgur.com/0ju23.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0ju23.png" alt="enter image description here"></a></p> <p>In the scenario above, my script should always pick the client table PKId 1 only and ignore the row PKId 2 in client table by matching the main table Id column and client table ClientId column. </p> <p>And for another scenario below:</p> <p><a href="https://i.stack.imgur.com/WE9Sx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WE9Sx.png" alt="enter image description here"></a></p> <p>Since the row PKId 1 has empty ClientId and there's no way to match the client Id 10 in client table, my script should use main table Idnumber to find and match record in the client table and would pick up the row PKId 2 by the Idnumber column.</p> <p>I wanted to do a case in the join condition but not sure how I should construct it. I'm thinking about something like below (not actual SQL statement, just some idea):</p> <pre><code>Select c.Id, c.Name, c.AuthorizeToken From Client c Left Join Main m on (If m.Id = c.ClientId has data return, get AuthorizeToken from that row only; else if m.Id = c.ClientId has no data return, use m.Idnumber = c.Idnumber to find and get AuthorizeToken) </code></pre> <p>Appreciate if can advice me on any alternative to achieve this. </p>
0
Media queries + browser zoom
<p>I've come across a super weird problem when it comes to media queries and browser zoom.</p> <p>I'm using Chrome 52.0.2743.116 m.</p> <p>The issue is this:</p> <p>When you zoom in using the browser zoom to 125% and resize the browser until tablet is supposed to kick in (max-width: 1024px), there seems to be a moment where neither max-width: 1024px or min-width: 1025px is true.</p> <p>If I change it to max-width: 1024.9px - it works.</p> <p>Here's a quick example:</p> <pre><code>&lt;div class="box"&gt; Text &lt;/div&gt; &lt;div class="box"&gt; Text &lt;/div&gt; &lt;div class="box"&gt; Text &lt;/div&gt; </code></pre> <p>And the CSS:</p> <pre><code>@media (max-width:768px) { .box { background: blue; } } @media (min-width: 769px) and (max-width: 1024px) { .box { background: red; } } @media (min-width:1025px) { .box { background: green; } } </code></pre> <p>Example: <a href="http://codepen.io/tomusborne/pen/EyrNvG" rel="nofollow">http://codepen.io/tomusborne/pen/EyrNvG</a></p> <p>Zoom in 125%, then resize down until it turns red. Resize up pixel by pixel, and you'll notice there's no background color at all for one pixel between tablet and desktop.</p> <p>Anyone know what's going on here? Is using 1024.9px a decent solution? Am I just going crazy?</p>
0
Execute stored procedure using entity framework
<p>is it possible to execute a stored procedure using EF, that select records from database from two or more tables using inner join and left outer join.</p> <p>my point of view is to avoid the method of doing joins in EF or LINQ, which i have many issues with it. </p> <p>so if i create that procedure, can i call it with parameters from user input, can assign the result to <code>.ToList()</code> method and then add the result to asp:repeater <code>.DataSource</code>. </p> <p>I know it may be a strange question, but i want to do this for many reasons first, to use EF because i feel more comfortable. second, to get rid of using joins in EF. third, i read somewhere that using stored procedure will enhance query performance, when used to call a query frequently.</p> <p>if any one could help me to answer these questions with an example i would be appreciate. </p>
0
How to display image from rails local project folder?
<p>Very basic question, but somehow I can't get it to work. I am trying to have an image located in project's local folder to display on Rails. Additionally, I am using bootstrap; thus I need to declare <code>class: &quot;img-responsive&quot;</code> as well. Here is the original code: <code>&lt;img class=&quot;img-responsive&quot; src=&quot;assets/img/mockup/img2.jpg&quot; alt=&quot;&quot;&gt;</code></p> <p>I have consulted <a href="https://stackoverflow.com/questions/31368682/how-to-use-the-image-tag-with-bootstrap-class-img-responsive-chapter-11">this post</a> which suggested <code>&lt;%= image_tag(&quot;xyz.png&quot;, class: &quot;img-responsive img-thumbnail img-circle&quot;) %&gt;</code> and <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html" rel="nofollow noreferrer">rubyonrails guide</a> which suggested <code>image_tag(&quot;/icons/icon.gif&quot;, class: &quot;menu_icon&quot;)</code>.</p> <p>I have tried</p> <pre><code>&lt;%= image_tag (&quot;assets/img/mockup/img2.jpg&quot;, class: &quot;img-responsive&quot;)%&gt; </code></pre> <p>and</p> <pre><code>&lt;%= image_tag &quot;assets/img/mockup/img2.jpg&quot; %&gt; </code></pre> <p>But it still does not work. I can confirm that the path is: <code>app/assets/img/mockup/img2.jpg</code></p> <p>How can I display the said image on rails app view?</p>
0
Not able to write Spark SQL DataFrame to S3
<p>I have installed spark 2.0 on EC2 &amp; I am using SparkSQL using Scala to retrieve records from DB2 &amp; I want to write to S3, where I am passing access keys to the Spark Context..Following is my code :</p> <pre><code>val df = sqlContext.read.format("jdbc").options(Map( "url" -&gt; , "user" -&gt; usernmae, "password" -&gt; password, "dbtable" -&gt; tablename, "driver" -&gt; "com.ibm.db2.jcc.DB2Driver")).option("query", "SELECT * from tablename limit 10").load() df.write.save("s3n://data-analytics/spark-db2/data.csv") </code></pre> <p>And it is throwing following exception :</p> <pre><code>org.apache.hadoop.fs.s3.S3Exception: org.jets3t.service.S3ServiceException: Service Error Message. -- ResponseCode: 403, ResponseStatus: Forbidden, XML Error Message: &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Error&gt;&lt;Code&gt;AccessDenied&lt;/Code&gt;&lt;Message&gt;Access Denied&lt;/Message&gt;&lt;RequestId&gt;1E77C38FA2DB34DA&lt;/RequestId&gt;&lt;HostId&gt;V4O9sdlbHwfXNFtoQ+Y1XYiPvIL2nTs2PIye5JBqiskMW60yDhHhnBoCHPDxLnTPFuzyKGh1gvM=&lt;/HostId&gt;&lt;/Error&gt; Caused by: org.jets3t.service.S3ServiceException: Service Error Message. at org.jets3t.service.S3Service.putObject(S3Service.java:2358) at org.apache.hadoop.fs.s3native.Jets3tNativeFileSystemStore.storeEmptyFile(Jets3tNativeFileSystemStore.java:162) </code></pre> <p>What is the exact problem occurring here as I am passing the Access Keys also to Sparkcontext ?? Any other way to write to S3??</p>
0
"Result of method is ignored"- what does this imply?
<p>For some methods I get the warning. This is what it says when expanded. The following code (<code>mkDirs()</code>) gives the warning</p> <pre><code>if (!myDir.exists()) { myDir.mkdirs(); } </code></pre> <blockquote> <p>Reports any calls to specific methods where the result of that call is ignored. Both methods specified in the inspection's settings and methods annotated with org.jetbrains.annotations.Contract(pure=true) are checked. For many methods, ignoring the result is perfectly legitimate, but for some methods it is almost certainly an error. Examples of methods where ignoring the result of a call is likely to be an error include java.io.inputStream.read(), which returns the number of bytes actually read, any method on java.lang.String or java.math.BigInteger, as all of those methods are side-effect free and thus pointless if ignored.</p> </blockquote> <p>What does it mean? How to to avoid it? How should it be addressed?</p>
0
Python 2.7 [Errno 113] No route to host
<p>I have 2 computers on the same LAN. The first PC has an ip address 192.168.178.30, the other PC has an ip address 192.168.178.26. Ping, traceroute, telnet, ssh, everything works between the two PCs. Both PCs run the same OS - CentOS 7 and both PCs have the same python version 2.7.5 (checked with the python -V command).</p> <p>I copied simple python code from a computer networking book. </p> <p>client.py</p> <pre><code>from socket import * serverName = '192.168.178.30' serverPort = 12000 clientSocket = socket(AF_INET, SOCK_STREAM) clientSocket.connect((serverName,serverPort)) sentence = raw_input('Input lowercase sentence: ') clientSocket.send(sentence) modifiedSentence = clientSocket.recv(1024) print 'From Server:', modifiedSentence clientSocket.close() </code></pre> <p>server.py</p> <pre><code>from socket import * serverPort = 12000 serverSocket = socket(AF_INET,SOCK_STREAM) serverSocket.bind(('192.168.178.30',serverPort)) serverSocket.listen(5) print 'The server is ready to receive' while 1: connectionSocket, addr = serverSocket.accept() sentence = connectionSocket.recv(1024) capitalizedSentence = sentence.upper() connectionSocket.send(capitalizedSentence) connectionSocket.close() </code></pre> <p>The code works when it is ran on the same PC (where the server is listening on localhost). When I run the client code on one PC and the server code on the other PC I get this error on the client side.</p> <pre><code>Traceback (most recent call last): File "client.py", line 5, in &lt;module&gt; clientSocket.connect((serverName,serverPort)) File "/usr/lib64/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 113] No route to host </code></pre> <p>Can someone help?</p>
0
How do I add trigger to an AWS Lambda function using AWS CLI?
<p>Any way of doing this using AWS CLI? <a href="https://i.stack.imgur.com/ME7la.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ME7la.png" alt="Adding trigger using AWS Management Console"></a></p>
0
How to access react-redux store outside of component
<p>I have file which exports various utility functions to use across components, and these functions needs to access redux state. How do I import the state object to this file?</p>
0
@ViewChild in *ngIf
<h2>Question</h2> <p>What is the most elegant way to get <code>@ViewChild</code> after corresponding element in template was shown?</p> <p>Below is an example. Also <a href="http://plnkr.co/edit/xAhnVVGckjTHLHXva6wp?p=preview" rel="noreferrer">Plunker</a> available.</p> <p><strong>Component.template.html:</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;layout&quot; *ngIf=&quot;display&quot;&gt; &lt;div #contentPlaceholder&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Component.component.ts:</strong></p> <pre class="lang-js prettyprint-override"><code>export class AppComponent { display = false; @ViewChild('contentPlaceholder', { read: ViewContainerRef }) viewContainerRef; show() { this.display = true; console.log(this.viewContainerRef); // undefined setTimeout(() =&gt; { console.log(this.viewContainerRef); // OK }, 1); } } </code></pre> <p>I have a component with its contents hidden by default. When someone calls <code>show()</code> method it becomes visible. However, before Angular 2 change detection completes, I can not reference to <code>viewContainerRef</code>. I usually wrap all required actions into <code>setTimeout(()=&gt;{},1)</code> as shown above. Is there a more correct way?</p> <p>I know there is an option with <code>ngAfterViewChecked</code>, but it causes too much useless calls.</p> <h2><a href="http://plnkr.co/edit/myu7qXonmpA2hxxU3SLB?p=preview" rel="noreferrer">ANSWER (Plunker)</a></h2>
0
Delete row from table and use bootstrap modal as confirmation
<p>I'm looking to delete a row from a table of users in my codeigniter framework project.</p> <p>I want to click the delete button, and have a modal window popup asking the user, if they are sure to delete the record, and upon clicking yes I would like to display another one confirming that it is complete.</p> <p>I'm just having a problem with passing the database dynamic ID to my ajax call without page refresh as I'm not sure how to go about it:-</p> <pre><code>&lt;div class = "wrapper"&gt; &lt;table class="table table-striped"&gt; &lt;thead class = "table_head"&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;First Name&lt;/th&gt; &lt;th&gt;Last Name&lt;/th&gt; &lt;th&gt;Username&lt;/th&gt; &lt;th&gt;Class&lt;/th&gt; &lt;th&gt;Edit&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody class ="searchable"&gt; &lt;?php echo validation_errors(); ?&gt; &lt;?php if (is_array($users)) {?&gt; &lt;?php foreach($users as $user){?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $user-&gt;ID;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $user-&gt;first_name;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $user-&gt;last_name;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $user-&gt;username;?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $user-&gt;class;?&gt;&lt;/td&gt; &lt;td&gt;&lt;a href ="&lt;?php echo base_url().'index.php/User/edit_user/'. $user-&gt;ID ;?&gt;"&gt; Edit&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a id = "mybutton" data-toggle="modal" data-target="#confirm_delete_modal" data-id="&lt;?php echo $user-&gt;ID;?&gt;"&gt; Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php }} ?&gt; &lt;?php if(!$users){ echo '&lt;div class="noresults"&gt;'; echo 'No users available'; echo '&lt;/div&gt;'; }?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>As can be seen above in the edit part, I need to pass the $user->ID to the modal window in order to delete the specified user.</p> <pre><code> &lt;div id="confirm_delete_modal" class="modal fade" role="dialog"&gt; &lt;div class="modal-body"&gt; &lt;p id = "valcomplete"&gt; Are you sure you wish to delete this user?&lt;/p&gt; &lt;/div&gt; &lt;a id ="confirmbutton" style = "cursor:pointer; color:black;"&gt;Yes&lt;/a&gt; &lt;a data-toggle="modal" data-target="#confirm_delete_modal" id ="exitbutton" style = " cursor:pointer; color:black;"&gt;No&lt;/a&gt; </code></pre> <p></p> <pre><code> &lt;div id="deleted" class="modal fade" role="dialog"&gt; &lt;div class="modal-body"&gt; &lt;p id = "valcomplete"&gt; User deleted&lt;/p&gt; &lt;/div&gt; &lt;a data-toggle="modal" data-target="#deleted" id ="exitbutton" style = "color:black;"&gt;Exit&lt;/a&gt; &lt;/div&gt; </code></pre> <p>What I have now:</p> <pre><code> $('#mybutton').click(function(){ var ID = $(this).data('id'); $('#confirm-button').data('id', ID); //set the data attribute on the modal button }); $('#confirm-button').click(function(){ var ID = $(this).data('id'); $.ajax({ url: "&lt;?php echo base_url(); ?&gt;index.php/Admin/delete_user/"+ID, type: "post", data:ID, success: function (data) { $("#confirm_delete_modal").modal('hide'); $("#deleted").modal('show'); } }); }); </code></pre> <p>Can anyone help me ?? Thanks</p>
0
JSON add node to an existing JObject
<p>I am trying to add a new node to an existing <code>JSON</code> <code>JObject</code>, but when I add it does not format correctly. It adds quotes around the entire node, and \ are put in place.</p> <p>Background: I am loading a <code>JSON</code> file, doing some logic then adding a node back in. Figured I can do it like this:</p> <pre><code>mainJson.Add("NewNode", JsonConvert.SerializeObject(MyObject)); File.WriteAllText("myfile.json", mainJson.ToString()); </code></pre> <p>Problem is that this is the result:</p> <pre><code>{ "JSONFile": [ { "More": "Nodes", "InThe": "File" } ], "Customers": "{\"FirstName\":\"Mike\",\"LastName\":\"Smith\"},{\"FirstName\":\"Jane\",\"LastName\":\"Doe\"}", } </code></pre> <p>I know that my JsonConvert.SerializeObject(MyObject) is working if I do this:</p> <pre><code>string json = JsonConvert.SerializeObject(MyObject); File.WriteAllText("myfile2.json" json); </code></pre> <p>The result is this:</p> <pre><code>[ { "FirstName": "Mike", "LastName": "Smith" }, { "FirstName": "Jane", "LastName": "Doe" } ] </code></pre> <p>What am I missing?</p> <p><strong>edit:</strong> Following @Swagata Prateek comment of;</p> <pre><code>mainJson.Add("Customers",JObject.FromObject(MyObject)); </code></pre> <blockquote> <p>An unhandled exception of type 'System.ArgumentException' occurred in Newtonsoft.Json.dll</p> <p>Additional information: Object serialized to Array. JObject instance expected.</p> </blockquote> <p>I should note that MyObject is actual <code>ObservableCollection</code> if that makes a difference</p>
0
angular js: ng-min \ ng-max
<p>I using angular js, combined with angular ui, to show modal window in my website. <strong>HTML</strong></p> <pre><code>&lt;script type="text/ng-template" id="myModalContent.html"&gt; &lt;div class="modal-header text-center"&gt; &lt;h3 class="modal-title" id="modal-title"&gt;Jump to page&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body text-center" id="modal-body"&gt; &lt;input type="number" ng-model="info.page" class="text-center" ng-enter="ok()" ng-min="{{info.min}}" ng-max="{{info.max}}" /&gt; &lt;div&gt;MAX: {{info.max}}&lt;/div&gt; &lt;div&gt;MIN: {{info.min}}&lt;/div&gt; &lt;button class="btn btn-primary" type="button" ng-click="ok()" style="margin-top: 20px;"&gt;OK&lt;/button&gt; &lt;/div&gt; &lt;/script&gt; </code></pre> <p>The user have to fill an input number in a range of <code>info.max</code> to <code>info.min</code>.</p> <p>Here the relevant angular code - Triggering the modal window opening:</p> <pre><code>function gotoPageDialog(fileNo, current, max) { var modalInstance = $uibModal.open({ templateUrl: 'myModalContent.html', controller: 'ModalInstanceCtrl', size: 'sm', resolve: { current_info: function() { return { fileNo: fileNo, page: current, max: max, min: 1 } } } }); modalInstance.result.then(function(result) { //... }; } } </code></pre> <p>And the modal window it self:</p> <pre><code>app.controller('ModalInstanceCtrl', function($scope, $uibModalInstance, current_info) { $scope.info = current_info; $scope.ok = function() { $uibModalInstance.close($scope.info); }; $scope.cancel = function() { $uibModalInstance.dismiss('cancel'); }; }); </code></pre> <p>The result is:</p> <p><a href="https://i.stack.imgur.com/RgtSY.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/RgtSY.jpg" alt="enter image description here"></a></p> <p>The input value is "-1", What's mean that the <code>ng-min</code> and <code>ng-max</code> range is not working.</p> <p>What I'm doing wrong?</p> <p>Thank you.</p>
0
How to to return an image with Web API Get method
<p>I need to return an image with a Web API Get method. The code below seems to work fine except that I get this message in the Fiddler's ImageView window, "This response is encoded, but does not claim to be an image." </p> <pre><code>public HttpResponseMessage Get() { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { HttpResponseMessage response = new HttpResponseMessage(); response.Content = new StreamContent(fs); response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return response; } } </code></pre> <p>I see the same result in the Fiddler with this code also:</p> <pre><code>public HttpResponseMessage Get() { HttpResponseMessage response = new HttpResponseMessage(); Byte[] b = (GetImageByteArray()); response.Content = new ByteArrayContent(b); response.Content.LoadIntoBufferAsync(b.Length).Wait(); response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); return response; } </code></pre> <p>I get the same result if I use .png format. </p> <p>Appreciate your help,</p>
0
pyinstaller creating EXE RuntimeError: maximum recursion depth exceeded while calling a Python object
<p>I am running WinPython 3.4.4.3 with pyinstaller 3.2 (obtained via pip install pyinstaller).</p> <p>Now I've got some really simple Qt4 code that I want to convert to EXE and I've run into problem that I cannot solve. </p> <p><strong>The Code:</strong></p> <pre><code>import sys import math from PyQt4 import QtGui, QtCore import SMui import numpy as np from scipy.interpolate import InterpolatedUnivariateSpline class SomeCalculation(QtGui.QMainWindow, SMui.Ui_MainWindow): def __init__(self): super(self.__class__, self).__init__() self.setupUi(self) self.setWindowTitle('Some Calculation') self.calculate.clicked.connect(self.some_math) def some_math(self): a_diameter=self.a_diameter.value() b_diameter=self.b_diameter.value() complement=self.complement.value() angle=self.angle.value() preload=self.preload.value() ### ONLY MATH HAPPENS HERE also defining X and Y #### interpolator = InterpolatedUnivariateSpline(X, Y) ### MORE MATH HAPPENS HERE #### self.axial.setText(str(axial)) self.radial.setText(str(radial)) def main(): app = QtGui.QApplication(sys.argv) window=SomeCalculation() window.show() app.exec_() if __name__=='__main__': main() </code></pre> <p>I try to run <code>pyinstaller file_name.py</code> and I'm getting:</p> <pre><code>RuntimeError: maximum recursion depth exceeded while calling a Python object </code></pre> <p>Now if there's a few things that I have found out that also affect the issue:</p> <p>1) If I comment out this line: <code>from scipy.interpolate import InterpolatedUnivariateSpline</code></p> <p>2) Creating EXE file from another different script that uses Scipy.Interpolate (RBS, but still) - works like a charm.</p> <p>3) If I try to convert it to EXE using WinPython 3.5.1.1 + pyinstaller obtained the same way, and it's the same 3.2 version of it - it generates my exe file no problems. </p> <p>I want to understand what's causing the error in the original case and I cannot find any answer on google unfortunately, most of the fixes I could find were related with matplotlib and not interpolation though. </p>
0
How to slide <View/> in and out from the bottom in React Native?
<p>In React Native iOS, I would like to slide in and out of a like in the following picture. </p> <p>In the following example, when a button is pressed, the <code>Payment Information</code> view pops up from the bottom, and when the collapse button is pressed, it goes back down and disappears. </p> <p>What would be the correct and proper way to go about doing so? </p> <p><a href="https://i.stack.imgur.com/79A0Xl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/79A0Xl.png" alt="enter image description here"></a></p> <p>Thank you in advance!</p> <p><strong>EDIT</strong></p> <p><a href="https://i.stack.imgur.com/hHx4tm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hHx4tm.png" alt="enter image description here"></a></p>
0
'Fatal Error Unable to create lock file: Bad file descriptor (9)' while running php artisan server
<p>When I run php artisan server I got the error:</p> <pre><code>php artisan serve </code></pre> <blockquote> <p>Laravel development server started on <a href="http://localhost:8000/" rel="nofollow">http://localhost:8000/</a></p> <p>Tue Aug 23 15:51:55 2016 (2381): Fatal Error Unable to create lock file: Bad file descriptor (9)</p> </blockquote>
0
How to convert a string to an array using Ruby on Rails
<p>I have a text field that takes in a string value, like</p> <pre><code>"games,fun,sports" </code></pre> <p>My main goal here is to take the string and turn it into a Array like this:</p> <pre><code>[games, fun, sports] </code></pre> <p>in the filters attribute for the integrations object I have. Right now I have the beginning of a method that doesn't seem to work.</p> <p>Here is my code:</p> <p>View:</p> <pre><code> &lt;%= form_for @integrations, url: url_for(:controller =&gt; :integrations, :action =&gt; :update, :id =&gt; @integrations.id) do |f| %&gt; &lt;%= f.label :filters %&gt; &lt;%= f.text_field :filters, class: "filter-autocomplete" %&gt; &lt;%= f.submit "Save" %&gt; &lt;% end %&gt; </code></pre> <p>That is the text field that takes in the string.</p> <p>Model:</p> <pre><code>def filters=(filters) end </code></pre> <p>This is the place that I'd like to make the switch from string to array.</p> <p>Controller:</p> <pre><code> def update @integrations = current_account.integrations.find(params[:id]) if @integrations.update_attributes(update_params) flash[:success] = "Filters added" redirect_to account_integrations_path else render :filters end end def filters @integrations = current_account.integrations.find(params[:id]) end private def update_params [:integration_webhook, :integration_pager_duty, :integration_slack].each do |model| return params.require(model).permit(:filters) if params.has_key?(model) end end </code></pre> <p>So, recap: I have a integrations model that takes in a string of filters. I want a method that will break up the string into an element of filter attributes. </p> <p>Here is the object that I'm trying to add the filters to:</p> <p>Object:</p> <pre><code> id: "5729de33-befa-4f05-8033-b0acd5c4ee4b", user_id: nil, type: "Integration::Webhook", settings: {"hook_url"=&gt;"https://hooks.zapier.com/hooks/catch/1062282/4b0h0daa/"}, created_at: Mon, 29 Aug 2016 03:30:29 UTC +00:00, owner_id: "59d4357f-3210-4ddc-9cb9-3c758fc1ef3a", filters: "[\"Hey\", \"ohh\"]"&gt; </code></pre> <p>As you can see the <code>filters</code> is what I'm trying to modify. Instead of this in the object:</p> <pre><code>"[\"Hey\", \"ohh\"]" </code></pre> <p>I would like this: </p> <pre><code>[Hey, ohh] </code></pre>
0
Material Design Style PackIcon
<p>I created with Material Design a UserControl Button, based on the method behind I would like to reuse the template with change of the icon. I tried to add the materialdesign:Packicon into the UserControl.Resources, but seems wrong. The Attribute Style is already in use. How can I achieve my icon change?</p> <pre><code>&lt;UserControl x:Class="MaterialDesignTest1.UserControl2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" d:DesignWidth="300" Height="132"&gt; &lt;UserControl.Resources&gt; &lt;ResourceDictionary&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" /&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; &lt;/ResourceDictionary&gt; &lt;/UserControl.Resources&gt; &lt;Grid&gt; &lt;Grid Height="132" &gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;!-- Header --&gt; &lt;Button Grid.Row="0" Grid.Column="0" Background="WhiteSmoke" BorderBrush="LightGray" Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1,1,1,1" Width="50" Height="50"&gt; &lt;materialDesign:PackIcon Height="30" Width="30" Kind="BluetoothConnect" /&gt; &lt;/Button&gt; &lt;/Grid&gt; </code></pre>
0
Java Entity Manager - JSON reader was expecting a value but found 'db'
<p>I have this code already working:</p> <pre><code>EntityManager entityManager = getEntityManager(); entityManager.getTransaction().begin(); String query = "db.Band.find({})"; List&lt;Band&gt; list = (List&lt;Band&gt;) entityManager.createNativeQuery(query, Band.class).getResultList(); entityManager.close(); return list; </code></pre> <p>It returns a <code>List</code> with no problem. Now I want to sort that <code>List</code> by <code>date</code>:</p> <pre><code>EntityManager entityManager = getEntityManager(); entityManager.getTransaction().begin(); String query = "db.Band.find({something__id:ObjectId(\"" + myId + "\")}).sort({\"somethingelse.date\":-1})"; List&lt;Band&gt; list = (List&lt;Band&gt;) entityManager.createNativeQuery(query, Band.class).getResultList(); entityManager.close(); return list; </code></pre> <p>My console gives me this message:</p> <pre class="lang-none prettyprint-override"><code>org.bson.json.JsonParseException: JSON reader was expecting a value but found 'db' </code></pre> <p>I checked that my <code>String</code> was working properly in Mongo console and it did. Any ideas?</p> <p>Edit: I tried putting "something__id" between quotes because it wouldn't work even without the sort part if I didn't (I just realised that), but now it says I am making an unsupported native query, pointing out the Sort part. Should I sort it after I already have it in a List object?</p>
0
Airbnb Airflow vs Apache Nifi
<p>Are Airflow and Nifi perform the same job on workflows? What are the pro/con for each one? I need to read some json files, add more custom metadata to it and put it in a Kafka queue to be processed. I was able to do it in Nifi. I am still working on Airflow. I am trying to choose the best workflow engine for my project Thank you! </p>
0
Angular2-Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
<p>I am calling a http post in Angular 2. This is working fine in post man but when I implement this API call in Angular 2 I get No 'Access-Control-Allow' error. Here is my code</p> <pre><code>getInspections(): Observable&lt;IInspection[]&gt; { if (!this.inspections) { let body =JSON.stringify({"Statuses":["Submitted", "Opened"]}); let headers = new Headers({ 'Content-Type': 'application/json' }); headers.append('Access-Control-Allow-Origin','*'); let options = new RequestOptions({ headers: headers }); return this.http.post(this._baseUrl + '/api/Inspect/ListI',body,options) .map((res: Response) =&gt; { this.inspections = res.json(); return this.inspections; }) .catch(this.handleError); } else { //return cached data return this.createObservable(this.inspections); } } </code></pre> <p>Or can I do this? Just pass header instead of options</p> <pre><code>getInspections(): Observable&lt;IInspection[]&gt; { if (!this.inspections) { let body =JSON.stringify({"Statuses":["Submitted", "Opened"]}); let headers = new Headers({ 'Content-Type': 'application/json' }); //headers.append('Access-Control-Allow-Origin','*'); // let options = new RequestOptions({ headers:headers }); return this.http.post(this._baseUrl + '/api/Inspect/ListI',body,headers) .map((res: Response) =&gt; { this.inspections = res.json(); return this.inspections; }) .catch(this.handleError); } else { //return cached data return this.createObservable(this.inspections); } } </code></pre>
0
Angular 2 do not refresh view after array push in ngOnInit promise
<p>I created a NativeScript app with angular 2, i have an array of objects that i expect to see in the frontend of the application. the behaviour is that if i push an object into the array directly inside the ngOnInit() it works, but if i create a promise in the ngOnInit() it doesn't work. here is the code:</p> <pre><code>export class DashboardComponent { stories: Story[] = []; pushArray() { let story:Story = new Story(1,1,"ASD", "pushed"); this.stories.push(story); } ngOnInit() { this.pushArray(); //this is shown var promise = new Promise((resolve)=&gt;{ resolve(42); console.log("promise hit"); }); promise.then(x=&gt; { this.pushArray(); //this is NOT shown }); } } </code></pre> <p>the relative html is: </p> <pre><code>&lt;Label *ngFor="let story of stories" [text]='story.message'&gt;&lt;/Label&gt; </code></pre> <p>when the app starts i see only one push, but than i created a button that trigger a "console.log(JSON.stringify(this.stories));" and at that moment, when i tap the button, the ui seems to detects the changed array, and the other pushed object appears.</p> <p><strong>EDIT:</strong></p> <p>I created a more simple example in this thread: <a href="https://stackoverflow.com/questions/39203004/angular-2-when-i-change-a-variable-in-a-promise-than-in-ngoninit-the-view-doesn">Angular 2: when i change a variable in a promise.than in ngOnInit the view doesn&#39;t refresh</a></p>
0
How to add more than one `tools:replace` in Android Manifest Application?
<p>I'm using a library that has the below in its Manifest.</p> <pre><code>&lt;application android:allowBackup="true" android:label="@string/app_name" android:supportsRtl="true"/&gt; </code></pre> <p>However, as the application that I use to include the library the reverse of the setting instead</p> <pre><code>&lt;application android:allowBackup="false" android:label="@string/app_name" android:supportsRtl="false"/&gt; </code></pre> <p>Hence it would have merger error like <a href="https://stackoverflow.com/questions/39178130/is-androidsupportsrtl-true-in-the-library-manifest-essential-it-is-causing">Is `android:supportsRtl=&quot;true&quot;` in the Library Manifest essential? It is causing error sometimes</a></p> <p>To solve it, we just need to add the following to our Manifest application.</p> <pre><code>tools:replace="android:supportsRtl" </code></pre> <p>and</p> <pre><code>tools:replace="android:allowBackup" </code></pre> <p>However, adding two <code>tools:replace</code> will have error in compilation. How could I combine the two <code>tools:replace</code>?</p> <p>I tried the below, and it's not working.</p> <pre><code>tools:replace="android:supportsRtl|android:allowBackup" </code></pre>
0
The configuration file 'appsettings.json' was not found and is not optional
<p>The Azure error is:</p> <blockquote> <p>.Net Core: Application startup exception: System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional.</p> </blockquote> <p>So this is a bit vague. I can't seem to nail this down. I'm trying to deploy a .Net Core Web API project to Azure, and I'm getting this error:</p> <blockquote> <p>:( Oops. 500 Internal Server Error An error occurred while starting the application.</p> </blockquote> <p>I've deployed plain old .Net WebAPI's and they have worked. I've followed online tutorials and they have worked. But somehow my project is broke. Enabling stdoutLogEnabled on Web.config and looking at the Azure Streaming Logs gives me this:</p> <pre><code>2016-08-26T02:55:12 Welcome, you are now connected to log-streaming service. Application startup exception: System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Quanta.API.Startup..ctor(IHostingEnvironment env) in D:\Source\Workspaces\Quanta\src\Quanta.API\Startup.cs:line 50 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.Extensions.Internal.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type) at Microsoft.AspNetCore.Hosting.Internal.StartupLoader.LoadMethods(IServiceProvider services, Type startupType, String environmentName) at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.&lt;&gt;c__DisplayClass1_0.&lt;UseStartup&gt;b__1(IServiceProvider sp) at Microsoft.Extensions.DependencyInjection.ServiceLookup.FactoryService.Invoke(ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.SingletonCallSite.Invoke(ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.&lt;&gt;c__DisplayClass12_0.&lt;RealizeService&gt;b__0(ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureStartup() at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() Hosting environment: Production Content root path: D:\home\site\wwwroot Now listening on: http://localhost:30261 Application started. Press Ctrl+C to shut down. </code></pre> <p>Ok, that seems simple. It can't find appsettings.json. Looking at my config ( startup.cs ) it seems very well defined. My Startup looks like this:</p> <pre class="lang-cs prettyprint-override"><code>public class Startup { private static string _applicationPath = string.Empty; private static string _contentRootPath = string.Empty; public IConfigurationRoot Configuration { get; set; } public Startup(IHostingEnvironment env) { _applicationPath = env.WebRootPath; _contentRootPath = env.ContentRootPath; // Setup configuration sources. var builder = new ConfigurationBuilder() .SetBasePath(_contentRootPath) .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); if (env.IsDevelopment()) { // This reads the configuration keys from the secret store. // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 builder.AddUserSecrets(); } builder.AddEnvironmentVariables(); Configuration = builder.Build(); } private string GetXmlCommentsPath() { var app = PlatformServices.Default.Application; return System.IO.Path.Combine(app.ApplicationBasePath, "Quanta.API.xml"); } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var pathToDoc = GetXmlCommentsPath(); services.AddDbContext&lt;QuantaContext&gt;(options =&gt; options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"], b =&gt; b.MigrationsAssembly("Quanta.API"))); //Swagger services.AddSwaggerGen(); services.ConfigureSwaggerGen(options =&gt; { options.SingleApiVersion(new Info { Version = "v1", Title = "Project Quanta API", Description = "Quant.API", TermsOfService = "None" }); options.IncludeXmlComments(pathToDoc); options.DescribeAllEnumsAsStrings(); }); // Repositories services.AddScoped&lt;ICheckListRepository, CheckListRepository&gt;(); services.AddScoped&lt;ICheckListItemRepository, CheckListItemRepository&gt;(); services.AddScoped&lt;IClientRepository, ClientRepository&gt;(); services.AddScoped&lt;IDocumentRepository, DocumentRepository&gt;(); services.AddScoped&lt;IDocumentTypeRepository, DocumentTypeRepository&gt;(); services.AddScoped&lt;IProjectRepository, ProjectRepository&gt;(); services.AddScoped&lt;IProtocolRepository, ProtocolRepository&gt;(); services.AddScoped&lt;IReviewRecordRepository, ReviewRecordRepository&gt;(); services.AddScoped&lt;IReviewSetRepository, ReviewSetRepository&gt;(); services.AddScoped&lt;ISiteRepository, SiteRepository&gt;(); // Automapper Configuration AutoMapperConfiguration.Configure(); // Enable Cors services.AddCors(); // Add MVC services to the services container. services.AddMvc() .AddJsonOptions(opts =&gt; { // Force Camel Case to JSON opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app) { app.UseStaticFiles(); // Add MVC to the request pipeline. app.UseCors(builder =&gt; builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); app.UseExceptionHandler( builder =&gt; { builder.Run( async context =&gt; { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); var error = context.Features.Get&lt;IExceptionHandlerFeature&gt;(); if (error != null) { context.Response.AddApplicationError(error.Error.Message); await context.Response.WriteAsync(error.Error.Message).ConfigureAwait(false); } }); }); app.UseMvc(routes =&gt; { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); // Uncomment the following line to add a route for porting Web API 2 controllers. //routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); }); //Ensure DB is created, and latest migration applied. Then seed. using (var serviceScope = app.ApplicationServices .GetRequiredService&lt;IServiceScopeFactory&gt;() .CreateScope()) { QuantaContext dbContext = serviceScope.ServiceProvider.GetService&lt;QuantaContext&gt;(); dbContext.Database.Migrate(); QuantaDbInitializer.Initialize(dbContext); } app.UseSwagger(); app.UseSwaggerUi(); } } </code></pre> <p>This works fine locally. But once we publish to Azure, this fails. I'm at a loss. I've created new .Net core project that deploy to Azure just find. But this one project, that I put all my time into to, seems to fail. I'm about ready to copy and paste code out of the project that fails to run and into a new project, but i'm really curious on what's breaking this.</p> <p>Any ideas?</p> <p>EDIT: So my Program.cs was:</p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; namespace Quanta.API { public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup&lt;Startup&gt;() .Build(); host.Run(); } } } </code></pre> <p>Edit2: Per Frans, I checked the publishOptions. It was:</p> <pre><code>"publishOptions": { "include": [ "wwwroot", "web.config" ] </code></pre> <p>I took a publishOptions from a working project and changed it to:</p> <pre><code> "publishOptions": { "include": [ "wwwroot", "Views", "Areas/**/Views", "appsettings.json", "web.config" ] }, </code></pre> <p>It still gave a 500 error, but it didn't give a stack trace saying it coulding load appsettings.json. Now it was complaining about a connection to SQL. I noticed that my SQL connection string code is mentioned in a lot of RC1 blog posts. RC2 of .Net Core changed it. So I updated it to:</p> <pre><code> "Data": { "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=QuantaDb;Trusted_Connection=True;MultipleActiveResultSets=true" } }, </code></pre> <p>And changed my startup to:</p> <pre class="lang-cs prettyprint-override"><code> services.AddDbContext&lt;QuantaContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b =&gt; b.MigrationsAssembly("Quanta.API"))); </code></pre> <p>Finally, it worked. </p> <p>I must have followed an older RC1 example and not realized it.</p>
0
How to run PHP code from Visual Studio Code (VSCode)?
<p>I can't find a way to run php on Visual studio code, Does anyone know how?</p> <p><strong>Duplicate:</strong></p> <p>Yes it is but a little bit different from <a href="https://stackoverflow.com/questions/29960999/how-to-run-or-debug-php-on-visual-studio-code-vscode">here</a>.</p> <p><strong>Steps:</strong></p> <p>I followed below steps to configure php in VS Code.</p> <ol> <li>Configure PHP linting in user settings <a href="https://i.stack.imgur.com/2XaiA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2XaiA.png" alt="enter image description here"></a></li> <li>Install Php Debug extension in VSCode</li> <li>Then configure php.ini file <a href="https://i.stack.imgur.com/fn3DP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fn3DP.png" alt="enter image description here"></a></li> <li>Create a external php file in root folder</li> <li>add <code>&lt;? echo "My First PHP site in VSCode."; ?&gt;</code> in external php file which I created now</li> <li>In my index.html file I referenced my php file like: <a href="https://i.stack.imgur.com/0YHWe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0YHWe.png" alt="enter image description here"></a></li> <li>Run my web server apache using xampp control panel </li> <li>Build my project and run it on web browser it shows me nothing.</li> <li>Also when I open dev tools of my chrome browser its shows me my php code of index file commented. why? I don't know. <a href="https://i.stack.imgur.com/h9VS2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/h9VS2.png" alt="enter image description here"></a></li> </ol> <p><strong>Question:</strong></p> <p>What I am doing wrong in my above steps to configure php in vs code. Please explain me in easy steps so I can easily achieve my goal. Thanks in advance. </p>
0
I am getting a 404 error on my new Reactjs app, is it looking for a main.js file?
<p>This app should be rendering what I have here (/Users/ldco2016/Projects/reactquiz/src/components/App.jsx:</p> <pre><code>import React, {Component} from 'react'; import ReactDOM from 'react-dom'; class App extends Component{ render(){ return( &lt;div&gt; APP &lt;/div&gt; ) } } export default App </code></pre> <p>but instead I get a blank page and the Chrome Dev tools console is telling me this:</p> <pre><code>GET http://localhost:8080/app/js/main.js 404 (Not Found) </code></pre> <p>I know what that means but I am unclear as to whether it is trying to find the page I want to render or the main.js file.</p> <p>/Users/ldco2016/Projects/reactquiz/package.json:</p> <pre><code>{ "name": "reactquiz", "version": "1.0.0", "description": "A Reactjs Quiz App", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" &amp;&amp; exit 1" }, "author": "Daniel Cortes", "license": "ISC", "devDependencies": { "babel-core": "6.13.*", "babel-loader": "6.2.*", "webpack": "1.13.*" }, "dependencies": { "react": "^15.3.1", "react-dom": "^15.3.1" } } </code></pre> <p>/Users/ldco2016/Projects/reactquiz/app/index.html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Reactjs Quiz&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="app"&gt;&lt;/div&gt; &lt;script src="js/main.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>ldco2016@DCortes-MacBook-Pro-3 ~/Projects/reactquiz/webpack.config.js:</p> <pre><code>module.export = { entry: [ './src/index.js' ], output: { path: __dirname, filename: 'app/js/main.js' }, module: { loaders: [{ test: /\.jsx?$/, loader: 'babel', exclude: /node_modules/ }] } } </code></pre> <p>/Users/ldco2016/Projects/reactquiz/src/index.js:</p> <pre><code>import React from 'react'; import ReactDOM from 'react-dom'; import App from './components/App.jsx'; ReactDOM.render( &lt;App /&gt;, document.getElementById('app') ); </code></pre>
0
What's the common practice of gitignore for aspnet core project
<p>I know it depends on the project but i want to learn is there a common practice for typical asp.net core project(such as ignoring <code>node_modules</code>). </p>
0
Javascript : optional parameters in function
<p>Let's say I have this : </p> <pre class="lang-js prettyprint-override"><code>function concatenate(a, b, c) { // Concatenate a, b, and c } </code></pre> <p>How do I handle those calls ? </p> <pre class="lang-js prettyprint-override"><code>x = concatenate(a) x = concatenate(a, b) x = concatenate(a, c) </code></pre> <p>How can I make my function aware of the parameter I gave to it ? </p>
0
Change checked attribute of controlled checkbox (React)
<p>I am new to React and am probably lacking the correct terminology to find a solution to my problem. It cannot be that hard.</p> <p>I am building a simple app which displays a set of questions, one question at a time. After answering one question, the next question is shown. </p> <p>I have a component <code>Question</code> that renders 3 checkboxes, each checkbox represents one possible <code>answer</code> to the Question.</p> <pre><code>{this.props.question.answers.map((answer, index) =&gt; { return ( &lt;li className="Question__answer" key={answer.id}&gt; &lt;label className="Question__answer-label"&gt; &lt;input className="Question__answer-checkbox" type="checkbox" value={index} onChange={this.props.setAnswer} defaultChecked={false} /&gt; {answer.answer} &lt;/label&gt; &lt;/li&gt; ... &lt;button className="Question__next" type="button" onClick={this.props.onNext} disabled={this.props.isDisabled}&gt; Next question &lt;/button&gt; ) })} </code></pre> <p>Inside my main component <code>Quiz</code> I call the component like this:</p> <p><code>&lt;Question step={this.state.step} question={this.state.questions[this.state.step]} setAnswer={this.setAnswer} onNext={this.onNext} isDisabled={this.isDisabled()} /&gt;</code></p> <p><code>onNext</code> is my function which increments <code>this.state.step</code> in order to display the next question:</p> <pre><code>onNext(event) { this.setState({step: this.state.step + 1}); } </code></pre> <p>Everything works fine, except: When the next question is displayed, I want all 3 checkboxes to be unchecked again. Currently they remember their checked state from the previously answered question.</p>
0
child_process exits with code null
<p>I am running my node server in centos6.X, and forking a child process.</p> <pre><code>var cp = require('child_process'); child = cp.fork(__dirname+'/worker'); child.on('exit', function (code, signal) { console.log('Child exited with code = ' +code+' signal = '+signal); }); </code></pre> <p>but after few seconds I get this error </p> <blockquote> <p>Child exited with code = null signal = SIGKILL</p> </blockquote> <p>I am now clueless how to get rid of this, there is no more trace, as to what is happening.</p> <p><strong>more clarification</strong></p> <p>I have put console.logs in worker and they are getting printed. the worker is now waiting for message from main server. but exits after waiting for few seconds. I also run the worker js independently with node command and there it does not exit.</p> <p>The same code works fine on my local OSX laptop. but on cloud centos6.X I am facing this issue.</p>
0
Stop execution of PowerShell script and return to original batch file
<p>I am unable to stop a PowerShell script if the batch scripts which are being called by this PowerShell scripts throws an error. </p> <p><strong>bat 1</strong>:</p> <pre><code>PowerShell -NoProfile -ExecutionPolicy Bypass -Command "&amp; '%PowerShellScriptPath%\CallInstall.ps1'"; </code></pre> <p><code>CallInstall.ps1</code> calls few batch files and vbs files, in the event of failure of a prerequisite the bat2 calls a vbs based message box to display an error. Ideally at this time the execution should stop and the bat1 should start the remaining process but in my case <code>CallInstall.ps1</code> still executes all the batch and vbs scripts before going back to bat1.</p> <p><code>CallInstall.ps1</code>:</p> <pre class="lang-bsh prettyprint-override"><code>[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null Set-Location $PSScriptRoot $ScriptsHome = Get-Item '.\ScriptInstall\*' #Define Form $Form = New-Object System.Windows.Forms.Form $Form.width = 1000 $Form.height = 200 $Form.Text = "** Installation in Progress**" $Form.Font = New-Object System.Drawing.Font("Times New Roman" ,12, [System.Drawing.FontStyle]::Regular) $Form.MinimizeBox = $False $Form.MaximizeBox = $False $Form.WindowState = "Normal" $Form.StartPosition = "CenterScreen" $Form.Opacity = .8 $Form.BackColor = "Gray" # Init ProgressBar $ProgressBar = New-Object System.Windows.Forms.ProgressBar $ProgressBar.Maximum = $ScriptsHome.Count $ProgressBar.Minimum = 0 $ProgressBar.Location = new-object System.Drawing.Size(10,70) $ProgressBar.size = new-object System.Drawing.Size(967,10) $Form.Controls.Add($ProgressBar) #$Form.Controls.Add($MessagesLabel) #Running Script Name #$Label = New-Object System.Windows.Forms.Label #$Label.AutoSize = $true #$Label.Location = New-Object System.Drawing.Point(10,50) #$Form.Controls.Add($Label) #Define Array messages #Array $Messages = @("Message 1", "Message 2", "Message 3", "Message 4", "Message 5", ) $MessagesLabel = New-Object System.Windows.Forms.Label $MessagesLabel.AutoSize = $true $MessagesLabel.Location = New-Object System.Drawing.Point(10,50) $Form.Controls.Add($MessagesLabel) # Add_Shown action $ShownFormAction = { $Form.Activate() foreach ($script in $ScriptsHome) { $ProgressBar.Increment(1) $MessagesLabel.Text = $Messages[$ProgressBar.Value - 1] Start-Process $script.FullName -Wait -WindowStyle Hidden } $Form.Dispose() } $Form.Add_Shown($ShownFormAction) # Show Form $Form.ShowDialog() #Create Logs Invoke-Expression -Command .\LogScript.ps1 </code></pre> <p>Inside the ScriptInstall folder there are 10 batch and vbs scripts on one of the batch script:</p> <pre class="lang-batch prettyprint-override"><code>:error cscript %base_dir%\fail.vbs &gt; %Log% :match findstr /I /c:"xxxx" c:\match.txt if %errorlevel% == 0 ( goto nextStep ) else ( goto ErrorCheck ) </code></pre> <p>and in <code>fail.vbs</code>:</p> <pre class="lang-vb prettyprint-override"><code>Dim vbCrLf : vbCrLf = Chr(13) &amp; Chr(10) Set WshShell = WScript.CreateObject("WScript.Shell") MsgBox "Installation Fail !!!" &amp; vbCrLf &amp; "Message1" &amp; vbCrLf &amp; "Click OK to Exit" , 16, "Fail" </code></pre> <p>Ideally upon pressing ok on this <code>fail.vbs</code> box <code>CallInstall.ps1</code> should not proceed with rest of the scripts in ScriptInstall folder but it does otherwise. It continues with remaining scripts in ScriptInstall folder and then returns the execution to bat1.</p>
0
Define `become=yes' per role with Ansible
<p>In my system provisioning with Ansible, I don't want to specify <code>become=yes</code> in every task, so I created the following <em>ansible.cfg</em> in the project main directory, and Ansible automatically runs everything as root:</p> <pre><code>[privilege_escalation] become = True </code></pre> <p>But as the project kept growing, some new roles should not be run as root. I would like to know if it is possible to have some instruction inside the role that all tasks whithin that role should be run as root (eg. something in vars/), instead of the global <em>ansible.cfg</em> solution above!</p>
0
SQL Server: CASE statement in WHERE clause with IN condition
<p>I would like to use, in a stored procedure with @input as input value, a case statement in a where clause like this :</p> <pre><code>SELECT my_column FROM MY_TABLE WHERE MY_TABLE.my_column in (CASE WHEN @input = '1' THEN ('A','B','C') ELSE ('A') END) </code></pre> <p>Incredibly, it works when I place only one value after "THEN" like this :</p> <pre><code>SELECT my_column FROM MY_TABLE WHERE MY_TABLE.my_column in (CASE WHEN @input = '1' THEN ('C') ELSE ('A') END) </code></pre> <p>Can I use the <code>IN</code> condition with a <code>CASE</code> statement like I wanted above? Is there an another way to do what I want ?</p> <p>Thank you for your help,</p> <p>CLJ</p>
0
How to maintain Firebase Auth for multiple pages on the web?
<p>I am using Firebase for a web application. The goal is to allow a familiar log-in/sign-up where the user signs up or logs in one one page, and upon successful authentication, is brought to the home page.</p> <p>The flow would look something like this: Log-in/Sign-up -> (allows access to) -> [Home, Profile, Search, Friends, etc.]</p> <p>I am using Javascript (No AngularJs since I am unfamiliar with it entirely). The problem I am having is that once the user successfully logs in or signs up, their "user object" becomes null on using <code>window.location = 'home.html'</code> </p> <p>Here is the complete code. I am using the sample found Firebase for now for the authentication process, but the home.html is my doing:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;!--Bootstrap CSS CDN--&gt; &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"&gt; &lt;!---jQuery CDN--&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; /** * Handles the sign in button press. */ function toggleSignIn() { if (firebase.auth().currentUser) { // [START signout] firebase.auth().signOut(); // [END signout] } else { var email = document.getElementById('email').value; var password = document.getElementById('password').value; if (email.length &lt; 4) { alert('Please enter an email address.'); return; } if (password.length &lt; 4) { alert('Please enter a password.'); return; } // Sign in with email and pass. // [START authwithemail] firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // [START_EXCLUDE] if (errorCode === 'auth/wrong-password') { alert('Wrong password.'); } else { alert(errorMessage); } console.log(error); document.getElementById('quickstart-sign-in').disabled = false; // [END_EXCLUDE] }); // [END authwithemail] window.location = '/1home.php' } document.getElementById('quickstart-sign-in').disabled = true; } /** * Handles the sign up button press. */ function handleSignUp() { var email = document.getElementById('email').value; var password = document.getElementById('password').value; if (email.length &lt; 4) { alert('Please enter an email address.'); return; } if (password.length &lt; 4) { alert('Please enter a password.'); return; } // Sign in with email and pass. // [START createwithemail] firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // [START_EXCLUDE] if (errorCode == 'auth/weak-password') { alert('The password is too weak.'); } else { alert(errorMessage); } console.log(error); // [END_EXCLUDE] }); // [END createwithemail] } /** * Sends an email verification to the user. */ function sendEmailVerification() { // [START sendemailverification] firebase.auth().currentUser.sendEmailVerification().then(function() { // Email Verification sent! // [START_EXCLUDE] alert('Email Verification Sent!'); // [END_EXCLUDE] }); // [END sendemailverification] } function sendPasswordReset() { var email = document.getElementById('email').value; // [START sendpasswordemail] firebase.auth().sendPasswordResetEmail(email).then(function() { // Password Reset Email Sent! // [START_EXCLUDE] alert('Password Reset Email Sent!'); // [END_EXCLUDE] }).catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; // [START_EXCLUDE] if (errorCode == 'auth/invalid-email') { alert(errorMessage); } else if (errorCode == 'auth/user-not-found') { alert(errorMessage); } console.log(error); // [END_EXCLUDE] }); // [END sendpasswordemail]; } /** * Handles registering callbacks for the auth status. * * This method registers a listener with firebase.auth().onAuthStateChanged. This listener is called when * the user is signed in or out, and that is where we update the UI. * * When signed in, we also authenticate to the Firebase Realtime Database. */ function initApp() { // Listening for auth state changes. // [START authstatelistener] firebase.auth().onAuthStateChanged(function(user) { // [START_EXCLUDE silent] document.getElementById('quickstart-verify-email').disabled = true; // [END_EXCLUDE] if (user) { // User is signed in. var displayName = user.displayName; var email = user.email; var emailVerified = user.emailVerified; var photoURL = user.photoURL; var isAnonymous = user.isAnonymous; var uid = user.uid; var refreshToken = user.refreshToken; var providerData = user.providerData; // [START_EXCLUDE silent] document.getElementById('quickstart-sign-in-status').textContent = 'Signed in'; document.getElementById('quickstart-sign-in').textContent = 'Sign out'; document.getElementById('quickstart-account-details').textContent = JSON.stringify({ displayName: displayName, email: email, emailVerified: emailVerified, photoURL: photoURL, isAnonymous: isAnonymous, uid: uid, refreshToken: refreshToken, providerData: providerData }, null, ' '); if (!emailVerified) { document.getElementById('quickstart-verify-email').disabled = false; } // [END_EXCLUDE] } else { // User is signed out. // [START_EXCLUDE silent] document.getElementById('quickstart-sign-in-status').textContent = 'Signed out'; document.getElementById('quickstart-sign-in').textContent = 'Sign in'; document.getElementById('quickstart-account-details').textContent = 'null'; // [END_EXCLUDE] } // [START_EXCLUDE silent] document.getElementById('quickstart-sign-in').disabled = false; // [END_EXCLUDE] }); // [END authstatelistener] document.getElementById('quickstart-sign-in').addEventListener('click', toggleSignIn, false); document.getElementById('quickstart-sign-up').addEventListener('click', handleSignUp, false); document.getElementById('quickstart-verify-email').addEventListener('click', sendEmailVerification, false); document.getElementById('quickstart-password-reset').addEventListener('click', sendPasswordReset, false); } window.onload = function() { initApp(); }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="jumbotron text-center"&gt; &lt;/div&gt; &lt;div class="container"&gt; &lt;div class="jumbotron"&gt; &lt;div class="row"&gt; &lt;div class="col-md-6"&gt; &lt;!--&lt;img src="" style="width:500px; height:340px"&gt;--&gt; &lt;/div&gt; &lt;div class="col-md-6"&gt; &lt;!-- Container for the demo --&gt; &lt;div class="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-cell--12-col-tablet mdl-cell--12-col-desktop"&gt; &lt;div class="mdl-card__title mdl-color--light-blue-600 mdl-color-text--white"&gt; &lt;h2 class="mdl-card__title-text"&gt;Sign Up&lt;/h2&gt; &lt;/div&gt; &lt;div class="mdl-card__supporting-text mdl-color-text--grey-600"&gt; &lt;p&gt;Enter an email and password below and either sign in to an existing account or sign up&lt;/p&gt; &lt;input class="mdl-textfield__input" style="display:inline;width:auto;" type="text" id="email" name="email" placeholder="Email"/&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt; &lt;input class="mdl-textfield__input" style="display:inline;width:auto;" type="password" id="password" name="password" placeholder="Password"/&gt; &lt;br/&gt;&lt;br/&gt; &lt;button disabled class="mdl-button mdl-js-button mdl-button--raised" id="quickstart-sign-in" name="signin"&gt;Sign In&lt;/button&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;button class="mdl-button mdl-js-button mdl-button--raised" id="quickstart-sign-up" name="signup"&gt;Sign Up&lt;/button&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;button class="mdl-button mdl-js-button mdl-button--raised" disabled id="quickstart-verify-email" name="verify-email"&gt;Send Email Verification&lt;/button&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;button class="mdl-button mdl-js-button mdl-button--raised" id="quickstart-password-reset" name="verify-email"&gt;Send Password Reset Email&lt;/button&gt; &lt;!-- Container where we'll display the user details --&gt; &lt;div class="quickstart-user-details-container"&gt; &lt;!--Firebase--&gt; sign-in status: &lt;span id="quickstart-sign-in-status"&gt;Unknown&lt;/span&gt; &lt;div&gt;&lt;!--Firebase--&gt; auth &lt;code&gt;currentUser&lt;/code&gt; object value:&lt;/div&gt; &lt;pre&gt;&lt;code id="quickstart-account-details"&gt;null&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt; &lt;/div&gt;&lt;!----&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!--Bootstrap Js CDN--&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;!--Firebase Initialization--&gt; &lt;script src="https://www.gstatic.com/firebasejs/3.2.1/firebase.js"&gt;&lt;/script&gt; &lt;script&gt; // Initialize Firebase var config = { apiKey: "XXXXXXXXXXXXXXXXX", authDomain: "XXXXXXXXXXXXXX", databaseURL: "XXXXXXXXXXXXX", storageBucket: "XXXXXXXXXXXXXXXX", }; firebase.initializeApp(config); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Additionally, the page that is auth screen redirects to is monitoring the auth state with <code>onAuthStateChanged</code>. This is where using <code>console.log(user);</code> returns null, although using <code>console.log("Attempted sign in);</code> is printed. I copied the initApp function from the Firebase Auth sample. Perhaps I am using it in the wrong place?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name ="viewport" content ="width=device-width, initial-scale=1.0"&gt; &lt;!--Bootstrap CSS CDN--&gt; &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"&gt; &lt;!---jQuery CDN--&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="styles.css"&gt; &lt;link rel="stylesheet" href="animations.css"&gt; &lt;!--Firebase--&gt; &lt;script type="text/javascript"&gt; function initApp() { // Listening for auth state changes. // [START authstatelistener] firebase.auth().onAuthStateChanged(function(user) { // [START_EXCLUDE silent] // [END_EXCLUDE] console.log("Attempted Sign in"); console.log(user); if (user) { // User is signed in. console.log("Attempted Sign in successful"); var displayName = user.displayName; var email = user.email; var emailVerified = user.emailVerified; var photoURL = user.photoURL; var isAnonymous = user.isAnonymous; var uid = user.uid; var refreshToken = user.refreshToken; var providerData = user.providerData; console.log(uid); console.log(displayName); console.log(email); console.log(photoURL); // [START_EXCLUDE silent] if (!emailVerified) { } // [END_EXCLUDE] } else { // User is signed out. // [START_EXCLUDE silent] // [END_EXCLUDE] } // [START_EXCLUDE silent] // [END_EXCLUDE] }); // [END authstatelistener] } window.onload = function() { initApp(); // Register the callback to be fired every time auth state changes ref.onAuth(function(authData) { if (authData) { console.log("User " + authData.uid + " is logged in with " + authData.provider); } else { console.log("User is logged out"); } }); }; &lt;/script&gt; </code></pre> <p>So, to re-iterate the issue and goal: I want to be able to authenticate a user on this page (the code above represents a login/signup screen), and then send them a set of pages that loads content based on their Firebase ID. </p>
0
Python Matplotlib FuncAnimation.save() only saves 100 frames
<p>I am trying to save an animation I've created with the FuncAnimation class in Matplotlib. My animation is more complicated, but I get the same error when I try to save the simple example given <a href="https://stackoverflow.com/questions/16732379/stop-start-pause-in-python-matplotlib-animation">here</a>.</p> <pre><code>import matplotlib.pyplot as plt import numpy as np import matplotlib.animation as animation pause = False def simData(): t_max = 10.0 dt = 0.05 x = 0.0 t = 0.0 while t &lt; t_max: if not pause: x = np.sin(np.pi*t) t = t + dt yield x, t def onClick(event): global pause pause ^= True def simPoints(simData): x, t = simData[0], simData[1] time_text.set_text(time_template%(t)) line.set_data(t, x) return line, time_text fig = plt.figure() ax = fig.add_subplot(111) line, = ax.plot([], [], 'bo', ms=10) # I'm still not clear on this stucture... ax.set_ylim(-1, 1) ax.set_xlim(0, 10) time_template = 'Time = %.1f s' # prints running simulation time time_text = ax.text(0.05, 0.9, '', transform=ax.transAxes) fig.canvas.mpl_connect('button_press_event', onClick) ani = animation.FuncAnimation(fig, simPoints, simData, blit=False, interval=10, repeat=True) plt.show() </code></pre> <p>However, when I try to save this animation by adding the line</p> <pre><code>ani.save('test.mp4') </code></pre> <p>at the end, only the first 100 frames are saved.</p> <p>After the animation is saved, the function restarts and displays as expected, displaying and updating the figure 200 times (or until t reaches t_max, whatever I set that to be). But the movie that is saved only contains the first 100 frames.</p> <p>The pause functionality makes it tricky. Without it I could just put in frames = 200 into the FuncAnimation call rather that using the iterator/generator type function I currently have for the frames argument. But by just putting in frames = 200, the frame count seems to be un-pauseable. </p> <p>How can I fix this?</p>
0
ImportError: No module named '_version' when importing mechanize
<p>I installed mechanize via pip and get an errer when I import the module:</p> <pre><code>$ python Python 3.5.2 (default, Jun 28 2016, 08:46:01) [GCC 6.1.1 20160602] on linux Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import mechanize Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/python3.5/site-packages/mechanize/__init__.py", line 119, in &lt;module&gt; from _version import __version__ ImportError: No module named '_version' </code></pre> <p>The file <code>-version.py</code> is present in the site-packages directory:</p> <pre><code>$ ls /usr/lib/python3.5/site-packages/mechanize _auth.py __init__.py _response.py _beautifulsoup.py _lwpcookiejar.py _rfc3986.py _clientcookie.py _markupbase.py _sgmllib_copy.py _debug.py _mechanize.py _sockettimeout.py _firefox3cookiejar.py _mozillacookiejar.py _testcase.py _form.py _msiecookiejar.py _urllib2_fork.py _gzip.py _opener.py _urllib2.py _headersutil.py _pullparser.py _useragent.py _html.py __pycache__ _util.py _http.py _request.py _version.py </code></pre> <p>What am I missing?</p>
0
Download and install scapy for windows for python 3.5?
<p>I installed python 3.5 for my windows 8.1 computer. I need to install scapy for this version (I deleted all the files of the last one). How do i download and install it? can't find anything that help me to do that no matter how i searched.</p>
0
Laravel's application key - what it is and how does it work?
<p>From what I know, the app key in Laravel provides protection for session and sensitive data, but what I want to understand is how exactly does it work? What is the purpose of it? I couldn't find any information about it.</p>
0
Sourcemaps are detected in chrome but original source is not loaded, using webpack-2
<p>When running an application that is built using webpack 2, sourcemaps are detected in chrome but original source is not loaded. I'm using webpack beta21.</p> <p>These files used to be detected automatically, ie when a breakpoint was put in the the output from webpack js file, the source view would jump to the original source input to webpack. But now I am stuck with this screen: <a href="https://i.stack.imgur.com/70nAz.png"><img src="https://i.stack.imgur.com/70nAz.png" alt="enter image description here"></a></p> <p>config:</p> <pre><code>var path = require("path"); var webpack = require("webpack"); var WebpackBuildNotifierPlugin = require('webpack-build-notifier'); const PATHS = { app: path.join(__dirname, '../client'), build: path.join(__dirname, '../public') }; module.exports = { entry: { app: PATHS.app + '/app.js' }, output: { path: PATHS.build, filename: '[name].js' }, devtool: "source-map", module: { loaders: [ { test: /\.js?$/, loader: 'babel-loader', include: [ path.resolve(__dirname, 'client'), ], exclude: /node_modules/ }, { test: /\.css/, loader: "style!css" } ] }, resolve: { // you can now require('file') instead of require('file.js') extensions: ['', '.js', '.json'] } , plugins: [ new WebpackBuildNotifierPlugin() ] }; </code></pre>
0
Using alert annotations in an alertmanager receiver
<p>I've got an alert configured like this:</p> <pre><code>ALERT InstanceDown IF up == 0 FOR 30s ANNOTATIONS { summary = "Server {{ $labels.Server }} is down.", description = "{{ $labels.Server }} ({{ $labels.job }}) is down for more than 30 seconds." } </code></pre> <p>The slack receiver looks like this:</p> <pre><code>receivers: - name: general_receiver slack_configs: - api_url: https://hooks.slack.com/services/token channel: "#telemetry" title: "My summary" text: "My description" </code></pre> <p>Is it possible to use the annotations in my receiver? <a href="https://github.com/prometheus/alertmanager/issues/250#issuecomment-239305395" rel="noreferrer">This github comment</a> indicates it is but I haven't been able to get anything to work from it.</p>
0
Check if list contains another list in R
<p>I want to check if a list (or a vector, equivalently) is contained into another one, not if it is a subset of thereof. Let us assume we have</p> <pre><code>r &lt;- c(1,1) s &lt;- c(5,2) t &lt;- c(1,2,5) </code></pre> <p>The function should behave as follows:</p> <pre><code>is.contained(r,t) [1] FALSE # as (1,1) is not contained in (1,2,5) since the former # contains two 1 whereas the latter only one. is.contained(s,t) [1] TRUE </code></pre> <p>The operator <code>%in%</code> checks for subsets, hence it would return <code>TRUE</code> in both cases, likewise <code>all</code> or <code>any</code>. I am sure there is a one-liner but I just do not see it.</p>
0
common.h: No such file or directory (Ubuntu gcc)
<p>When I was trying to compile a C program like this:</p> <pre><code>1 #include &lt;stdio.h&gt; 2 #include &lt;stdlib.h&gt; 3 #include &lt;sys/time.h&gt; 4 #include &lt;assert.h&gt; 5 #include "common.h" 6 7 int 8 main(int argc, char *argv[]) 9 { 10 if (argc != 2) { 11 fprintf(stderr, "usage: cpu &lt;string&gt;\n"); 12 exit(1); 13 } 14 char *str = argv[1]; 15 while (1) { 16 Spin(1); 17 printf("%s\n", str); 18 } 19 return 0; 20 } </code></pre> <p>and I received a error </p> <pre><code>CPU.c:5:19: fatal error: common.h: No such file or directory </code></pre> <p>I have update my gcc compiler, so I cannot figure out why there is a miss of "Common.h"</p>
0
Using Google Adsense ads on Angular 2 application
<p>Is there any way to use Google Adsense ads on an Angular 2 app?</p> <p>I have seen this <a href="https://stackoverflow.com/questions/37580561/google-adsense-ads-in-angular-2-components">Google AdSense ads in Angular 2 components?</a> but the answer isn't actually working for me. I see a blank space instead of my ad. What I'm trying to place is responsive ad. I did exactly as the answer in the above question said, with this template code:</p> <pre><code>&lt;div class="text-center"&gt; &lt;ins class="adsbygoogle" style="display:inline-block;height:150px" data-ad-client="my ca-pub" data-ad-slot="my ad slot"&gt;&lt;/ins&gt; &lt;/div&gt; </code></pre> <p>Any ideas?</p>
0
Java equivalent of C# Delegates (queues methods of various classes to be executed)
<p>TLDR:</p> <p>Is there a Java equivalent of C#'s <a href="http://www.tutorialsteacher.com/csharp/csharp-delegates" rel="noreferrer">delegates</a> that will allow me to queue up methods of various classes and add them to the queue dynamically? Language constructs instead of the code for it.</p> <p>Context:</p> <p>I have used Unity 3D before and I love things like the <code>Update</code> method of scripts. Just declaring the method adds it to the list of methods executed each frame. I want to create something like that in my LWJGL game. For this, I would want to use delegates (or something equivalent to it). Is there any Java language construct that would allow me to do this? I would prefer answers that include two or more (so that I can pick and choose which will be the most optimal for my code) constructs and a way of using them. I don't want the code, I just want to know where to start. The most fun part of programming is working the problem out and I don't want to be deprived of that. Also, I don't want to be told EXACTLY how to do it. I want to be guided in the right direction instead of being thrown in that direction onto that destination. How would I learn? :-)</p>
0
How to reload the component of same URL in Angular 2?
<p>I am trying to reload the same url in Angular 2 by using router.navigate but it is not working. url : <a href="http://localhost:3000/landing" rel="noreferrer">http://localhost:3000/landing</a> Scenario : I am on <a href="http://localhost:3000/landing" rel="noreferrer">http://localhost:3000/landing</a> and now I am changing a particular parameter in the page which should reload the page.</p> <p>Code :</p> <pre><code>let link = ['Landing']; this.router.navigate(link); </code></pre>
0
How get sum of total values in stackedBar ChartJs
<p>I'm trying to get the sum of all values of a stackedBar and include this total in tooltip.</p> <blockquote> <p>Note: my datasets aren't static, this is an example</p> </blockquote> <pre><code>var barChartData = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: 'Corporation 1', backgroundColor: "rgba(220,220,220,0.5)", data: [50, 40, 23, 45, 67, 78, 23] }, { label: 'Corporation 2', backgroundColor: "rgba(151,187,205,0.5)", data: [50, 40, 78, 23, 23, 45, 67] }, { label: 'Corporation 3', backgroundColor: "rgba(151,187,205,0.5)", data: [50, 67, 78, 23, 40, 23, 55] }] }; window.onload = function() { var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx, { type: 'bar', data: barChartData, options: { title:{ display:true, text:"Chart.js Bar Chart - Stacked" }, tooltips: { mode: 'label', callbacks: { label: function(tooltipItem, data) { var corporation = data.datasets[tooltipItem.datasetIndex].label; var valor = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; var total = eval(data.datasets[tooltipItem.datasetIndex].data.join("+")); return total+"--"+ corporation +": $" + valor.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'); } } }, responsive: true, scales: { xAxes: [{ stacked: true, }], yAxes: [{ stacked: true }] } } }); }; </code></pre> <p>Now <code>total</code> is the sum per dataset and I need the sum per stackedBar.</p> <p>Example</p> <p>Label A: value A</p> <p>Label B: value B</p> <p>Label C: value C</p> <p>TOTAL: value A + value B + value C</p> <p>It is possible to get that total value?</p> <p>Thanks, Idalia.</p>
0
Is there a limit on the number of indexes that can be created on Elastic Search?
<p>I'm using AWS-provided Elastic Search.</p> <p>I have a signup page on my website, and on each signup; a new index for the new user gets created (to be used later by his work-group), which means that the number of indexes is continuously growing, (now it reached around 4~5k).</p> <p>My question is: is there a performance limit on the number of indexes? is it safe (performance-wise) to keep creating new indexes dynamically with each new user?</p>
0
What's the observable equivalent to `Promise.reject`
<p>I had this code</p> <pre><code> return this.http.get(this.pushUrl) .toPromise() .then(response =&gt; response.json().data as PushResult[]) .catch(this.handleError); </code></pre> <p>I wanted to use <code>observable</code> instead of <code>Promise</code></p> <p>how can i return the error to the calling method?</p> <p>What's the equivalent to <code>Promise.reject</code> ?</p> <pre><code> doSomeGet() { console.info("sending get request"); this.http.get(this.pushUrl) .forEach(function (response) { console.info(response.json()); }) .catch(this.handleError); } private handleError(error: any) { console.error('An error occurred', error); // return Promise.reject(error.message || error); } } </code></pre> <p>the calling method was:</p> <pre><code>getHeroes() { this.pushService .doSomeGet(); // .then(pushResult =&gt; this.pushResult = pushResult) // .catch(error =&gt; this.error = error); } </code></pre>
0
How to compare Go errors
<p>I have an error value which when printed on console gives me <code>Token is expired</code></p> <p>How can I compare it with a specific error value? I tried this but it did not work:</p> <pre><code>if err == errors.New("Token is expired") { log.Printf("Unauthorised: %s\n", err) } </code></pre>
0
The "RenderBody" method has not been called for layout page "~/Views/Shared/index.cshtml"
<p>The "RenderBody" method has not been called for layout page "~/Views/Shared/index.cshtml"</p> <p>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>how to fix this error</p>
0
How to launch Chrome Advanced REST Client
<p>There's <a href="https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US" rel="noreferrer">this great REST client "extension" for Chrome</a>, but the only way I can find to launch it is to go to the Chrome webstore!</p> <p>It's listed as Enabled in my Chrome extensions. Is there any local way to launch it?</p> <p><a href="https://i.stack.imgur.com/dUjGs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dUjGs.png" alt="Advanced REST client Chrome extenstion"></a></p>
0
Find item of specific type in array
<p>I want an extension on a Array where you can find an item that is of some type.</p> <p>I tried like this:</p> <pre><code> func findItem&lt;U: Type&gt;(itemToFind: U) -&gt; AnyObject? { for item in self { if let obj = item as? itemToFind { return obj } } return nil } </code></pre> <p>So I check if it is the same type and then I want to return the obj. </p> <p>The error I get is:</p> <blockquote> <p>Inheritance from non-protocol, non-class 'Type'.</p> </blockquote> <p>How can I fix this that I can pass to the function <code>ViewController.self</code> and that I get back nil if not found or the viewcontroller that is in the array?</p>
0
How to switch to a new remote git repository
<p>I've recently cloned a repo to my local drive, but now I'm trying to push all changes to a complete new repo. However, git keeps telling me that permission is denied, and that's because it's trying to push to the originally-cloned repo.</p> <p>DETAILS:</p> <p>I originally cloned from <a href="https://github.com/taylonr/intro-to-protractor" rel="noreferrer">https://github.com/taylonr/intro-to-protractor</a> (i.e. based on a Pluralsight course at <a href="https://app.pluralsight.com/library/courses/protractor-introduction/table-of-contents" rel="noreferrer">https://app.pluralsight.com/library/courses/protractor-introduction/table-of-contents</a> ) .</p> <p>Now that I've completed the course, I'd like to push my finalized code up to my own git repo (which I just created on github): </p> <p><a href="https://github.com/robertmazzo/intro-to-protractor" rel="noreferrer">https://github.com/robertmazzo/intro-to-protractor</a></p> <p>When I use the following git command: </p> <blockquote> <p>git remote add origin <a href="https://github.com/robertmazzo/intro-to-protractor.git" rel="noreferrer">https://github.com/robertmazzo/intro-to-protractor.git</a></p> </blockquote> <p>it tells me <code>remote origin already exists</code> , which I guess is fine because I already created it on github.com.</p> <p>However, when I push my changes up I'm getting an exception.</p> <blockquote> <p>git push origin master</p> </blockquote> <p><code>remote: Permission to taylonr/intro-to-protractor.git denied to robertmazzo. fatal: unable to access 'https://github.com/taylonr/intro-to-protractor.git/': The requested URL returned error: 403</code></p> <p>So I'm investigating how I can switch to my new repository, but this is exactly where my issue is. I cannot figure this part out.</p>
0
Tkinter custom create buttons
<p>Can tkinter create custom buttons from an image or icon like this?</p> <p><a href="https://i.stack.imgur.com/pOTbI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pOTbI.png" alt="enter image description here" /></a></p>
0
How to pad a string with leading zeros in Python 3
<p>I'm trying to make <code>length = 001</code> in Python 3 but whenever I try to print it out it truncates the value without the leading zeros (<code>length = 1</code>). How would I stop this happening without having to cast <code>length</code> to a string before printing it out?</p>
0
Multiple conditions in guard statement in Swift
<p>Is there a way to include multiple conditions in a guard statement of Swift?</p> <p>For example, if I want to check two optional values are nil using a guard, how should I do it using single guard statement?</p>
0
How to get all elements' text attribute at once in Robot Framework?
<p>I have some web elements which has the same prefix for their <code>ID</code> attribute. I can get these elements all at once with <code>get webelements</code>; I want to extract their text attribute with one command. I have wrote this line:</p> <pre><code>${elList} = get webelements xpath=//*[starts-with(@id, '${formName}:${row}')] ${rowList} = evaluate [item.get_attribute('text') for item in ${elList}] selenium </code></pre> <p>Which returns:</p> <pre><code>Evaluating expression '[item.get_attribute('text') for item in [&lt;selenium.webdriver.remote.webelement.WebElement object at 0x7f7b6c5f09d0&gt;, &lt;selenium.webdriver.remote.webelement.WebElement object at 0x7f7b6c5f0990&gt;]]' failed: SyntaxError: invalid syntax (&lt;string&gt;, line 1) </code></pre> <p>I can't understand the problem here; BTW I'll appreciate any other solution for my issue.</p> <p><strong>EDIT1:</strong> I also have tried below code:</p> <pre><code>${elList} = get webelements xpath=//*[starts-with(@id, '${formName}:${row}')] :FOR ${item} IN @{elList} \ log to console ${item.get_attribute('text')} </code></pre> <p>But the console just shows <code>None</code>; it is the same for <code>${item.get_attribute('value')}</code>.</p>
0
Plot confusion matrix sklearn with multiple labels
<p>I am plotting a confusion matrix for a multiple labelled data, where labels look like: </p> <blockquote> <p>label1: 1, 0, 0, 0</p> <p>label2: 0, 1, 0, 0</p> <p>label3: 0, 0, 1, 0</p> <p>label4: 0, 0, 0, 1</p> </blockquote> <p>I am able to classify successfully using the below code. <strong>I only need some help to plot confusion matrix.</strong></p> <pre><code> for i in range(4): y_train= y[:,i] print('Train subject %d, class %s' % (subject, cols[i])) lr.fit(X_train[::sample,:],y_train[::sample]) pred[:,i] = lr.predict_proba(X_test)[:,1] </code></pre> <p>I used the following code to print confusion matrix, but it always return a 2X2 matrix </p> <pre><code>prediction = lr.predict(X_train) print(confusion_matrix(y_train, prediction)) </code></pre>
0
WebStorm “Let definition are not supported by current JavaScript version”
<p>I am trying to use new tools available for coding in JavaScript. I've seen the post <a href="https://stackoverflow.com/questions/35772101/phpstorm-let-definition-are-not-supported-by-current-javascript-version">PhpStorm &quot;Let definition are not supported by current JavaScript version&quot;</a>. I've tried as suggested over there, but do not work.</p> <p>When I hover over the <code>export</code></p> <blockquote> <p>Export declarations are not supported by current JavaScript version</p> </blockquote> <p>When I hover over the <code>yield</code></p> <blockquote> <p>Generators are not supported by current JavaScript version</p> </blockquote> <p>and hovering over the <code>let</code></p> <blockquote> <p>Let definition are not supported by current JavaScript version</p> </blockquote> <p>So the question is how to upgrade the JavaScript version?</p>
0
how to download images using google earth engine's python API
<p>I am using Google's Earth Engine API to access LandSat images. The program is as given below,</p> <pre><code>import ee ee.Initialize() </code></pre> <p><strong>Load a landsat image and select three bands.</strong></p> <pre><code>landsat = ee.Image('LANDSAT/LC8_L1T_TOA /LC81230322014135LGN00').select(['B4', 'B3', 'B2']); </code></pre> <p><strong>Create a geometry representing an export region.</strong></p> <pre><code>geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]); </code></pre> <p><strong>Export the image, specifying scale and region.</strong></p> <pre><code> export.image.toDrive({ image: landsat, description: 'imageToDriveExample', scale: 30, region: geometry }); </code></pre> <p>it throws the following error. </p> <pre><code>Traceback (most recent call last): File "e6.py", line 11, in &lt;module&gt; export.image.toDrive({ NameError: name 'export' is not defined </code></pre> <p>Please Help. I am unable to find the right function to download images. </p>
0
Space Between CardView
<p>I need to add space between <code>CardView</code>.</p> <p>I tried to use the <code>card_view:cardUseCompatPadding</code> and it doesn't work. Any help? </p> <pre><code>&lt;RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;android.support.v7.widget.CardView android:id="@+id/all_restaurant_card_view" android:layout_width="wrap_content" android:layout_height="120dp" xmlns:card_view="http://schemas.android.com/apk/res-auto" card_view:cardPreventCornerOverlap="true" card_view:cardUseCompatPadding="true"&gt; </code></pre>
0
Access HTML5 local storage from Angular2
<p>I'm following this tutorial: <a href="https://medium.com/@blacksonic86/authentication-in-angular-2-958052c64492" rel="noreferrer">https://medium.com/@blacksonic86/authentication-in-angular-2-958052c64492</a> about authentication in Angular2.</p> <p>I've the issue with this part: </p> <p><code>import localStorage from 'localStorage';</code></p> <p>I've read somewhere else that I should use this library <a href="https://github.com/marcj/angular2-localstorage" rel="noreferrer">https://github.com/marcj/angular2-localstorage</a> to access local storage in HTML5. Is it really the only option? Can I access HTML5 local storage from angular2 without using extra modules?</p>
0
Log4j2 file created but not log written
<p>I have used log4j2 with springboot, log file has been created but logs are not written in file. </p> <p><strong>log4j2.properties</strong></p> <pre><code>name=PropertiesConfig property.filename = /export/home/apps/logs appenders = console, file appender.console.type = Console appender.console.name = STDOUT appender.console.layout.type = PatternLayout appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n appender.file.type = File appender.file.name = LOGFILE appender.file.fileName=${filename}/app-frontend.log appender.file.layout.type=PatternLayout appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n loggers=file logger.file.name=guru.springframework.blog.log4j2properties logger.file.level = debug logger.file.appenderRefs = file logger.file.appenderRef.file.ref = LOGFILE rootLogger.level = debug rootLogger.appenderRefs = stdout rootLogger.appenderRef.stdout.ref = STDOUT </code></pre> <p><strong>pom.xml</strong></p> <pre><code>&lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-log4j2&lt;/artifactId&gt; &lt;/dependency&gt; &lt;/dependencies&gt; </code></pre> <p>method using logger</p> <pre><code>private static Logger logger = LogManager.getLogger(); @RequestMapping(value="/check", method = RequestMethod.GET) public String healthCheck() { logger.debug("Health-check invoked"); return "Hey, I am fine"; } </code></pre> <p>Above I have mention the codes I have used. Still can not find a way to solve. Logs are even not appearing in the console. </p>
0
No provider for ConnectionBackend
<p>So recently I had to update to the latest version of Angular2, RC.6. The biggest breaking change seems to be the whole bootstrapping (by "introducing" ngModule).</p> <pre><code>@NgModule({ imports: [HttpModule, BrowserModule, FormsModule], schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [AppComponent, ...], providers: [FrameService, Http, { provide: $WINDOW, useValue: window }], bootstrap: [AppComponent] }) class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule); </code></pre> <p>However after a lot of tears, sweat and pleading to all the deities I could come up with... I still remain with what is hopefully the last error in a series of many:</p> <p><strong>No provider for ConnectionBackend!</strong></p> <p>At this point I am tearing out the last strains of hair I have left as I am clueless at this point regarding the "what I am missing".</p> <p>Kind regards!</p>
0
What is data-bound properties?
<p>I am trying to understand OnInit functionality in angular2 and read the documentation: </p> <blockquote> <p>Description</p> <p>Implement this interface to execute custom initialization logic after your directive's data-bound properties have been initialized.</p> <p>ngOnInit is called right after the directive's data-bound properties have been checked for the first time, and before any of its children have been checked. It is invoked only once when the directive is instantiated.</p> </blockquote> <p>I do not understand <code>directive's data-bound properties</code> what does it mean? </p>
0