Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
39,645,324 | Fullcalendar , Make today (for current month) active | Today button disable for current month. when you go next or previous month it appear as active.(when click on the TODAY button control goes to current month).
In following code i am showing how to make today button active for current month.
function makeTodaybtnActive()
{
$('#calendar button.fc-today-button').removeAttr('disabled');
$('#calendar button.fc-today-button').removeClass('fc-state-disabled');
}
(where #calendar is fullcalendar id)
call this function when calendar load
$(window).load(function() {
makeTodaybtnActive();
});
Also in eventRender function
$('#calendar').fullCalendar({
eventRender: function(event, element) {
makeTodaybtnActive();
},
});
When calendar load (page load) that time first code work and when change the month and goes to current month (by clicking today button) then second code make Today button active.
| <php><calendar><fullcalendar> | 2016-09-22 17:28:15 | LQ_EDIT |
39,645,410 | How to upload multiple files in django rest framework | <p>In django rest framework, I am able to upload single file using <a href="https://github.com/danialfarid/ng-file-upload" rel="noreferrer">danialfarid/ng-file-upload</a> </p>
<p>views.py:</p>
<pre><code>class PhotoViewSet(viewsets.ModelViewSet):
serializer_class = PhotoSerializer
parser_classes = (MultiPartParser, FormParser,)
queryset=Photo.objects.all()
def perform_create(self, serializer):
serializer.save(blogs=Blogs.objects.latest('created_at'),
image=self.request.data.get('image'))
</code></pre>
<p>serializers.py:</p>
<pre><code>class PhotoSerializer(serializers.ModelSerializer):
class Meta:
model = Photo
</code></pre>
<p>models.py:</p>
<pre><code>class Photo(models.Model):
blogs = models.ForeignKey(Blogs, related_name='blogs_img')
image = models.ImageField(upload_to=content_file_name)
</code></pre>
<p>When I try to upload multiple file. I get in </p>
<p>chrome developer tools:
Request Payload</p>
<pre><code>------WebKitFormBoundaryjOsYUxPLKB1N69Zn
Content-Disposition: form-data; name="image[0]"; filename="datacable.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryjOsYUxPLKB1N69Zn
Content-Disposition: form-data; name="image[1]"; filename="datacable2.jpg"
Content-Type: image/jpeg
</code></pre>
<p>Response:</p>
<pre><code>{"image":["No file was submitted."]}
</code></pre>
<p>I don't know how to write serializer for uploading multiple file. Any body please help.</p>
<p>Thanks in Advance</p>
| <python><angularjs><django><django-rest-framework> | 2016-09-22 17:32:48 | HQ |
39,646,114 | Windows UI Automation doesn't recognize button controls | <p>I'm having problems trying to identify via <em>Windows UI Automation</em> the button controls that are inside the <em>Notification Area</em> window (classname: <strong>ToolbarWindow32</strong>):</p>
<p><a href="https://i.stack.imgur.com/lwe5c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lwe5c.png" alt="enter image description here"></a></p>
<p>I verified via the <em>Windows UI Automation</em> tools deployed in the <em>Windows SDK</em> that those "icons" are controls of type <code>ControlType.Button</code>, however when I try to run the code below I get a null-reference exception because the search condition I use doesn't get any control.</p>
<p>I'm doing something wrong, or maybe I found some kind of limitation in <em>Windows UI Automation</em> ?</p>
<p>This is the code, I mixed it with WinAPI calls just to facilitate the task for the helper users who maybe preffers to use that methodology.</p>
<pre><code>Dim tskBarClassName As String = "Shell_TrayWnd"
Dim tskBarHwnd As IntPtr = NativeMethods.FindWindow(tskBarClassName, Nothing)
Dim systrayBarClassName As String = "TrayNotifyWnd"
Dim systrayBarHwnd As IntPtr = NativeMethods.FindWindowEx(tskBarHwnd, IntPtr.Zero, systrayBarClassName, Nothing)
Dim ntfyBarClassName As String = "ToolbarWindow32"
Dim ntfyBarHwnd As IntPtr = NativeMethods.FindWindowEx(systrayBarHwnd, IntPtr.Zero, ntfyBarClassName, Nothing)
Dim window As AutomationElement = AutomationElement.FromHandle(ntfyBarHwnd)
Dim condition As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button)
Dim button As AutomationElement = window.FindFirst(TreeScope.Descendants, condition)
MsgBox(button.Current.Name) ' Here throws the null-reference exception.
</code></pre>
<p>Any solution for this?</p>
| <.net><vb.net><ui-automation> | 2016-09-22 18:13:55 | HQ |
39,646,253 | Android stops finding BLE devices: onClientRegistered() - status=133 clientIf=0 | <p>I am developing an app in which I can both find and configure BLE devices. I am using standard Android BLE API, but recently I've encountered some strange problems. </p>
<p>When I turn on my app the BLE scan works OK. I am scanning using:</p>
<pre><code>mBluetoothAdapter.startLeScan(mLeScanCallback); // for Kitkat and below
</code></pre>
<p>and</p>
<pre><code>mBluetoothAdapter.getBluetoothLeScanner().startScan(mScanCallback); // for Lollipop and above
</code></pre>
<p>In the Logcat I am getting following messages (I guess this is important for this issue):</p>
<pre><code>D/BluetoothAdapter: onClientRegistered() - status=0 clientIf=5
</code></pre>
<p>In my app I can also read certain characteristics from my BLE devices (eg. battery state). I connect to a device to read this characteristic in a separate fragment using:</p>
<pre><code>mBluetoothManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(mMacAddress);
mBluetoothGatt = mBluetoothDevice.connectGatt(mContext, false, mGattCallback);
</code></pre>
<p>The characteristics are read correctly. In the <code>onCharacteristicRead</code> callback I also disconnect and close Gatt:</p>
<pre><code>mBluetoothGatt.disconnect();
mBluetoothGatt.close();
</code></pre>
<p>Each time I open a fragment to read a characteristic (no matter whether it is the same device or not) <code>clientIf</code> value increases. I can see in the LogCat:</p>
<pre><code>D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=9
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=10
</code></pre>
<p>Everything works fine until the <code>clientIf</code> value equals 10. BLE scan stops finding any devices, I can't connect to any of my devices to read any characteristics etc. And the LogCat infinitely displays these messages:</p>
<pre><code>D/BluetoothGatt: unregisterApp() - mClientIf=0
D/BluetoothGatt: onClientRegistered() - status=133 clientIf=0
</code></pre>
<p>The only way to fix it is to kill the app and relaunch it or restart Bluetooth by turning it off and on manually. I've encountered this issue only on certain devices such as Xperia Z1 (Android KitKat) and Galaxy S4 (Android Lollipop). I couldn't reproduce this issue on Xperia Z3 Compact running Android Marshmallow...</p>
<p>Is there anything I can do about it? I've already tried multiple "solutions" such as - calling all BLE methods from the UI thread and closing/disconnecting GATT, but nothing helps. How can I fix it?</p>
| <android><android-bluetooth><android-ble><android-wireless> | 2016-09-22 18:21:45 | HQ |
39,646,619 | Couldn't convert factor to numeric values in R for binning operation | I am provided with a dataset and I am asked to perform binning based on a particular column value. Here the column value is in factor when I tried converting to numeric I am getting either the NA coercion or getting the factor values but not the data in the table.
**"data$imdbVotes <- as.numeric(as.character(data$imdbVotes))"**
When I tried with this code I got the error
**"Warning message:
NAs introduced by coercion "**[This is the table provided and I have to perform binning based on IMDB votes][1]
[1]: http://i.stack.imgur.com/FLi0t.png | <r> | 2016-09-22 18:42:19 | LQ_EDIT |
39,647,594 | Java AssertEquals on 2 Strings Using Regex | I have 2 `Strings`:
`String actual = "abcd1234efgh";`
`String expected = "abcd5678efgh";`
The number part will always be different. They are `HBase` `Put` timestamps that are generated at the time of the creation of the `Put` object.
How can I make `AssertEquals` return `true` to these `Strings` the most efficient way possible? | <regex><junit> | 2016-09-22 19:41:33 | LQ_EDIT |
39,647,732 | Enabling CORS on IIS for only Font files | <p>Is there a way to enable CORS for only files of a certain type on IIS7? I am going off this article (<a href="https://www.maxcdn.com/one/tutorial/how-to-use-cdn-with-webfonts/" rel="noreferrer">https://www.maxcdn.com/one/tutorial/how-to-use-cdn-with-webfonts/</a>) and noticed that the Apache and nginx examples show that CORS is only enabled if the request is looking for a certain Content-Type, whereas the IIS example shows CORS enabled for everything. </p>
<p>I have CSS that is being referenced on an external site but the font files are being blocked by the browser and wish to enable CORS on IIS7 but only for .woff, .woff2, .tff, .eot, and .svg files. I do not wish to enable CORS for everything if possible.</p>
| <fonts><iis-7><web-config><cors> | 2016-09-22 19:49:31 | HQ |
39,647,771 | taking default value in argparse | <p>I am using argparser module and when using the below two commands.
The first works fine, but the second one fails.</p>
<p>SyntaxError: invalid syntax</p>
<p>I want if no value is specified it should take today as the value.</p>
<p>I am fetching the result using results.day</p>
<pre><code>parser.add_argument('-sub4' , action='store' , dest='subject4' , help='Fourth subject' , type=str , default="")
parser.add_argument('-day' , action='store' , dest='day' , help="yesterday/week default-today , type=str , default="today")
</code></pre>
<p>Thanks</p>
| <python><python-2.7> | 2016-09-22 19:51:55 | LQ_CLOSE |
39,647,810 | How to prevent Browser cache on Angular 2 site? | <p>We're currently working on a new project with regular updates that's being used daily by one of our clients. This project is being developed using angular 2 and we're facing cache issues, that is our clients are not seeing the latest changes on their machines.</p>
<p>Mainly the html/css files for the js files seem to get updated properly without giving much trouble.</p>
| <caching><angular><browser-cache><cache-control><angular2-template> | 2016-09-22 19:54:32 | HQ |
39,648,139 | Why invalid syntax in line 5? | <p>Whats the syntax error in line 5?? I have tried everything already... Anybody knows?</p>
<pre><code>print ("a. Dolar --> Euro\nb. Euro --> Dolar\n")
opti = input("Pick an option: ")
val = float(input("Enter value: ")
if opti == "a":
convr = 0.895
print (str(convr * val) + " Euros")
elif opti == "b":
convr = 1/0.895
print (str(convr * val) + " Dollars")
else:
print ("NOT ALLOWED!")
</code></pre>
| <python><python-3.x><syntax><syntax-error> | 2016-09-22 20:16:32 | LQ_CLOSE |
39,648,451 | geom_blank drops NA | <p>Using <code>geom_blank</code> I want to add some new factor levels, but I can't seem to do this <em>and</em> keep the <code>NA</code> level</p>
<pre><code>library('ggplot2')
pl <- ggplot(data.frame(x = factor(c(1:2, NA)), y = 1), aes(x, y)) + geom_point()
pl
</code></pre>
<p><a href="https://i.stack.imgur.com/DrAES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DrAES.png" alt="enter image description here"></a></p>
<pre><code>pl + geom_blank(data = data.frame(x = addNA(factor(c(0:3, NA))), y = 1))
</code></pre>
<p><a href="https://i.stack.imgur.com/eFlWE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eFlWE.png" alt="enter image description here"></a></p>
<p>I would like to have the x at 0,1,2,3,NA using <code>geom_blank</code></p>
| <r><ggplot2> | 2016-09-22 20:37:18 | HQ |
39,648,578 | In PyCharm, how do you add a directory from one project as a source to another project? | <p>I have several python projects started from git repos, all related to each other, that are all open in one PyCharm window.</p>
<p>I have python code in one project, call it project B, that imports python packages from project A, but PyCharm can't find the source. </p>
<p>I've marked the directories with python packages in project A as source directories in PyCharm, and indeed other code in project A can lookup these python packages. But these source directories don't appear to be part of the lookup table for other projects in the same window.</p>
<p>Is there any way in PyCharm to make one project recognize directories from another project as a source directory?</p>
| <pycharm> | 2016-09-22 20:45:18 | HQ |
39,649,585 | How to add column with constant in Spark-java data frame | <p>I have imported </p>
<pre><code>import org.apache.spark.sql.Column;
import org.apache.spark.sql.functions;
</code></pre>
<p>in my Java-Spark driver</p>
<p>But</p>
<pre><code>DataFrame inputDFTwo = hiveContext.sql("select * from sourcing_src_tbl");
inputDFTwo.withColumn("asofdate", lit("2016-10-2"));
</code></pre>
<p>here "lit" is still showing error in eclipse(windows).Which library should I include to make it work.</p>
| <java><apache-spark> | 2016-09-22 22:05:11 | HQ |
39,649,857 | convert a list of string list date | <p>Good evening everyone!</p>
<p>My form sends a String list in this format:</p>
<pre><code>dd/ MM / yyyy
</code></pre>
<p>Wanted converts this string list in date to the format : </p>
<pre><code>yyyy - MM - dd
</code></pre>
<p>How can I do this in Java ?</p>
| <java><arraylist> | 2016-09-22 22:30:17 | LQ_CLOSE |
39,650,056 | Using ccache when building inside of docker | <p>I am working on moving the build for a C++ project into a docker image. The image will be built and pushed by a Jenkins job. Prior to docker, I made heavy use of ccache to speed up my builds on Jenkins, especially in the case of builds where very little changed. The trouble with docker is that the build now runs in an isolated environment, so I can no longer benefit from ccache. Is there a way to build inside of an ephemeral container while still taking advantage of ccache?</p>
| <docker><ccache> | 2016-09-22 22:52:08 | HQ |
39,650,343 | How to consume soap web service in android | How to consume a web service soap using ksoap2 library. I'm not sure which are these parameters: namescape, method_name, soapaction, url. my web service is:
http://www2.sentinelperu.com/ws/aws_datosfoto.aspx?wsdl
Request and Result in the next image:
http://i.stack.imgur.com/bMcD6.png
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Usuario", "");
...
...= new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Thanks, sorry for my bad english. | <android><web-services><soap><android-ksoap2> | 2016-09-22 23:28:38 | LQ_EDIT |
39,650,407 | Pandas.read_csv() with special characters (accents) in column names � | <p>I have a <code>csv</code> file that contains some data with columns names:</p>
<ul>
<li><em>"PERIODE"</em></li>
<li><em>"IAS_brut"</em></li>
<li><em>"IAS_lissé"</em></li>
<li><em>"Incidence_Sentinelles"</em></li>
</ul>
<p>I have a problem with the third one <strong><em>"IAS_lissé"</em></strong> which is misinterpreted by <code>pd.read_csv()</code> method and returned as �.</p>
<p>What is that character?</p>
<p>Because it's generating a bug in my flask application, is there a way to read that column in an other way <strong>without modifying the file?</strong></p>
<pre class="lang-py prettyprint-override"><code>In [1]: import pandas as pd
In [2]: pd.read_csv("Openhealth_S-Grippal.csv",delimiter=";").columns
Out[2]: Index([u'PERIODE', u'IAS_brut', u'IAS_liss�', u'Incidence_Sentinelles'], dtype='object')
</code></pre>
| <python><pandas><unicode><utf-8><special-characters> | 2016-09-22 23:36:12 | HQ |
39,651,101 | How I write a function in python that determines whether a word has no vowels? | <p>How I write a function "noVowel" in python that determines whether a word has no vowels?</p>
<p>In my case, "y" is not a vowel.</p>
<p>For example, I want the function to return True if the word is something like "My" and to return false if the word is something like "banana".</p>
| <python> | 2016-09-23 01:14:27 | LQ_CLOSE |
39,651,853 | How to create join table with foreign keys with sequelize or sequelize-cli | <p>I'm creating models and migrations for two types, Player and Team that have many to many relationship. I'm using sequelize model:create, but don't see how to specify foreign keys or join tables.</p>
<pre><code>sequelize model:create --name Player --attributes "name:string"
sequelize model:create --name Team --attributes "name:string"
</code></pre>
<p>After the model is created, I add associations.
In Player:</p>
<pre><code>Player.belongsToMany(models.Team, { through: 'PlayerTeam', foreignKey: 'playerId', otherKey: 'teamId' });
</code></pre>
<p>In Team:</p>
<pre><code>Team.belongsToMany(models.Player, { through: 'PlayerTeam', foreignKey: 'teamId', otherKey: 'playerId' });
</code></pre>
<p>Then the migrations are run with</p>
<pre><code>sequelize db:migrate
</code></pre>
<p>There are tables for Player and Team but there's no join table (nor foreign keys) in the database. How can the foreign keys and join table be created? Is there a definitive guide on how to do this? </p>
| <node.js><join><foreign-keys><sequelize.js><sequelize-cli> | 2016-09-23 02:55:03 | HQ |
39,652,124 | ms-dos batch file - add text to beginning of first line and different text to beginning of all subsequent lines in file | source file contents (csv):
430,081216,081216,131231231231,,'',8686866,'Shamrock',,
1, ,5,,'',, ,01234567,32.50,
2,-,3,,'',, ,382847,25.92,
3, ,5,,'',, ,98765430,32.89,
target file needs to be (csv):
H,430,081216,081216,131231231231,,'',8686866,'Shamrock',,
D,1, ,5,,'',, ,01234567,32.50,
D,2,-,3,,'',, ,382847,25.92,
D,3, ,5,,'',, ,98765430,32.89,
I need to add an "H," to the beginning of the first line in the file, and a "D," to the beginning of all subsequent lines in the file, and save off as another file name. I don't know the best way to do this. I'm a newbie at this and would appreciate any help you can provide. | <csv><batch-file> | 2016-09-23 03:31:18 | LQ_EDIT |
39,652,262 | 'NoneType' object has no attribute '__getitem__' - Tkinter | <p>I've taken a look through the existing questions, but I haven't been able to find a solution so far.</p>
<p>I'm new to the Python programming language and have started playing around with Tk, but keep receiving the following error message when trying to either 'get' a value (from a checkbox) or change a value of a label:</p>
<p>'NoneType' object has no attribute '<strong>getitem</strong>'</p>
<p>Below is an example of my code in which I receive the error when clicking a button</p>
<pre><code>from Tkinter import *
the_window = Tk()
the_window.title('Button Change Colour')
def change_to_red():
colour_area['text']='Red'
colour_area = Label(the_window, bg='Grey', text = 'test', width = 40, height = 5).grid(row = 1, column = 1, padx = 5, pady = 5)
red_button = Button(the_window, text='Red', width = 5, command = change_to_red).grid(row = 2, column = 1)
the_window.mainloop()
</code></pre>
<p>I'm sure it's something small/silly, but would appreciate your help nonetheless! :)</p>
| <python><tkinter><tk> | 2016-09-23 03:47:37 | LQ_CLOSE |
39,652,457 | Represent SQL Entry As PHP Page | <p>Can anyone here to solve my query.</p>
<ol>
<li>I want to manage many PDFs on base of php and mysql. So, i make a script to show list of books with their author name and size from mysql and i were also categorize them. <strong><em>Now i want to show a detailed page (where download link, author name, size, screenshots, description will show) of each book, this detailed page will open when someone click on book name only.</em></strong></li>
</ol>
<p><strong>Script For List Of Books:</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><?php
$server = "localhost";
$username = "root";
$password = "mysql";
$dbname = "db-gs";
// Create connection
$connect = mysqli_connect($server, $username, $password, $dbname);
// Check connection
if (!$connect) {
die("Connection failed: " . mysqli_connect_error());
}
// Selection of data
$sql = "SELECT id, bname, aname, size, cat, lang FROM books";
$result = mysqli_query($connect, $sql);
if (mysqli_num_rows($result) > 0) {
echo "<table><tr><th>SNo:</th><th>Books</th><th>Size</th><th>Language</th></tr>";
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>".$row["id"]."</td><td>".$row["bname"]."</td><td>".$row["size"]."</td><td>".$row["lang"]."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
mysqli_close($connect);
?></code></pre>
</div>
</div>
</p>
| <php><mysql><database><html> | 2016-09-23 04:07:25 | LQ_CLOSE |
39,652,767 | PySpark 2.0 The size or shape of a DataFrame | <p>I am trying to find out the size/shape of a DataFrame in PySpark. I do not see a single function that can do this.</p>
<p>In Python I can do</p>
<pre><code>data.shape()
</code></pre>
<p>Is there a similar function in PySpark. This is my current solution, but I am looking for an element one</p>
<pre><code>row_number = data.count()
column_number = len(data.dtypes)
</code></pre>
<p>The computation of the number of columns is not ideal...</p>
| <dataframe><size><pyspark><shape> | 2016-09-23 04:42:24 | HQ |
39,652,884 | One Definition Rule - Multiple definition of inline functions | <p>I was reading ODR and as the rule says <code>"In the entire program, an object or non-inline function cannot have more than one definition"</code> and I tried the following...</p>
<p>file1.cpp</p>
<pre><code>#include <iostream>
using namespace std;
inline int func1(void){ return 5; }
inline int func2(void){ return 6; }
inline int func3(void){ return 7; }
int sum(void);
int main(int argc, char *argv[])
{
cout << func1() << endl;
cout << func2() << endl;
cout << func3() << endl;
cout << sum() << endl;
return 0;
}
</code></pre>
<p>file2.cpp</p>
<pre><code>inline int func1(void) { return 5; }
inline int func2(void) { return 6; }
inline int func3(void) { return 7; }
int sum(void) { return func1() + func2() + func3(); }
</code></pre>
<p>It worked as the rule says. I can have multiple definition of inline functions. </p>
<ul>
<li>What is the difference between non-inline function linkage and inline function linkage?</li>
<li>How the linker differentiate between these two?</li>
</ul>
| <c++><c++11> | 2016-09-23 04:55:41 | HQ |
39,653,072 | How to use .forRoot() within feature modules hierarchy | <p>Can anyone please clarify to me how should I structure multiple nested feature modules hierarchy with .forRoot() calls?</p>
<p>For example what if I have modules like this:</p>
<pre><code>- MainModule
- SharedModule
- FeatureModuleA
- FeatureModuleA1
- FeatureModuleA2
- FeatureModuleB
</code></pre>
<p>All feature modules has a .forRoot() static functions. </p>
<p>How should I define <em>FeatureModuleA</em> with somehow "transfer" the .forRoot() functions?</p>
<pre><code>@NgModule({
imports: [
//- I can use .forRoot() calls here but this module not the root module
//- I don't need to import sub-modules here, FeatureA only a wrapper
//FeatureModuleA1.forRoot(), //WRONG!
//FeatureModuleA2.forRoot(), //WRONG!
],
exports: [
//I cannot use .forRoot() calls here
FeatureModuleA1,
FeatureModuleA2
]
})
class FeatureModuleA {
static forRoot(): ModuleWithProviders {
return {
//At this point I can set any other class than FeatureModuleA for root
//So lets create a FeatureRootModuleA class: see below!
ngModule: FeatureModuleA //should be: FeatureRootModuleA
};
}
}
</code></pre>
<p>I can create another class for root usage then set it within the forRoot() function of FeatureModuleA: </p>
<pre><code>@NgModule({
imports: [
//Still don't need any sub module within this feature module
]
exports: [
//Still cannot use .forRoot() calls but still need to export them for root module too:
FeatureModuleA1,
FeatureModuleA2
]
})
class FeatureRootModuleA { }
</code></pre>
<blockquote>
<p>But how can I "transfer" .forRoot() calls within this special
ModuleClass?</p>
</blockquote>
<p>As I see I need to import all sub-modules directly into my root MainModule and call .forRoot() for each there:</p>
<pre><code>@NgModule({
imports: [
FeatureModuleA1.forRoot(),
FeatureModuleA2.forRoot(),
FeatureModuleA.forRoot(),
SharedModule.forRoot()
]
})
class MainModule { }
</code></pre>
<p>Am I right? Before you answer please take a look at this file:
<a href="https://github.com/angular/material2/blob/master/src/lib/module.ts">https://github.com/angular/material2/blob/master/src/lib/module.ts</a></p>
<p>As I know this repo maintained by the official angular team. So they solve the above with just importing all .forRoot() calls within a special MaterialRootModule module. I don't really understand how it would be applied for my own root module? What does the <strong>root</strong> and <strong>.forRoot</strong> really means here? Is that relative to the package and not to the actual web project?</p>
| <angular><angular-material2> | 2016-09-23 05:17:12 | HQ |
39,653,155 | Write query for this example | <p>I have a table with below data,I want to write a query that give me id and the number of days that have connection. </p>
<p>For example for id 1 give me 2 times (2016-09-20 , 2016-09-22)</p>
<p><a href="https://i.stack.imgur.com/vs3t8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vs3t8.jpg" alt="enter image description here"></a></p>
| <sql><sql-server><tsql> | 2016-09-23 05:25:39 | LQ_CLOSE |
39,655,026 | Find out number of words in a string with alot of special character | I need to find out the number of words in a string. However this string is not the normal type of string. It has alot of special character like < , /em, /p and many more. So most of the method used in stackoverflow does not work. As a result i need to define a regular expression by myself.
What i intend to do is to define what is a word using a regular expression and count the number of time a word appear.
This is how i define a word.
It must start with a letter and end with one of this : or , or ! or ? or ' or - or ) or . or "
This is how i define my regular expression
pattern = Pattern.compile("^[a-zA-Z](:|,|!|?|'|-|)|.|")$");
matcher = pattern.matcher(line);
while (matcher.find())
wordCount++;
However there is error with the first line
pattern = Pattern.compile("^[a-zA-Z](:|,|!|?|'|-|)|.|")$");
How can i fix this problem? | <java><regex> | 2016-09-23 07:26:05 | LQ_EDIT |
39,655,396 | from values filled with javascript didnt submit | i have a webform, some values are filled with javacript from another div, sadly they are not submitted, here is my javacript that fill the forms, fields with values from another div -
$('.item-buy-btn').on('click', function(target){
var getBasket = $('#edit-submitted-goods').val();
var currentItem = $(this).parent().parent('.stamps').children('.views-field-nid').children('.field-content').text();
$('#edit-submitted-goods').val(currentItem);
});
the values are putted in the form, https://yadi.sk/i/9zJtSrGsvaQae
but when i click submit, data from it is reseted, and the result from it comes empty
thank you for any help with this | <javascript><jquery><forms> | 2016-09-23 07:45:14 | LQ_EDIT |
39,656,759 | Is it necessary to add permissions in an android app? | <p>Is it necessary to add permissions in an android app ? And if yes, then why ? And if we don't put, then what will happen ?</p>
<p>Are the permissions added only to show them while installing the APK file ?</p>
| <android> | 2016-09-23 09:00:19 | LQ_CLOSE |
39,656,794 | Entity Framework update/insert multiple entities | <p>Just a bit of an outline of what i am trying to accomplish.
We keep a local copy of a remote database (3rd party) within our application. To download the information we use an api.
We currently download the information on a schedule which then either inserts new records into the local database or updates the existing records.
here is how it currently works</p>
<pre><code>public void ProcessApiData(List<Account> apiData)
{
// get the existing accounts from the local database
List<Account> existingAccounts = _accountRepository.GetAllList();
foreach(account in apiData)
{
// check if it already exists in the local database
var existingAccount = existingAccounts.SingleOrDefault(a => a.AccountId == account.AccountId);
// if its null then its a new record
if(existingAccount == null)
{
_accountRepository.Insert(account);
continue;
}
// else its a new record so it needs updating
existingAccount.AccountName = account.AccountName;
// ... continue updating the rest of the properties
}
CurrentUnitOfWork.SaveChanges();
}
</code></pre>
<p>This works fine, however it just feels like this could be improved.</p>
<ol>
<li>There is one of these methods per Entity, and they all do the same thing (just updating different properties) or inserting a different Entity. Would there be anyway to make this more generic?</li>
<li>It just seems like a lot of database calls, would there be anyway to "Bulk" do this. I've had a look at this package which i have seen mentioned on a few other posts <a href="https://github.com/loresoft/EntityFramework.Extended" rel="noreferrer">https://github.com/loresoft/EntityFramework.Extended</a>
But it seems to focus on bulk updating a single property with the same value, or so i can tell.</li>
</ol>
<p>Any suggestions on how i can improve this would be brilliant. I'm still fairly new to c# so i'm still searching for the best way to do things.</p>
<p>I'm using .net 4.5.2 and Entity Framework 6.1.3 with MSSQL 2014 as the backend database</p>
| <c#><sql-server><entity-framework> | 2016-09-23 09:01:52 | HQ |
39,656,884 | Can you create objects with length 0 in R? | <p>Is it possible to create objects in R with length 0?</p>
| <r> | 2016-09-23 06:41:35 | LQ_CLOSE |
39,657,058 | Installing GD in Docker | <p>I am a complete Docker novice but am having to maintain an existing system. The Dockerfile I am using is as below:</p>
<pre><code>FROM php:5.6-apache
RUN docker-php-ext-install mysql mysqli
RUN apt-get update -y && apt-get install -y sendmail
RUN apt-get update && \
apt-get install -y \
zlib1g-dev
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install zip
RUN docker-php-ext-install gd
</code></pre>
<p>When I run 'docker build [sitename]' everything seems ok until I get the error:</p>
<pre><code>configure: error: png.h not found.
The command '/bin/sh -c docker-php-ext-install gd' returned a non-zero code: 1
</code></pre>
<p>What is the cause of this error?</p>
| <php><docker><dockerfile> | 2016-09-23 09:16:13 | HQ |
39,659,273 | Get current app's build version - Xamarin.Android | <p>I need to display the app's build version in my settings page.</p>
<p>So how can i get the <code>versionCode</code> and <code>versionName</code> from <code>AndroidManifest.xml</code> file programmatically.</p>
<p>Or</p>
<p>Is there any way to get the build version programmatically in <code>xamarin.forms</code>.</p>
| <xamarin><xamarin.android><xamarin.forms> | 2016-09-23 11:08:22 | HQ |
39,659,647 | In the sas ,the length of a variable is 8 bytes, but display 12 bytes | [In my opinion, the length of variable is the bytes in which the variable is stored , but in the following picture, the the length of variable displayed is beyond the length of variable. Help me, please][1]
[1]: http://i.stack.imgur.com/BLe4T.jpg
| <sas> | 2016-09-23 11:27:11 | LQ_EDIT |
39,659,966 | Javascript or PHP Array search like SQL %seacrch% | <p>Hello i'm trying to search in a Array like SQL with the "Like %search%" statement
Has anybody an idea? I need this.</p>
| <javascript><php><html><mysql><sql> | 2016-09-23 11:43:54 | LQ_CLOSE |
39,660,074 | "Post Image data using POSTMAN" | <p>I am trying to POST data to my API. I have a model with an <code>image</code> field where:</p>
<pre><code>image = models.ImageField()
</code></pre>
<p>I have an image on my local box, which I am trying to send. Am I sending it correctly?</p>
<pre><code>{
"id": "3",
"uid":"273a0d69",
"uuid": "90",
"image": "@/home/user/Downloads/tt.jpeg"
}
</code></pre>
| <django><django-models><django-rest-framework><postman> | 2016-09-23 11:50:35 | HQ |
39,660,436 | Why java packages do not work as a hierarchy? | <p>why java does not allow access to package restricted types that are in parents package?</p>
<p>With something like :</p>
<pre><code>Package a
|--Class A
|--Package b
|--Class B
</code></pre>
<p>It is not possible to access class <code>A</code> from class <code>B</code> if class <code>A</code> has package visibility. I thought it make sense but apparently not.</p>
<p>What is the reason for that?</p>
| <java><packages> | 2016-09-23 12:08:56 | LQ_CLOSE |
39,661,345 | Moving from typings to @types using Visual Studio & Typescript 2.0.3 | <p>I've tried to remove typings from my web project (Visual Studio 2015 Community) and install d.ts files via new NPM @types (typescript 2.0.3) in package.json:</p>
<pre><code> "dependencies": {
"@types/angular": "^1.5.8",
"@types/angular-cookies": "^1.4.2",
"@types/angular-local-storage": "^0.1.33",
"@types/angular-material": "^1.1.37",
"@types/angular-translate": "^2.4.33",
"@types/lodash": "^4.14.36"
}
</code></pre>
<p>Visual Studio's IntelliSense worked nicely with typings before because I included typings folder in my VS project. NPM installs types into <code>node_modules/@types</code> folder. Now here is my problem. I don't really want to include anything from <code>node_modules</code> in VS project.
<code>node_modules</code> folder should be fine to get deleted and recreated again by npm at will.
Visual Studio does not recognize the typings installed without them being included in the project!
I guess I could create a file with ///reference tags in it but then I would have to maintain this file manually when installing/removing typings.</p>
<p>Is there any recommended way to make VS IntelliSense work?</p>
| <visual-studio-2015><typescript-typings><typescript2.0> | 2016-09-23 12:55:25 | HQ |
39,661,568 | New to testing, how would I test this method with Mocha, Chai, Enzyme, and Sinon? | <p>Here's my method</p>
<pre><code> handleKeyEvent(event) {
const code = event.keyCode;
if (UsedKeys.includes(code)) {
event.preventDefault();
if (code === KeyCodes.DOWN) {
this.modifyIndexBy(1);
} else if (code === KeyCodes.UP) {
this.modifyIndexBy(-1);
}
}
}
</code></pre>
<p>I'm still pretty new to testing, and I have no idea how I'd go about testing this piece.
The method takes an event, so do I have to synthesize an event object and pass it in? </p>
<p>After that, do I just somehow test that <code>this.modifyIndexBy()</code> gets called? </p>
<p>This method doesn't return anything. Do I modify my code to be more testable?</p>
| <javascript><testing><mocha><sinon><chai> | 2016-09-23 13:06:51 | LQ_CLOSE |
39,661,858 | Change background color in launch screen when using DayNight theme | <p>I am using <strong>DayNight</strong> theme with <strong>launch screen</strong>.</p>
<p>Launch screen is a layer-list with white background.</p>
<p>So when its day, <strong>white</strong> launch screen shows followed by <strong>white</strong> activity. But at night, <strong>white</strong> launch screen shows follwed by <strong>dark</strong> activity.</p>
<p><em>How can i change the background color in the launch screen according to the theme.</em></p>
<p>Cannot use custom color attrs because there is only a DayNight theme.</p>
<p><strong>themes.xml</strong></p>
<pre><code><resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorControlNormal">@color/colorAccent</item>
</style>
<style name="LaunchTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/launch_screen</item>
</style>
</code></pre>
<p></p>
<p><strong>launch_screen.xml</strong></p>
<pre><code><layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/material_white"/>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_logo"
android:tileMode="disabled"/>
</item>
</code></pre>
<p></p>
| <android><android-theme><android-styles> | 2016-09-23 13:21:03 | HQ |
39,663,096 | docker-compose creating multiple instances for the same image | <p>I need to start multiple containers for the same image. If i create my compose file as shown below, it works fine. </p>
<pre><code>version: '2'
services:
app01:
image: app
app02:
image: app
app03:
image: app
app04:
image: app
app05:
image: app
</code></pre>
<p>Is there any easy way for me to mention the number of instances for the compose instead of copy and pasting multiple times?</p>
| <docker><docker-compose><docker-container> | 2016-09-23 14:19:14 | HQ |
39,664,290 | How to tell the version number of RxJS | <p>How to tell the version of the installed RxJS from the code? For example:</p>
<pre><code>var Rx = require('rxjs/Rx');
console.log(Rx.rev); // undefined
console.log(Rx.version); // undefined
</code></pre>
<p>Second question: How to tell if it's rxjs5 ?</p>
| <javascript><node.js><rxjs><rxjs5> | 2016-09-23 15:19:28 | HQ |
39,664,662 | How to upload and list directories at firefox and chrome/chromium using change and drop events | <p>Both mozilla and webkit browsers now allow directory upload. When directory or directories are selected at <code><input type="file"></code> element or dropped at an element, how to list all directories and files in the order which they appear in actual directory at both firefox and chrome/chromium, and perform tasks on files when all uploaded directories have been iterated?</p>
| <javascript><file-upload><directory><fileapi> | 2016-09-23 15:37:18 | HQ |
39,665,263 | onchange need to reset the value in jquery | on load I got my input value 5.02, now i need to change in 6.
now i am getting either null or 5.02.
how i can get my data is 6???
My code is:::
<input type="number" id="rate" class="form-control rate " th:value="${abc.rate}" placeholder="Rate" />
javaScript:::
$(".rate input[type='number']").change(function() {
$("#rate").val("");//i am reseting the value
rateForA =$('#rate').val();//but i am getting null
console.log(rateForA );
});
| <javascript><jquery> | 2016-09-23 16:13:13 | LQ_EDIT |
39,665,319 | std::List, cant access object | Im new to cpp and want to learn about list.
When i run my program it compiles fine but i dont get the result
im expecting.
This gives me the output "Legs: 0 Name: "
It should be "Legs 4 Name: dog".
Can any one see the problem?
As in the comment section, i have tried for over an hour and get get this to work, cant see the problem.
//Header file!
using namespace std;
#ifndef ANIMAL_H
#define ANIMAL_H
class Animal {
public:
Animal();
Animal(const Animal& orig);
virtual ~Animal();
int _Legs;
void SetName(string name);
string GetName();
private:
string _Name;
};
#endif /* ANIMAL_H */
//Animal.cpp
Animal::Animal() {
}
Animal::Animal(const Animal& orig) {
}
Animal::~Animal() {
}
string Animal::GetName(){return _Name;}
void Animal::SetName(string name){_Name = name;};
//Mainfile!
void List()
{
std::list<Animal> animal_list;
Animal temp;
temp = Animal();
temp._Legs = 4;
temp.SetName("Dog");
animal_list.push_back(temp);
for(std::list<Animal>::iterator list_iter = animal_list.begin();
list_iter != animal_list.end(); list_iter++)
{
std::cout<< "Legs:" << list_iter->_Legs << " Name: " << list_iter->GetName() << endl;
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
List();
return 0;
}
| <c++> | 2016-09-23 16:16:27 | LQ_EDIT |
39,665,339 | How can i ignore error to continue project in c# code? | <p>I am working on a windows form application. when i run the project in one of my class error occurs. (see below image)</p>
<p><a href="https://i.stack.imgur.com/ho7ra.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ho7ra.jpg" alt="enter image description here"></a></p>
<p>But when i press continue button The project runs well. Also, I can not delete this line of code. How can I ignore this error to continue project?</p>
| <c#><windows><winforms><visual-studio><error-handling> | 2016-09-23 16:17:35 | LQ_CLOSE |
39,665,608 | R filtering table and inserting information | <p>I currently have following table structure</p>
<p><strong>Table1</strong></p>
<pre><code>id a
11 4
11 3
22 1
22 3
22 5
33 2
33 1
44 6
44 8
66 5
66 7
77 6
</code></pre>
<p><strong>Table2</strong></p>
<pre><code>id score
11 12
33 22
44 20
</code></pre>
<p>I want to delete every row from Table1, that does not contain any of the id in Table2$id. <code>unique(Table2$id)</code> should generate such an unique id list. Further, I need to write the <em>score</em> from Table2 into each corresponding id of Table1. The desired dataframe would be:</p>
<p><strong>Result</strong></p>
<pre><code>id a score
11 4 12
11 3 12
33 2 22
33 1 22
44 6 20
44 8 20
</code></pre>
| <r><dataframe><filter><merge> | 2016-09-23 16:34:34 | LQ_CLOSE |
39,665,617 | How to style a Slider on Android with React Native | <p>I'd like to use a <a href="https://facebook.github.io/react-native/docs/slider.html" rel="noreferrer">Slider</a> on Android using React Native.</p>
<p>Custom tracking images and thumb are iOS only properties, so what are the available options on Android to style the track and the thumb?</p>
<p>More specifically I'm looking for a way to change the color of the thumb, the color of min/max track, and their thickness...</p>
| <react-native><react-native-android> | 2016-09-23 16:35:07 | HQ |
39,665,790 | SwiftLint: Exclude file for specific rule | <p>I'm trying to do something like this in my .swiftlint.yml file:</p>
<pre><code>force_cast:
severity: warning # explicitly
excluded:
- Dog.swift
</code></pre>
<p>I have this code and I don't like the force_try warning I'm getting for it:</p>
<pre><code>let cell = tableView.dequeueReusableCellWithIdentifier(Constants.dogViewCellReuseIdentifier,
forIndexPath: indexPath) as! DogViewCell
</code></pre>
<p>I want to suppress the warning for this file by excluding this file from the rule.</p>
<p>Is there a way to do that ?</p>
| <swiftlint> | 2016-09-23 16:46:34 | HQ |
39,666,308 | pd.read_csv by default treats integers like floats | <p>I have a <code>csv</code> that looks like (headers = first row):</p>
<pre><code>name,a,a1,b,b1
arnold,300311,arnld01,300311,arnld01
sam,300713,sam01,300713,sam01
</code></pre>
<p>When I run:</p>
<pre><code>df = pd.read_csv('file.csv')
</code></pre>
<p>Columns <code>a</code> and <code>b</code> have a <code>.0</code> attached to the end like so:</p>
<pre><code>df.head()
name,a,a1,b,b1
arnold,300311.0,arnld01,300311.0,arnld01
sam,300713.0,sam01,300713.0,sam01
</code></pre>
<p>Columns <code>a</code> and <code>b</code> are integers or blanks so why does <code>pd.read_csv()</code> treat them like floats and how do I ensure they are integers on the read? </p>
| <python><csv><pandas><integer> | 2016-09-23 17:19:38 | HQ |
39,666,339 | Fastlane: proper way to add a device to provisioning? | <p>I am using fastlane to handle provisioning.</p>
<p>This is what I did:</p>
<pre><code>match nuke development
match nuke distribution
</code></pre>
<p>then in a lane I have this for each bundleId I need to provision for:</p>
<pre><code>match(type: "development", app_identifier: "com.myCompany.myApp", force_for_new_devices: true)
</code></pre>
<p>When I want to download the provisioning I have a lane that does this:</p>
<pre><code>match(type: "development", app_identifier: "com.myCompany.myApp", readonly: true)
</code></pre>
<p>All this lets me work and build fine on devices that were ALREADY in the portal at the time of nuke.</p>
<p>How do I update provisioning correctly if I want to add a device?</p>
<p>I tried this:</p>
<pre><code>match development --force_for_new_devices true -a com.myCompany.myApp
</code></pre>
<p>It does not work.</p>
<p>I get this error:</p>
<pre><code>Provisioning profile '82afbd5b-9f19-4c78-b3ac-56a3565ce3f2' is not available on the Developer Portal
</code></pre>
<p>The only thing that works every time I have to add a device is to nuke everything and start fresh.</p>
<p>What's the proper way to add a device without having to nuke??</p>
<p>I am using xcode8, I disabled the automatic provisioning like suggested by fastlane.</p>
| <ios><fastlane> | 2016-09-23 17:21:44 | HQ |
39,666,585 | Does git store the read, write, execute permissions for files? | <p>I wanted to make some files in git read only. But I couldn't find any good documentation on doing this.</p>
<p><strong>Does git store the read, write, execute permissions for files?</strong></p>
| <git><permissions><file-permissions> | 2016-09-23 17:39:19 | HQ |
39,667,501 | show data from SQLite to Custom ListView is android studio | I Want to show my data from SQLite to Custom ListView (java , Android studio , SQLite ).
But it's force stop.
picture from my Main Activity:
picture from my Database class:
picture from my custom list view class:
Please Help me!!!!
(my English is not good sorry but can i understand your words) | <java><android><database><sqlite><android-studio> | 2016-09-23 18:37:38 | LQ_EDIT |
39,667,822 | Differences between Visual Studio Build step and MSBuild Build step | <p>I'm creating some build definitions and the only difference I see between the Visual Studio Build Step and MSBuild Build Step is that the VS Build Step adds the visual studio version to the build. </p>
<p>Somebody can explain maybe more differences?</p>
| <visual-studio><tfs><msbuild><tfs-2015> | 2016-09-23 19:00:22 | HQ |
39,668,109 | Assigning users to tasks in Visual Studio Team Services | <p>I've just joined my friend's Team Services account (free for the first 5 users account). If I visit the home page (<a href="https://XXXXXXX.visualstudio.com/Development/Development%20Team" rel="noreferrer">https://XXXXXXX.visualstudio.com/Development/Development%20Team</a>), I can see us both listed as Team Members. I can create backlog items/tasks and assign them to myself. My friend can create backlog items/tasks and assign them to himself. However, we can't assign each other.</p>
<p>Why could this be and any suggestions on how to resolve this?</p>
| <azure-devops> | 2016-09-23 19:19:16 | HQ |
39,668,369 | plotly in R: Listing legend items horizontally and centered below a plot | <p>I have been tweaking legends in plotly and R. One thing I am unable to figure out is how (if it is possible) to reposition legend items so that they are listed horizontally and centered below the plot. The default legend items are positioned vertically and located to the right of the plot, as shown here:</p>
<pre><code>plot_ly(data = iris, x = Sepal.Length, y = Petal.Length, mode = "markers", color = Species)
</code></pre>
<p>I am able to get the legend below and centered to the plot by the following:</p>
<pre><code>plot_ly(data = iris, x = Sepal.Length, y = Petal.Length, mode = "markers", color = Species) %>% layout(legend = list(x = 0.35, y = -0.5))
</code></pre>
<p>However, I notice that this legend position changes based on how I view the plot (the dimensions I make the plot window, etc). Because of this, the legend will sometimes accidentally overlap the plot (by being positioned too high up) or be separated from the plot by an awkwardly-large distance (by being positioned too low). Here is an example image of the legend being positioned too low:</p>
<p><a href="https://i.stack.imgur.com/KgQ97.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KgQ97.png" alt="Legend moves depending on plot window dimensions"></a></p>
<p>Moreover, when placing the legend below the plot, it may look better to have legend items listed horizontally (instead of vertically). In this example, it would be great to have virginica, versicolor, and setosa listed left to right in the legend (instead of top to bottom). Hence, ideally looking like this:</p>
<p><a href="https://i.stack.imgur.com/WBNZy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WBNZy.png" alt="Ideal"></a></p>
<p>Is it possible to obtain this - that is, a legend positioned centered and below the plot (that does not change location with window size) while listing its items horizontally?</p>
| <r><legend><plotly> | 2016-09-23 19:37:49 | HQ |
39,668,456 | How to deploy ASP.NET Core UserSecrets to production | <p>I followed the <a href="https://docs.asp.net/en/latest/security/app-secrets.html" rel="noreferrer">Safe storage of app secrets during development</a> guide over on the asp.net docs during development but it does not describe how to use it when publishing to another machine for QA, Production, etc. What I figured it would do was insert them into the appsettings.json during publish but it does not. I ended up having to place my SendGrid keys and other sensitive information directly into the appsettings.json which really defeats the purpose of the app secrets.</p>
<p>Is using app secrets the best way or is there another way to store API keys and SQL user/passwords in my configs?</p>
| <asp.net-core><asp.net-core-mvc> | 2016-09-23 19:44:56 | HQ |
39,668,773 | What is diff between requestIdToken and requestServerAuthCode in google singnin | <p>I am not able to differentiate between these two: requestIdToken and requestServerAuthCode, when we signin with google api from android device.</p>
<p>My requirement is to provide option for users to login in android device, and after login sync data to my server.
Server need to validate logged in user request from android device. I am thinking to use "requestIdToken".
On the server side i am using google client library to fetch user info from requestIdToken.</p>
| <android><google-api> | 2016-09-23 20:07:40 | HQ |
39,669,098 | Ember include in-app shared components addon in in-app engine | <p>In an Ember application that contains an in-app engine (my-engine) and an in-app addon for shared components (shared-components), how do you include the shared components addon as a dependency of the in-app engine so you may use the components in the templates of the engine? The shared components addon has two components, global-header and global-footer. </p>
| <javascript><ember.js> | 2016-09-23 20:33:51 | HQ |
39,669,538 | Python mock call_args_list unpacking tuples for assertion on arguments | <p>I'm having some trouble dealing with the nested tuple which <code>Mock.call_args_list</code> returns.</p>
<pre><code>def test_foo(self):
def foo(fn):
fn('PASS and some other stuff')
f = Mock()
foo(f)
foo(f)
foo(f)
for call in f.call_args_list:
for args in call:
for arg in args:
self.assertTrue(arg.startswith('PASS'))
</code></pre>
<p>I would like to know if there is a better way to unpack that call_args_list on the mock object in order to make my assertion. This loop works, but it feels like there must be a more straight forward way.</p>
| <python><unit-testing><python-unittest><python-unittest.mock> | 2016-09-23 21:05:12 | HQ |
39,670,360 | Angular2 FileSaver.js - Cannot find module 'file-saver' | <p>I am working on moving an angular 1.x site to a new angular 2.0 site I created the site using angular-cli 1.0.0-beta.15. </p>
<p>I have a button to export some data to a CSV file. When the page first loads I get an error message "Cannot find module 'file-saver'", but when I click the button everything works perfectly. </p>
<p>I have the FileSaver.js component installed:</p>
<p>package.json</p>
<pre><code>...
"dependencies": {
...
"@types/filesaver": "0.0.30",
"file-saver": "^1.3.2"
...
}
...
</code></pre>
<p>in my export.service.ts:</p>
<pre><code>import { saveAs } from 'file-saver';
...
let file = new Blob(['hello world'], { type: 'text/csv;charset=utf-8' });
saveAs(file, 'helloworld.csv');
...
</code></pre>
<p>Does anyone know how to resolve this error?</p>
| <angular><typescript> | 2016-09-23 22:21:45 | HQ |
39,670,382 | Apache POI error loading XSSFWorkbook class | <p>I'm trying to write a program that works with Excel docs, but the HSSF format is too small for my requirements. I'm attempting to move to XSSF, but I keep getting errors when trying to use it.</p>
<p>I managed to solve the first two by adding xmlbeans-2.3.0.jar and dom4j-1.6.jar to my program, but now this error is coming up, which doesn't seem to be resolved by adding the Apache commons jar available on the Apache website.</p>
<p>The error is as follows:</p>
<pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
at hot.memes.ExcelCreator.main(ExcelCreator.java:66)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.ListValuedMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
</code></pre>
| <java><apache><apache-poi><xssf> | 2016-09-23 22:24:34 | HQ |
39,670,428 | cannot use setText() will crash the app everytime | <p>text view will crash every time i use .setText()
this is my activity
TextView tvAvgRank;
SharedPreferences pref;</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stats);
pref = this.getSharedPreferences("ranks", Context.MODE_PRIVATE);
tvAvgRank = (TextView)findViewById(R.id.tvAvgRank);
tvAvgRank.setText(avgRank(loadRanks()));
}
</code></pre>
| <android><textview> | 2016-09-23 22:30:18 | LQ_CLOSE |
39,670,518 | How can I trim down this code? | <p>I have two text files "usernames.txt" and "passwords.txt" and I want to have them print out in a specific order, I have a snippet of code that does exactly what I need but I feel like It can be shortened.</p>
<pre><code>with open('passwords.txt','r') as f:
for line in f:
for password in line.split():
with open('usernames.txt','r') as f:
for line in f:
for username in line.split():
print username +":"+ password
</code></pre>
<p>This works perfect for me what I feel like I can make it even shorter!</p>
<p>current output is this:</p>
<pre><code>username1:password
username1:password1
username1:password2
username2:password
username2:password1
username2:password2
</code></pre>
| <python> | 2016-09-23 22:39:14 | LQ_CLOSE |
39,670,918 | Replace characters in column names gsub | <p>I am reading in a bunch of CSVs that have stuff like "sales - thousands" in the title and come into R as "sales...thousands". I'd like to use a regular expression (or other simple method) to clean these up. </p>
<p>I can't figure out why this doesn't work:</p>
<pre><code>#mock data
a <- data.frame(this.is.fine = letters[1:5],
this...one...isnt = LETTERS[1:5])
#column names
colnames(a)
# [1] "this.is.fine" "this...one...isnt"
#function to remove multiple spaces
colClean <- function(x){
colnames(x) <- gsub("\\.\\.+", ".", colnames(x))
}
#run function
colClean(a)
#names go unaffected
colnames(a)
# [1] "this.is.fine" "this...one...isnt"
</code></pre>
<p>but this code does:</p>
<pre><code>#direct change to names
colnames(a) <- gsub("\\.\\.+", ".", colnames(a))
#new names
colnames(a)
# [1] "this.is.fine" "this.one.isnt"
</code></pre>
<p>Note that I'm fine leaving one period between words when that occurs.</p>
<p>Thank you.</p>
| <r><gsub> | 2016-09-23 23:26:44 | HQ |
39,671,271 | Imgur delete anonymous upload (Greenshot) | <p>Need your help... thanks to Greenshot a missclick is sufficient to post a picture online to Imgur. (I did...and now I want to delete it)
the picture has been posted using anonymous mode.</p>
<p>Because I didn't post it manually I do not have the delete link, but I have the deleteHash (15 alphanum-character).</p>
<p>I know there is formular to ask to delete the picture. But I would like to delete it myself.</p>
<p>In the plugin history I found a delete button which tell me the picture has been deleted from Imgur but the picture is still there.</p>
<p>I tried this : <a href="http://imgur.com/delete/ABCDEFghi01abcd" rel="noreferrer">http://imgur.com/delete/ABCDEFghi01abcd</a>
but its tells me "This isn't a valid image link! Go on, get out of here!"</p>
<p>I tried this :</p>
<pre><code> <form action="https://api.imgur.com/3/image/ABCDEFghi01abcd" method="DELETE
<p><input type="submit" value="OK"></p>
</form>
</code></pre>
<p>but I got this : </p>
<pre><code>{"data":{"error":"Authentication required","request":"\/3\/image\/ABCDEFghi01abcd","method":"GET"},"success":false,"status":401}
</code></pre>
<p>(BTW how do we send a DELETE method ? it seems ignored and sent a GET instead...)</p>
<p>maybe the deleteHash code given by Greenshot is wrong ? </p>
<p>Any idea ? </p>
| <imgur> | 2016-09-24 00:22:13 | HQ |
39,671,396 | Logging array indices, not values (JavaScript) - why? | <p>Here's my script:</p>
<pre><code>var alphabet = ["A", "B", "C", "D", "3", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
var str = [];
for (i=0; i<alphabet.length; i++) {
str.push(i);
console.log(str.join(""));
}
</code></pre>
<p>It's printing out the indices of str (0, 01, 012...) rather than the values (A, AB, ABC...). What is going on here? </p>
| <javascript><arrays> | 2016-09-24 00:46:27 | LQ_CLOSE |
39,671,607 | sentence substitution with ruby using .gsub | Now what if I'm trying to change just parts of a word? Like "Car" to "cah", or vise versa in "Martha" to "Marther". In the second case, if I just did an if like this:
`<if sentance.include? "er"
user_input.gsub!(/er/, "a")
end >`
It would take all "a"'s in "MArthA", which is not what I want.
Any ideas?
For other examples.
http://stackoverflow.com/questions/8381499/replace-words-in-string-ruby/39671330?noredirect=1#comment66644316_39671330 | <ruby><string><gsub><string-substitution> | 2016-09-24 01:21:17 | LQ_EDIT |
39,672,032 | Scanner.skip("[\r\n]+") produz exception: java.util.NoSuchElementException | Estou tentando importar um arquivo csv para o java(JPA), para isso estou usando SCANNER, mas o problema é que no final da linha ele esta se perdendo, tentei usar o método skip("[\r\n]+") do scanner mas ainda assim, obtenho uma exception java.util.NoSuchElementException. Já tentei usar como parâmetro na função skip somente "\r\n" e também já tentei "[\r\n]".. sem sucesso, sera que alguém pode me ajudar?
Scanner sc = new Scanner (new File(loq)).useDelimiter(";");
pote = sc.next();
Questoes quest = new Questoes( );
do
{
EntityManagerFactory quest_factory = Persistence.createEntityManagerFactory("TRM");
EntityManager entitymanager = quest_factory.createEntityManager( );
entitymanager.getTransaction( ).begin( );
//pote = sc.next();
System.out.println(pote);
quest.setCategoria(Integer.parseInt(pote));
pote = sc.next();
System.out.println(pote);
quest.setNivel(Integer.parseInt(pote));
pote = sc.next();
System.out.println(pote);
quest.setQuestao(pote);
pote = sc.next();
System.out.println(pote);
quest.setR1(pote);
pote = sc.next();
System.out.println(pote);
quest.setR2(pote);
pote = sc.next();
System.out.println(pote);
quest.setR3(pote);
pote = sc.next();
System.out.println(pote);
quest.setCorreta(pote);
System.out.println("fim linha");
sc.skip("[\r\n]");
entitymanager.persist( quest );
entitymanager.getTransaction( ).commit( );
entitymanager.close( );
quest_factory.close( );
}
while((pote = sc.next())!= null);
sc.close();[enter image description here][1]
[1]: http://i.stack.imgur.com/9DyW4.png | <java><jpa><java.util.scanner> | 2016-09-24 02:56:27 | LQ_EDIT |
39,672,332 | Need assist with my loop with a c++ dice program | how do I continue to keep the player rolling the dice till they roll the correct number or lose?
Here are the directions.
For this assignment, write a program that will simulate a single game of Craps.
Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the die is equal to 7 or 11, the player wins immediately. If the sum of the first roll of the die is equal to 2, 3, or 12, the player has rolled "craps" and loses immediately. If the sum of the first roll of the die is equal to 4, 5, 6, 8, 9, or 10, the game will continue with the sum becoming the "point." The object of the game is now for the player to continue rolling the die until they either roll a sum that equals the point or they roll a 7. If the player "makes their point," they win. If they roll a 7, they lose.
Here is my program:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int dice_num1, dice_num2 = 0;
int roll_dice;
int dice_num3, dice_num4 = 0;
int roll_dice2;
char repeat = 'y';
while (repeat == 'y' || repeat == 'Y')
{
srand(time(0));
dice_num1 = rand() % 6 + 1;
dice_num2 = rand() % 6 + 1;
roll_dice = dice_num1 + dice_num2;
cout <<"Player rolled: "<< dice_num1<<" + "<<dice_num2<<" = "<<roll_dice<<endl;
cout <<"\nThe point is "<<roll_dice<<endl;
dice_num3 = rand() % 6 + 1;
dice_num4 = rand() % 6 + 1;
roll_dice2 = dice_num3 + dice_num4;
cout <<"\nPlayer rolled: "<< dice_num3<<" + "<<dice_num4<<" = "<<roll_dice2<<endl;
if (roll_dice2 == 7 || roll_dice2 == 11)
{
cout << "Congrats you are a Winner!" << endl ;
}
else if (roll_dice2 == 2 || roll_dice2 == 3 || roll_dice2 == 12)
{
cout << "Sorry, you rolled craps, You lose!" << endl;
}
else if (roll_dice2 == 4 || roll_dice2 == 5 ||roll_dice2 == 6 ||roll_dice2 == 8 || roll_dice2 == 9 || roll_dice2 == 10)
{
dice_num3 = rand() % 6 + 1;
dice_num4 = rand() % 6 + 1;
int sum_num2 = dice_num3 + dice_num4;
if( sum_num2 == roll_dice2 )
{
cout << "Congrats you are a Winner!" << endl;
break;
}
else if( sum_num2 == 7 )
{
cout << "Sorry, You Lose!" << endl;
break;
}
}
cout <<"\nAnother game? Y(es) or N(o)" << endl;
cin >> repeat;
if (repeat == 'n' || repeat == 'N')
{
cout <<"Thank you for playing!"<< endl;
return 0;
}
}
}
This is my output:
Player rolled: 4 + 5 = 9
The point is 9
Player rolled: 5 + 3 = 9
Another game? Y(es) or N(o)
This is what my output needs to be:
Player rolled: 2 + 2 = 4
The point is 4
Player rolled: 4 + 5 = 9
Player rolled: 5 + 1 = 6
Player rolled: 1 + 2 = 3
Player rolled: 2 + 3 = 5
Player rolled: 1 + 2 = 3
Player rolled: 3 + 5 = 8
Player rolled: 2 + 4 = 6
Player rolled: 6 + 3 = 9
Player rolled: 6 + 2 = 8
Player rolled: 3 + 4 = 7
You rolled 7 and lost!
How do i get this to continue rolling the dice in the loop, please tell me what i need to change. Thank you!
| <c++><loops><dice> | 2016-09-24 03:58:13 | LQ_EDIT |
39,672,653 | Is /dev/zero Unsafe to Use on Cygwin? | <p>So I ran the following command in Cygwin: <code>dd if=/dev/zero of=E:</code></p>
<p>Now my C: drive lost all its free space. Upon unpluggin my E: drive from its USB port, the PC automatically shuts down. Is /dev/zero being created within the C: drive, and if so does that make it potentially unsafe to use with Cygwin?</p>
| <cygwin><dd><windows-10-desktop> | 2016-09-24 04:52:22 | LQ_CLOSE |
39,672,807 | Types in object destructuring | <p>This</p>
<pre><code>const { foo: IFoo[] } = bar;
</code></pre>
<p>and this</p>
<pre><code>const { foo: Array<IFoo> } = bar;
</code></pre>
<p>will reasonably cause an error.</p>
<p>And this</p>
<pre><code>const { foo: TFoo } = bar;
</code></pre>
<p>will just destructure <code>TFoo</code> property.</p>
<p>How can types be specified for destructured object properties?</p>
| <typescript><destructuring> | 2016-09-24 05:16:25 | HQ |
39,672,816 | Can lazy-loaded modules share the same instance of a service provided by their parent? | <p>I've just run into a problem with a lazy-loaded module where parent and child module both require the same service but create an instance each. The declaration is identical for both, that is</p>
<pre><code>import { MyService } from './my.service';
...
@NgModule({
...
providers: [
MyService,
...
]
});
</code></pre>
<p>and here's the routing setup</p>
<pre><code>export parentRoutes: Routes = [
{ path: ':id', component: ParentComponent, children: [
{ path: '', component: ParentDetailsComponent },
{ path: 'child', loadChildren: 'app/child.module#ChildModule' },
...
]}
];
</code></pre>
<p>which, of course, is then imported in the parent module as</p>
<pre><code>RouterModule.forChild(parentRoutes)
</code></pre>
<p>How do I go about this if I wanted to share the same service instance?</p>
| <angular><angular2-services> | 2016-09-24 05:18:20 | HQ |
39,672,930 | remove max and min duplicate of a list of number | > Hi i would i like to remove ONLY max and min duplicate of a list of
> numbers. example: (**1 1 1** 4 4 5 6 **8 8 8**) result (**1** 4 4 5 6
> **8**)
how to combine max() min() function with list(set(x))??
or is there any other way? Please do enlighten me | <python> | 2016-09-24 05:37:49 | LQ_EDIT |
39,673,009 | Validating start and end date in codeigniter start date < end date | these are use in view page pls add the java script to validate this date i am using code igniter
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Mfg. date
</label>
<div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback">
<input type="date" class="form-control" id="startDate" name="mfg_date" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Exp. Date
</label>
<div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback">
<input type="date" class="form-control" id="endDate" name="exp_date" value="">
</div>
</div>
<input type="hidden" name="action" value="add_medicines"/>
<button type="submit" class="btn btn-success" />Add</button>
<!-- end snippet -->
| <javascript><php><codeigniter><validation><date> | 2016-09-24 05:51:52 | LQ_EDIT |
39,673,099 | Android Nougat PopupWindow showAsDropDown(...) Gravity not working | <p>I have this code.</p>
<pre><code>PopupWindow popUp = new PopupWindow();
popUp.setFocusable(true);
popUp.setOutsideTouchable(true);
popUp.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popUp.setHeight(600);
popUp.setContentView(anchorView);
popUp.showAsDropDown(anchorView);
popUp.update();
</code></pre>
<p>And its perfectly works on Android Version < Android Nougat. But in Android Nougat, the popup is being displayed at the top of the screen instead of relative to the anchor view.</p>
| <android><popupwindow><android-7.0-nougat> | 2016-09-24 06:06:12 | HQ |
39,673,627 | How to use destructuring assignment to define enumerations in ES6? | <p>You can use destructuring assignment to define enumerations in ES6 as follows:</p>
<pre class="lang-js prettyprint-override"><code>var [red, green, blue] = [0, 1, 2];
</code></pre>
<p>Instead, I'd like the right hand side of the destructuring assignment to be dynamic. For example:</p>
<pre class="lang-js prettyprint-override"><code>var MAX_ENUM_SIZE = 32;
var ENUM = new Array(MAX_ENUM_SIZE);
for (var i = 0; i < MAX_ENUM_SIZE; i++) ENUM[i] = i;
var [red, green, blue] = ENUM;
</code></pre>
<p>Unfortunately, this seems like a hack. What if I want a bigger enumeration in the future? Hence, I was thinking of using destructuring assignment with an iterator as follows:</p>
<pre class="lang-js prettyprint-override"><code>var [red, green, blue] = enumeration(/* I don't want to specify size */);
</code></pre>
<p>However, I don't think it's possible to use destructuring assignment with iterators<sup>[citation needed]</sup>. Is there any way to accomplish this goal?</p>
| <javascript><enums><iterator><ecmascript-6><destructuring> | 2016-09-24 07:12:46 | HQ |
39,674,057 | How to exclude Pods from Code Coverage in Xcode | <p>Is there a way to <strong>exclude</strong> Pods from Code Coverage?<br>
I would like to see Code Coverage only for the code I've written.</p>
<p>Not that it should matter, but I'm using Xcode 8.</p>
| <ios><xcode><testing> | 2016-09-24 08:07:14 | HQ |
39,674,500 | make Ionic App visible only for mobile phone | my app does not have registration, how can I make it visible only for trusted mobile phone ?
and How can I prevented to use my api publicly ?
| <ionic-framework><oauth><oauth-2.0><ionic2> | 2016-09-24 08:57:44 | LQ_EDIT |
39,674,898 | Python web scraping using 're' | I'm running into a wall why this code does not work, even thought it's the same code as on an online tutorial [Python Web Scraping Tutorial 5 (Network Requests)][1]. I tried running the code also via online Python interpreter.
import urllib
import re
htmltext = urllib.urlopen("https://www.google.com/finance?q=AAPL")
regex = '<span id="ref_[^.]*_l">(.+?)</span>'
pattern = re.compile(regex)
results = re.findall(pattern,htmltext)
results
I get:
re.pyc in findall(pattern, string, flags)
175
176 Empty matches are included in the result."""
--> 177 return _compile(pattern, flags).findall(string)
178
179 if sys.hexversion >= 0x02020000:
TypeError: expected string or buffer
Expected result(s):
112.71
Help appreciated. I tried using "read()" on the url but that didn't work. According to documentation even empty results should be included. Thanks
[1]: http://www.youtube.com/watch?v=5FoSwMZ4uJg&t=6m22s | <python><regex><web-scraping><typeerror> | 2016-09-24 09:42:59 | LQ_EDIT |
39,675,093 | How do you comment a line in .sbt file | <p>This may sound like a stupid question, but I've been searching all over the internet on how to comment a line in an sbt file. Does anyone know how to?</p>
| <scala><sbt><sbt-assembly> | 2016-09-24 10:03:44 | HQ |
39,675,592 | How to fix this regex to capture everything between the braces {} | I have a text string as follows:
The {"house apple!" >> "apples?"} {"does" >> "do"} not fall {-"far"}from {+" this an "}tree{"," >> ": "}.
I want to extract all of the content that is between { and }.
I have tried the following:
/{.*}/
However, this captures all of the content starting from the first {. Even content that is not inside the braces.{}
What am I doing wrong?
| <ruby><regex> | 2016-09-24 11:00:35 | LQ_EDIT |
39,675,639 | How to add drag n drop functionality in rails | <p>I want to add drag n drop functionality in my app like <a href="http://draw.io" rel="nofollow">Draw.io</a> and like trello. Meanz I need fast drag n drop in my app page. But I know how to do it?</p>
<p>Please give me some guidelines?</p>
| <javascript><jquery><ruby-on-rails><drag-and-drop><drag> | 2016-09-24 11:07:10 | LQ_CLOSE |
39,675,844 | How do coroutines in Python compare to those in Lua? | <p>Support for coroutines in Lua is provided by <a href="https://www.lua.org/manual/5.3/manual.html#2.6" rel="noreferrer">functions in the <code>coroutine</code> table</a>, primarily <code>create</code>, <code>resume</code> and <code>yield</code>. The developers describe these coroutines as <a href="http://laser.inf.ethz.ch/2012/slides/Ierusalimschy/coroutines-4.pdf" rel="noreferrer">stackful, first-class and asymmetric</a>.</p>
<p>Coroutines are also available in Python, either using <a href="https://www.python.org/dev/peps/pep-0342/" rel="noreferrer">enhanced generators</a> (and <a href="https://www.python.org/dev/peps/pep-0380/" rel="noreferrer"><code>yield from</code></a>) or, added in version 3.5, <a href="https://www.python.org/dev/peps/pep-0492/" rel="noreferrer"><code>async</code> and <code>await</code></a>.</p>
<p>How do coroutines in Python compare to those in Lua? Are they also stackful, first-class and asymmetric?</p>
<p>Why does Python require so many constructs (<code>async def</code>, <code>async with</code>, <code>async for</code>, <a href="https://www.python.org/dev/peps/pep-0530/" rel="noreferrer">asynchronous comprehensions</a>, ...) for coroutines, while Lua can provide them with just three built-in functions?</p>
| <python><asynchronous><lua><async-await><coroutine> | 2016-09-24 11:32:53 | HQ |
39,676,204 | Search engine friendly html meta tag needed | <p>My Six month old Website is not listed in google page rank well. Is there any modification required?</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $page_title; ?></title>
<meta http-equiv="description" content="<?php echo $page_description; ?>" />
<meta name="robots" content="index, follow" >
<meta name="keywords" content=" site key words" >
<meta name="classification" content="site classification" >
<meta name="rating" content="general" >
<meta name="distribution" content="global" >
<meta name="author" content="site author" >
</head>
</code></pre>
| <html> | 2016-09-24 12:13:23 | LQ_CLOSE |
39,677,172 | my jsp page gets error while inserting data into mysql databse | com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'gender' in 'field list'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
at org.apache.jsp.reg_jsp._jspService(reg_jsp.java:157)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
not insertedcom.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'gender' in 'field list'
| <mysql><jsp> | 2016-09-24 13:59:26 | LQ_EDIT |
39,677,176 | How can i restart currentTimeMillis or make this currentTimeMillis work properly | So the problem here is that when i try to run again it won't do anything.
It will run the while once then break. I know that i'm not using currentTimeMillis right does any one know what's the problem here. I'm not good at coding if you have some suggestions to improve my code feel free to tell me.
And yes I tried to look anwsers online but i didn't find anything. Sorry for bad English!
public static String list(ArrayList<String> lause2) {
Collections.shuffle(lause2);
String pleb = lause2.get(lause2.size() - 1);
return pleb;
}
public static void main(String[] args) throws Exception {
Scanner printer = new Scanner(System.in);
ArrayList<String> lause2 = new ArrayList<>();
ArrayList<Integer> keskiarvo = new ArrayList<>();
long start = System.currentTimeMillis();
long end = start + 10 * 6000;
int laskuri = 0;
boolean go = true;
boolean run = true;
System.out.println("Welcome to Typefaster");
System.out.println("Program will give you random words you will write them as fast as you can for an minute if you fail ones it's over Good luck!");
lause2.add("hello");
//Loads of different lause2.add("random");
lause2.add("vacation");
System.out.println(list(lause2));
while (System.currentTimeMillis() < end) {
laskuri++;
String something = list(lause2);
System.out.println("Write " + something);
String kirjoitus = printer.nextLine();
if (kirjoitus.equals(something)) {
System.out.println("yee");
} else {
break;
}
}
System.out.println("You wrote " + laskuri + " words");
keskiarvo.add(laskuri);
int laskuri2 = 0;
System.out.println("Run again?");
char again = printer.next().charAt(0);
if (again == 'y') {
run = true;
} else if (again == 'n') {
System.out.println("Byebye");
go = false;
}
long start2 = System.currentTimeMillis();
long end2 = start2 + 10*6000;
while (System.currentTimeMillis() < end2 && run) {
laskuri2++;
String something1 = list(lause2);
System.out.println("Write " + something1);
String kirjoitus1 = printer.nextLine();
if (kirjoitus1.equals(something1)) {
System.out.println("yee");
} else {
break;
}
System.out.println("You wrote " + laskuri2 + " words");
keskiarvo.add(laskuri2);
}
}
| <java><debugging> | 2016-09-24 13:59:54 | LQ_EDIT |
39,677,230 | How to rectify this error? | <pre><code> python serve.py
/usr/local/lib/python3.4/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.sqlalchemy is deprecated, use flask_sqlalchemy instead.
.format(x=modname), ExtDeprecationWarning
Traceback (most recent call last):
File "serve.py", line 1, in <module>
from CTFd import create_app
File "/home/rajat/Downloads/CTFd/CTFd/__init__.py", line 7, in <module>
from utils import get_config, set_config
ImportError: cannot import name 'get_config'
</code></pre>
<p>Don't know what is causing this error</p>
<p>Tried pip install utils</p>
<p>Thanks in advance </p>
| <python><python-2.7><python-3.x> | 2016-09-24 14:06:32 | LQ_CLOSE |
39,677,484 | How to add documentation to enum associated values in Swift | <p>Is there a way to add descriptions to associated values of enums in Swift 3? I want them to show up in the symbol documentation popup (option+click), like they do for function parameters in Xcode 8.</p>
<p>This is my enum:</p>
<pre><code>enum Result {
/**
Request succeeded.
- Parameters:
- something: Some description.
- otherThing: Other description.
*/
case Success(something: Int, otherThing: Int)
/**
Request failed.
- Parameter error: Error.
*/
case Error(error: Error)
}
</code></pre>
<p>I tried using <code>- Parameters:</code>, but it doesn't work in enums.</p>
| <swift><xcode> | 2016-09-24 14:32:07 | HQ |
39,678,244 | Entering data in a input from an other host | <p>I have a question, is possible to send data from an other host in an input of another host?</p>
<p>For example, my host is www.example.com and i wanna send data to an input from the host called www.example2.com. Is it possible with PHP, Python, JavaScript?</p>
| <javascript><php><python> | 2016-09-24 15:55:53 | LQ_CLOSE |
39,678,302 | How to show plus and minus sign when subtracting two variables: | <p>How to show plus and minus sign when subtracting two variables:Following codes shows -1, that is fine but when the value is positive then it is not showing +sign.</p>
<pre><code>$gf=5;
$ga=6;
$gd=$gf-$ga;
echo $gd;
</code></pre>
| <php><variables> | 2016-09-24 16:04:06 | LQ_CLOSE |
39,678,404 | ssl on custom domain for heroku app | <p>I want to connect a custom domain to an app built on Heroku. Can someone confirm that I actually need to buy a certificate and in addition buy the SSL addon on Heroku?</p>
<p>Do I need both or is one of them enough? What is the point of the addon?</p>
<p>/Knut</p>
| <ssl><heroku> | 2016-09-24 16:15:27 | HQ |
39,678,463 | Docker-compose: Database is uninitialized | <p>I have a problem with docker-compose and mysql:</p>
<p>docker-compose.yml</p>
<pre><code>version: '2'
services:
db:
image: mysql
volumes:
- "./sito/db/:/var/lib/mysql"
ports:
- "3306:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD:
app:
depends_on:
- db
image: eboraas/apache-php
links:
- db
ports:
- "80:80"
volumes:
- ./sito/:/var/www/html/
</code></pre>
<p>An error occurred when I compose this container:</p>
<pre><code>Recreating phpapp_phpapache_1
Attaching to phpapp_db_1, phpapp_phpapache_1
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
phpapache_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.30.0.3. Set the 'ServerName' directive globally to suppress this message
phpapp_db_1 exited with code 1
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db_1 | error: database is uninitialized and password option is not specified
</code></pre>
<p>But the database don't have a password. How can I solve it?</p>
| <mysql><docker><docker-compose> | 2016-09-24 16:21:00 | HQ |
39,678,949 | How to iterate through a binary number in c++? in my following function I'm getting invalid operands to binary conversion (bitset<8> and int) | This is the function in my code, which is getting the stated error
int value(int x)
{ int temp=0,counter=0;
bitset<8> i(x);
while (i != 0) {
temp = i % 10;
if(temp == 1)
{counter++;
}
i = i/10;
}
return counter;
} | <c++> | 2016-09-24 17:13:44 | LQ_EDIT |
39,679,151 | Split an array of strings into other array of stings | I`m making a project, which gets an array of strings from a .txt file, which contains the two names of a person. The problem is that when i try to split the elements from the string "line" and try to give other two strings those values, something happens.
The text file contains:
"Noah Mason
Emma Williams
Richard Daniel
and so on..."
I want to split the lines into two separate arrays of stings "firstName" and "secondName". And i want something like this:
firstName[0]="Noah";
firstName[1]="Emma";
firstName[2]="Richard";
secondName[0]="Mason";
secondName[0]="Williams";
secondName[0]="Daniel";
Thank you in advance! | <c#><string><split> | 2016-09-24 17:36:41 | LQ_EDIT |
39,679,459 | Java Regex Facebook | I’m trying to figure out a regex expression in java for this facebook url:
https://www.facebook.com/566162426788268/photos/a.566209603450217.1073741828.566162426788268/1214828765254961/?type=3&theater
I have come up with the solution
\w++(?=/\?)
help appreicated | <java><regex><facebook> | 2016-09-24 18:07:26 | LQ_EDIT |
39,679,564 | How to parcelable object | <p>I am trying to learn parcelable .Earlier I was using get and set function but now I am using parcelable to pass the object to other class I made the passdata class and implemented the parcelable but how I can add the list to the class object.</p>
<pre><code>class Passdata implements Parcelable {
private String title,album;
private long duration;
private Uri data,album_art;
public String getTitle() {
return title;
}
void setTitle(String title) {
this.title = title;
}
public String getAlbum() {
return album;
}
void setAlbum(String album) {
this.album = album;
}
public long getDuration() {
return duration;
}
void setDuration(long duration) {
this.duration = duration;
}
public Uri getData() {
return data;
}
void setData(Uri data) {
this.data = data;
}
public Uri getAlbum_art() {
return album_art;
}
void setAlbum_art(Uri album_art) {
this.album_art = album_art;
}
Passdata(Parcel in) {
title = in.readString();
album = in.readString();
duration = in.readLong();
data = in.readParcelable(Uri.class.getClassLoader());
album_art = in.readParcelable(Uri.class.getClassLoader());
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(album);
dest.writeLong(duration);
dest.writeParcelable(data, flags);
dest.writeParcelable(album_art, flags);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<Passdata> CREATOR = new Creator<Passdata>() {
@Override
public Passdata createFromParcel(Parcel in) {
return new Passdata(in);
}
@Override
public Passdata[] newArray(int size) {
return new Passdata[size];
}
};
}
</code></pre>
<p>how can I add the object like this</p>
<pre><code> do {
int audioTitle = audioCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
int audioartist = audioCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST);
int audioduration = audioCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION);
int audiodata = audioCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
int audioalbum = audioCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM);
int audioalbumid = audioCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM_ID);
Passdata info = new Passdata();
info.setData(Uri.parse(audioCursor.getString(audiodata)));
info.setTitle(audioCursor.getString(audioTitle));
info.setDuration(audioCursor.getLong(audioduration));
// info.setArtist(audioCursor.getString(audioartist));
info.setAlbum(audioCursor.getString(audioalbum));
info.setAlbum_art(ContentUris.withAppendedId(albumArtUri, audioCursor.getLong(audioalbumid)));
audioList.add(info);
}
</code></pre>
<p>I am getting error in the place were I am creating the passdata object
how to fix this??</p>
| <android><object><arraylist><parcelable> | 2016-09-24 18:18:39 | LQ_CLOSE |
39,680,147 | Can I set variable column widths in pandas? | <p>I've got several columns with long strings of text in a pandas data frame, but am only interested in examining one of them. Is there a way to use something along the lines of <code>pd.set_option('max_colwidth', 60)</code> but for a <strong>single column</strong> only, rather than expanding the width of all the columns in my df?</p>
| <python><pandas> | 2016-09-24 19:27:39 | HQ |
39,681,046 | Keras - stateful vs stateless LSTMs | <p>I'm having a hard time conceptualizing the difference between stateful and stateless LSTMs in Keras. My understanding is that at the end of each batch, the "state of the network is reset" in the stateless case, whereas for the stateful case, the state of the network is preserved for each batch, and must then be manually reset at the end of each epoch.</p>
<p>My questions are as follows:
1. In the stateless case, how is the network learning if the state isn't preserved in-between batches?
2. When would one use the stateless vs stateful modes of an LSTM?</p>
| <tensorflow><deep-learning><keras><lstm> | 2016-09-24 21:16:44 | HQ |
39,681,163 | Angular 2: sanitizing HTML stripped some content with div id - this is bug or feature? | <p>I use <code><div [innerHTML]="body"></div></code> to pass unescaped HTML to my template, and when I pass to <code>body</code> <code>div</code> with attribute <code>id</code>, Angular throw:</p>
<blockquote>
<p>WARNING: sanitizing HTML stripped some content (see <a href="http://g.co/ng/security#xss" rel="noreferrer">http://g.co/ng/security#xss</a>).
WARNING: sanitizing HTML stripped some content (see <a href="http://g.co/ng/security#xss" rel="noreferrer">http://g.co/ng/security#xss</a>).
WARNING: sanitizing HTML stripped some content (see <a href="http://g.co/ng/security#xss" rel="noreferrer">http://g.co/ng/security#xss</a>).</p>
</blockquote>
<p><a href="http://plnkr.co/edit/noTI3NKSBlq3W1CwrZkt?p=preview" rel="noreferrer">See. plunker</a></p>
<p>So why it says this? What can be dangerous <code>id</code> in <code>div</code>? Could this bug?</p>
| <security><angular><warnings><html-sanitizing> | 2016-09-24 21:32:18 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.