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 |
|---|---|---|---|---|---|
35,273,025 | C++ Copy constructor gets called instead of initializer_list<> | <p>Based on this code</p>
<pre><code>struct Foo
{
Foo()
{
cout << "default ctor" << endl;
}
Foo(std::initializer_list<Foo> ilist)
{
cout << "initializer list" << endl;
}
Foo(const Foo& copy)
{
cout << "copy ctor" << endl;
}
};
int main()
{
Foo a;
Foo b(a);
// This calls the copy constructor again!
//Shouldn't this call the initializer_list constructor?
Foo c{b};
_getch();
return 0;
}
</code></pre>
<p>The output is:</p>
<p><strong>default ctor</strong></p>
<p><strong>copy ctor</strong></p>
<p><strong>copy ctor</strong></p>
<p>In the third case, I'm putting b into the brace-initialization which should call the initializer_list<> constructor.</p>
<p>Instead, the copy constructor takes the lead.</p>
<p>Will someone of you tell me how this works and why?</p>
| <c++><copy-constructor><initializer-list><list-initialization> | 2016-02-08 15:18:00 | HQ |
35,273,333 | Select value from JSON using PHP | <p>How to select data from bellow JSON code?</p>
<pre><code>"response": {
"status": 1,
"httpStatus": 200,
"data": [
{
"offer_id": "8000",
"countries": {
"SG": {
"id": "702",
"code": "SG",
"name": "Singapore",
"regions": []
}
}
</code></pre>
<p>How could I select the words SG and SINGAPORE </p>
| <php><json> | 2016-02-08 15:33:40 | LQ_CLOSE |
35,273,385 | Error: Please select Android SDK in Android Studio 2.0 | <p>I am using Android Studio 2.0 Beta2, and i am trying to run old project that uses google maps api v1 (package <em>com.google.android.maps</em>) as *.jar file. To run this old project i need specify compileSdkVersion older than the last one (23). I used </p>
<pre><code>compileSdkVersion 'Google Inc.:Google APIs:17'
</code></pre>
<p>But i got <strong>Error: Please select Android SDK</strong> error in Android Studio. How i can run this old project with older compileSdkVersion?</p>
| <android-studio><android-sdk-tools><google-maps-android-api-1> | 2016-02-08 15:36:48 | HQ |
35,273,597 | Is use of generics valid in XCTestCase subclasses? | <p>I have a <code>XCTestCase</code> subclass that looks something like this. I have removed <code>setup()</code> and <code>tearDown</code> methods for brevity: </p>
<pre><code>class ViewControllerTests <T : UIViewController>: XCTestCase {
var viewController : T!
final func loadControllerWithNibName(string:String) {
viewController = T(nibName: string, bundle: NSBundle(forClass: ViewControllerTests.self))
if #available(iOS 9.0, *) {
viewController.loadViewIfNeeded()
} else {
viewController.view.alpha = 1
}
}
}
</code></pre>
<p>And its subclass that looks something like this : </p>
<pre><code>class WelcomeViewControllerTests : ViewControllerTests<WelcomeViewController> {
override func setUp() {
super.setUp()
self.loadControllerWithNibName("welcomeViewController")
// Put setup code here. This method is called before the invocation of each test method in the class.
}
func testName() {
let value = self.viewController.firstNameTextField.text
if value == "" {
XCTFail()
}
}
}
</code></pre>
<p>In theory, this should work as expected -- the compiler doesn't complain about anything. But it's just that when I run the test cases, the <code>setup()</code> method doesn't even get called. But, it says the tests have passed when clearly <code>testName()</code> method should fail. </p>
<p>Is the use of generics a problem? I can easily think of many non-generic approaches, but I would very much want to write my test cases like this. Is the XCTest's interoperability between Objective-C and Swift the issue here? </p>
| <ios><swift><generics><xctest> | 2016-02-08 15:47:20 | HQ |
35,274,167 | Session data could not be read from another window | <p>On a test1.php I have this:</p>
<pre><code><?php
echo "Session variables are about to be set.";
// Set session variables
$_SESSION["animal"] = "cat";
echo "Session variables are set.";
echo "Favorite animal is " . $_SESSION["animal"] . ".";
?>
<div ms_positioning="text2D" class="style7"><a href="javascript:winOpen();" test2.php="">Contact Information</a></div>
<script>
function winOpen() {
window.open("/test2.php",null,"scrollbars=no,resizable=no,width=600,height=300,top=100,left=100");
}
</script>
</code></pre>
<p>In test2.php, I have this:</p>
<pre><code><?php
// Echo session variables that were set on previous page
echo "Favorite animal is " . $_SESSION["animal"] . ".";
?>
</code></pre>
<p>But data is not showing up on test2.php. It did echo back on test1.php.</p>
<p>any suggestions?</p>
| <javascript><php><html> | 2016-02-08 16:12:28 | LQ_CLOSE |
35,275,500 | template typename not running on dynamic allocation | I have written 3 template functions but when I run the code, it gives error on the first function's body where the memory to arr is dynamically allocated. Following is the code, please help me in finding what I missed. Thanks
Error: Error 1 error C2440: '=' : cannot convert from 'int **' to 'int *'
#include<iostream>
using namespace std;
template<typename T>
void input(T arr, int size){
**arr = new T[size];**
for(int i=0; i<size; i++){
cout<<"\nEnter: ";
cin>>arr[i];
}
}
template<typename T>
void sort(T arr, int size){
int temp;
for(int j=0; j<size-1; j++){
for(int i=0; i<size-1; i++){
if(arr[i]>arr[i+1]){
temp=arr[i];
arr[i]=arr[i+1];
arr[i+1]=temp;
}
}
}
}
template<typename T>
void display(T arr, int size){
cout<<"\nAfter Sorting: "<<endl;
for(int i=0; i<size; i++){
cout<<arr[i]<<"\t";
}
}
int main(){
int* x=NULL;
int size;
cout<<"Enter the number of elements: ";
cin>>size;
cout<<"\nEnter integer values:";
input<int*>(x, size);
// sort(x, size);
display<int*>(x, size);
/***
cout<<"\nEnter floating values:";
input(x, size);
sort(x, size);
display(x, size);
cout<<"\nEnter character values:";
input(x, size);
sort(x, size);
display(x, size);
*/
system("pause");
} | <c++><oop> | 2016-02-08 17:19:19 | LQ_EDIT |
35,275,607 | create a google form generator like application using pure "raw php" | <p>I'm new to php and I want to know how to develop a simple application similar to google form generator, using only raw php without using any frameworks, java scripts. The scenario is like this. I have a form with a combo box containing item names; textbox, textarea, radio, checkbox, combo box, etc. Also there is a text field to enter name. user can select an item name from combo box and give a name to that combobox. Likewise can add several fields. after finished adding needed controllers and names for them, there should be a ok button to generate a form by using our selected controllers.And should redirect to that form as well. That created form also has to be work. (this is similar to google form scenario)</p>
<p>If anybody can help it would be really helpful and very grateful.
Thanks :)</p>
| <php><forms> | 2016-02-08 17:24:23 | LQ_CLOSE |
35,276,283 | Jenkins gives me blank page | <p>I am getting this error when i start jenkins, which I believe is causing the jenkins to not work. Jenkins page comes up blank. I think the scm-sync-configuration is causing this to happen. It there anyway to workaround this or disable this plugin?</p>
<pre><code>Running from: /Applications/Jenkins/jenkins.war
webroot: $user.home/.jenkins
Feb 08, 2016 12:30:13 PM winstone.Logger logInternal
INFO: Beginning extraction from war file
Feb 08, 2016 12:30:13 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: jetty-winstone-2.9
Feb 08, 2016 12:30:14 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
Jenkins home directory: /Users/sss/.jenkins found at: $user.home/.jenkins
Feb 08, 2016 12:30:16 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started SelectChannelConnector@0.0.0.0:8080
Feb 08, 2016 12:30:16 PM winstone.Logger logInternal
INFO: Winstone Servlet Engine v2.0 running: controlPort=disabled
Feb 08, 2016 12:30:16 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Feb 08, 2016 12:30:16 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Feb 08, 2016 12:30:17 PM hudson.plugins.scm_sync_configuration.SCMManipulator scmConfigurationSettledUp
INFO: Creating scmRepository connection data ..
Feb 08, 2016 12:30:17 PM hudson.plugins.scm_sync_configuration.scms.ScmSyncSubversionSCM extractScmCredentials
INFO: Extracting SVN Credentials for url : https://svn.aaa.com/
Feb 08, 2016 12:30:17 PM jenkins.InitReactorRunner$1 onTaskFailed
SEVERE: Failed Loading plugin scm-sync-configuration
java.io.IOException: Failed to initialize
at hudson.ClassicPluginStrategy.load(ClassicPluginStrategy.java:441)
at hudson.PluginManager$2$1$1.run(PluginManager.java:384)
at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
at jenkins.model.Jenkins$8.runTask(Jenkins.java:913)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
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)
Caused by: java.lang.NullPointerException
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:57)
at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(UnsafeQualifiedObjectFieldAccessorImpl.java:38)
at java.lang.reflect.Field.get(Field.java:393)
at hudson.plugins.scm_sync_configuration.scms.ScmSyncSubversionSCM.extractScmCredentials(ScmSyncSubversionSCM.java:59)
at hudson.plugins.scm_sync_configuration.scms.SCM.getConfiguredRepository(SCM.java:66)
at hudson.plugins.scm_sync_configuration.SCMManipulator.scmConfigurationSettledUp(SCMManipulator.java:57)
at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness.initializeRepository(ScmSyncConfigurationBusiness.java:72)
at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationBusiness.init(ScmSyncConfigurationBusiness.java:67)
at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin.initialInit(ScmSyncConfigurationPlugin.java:174)
at hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin.start(ScmSyncConfigurationPlugin.java:157)
at hudson.ClassicPluginStrategy.startPlugin(ClassicPluginStrategy.java:449)
at hudson.ClassicPluginStrategy.load(ClassicPluginStrategy.java:438)
... 9 more
Feb 08, 2016 12:30:17 PM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Feb 08, 2016 12:30:17 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Feb 08, 2016 12:30:17 PM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Feb 08, 2016 12:30:20 PM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Feb 08, 2016 12:30:20 PM hudson.model.AsyncPeriodicWork$1 run
INFO: Started Download metadata
Feb 08, 2016 12:30:20 PM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 2 ms
Feb 08, 2016 12:30:21 PM org.jenkinsci.main.modules.sshd.SSHD start
INFO: Started SSHD at port 49295
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Feb 08, 2016 12:30:21 PM hudson.UDPBroadcastThread run
INFO: Cannot listen to UDP port 33,848, skipping: java.net.SocketException: Can't assign requested address
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Loaded all jobs
Feb 08, 2016 12:30:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
Feb 08, 2016 12:30:21 PM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
</code></pre>
| <jenkins> | 2016-02-08 18:05:04 | HQ |
35,276,379 | Knowing how many repeat the letters in the String | <p>i have an interview Question which is
Knowing repeat the letters in the String
i solve it like this </p>
<pre><code>String str = "my name is Java Developer";
int count = 0;
for (int i = 0; i < str.length(); i++) {
for (int j = 0; j < str.length(); j++) {
if (str.charAt(i) == str.charAt(j)) {
count = count + 1;
}
}
System.out.print(count + " ");
count = 0;
}
</code></pre>
<p>but
my problem was
1 - avoid the space from count
2-there is repeated character counted like m in 'my' and m in 'name'
i don't want to repeat the count for the characters
3- i want to solve it in another way plus this one </p>
<p>thank you ,,</p>
| <java> | 2016-02-08 18:11:18 | LQ_CLOSE |
35,276,559 | Benefits of ES6 Reflect API | <p>I've been working on upgrading some code to use ES6 syntax. I had the following line of code:</p>
<p><code>delete this._foo;</code></p>
<p>and my linter raised a suggestion to use:</p>
<p><code>Reflect.deleteProperty(this, '_foo');</code> </p>
<p>You can find the documentation for this method <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty" rel="noreferrer">here</a>.</p>
<p>The MDN docs state:</p>
<blockquote>
<p>The Reflect.deleteProperty method allows you to delete a property on
an object. It returns a Boolean indicating whether or not the property
was successfully deleted. It is almost identical to the non-strict
delete operator.</p>
</blockquote>
<p>I understand that the <code>delete</code> keyword does not return a value indicating success, but it is much less verbose.</p>
<p>If I'm not dependent on the success/failure of <code>delete</code> is there any reason to favor <code>Reflect.deleteProperty</code>? What does it mean that <code>delete</code> is non-strict?</p>
<p>I feel like a lot of the use cases for the <code>Reflect</code> API are for resolving exceptional cases and/or providing better conditional flow, but at the cost of a much more verbose statement. I'm wondering if there's any benefit to use the <code>Reflect</code> API if I'm not experiencing any issues with my current usages.</p>
| <javascript><ecmascript-6> | 2016-02-08 18:21:43 | HQ |
35,277,536 | What does a blue circle on the "Run" button in Matlab mean? | <p>Title pretty much says it all. I am running R2015a, and got this to appear in my editor. There is a small blue circle appearing on the "Run" button. I've never seen this before, and can't find any documentation on the mathworks website that explains it's meaning.</p>
<p>What does this blue circle with 3 dots mean?</p>
<p><a href="https://i.stack.imgur.com/UGsiY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UGsiY.png" alt="enter image description here"></a></p>
| <matlab> | 2016-02-08 19:17:55 | HQ |
35,277,668 | GET request to IIS returns Microsoft-HttpApi/2.0 | <p>I've got 6 identical machines running IIS and Apache. Today one of them decided to just stop serving requests. I can access all of the webapps when I try from localhost/resource but when I try from url/resource I get a 404. I did a Get request against the machine that isn't working and I get this back:</p>
<ul>
<li>Server: Microsoft-HTTPAPI/2.0</li>
<li>Connection: close</li>
</ul>
<p>Compared to a working server:</p>
<ul>
<li>Server: Microsoft-IIS/8.5</li>
<li>X-Powered-By: ASP.NET</li>
<li>Content-Type: text/html</li>
</ul>
<p>Tried searching for this problem but came up with nothing, anyone got any idea's?</p>
| <iis> | 2016-02-08 19:27:21 | HQ |
35,277,682 | How to tie emitted events events into redux-saga? | <p>I'm trying to use <a href="https://github.com/yelouafi/redux-saga">redux-saga</a> to connect events from <a href="http://pouchdb.com/api.html#replication">PouchDB</a> to my <a href="http://reactjs.com/">React.js</a> application, but I'm struggling to figure out how to connect events emitted from PouchDB to my Saga. Since the event uses a callback function (and I can't pass it a generator), I can't use <code>yield put()</code> inside the callback, it gives weird errors after ES2015 compilation (using Webpack).</p>
<p>So here's what I'm trying to accomplish, the part that doesn't work is inside <code>replication.on('change' (info) => {})</code>.</p>
<pre><code>function * startReplication (wrapper) {
while (yield take(DATABASE_SET_CONFIGURATION)) {
yield call(wrapper.connect.bind(wrapper))
// Returns a promise, or false.
let replication = wrapper.replicate()
if (replication) {
replication.on('change', (info) => {
yield put(replicationChange(info))
})
}
}
}
export default [ startReplication ]
</code></pre>
| <javascript><ecmascript-6><redux><redux-saga> | 2016-02-08 19:28:07 | HQ |
35,278,193 | Chrome DevTools won't let me set breakpoints on certain lines | <p><a href="https://i.stack.imgur.com/utVAf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/utVAf.png" alt="enter image description here"></a></p>
<p>In the image above, I tried setting breakpoints on every line from line 437 to line 443. However, I cannot set breakpoints on lines 439 and 440. When the function runs, the breakpoints on lines 437, 438, 441, and 442 are ignored. Chrome breaks on line 443. This means that I cannot do some debugging before the first conditional runs.</p>
<p>When I click on lines 439 or 440, the breakpoint appears for half a second and jumps to line 443.</p>
<p>Is this a bug or am I missing something? How do I set a breakpoint at or before line 439?</p>
| <javascript><google-chrome><google-chrome-devtools> | 2016-02-08 19:56:41 | HQ |
35,278,334 | Python: how to find to consecutive positive negative values in an array? | I have the following array:
X
array([ 3.5, -3, 5.4, 3.7, 14.9, -7.8, -3.5, 2.1])
For each values of `X` I know its recording time `T`. I want to find the indexes between two consecutive positive-negative or viceversa. Concluding I would like an array like
Y = array([ T(1)-T(0), T(2)-T(1), T(5)-T(4), T(7)-T(6)]) | <python><arrays><algorithm><sign> | 2016-02-08 20:06:33 | LQ_EDIT |
35,279,291 | Angular2: How to find out what was previous page url when using angular2 routing | <p>I am developing an angular2 app and I use router.
I am in a page /myapp/signup. after signup I navigate the use to /myapp/login. /myapp/login can also be navigated from my home page which is /myapp. So now, when the user users /myapp/login I go back. This can be done by using location.back(). But I dont want to go back when the user is coming from /myapp/signup. So I should check if the user is coming from /myapp/signup and if so, I want to direct it to somewhere else.
How can I know the previous url so that I direct the user to a specific state based on that ?</p>
| <angular><angular2-routing> | 2016-02-08 21:04:17 | HQ |
35,279,933 | Update Table Using Laravel Model | <p>I've got a table for a sports team. The record shows the team selection and some other information. I want to update the record with the team selection. My model is thus:</p>
<pre><code>class Selection extends Model {
protected $table = "selection";
protected $fillable = [
'loose',
'hooker',
'tight',
'secrow1',
'secrow2',
'blindflank',
'openflank',
'eight',
'scrum',
'fly',
'leftwing',
'rightwing',
'fullback',
'sub1',
'sub2',
'sub3',
'sub4',
'sub5'
];
</code></pre>
<p>}</p>
<p>So I have a form which gives all the data for the positions and gives the id for the record in the DB. In my controller, I've got:</p>
<pre><code>public function storeFirstTeam()
{
$input = Request::all();
Selection::update($input->id,$input);
return redirect('first-team');
}
</code></pre>
<p>But I get the following error:</p>
<blockquote>
<p>Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically, assuming $this from incompatible context</p>
</blockquote>
<p>Can anyone point out my silly error?</p>
| <laravel><model><eloquent> | 2016-02-08 21:43:51 | HQ |
35,280,278 | oracle function error pls-00103 Encountered the symbol "SELECT" when expecting one of the following | I receive the following error when I compile this function:
Compilation errors for PROCEDURE INV.USP_MSC_MODIFICA_ESTADO
Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
continue avg count current exists max min prior sql stddev
sum variance execute forall merge time timestamp interval
date <a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternat Line: 14 Text: IF SELECT TRUNC((SYSDATE) -TO_DATE(@FCH_GRABACION, 'DD/MM/YYYY HH24:MI:SS')) From DUAL=1 THEN
CREATE OR REPLACE PROCEDURE "USP_MSC_MODIFICA_ESTADO"
AS
BEGIN
DECLARE CURSOR RESERVAR IS
SELECT ID_RESERVA,FCH_GRABACION FROM tb_msc_reserva
WHERE to_date(to_char(FCH_GRABACION,'dd/mm/yyyy')) = to_date(to_char(SYSDATE,'dd/mm/yyyy')) - 1;
id_reserva VARCHAR2(50);
fch_grabacion DATE;
BEGIN
OPEN RESERVAR;
FETCH RESERVAR INTO id_reserva, fch_grabacion;
IF SELECT TRUNC((SYSDATE) -TO_DATE(@FCH_GRABACION, 'DD/MM/YYYY HH24:MI:SS')) From DUAL=1 THEN
UPDATE inv.tb_msc_reserva t
SET t.flg_estado='C'
WHERE ID_Reserva=@ID_RESERVA;
COMMIT;
END IF ;
WHILE (@@FETCH_STATUS = 0)
CLOSE RESERVAR;
END;
Please help me
Thanks
| <oracle><syntax><plsql><compiler-errors><pls-00103> | 2016-02-08 22:06:25 | LQ_EDIT |
35,280,479 | Can I choose where my conda environment is stored? | <p>Can I change the path /Users/nolan/miniconda/envs/ to another one when creating a virtual environment ? I'd like it to be specific to my project directory. (As we can do with virtualenv)</p>
<pre><code>$conda info -e
Using Anaconda Cloud api site https://api.anaconda.org
# conda environments:
#
_build /Users/nolan/miniconda/envs/_build
myen3 /Users/nolan/miniconda/envs/myen3
nolanemirot /Users/nolan/miniconda/envs/nolanemirot
root * /Users/nolan/miniconda
</code></pre>
| <conda> | 2016-02-08 22:20:46 | HQ |
35,280,956 | Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS - Python 3.x & OS X | <p>I am trying to install Python 3.5.1 according to these instructions: </p>
<p><a href="http://thomas-cokelaer.info/blog/2014/08/installing-another-python-version-into-virtualenv/" rel="noreferrer">http://thomas-cokelaer.info/blog/2014/08/installing-another-python-version-into-virtualenv/</a> </p>
<p>I have: OS X 10.11.3, no Homebrew. Xcode is installed. Xcode Command Line Tools are installed. </p>
<p>Everything goes well until <code>make install</code> has run for a while. Then it quits with this:</p>
<pre><code>if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python.exe -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
</code></pre>
<p>I have been searching for a long time and all I can find are instructions for Homebrew or for Apache or other servers. I understand that I've got to get SSL/TLS on my system, but I've had no luck.</p>
<p>The biggest reason I don't want Homebrew is that I want non-CS students to follow the same procedure, and I don't want them to install Homebrew. </p>
| <python><macos><python-3.x> | 2016-02-08 22:57:11 | HQ |
35,281,460 | Why does Number.MIN_VALUE < -1219312 (or any small value) evaluate to false? | <p>I've tried this in multiple browsers and they all evaluate to false! Am I missing something here?</p>
| <javascript> | 2016-02-08 23:44:34 | LQ_CLOSE |
35,282,105 | program error exceptions shouldn't be caught by application program | <p>I'm learning java and I don't understand
Why should the program error exception never be caught by the application program?</p>
| <java><exception> | 2016-02-09 00:49:48 | LQ_CLOSE |
35,282,489 | What will be the C# Class for my xml and how to deserialize it | <p>Below is the my source xml. i want to write c# class for it and then deserialize it. so i can use c# object and save this to database.
History- : i was doing json deserialize that works great but am running into issue in my xml 'LastChangeId' node can be part of this xml , sometime may not be there at all or sometime there are multiple nodes for it. this issue messing with my json parsing. and i have to switch back to xml. any help will appreciable. </p>
<pre><code><FundingSource >
<ClientAccountPaySourceId>16</ClientAccountPaySourceId>
<ClientAccountId>67</ClientAccountId>
<ClientAccountName>Default Account</ClientAccountName>
<PrimaryPartyId>62</PrimaryPartyId>
<PrimaryRoleId>1290</PrimaryRoleId>
<TenderTypeId>3</TenderTypeId>
<TenderTypeName>Credit Card</TenderTypeName>
<TenderInterfaceName>Credit Card</TenderInterfaceName>
<CreditCareTypeName>Visa</CreditCareTypeName>
<ChargeAccountMask>1111</ChargeAccountMask>
<ExpirationDate>04/20</ExpirationDate>
<BillingAccountName>Joe Montana</BillingAccountName>
<BillingStreet>1235 Main St</BillingStreet>
<BillingCity>Pleasanton</BillingCity>
<BillingPostalCode>94588</BillingPostalCode>
<BillingCountry>US</BillingCountry>
<BillingTelephone>1231234567</BillingTelephone>
<DisplayOrder>1</DisplayOrder>
<UseForRecurring>true</UseForRecurring>
<UseForNonRecurring>true</UseForNonRecurring>
<IsActive>true</IsActive>
<Invalid>false</Invalid>
<ChargeAccountToken>VC84632147254611111111</ChargeAccountToken>
<IsExternal>false</IsExternal>
<LastChangeId >
<ClientAccountPaySourceId>16</ClientAccountPaySourceId>
<TimeUtc>2016-02-02 01:04:16</TimeUtc>
<TimeLocal>2016-02-01 17:04:16</TimeLocal>
<UserName>Josh.Lyon</UserName>
<PartyId>20</PartyId>
<RoleId>1160</RoleId>
<BusinessUnitCode>2</BusinessUnitCode>
<EndpointKey>default</EndpointKey>
</LastChangeId>
</FundingSource>
</code></pre>
| <c#><sql><xml> | 2016-02-09 01:32:57 | LQ_CLOSE |
35,282,803 | Confuse about error and reject in Promise | <p>All:</p>
<p>I am pretty new to JS Promise, there is one confuse when it comes to Promise chaining, say I have a promise chaining like:</p>
<pre><code>var p = new Promise(function(res, rej){
})
.then(
function(data){
},
function(err){
})
.then(
function(data){
},
function(err){
})
.catch(
function(err){
})
</code></pre>
<p>What confuse me:</p>
<ol>
<li>When the function(err) get called and when the catch get called?</li>
<li>How to resolve and reject in <code>then</code>?</li>
</ol>
<p>Thanks</p>
| <javascript><promise> | 2016-02-09 02:11:14 | HQ |
35,283,091 | How to send an email by javascript | <p>I am making a simple website where we save something by email; i found out how to open the email, but i cant get it to email a specific thing.</p>
<p>this is my code:</p>
<pre><code> var a = function(){
b = document.getElementById("email").value;
m = document.getElementById("Text").value;
window.open("mailto:"+b);
};
</code></pre>
<p>I'm trying to make it so it emails m as the body.</p>
| <javascript><email> | 2016-02-09 02:48:47 | LQ_CLOSE |
35,283,838 | How I can Count an Integer Value from Edittext Android | i really new in android programming
i wanna make a application that can count how many number you input in 'editText',but unfortunately i can't find any method that can count how many integer i input
thanks for helping me
best regrads | <android><android-edittext> | 2016-02-09 04:23:20 | LQ_EDIT |
35,283,999 | I am not able to click on filter on grid in selenium | I am giving the code below where i need to click on the filter icon. please help me out
<thead class="k-grid-header" role="rowgroup">
<tr role="row">
<th class="k-header k-filterable k-with-icon" scope="col" data-title="User Name" data-index="0" data-field="UserName" data-role="columnsorter">
<a class="k-grid-filter" href="javascript:void(0)" tabindex="-1">
<span class="k-icon k-filter"/>
</a>
<a class="k-link" href="/Admin/AdminRoleGrid/Read?adminGrid-sort=UserName-asc">User Name</a>
</th> | <java><html><css><selenium><xpath> | 2016-02-09 04:36:54 | LQ_EDIT |
35,284,223 | Is there a limit for number of items (CSSearchableItem) in Core Spotlight CSSearchableIndex in iOS 9? | <p>I have around <strong>110,000</strong> entries (CSSearchableItem) that I want to index into iOS 9 Spotlight Search results. However I only managed to show around <strong>30,000</strong> items. The rest was never indexed / appeared when I do the search. So I'm not really sure if there's a limit for an app to to index its entries into the system.</p>
<p>Thanks.</p>
| <ios><ios9><corespotlight> | 2016-02-09 04:58:55 | HQ |
35,284,827 | Horizontal UIScrollview in ios | How to create horizontal UIScrollview in ios as look like in image.[![ with center it is auto select[1]][1]
[1]: http://i.stack.imgur.com/qo9qg.png | <ios><objective-c><cocoa-touch><uiscrollview> | 2016-02-09 05:52:06 | LQ_EDIT |
35,284,974 | laravel collection to array | <p>I have two models, <code>Post</code> and <code>Comment</code>; many comments belong to a single post. I'm trying to access all comments associated with a post as an array.</p>
<p>I have the following, which gives a collection.</p>
<p><code>$comments_collection = $post->comments()->get()</code></p>
<p>How would I turn this <code>$comments_collection</code> into an array? Is there a more direct way of accessing this array through eloquent relationships?</p>
| <php><arrays><laravel><eloquent> | 2016-02-09 06:03:00 | HQ |
35,285,599 | Parent element selector using pure CSS | <p>What is the way of getting parent element using pure CSS. Am using VS 2013, So it must be css3. I have seen in google about has() and < selectors. Unfortunately they do not work. </p>
| <css> | 2016-02-09 06:48:26 | LQ_CLOSE |
35,285,741 | Sum of a range? | I am very new to Python. I am trying to find the sum of all numbers less that 1000 divisible by 3 and 5. I have this so far:
```for i in range(0, 1000):
if i % 3 == 0:
print i
elif i % 5 == 0:
print i
b = sum(i)
print b```
I get a TypeError: 'int' object is not iterable (referring to b = sum(i)) | <python><sum><range> | 2016-02-09 06:57:13 | LQ_EDIT |
35,285,902 | Laravel: find if a pivot table record exists | <p>I have two models which are joined by a pivot table, <code>User</code> and <code>Task</code>.</p>
<p>I have a <code>user_id</code> and a <code>task_id</code>.</p>
<p>What is the neatest way to check whether a record exists for this combination of user and task?</p>
| <php><laravel><eloquent><pivot-table> | 2016-02-09 07:08:21 | HQ |
35,286,029 | Docker: npm install behind proxy | <p>I have this Dockerfile:</p>
<pre><code>FROM node:argon
ENV http_proxy http://user:pass@proxy.company.priv:3128
ENV https_proxy https://user:pass@proxy.company.priv:3128
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
</code></pre>
<p>But I get this error, in <strong>npm install</strong> step:</p>
<blockquote>
<p>npm info it worked if it ends with ok npm info using npm@2.14.12 npm
info using node@v4.2.6 npm WARN package.json deployer-ui@1.0.0 No
description npm WARN package.json deployer-ui@1.0.0 No repository
field. npm WARN package.json deployer-ui@1.0.0 No README data npm info
preinstall deployer-ui@1.0.0 npm info attempt registry request try #1
at 7:09:23 AM npm http request GET
<a href="https://registry.npmjs.org/body-parser" rel="noreferrer">https://registry.npmjs.org/body-parser</a> npm info attempt registry
request try #1 at 7:09:23 AM npm http request GET
<a href="https://registry.npmjs.org/express" rel="noreferrer">https://registry.npmjs.org/express</a> npm info retry will retry, error on
last attempt: Error: tunneling socket could not be established,
cause=write EPROTO npm info retry will retry, error on last attempt:
Error: tunneling socket could not be established, cause=write EPROTO</p>
</blockquote>
<p>I guess it is due to the proxy. I have also tried to put</p>
<pre><code>RUN npm config set proxy http://user:pass@proxy.company.priv:3128
RUN npm config set https-proxy http://user:pass@proxy.company.priv:3128
</code></pre>
<p>but still getting the same error.</p>
<p>Moreover, in my file <strong>/etc/systemd/system/docker.service.d/http-proxy.conf</strong> I have this:</p>
<pre><code>Environment="HTTP_PROXY=http://user:pass@proxy.company.priv:3128"
Environment="HTTPS_PROXY=https://user:pass@proxy.company.priv:3128"
</code></pre>
<p>Thanks in advance.</p>
| <proxy><docker><npm> | 2016-02-09 07:17:04 | HQ |
35,286,055 | javascript rounding by 500 | <p>how to round 17000595 to 17000500 with javascript?</p>
| <javascript><rounding> | 2016-02-09 07:18:41 | LQ_CLOSE |
35,286,326 | Move a marker between 2 coordinates following driving directions | <p>I want to move a marker from one Latlng to another. I have used this code to move the marker smoothly based on Distance and Time.</p>
<pre><code>public void animateMarker(final LatLng toPosition,
final boolean hideMarker) {
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
Projection proj = googleMap.getProjection();
Point startPoint = proj.toScreenLocation(cabMarker.getPosition());
final LatLng startLatLng = proj.fromScreenLocation(startPoint);
final Interpolator interpolator = new LinearInterpolator();
handler.post(new Runnable() {
@Override
public void run() {
Location prevLoc = new Location("service Provider");
prevLoc.setLatitude(startLatLng.latitude);
prevLoc.setLongitude(startLatLng.longitude);
Location newLoc = new Location("service Provider");
newLoc.setLatitude(toPosition.latitude);
newLoc.setLongitude(toPosition.longitude);
System.out.println("Locations ---- " + prevLoc + "-" + newLoc);
float bearing = prevLoc.bearingTo(newLoc);
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) elapsed
/ CAB_TRACK_INTERVAL);
double lng = t * toPosition.longitude + (1 - t)
* startLatLng.longitude;
double lat = t * toPosition.latitude + (1 - t)
* startLatLng.latitude;
cabMarker.setPosition(new LatLng(lat, lng));
cabMarker.setRotation(bearing + 90);
if (t < 1.0) {
// Post again 16ms later.
handler.postDelayed(this, 16);
} else {
if (hideMarker) {
cabMarker.setVisible(false);
} else {
cabMarker.setVisible(true);
}
}
}
});
}
</code></pre>
<p>But the problem is marker wont move on driving directions but in a straight line from A to B. Is it possible to get around 10 road midpoints in between A and B and then and move it along that path? </p>
| <android><google-maps> | 2016-02-09 07:36:00 | HQ |
35,287,148 | Can firefox inspector change files on server? | i'm playing around with
firefox inspector and change some things
on a web page.
Now the web hoster write me the webpage will be hacked.
I watch the page via www, dont have any passwords or so.
Is this coincidence or can a realy make changes on server
with the inspector?
The hoster write the affected file was a /cache_ac67f2ce3f.php
Thanks for your help | <php><firefox> | 2016-02-09 08:28:02 | LQ_EDIT |
35,287,267 | pointer to struct C programming | I am having a problem with pointers.
this is an example of what I want
struct Book
{
char name[10];
int price;
}
int main()
{
struct Book b[10]; //Array of structure variables
struct Book* p; //Pointer of Structure type
p = &b; --- HERE is the ERROR
}
This is the error part
p = &b;
| <c><pointers><struct> | 2016-02-09 08:35:33 | LQ_EDIT |
35,287,302 | Android Data Binding: how to pass variable to include layout | <p>Google documentation says that variables may be passed into an included layout's binding from the containing layout but I can't make it work but get data binding error ****msg:Identifiers must have user defined types from the XML file. handler is missing it.
The including XML looks like this:</p>
<pre><code><layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<import type="com.example.FocusChangeHandler"/>
<variable
name="handler"
type="FocusChangeHandler"/>
</data>
<!-- Some other views --->
<include
android:id="@+id/inputs"
layout="@layout/input_fields"
bind:handler="@{handler}"/>
</layout>
</code></pre>
<p>And the included XML like this: </p>
<pre><code><layout xmlns:android="http://schemas.android.com/apk/res/android">
<EditText
android:id="@+id/nameEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onFocusChange="@{handler.onFocusChange}"/>
</layout>
</code></pre>
<p>I'm able to refer the Views from included layout through generated binding class but passing a variable just doesn't work. </p>
| <android-databinding> | 2016-02-09 08:37:14 | HQ |
35,287,488 | SVGs in C#, draw multiple complex rectangles. | I'm creating a gannt chart to show hundreds of calendars for individual instances of orders, currently using an algorthim to draw lines and rectangles to create a grid, the problem is I'm the bitmaps are becoming far to large to draw, taking up ram, I've tried multiple different methods including drawing the bitmaps at half size and scaling them up (comes out horribly fuzzy) and still to large.
I want to be able to draw SVGs as I figure for something that draws large simple shapes should reduce the size dramatically compared to bitmaps.
the problem is I cant find anything on msdn that includes any sort of c# library for drawing svgs and I dont want to use external code.
Do I need to create It in XAML or is there a library similar to how bitmaps are drawn ?
[current bitmap version, either going out of bounds on the max size or just freezing because system is out of memeory][1]
[1]: http://i.stack.imgur.com/SWZJ8.png | <c#><svg><bitmap> | 2016-02-09 08:48:16 | LQ_EDIT |
35,287,565 | Does Collections.unmodifiableList(list) require a lock? | <p>I have a <code>productList</code> maintained in a file named <code>Products.java</code></p>
<pre><code>private List<String> productList = Collections.synchronizedList(new ArrayList());
</code></pre>
<p>Now creating a synchronized list, will ensure that operations like add/remove will have a implicit lock and I don't need to lock these operations explicitily.</p>
<p>I have a function exposed which returns an <code>unmodifiableList</code> of this list.</p>
<pre><code>public List getProductList(){
return Collections.unmodifiableList(productList);
}
</code></pre>
<p>In my application, various threads can call this function at the same time. So do I need to put a <code>synchronized</code> block when converting a List into an unmodifiable List or will this be already taken care of since I am using a sychronizedList ?</p>
<p>TIA.</p>
| <java><multithreading><arraylist><collections> | 2016-02-09 08:51:55 | HQ |
35,287,949 | React with ES7: Uncaught TypeError: Cannot read property 'state' of undefined | <p>I'm getting this error <strong><em>Uncaught TypeError: Cannot read property 'state' of undefined</em></strong> whenever I type anything in the input box of AuthorForm. I'm using React with ES7.</p>
<p>The error occurs on <strong>3rd line of setAuthorState function in ManageAuthorPage</strong>. Regardless of that line of code even if I put a console.log(this.state.author) in setAuthorState, it will stop at the console.log and call out the error. </p>
<p>Can't find similar issue for someone else over the internet.</p>
<p>Here is the <strong>ManageAuthorPage</strong> code:</p>
<pre><code>import React, { Component } from 'react';
import AuthorForm from './authorForm';
class ManageAuthorPage extends Component {
state = {
author: { id: '', firstName: '', lastName: '' }
};
setAuthorState(event) {
let field = event.target.name;
let value = event.target.value;
this.state.author[field] = value;
return this.setState({author: this.state.author});
};
render() {
return (
<AuthorForm
author={this.state.author}
onChange={this.setAuthorState}
/>
);
}
}
export default ManageAuthorPage
</code></pre>
<p>And here is the <strong>AuthorForm</strong> code: </p>
<pre><code>import React, { Component } from 'react';
class AuthorForm extends Component {
render() {
return (
<form>
<h1>Manage Author</h1>
<label htmlFor="firstName">First Name</label>
<input type="text"
name="firstName"
className="form-control"
placeholder="First Name"
ref="firstName"
onChange={this.props.onChange}
value={this.props.author.firstName}
/>
<br />
<label htmlFor="lastName">Last Name</label>
<input type="text"
name="lastName"
className="form-control"
placeholder="Last Name"
ref="lastName"
onChange={this.props.onChange}
value={this.props.author.lastName}
/>
<input type="submit" value="Save" className="btn btn-default" />
</form>
);
}
}
export default AuthorForm
</code></pre>
| <javascript><reactjs><ecmascript-6><ecmascript-7> | 2016-02-09 09:12:19 | HQ |
35,288,793 | django media url tag | <p>Does django have <code>media</code> tag similar to <code>static</code> and <code>url</code> and how to setup it?</p>
<pre><code>{% static 'styles/boo.css' %}
{% url 'some_app:some_name' %}
Is this possible: {% media 'what here' %}?
</code></pre>
<p>How to setup it?</p>
| <python><django><django-urls> | 2016-02-09 09:52:18 | HQ |
35,289,273 | Django annotate() error AttributeError: 'CharField' object has no attribute 'resolve_expression' | <p>Hello I want to concatenate more fields into django, but even this simple code:</p>
<pre><code> Project.objects.annotate(
companyname=Concat('company__name',Value('ahoj')),output_field=CharField()
)
</code></pre>
<p>Gives me an error:</p>
<pre><code>AttributeError: 'CharField' object has no attribute 'resolve_expression'
</code></pre>
<p>Traceback:</p>
<pre><code> File "/root/MUP/djangoenv/lib/python3.4/site-packages/django/db/models/manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/root/MUP/djangoenv/lib/python3.4/site-packages/django/db/models/query.py", line 908, in annotate
clone.query.add_annotation(annotation, alias, is_summary=False)
File "/root/MUP/djangoenv/lib/python3.4/site-packages/django/db/models/sql/query.py", line 986, in add_annotation
annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None,
AttributeError: 'CharField' object has no attribute 'resolve_expression'
</code></pre>
| <python><django> | 2016-02-09 10:12:59 | HQ |
35,289,314 | Making a Java class Thread safe | I am trying to understand as to how to make the Java class thread-safe.
package com.test;
public class ThreadBean {
private int x;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
}
Inorder to do this,I need to create another program that spawns the threads(lets say 2 threads) and then each of the two threads sets values using the setX().When the values are being read using getX() I should be able to see inconsistencies thanks to the above ThreadBean class not being threadsafe.This maybe a simplistic case but this is just for my understanding.Please advise.Thanks | <java><multithreading><thread-safety> | 2016-02-09 10:14:48 | LQ_EDIT |
35,289,626 | SQL Plus command line: Arrow keys not giving previous commands back | <p>I am using Oracle 10g Express Edition on Fedora core 5 32+ bit os. The problem is when I use the SQL Plus command line to make SQL statements I can not get the previously typed command back at the prompt when I use the up and down arrow keys on my keyboard. This is quite easy when I am using a shell, but here with this Oracle command line interface it is not working at all. Here is the example as what actually is happening whe I press the up or down arrow keys.</p>
<p>SQL> drop table mailorders;</p>
<p>Table dropped.</p>
<p>SQL> ^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A</p>
| <linux><sqlplus> | 2016-02-09 10:29:05 | HQ |
35,289,773 | Cannot convert a partially converted tensor in TensorFlow | <p>There are many methods in TensorFlow that requires specifying a shape, for example truncated_normal:</p>
<pre><code>tf.truncated_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)
</code></pre>
<p>I have a placeholder for the input of shape [None, 784], where the first dimension is None because the batch size can vary. I could use a fixed batch size but it still would be different from the test/validation set size.</p>
<p>I cannot feed this placeholder to tf.truncated_normal because it requires a fully specified tensor shape. What is a simple way to having tf.truncated_normal accept different tensor shapes?</p>
| <python><tensorflow> | 2016-02-09 10:35:55 | HQ |
35,289,802 | Docker pull error : x509: certificate has expired or is not yet valid | <p>Description of problem:</p>
<p>I'm trying to pull ubuntu from the public registry with this command :</p>
<pre><code>docker pull ubuntu
</code></pre>
<p>And then i got this results (the previous command was working yesterday) :</p>
<p>"Error while pulling image: Get <a href="https://index.docker.io/v1/repositories/library/ubuntu/images" rel="noreferrer">https://index.docker.io/v1/repositories/library/ubuntu/images</a>: x509: certificate has expired or is not yet valid"</p>
<p>docker version :</p>
<pre><code>Client:
Version: 1.10.0
API version: 1.22
Go version: go1.5.3
Git commit: 590d510
Built: Thu Feb 4 18:36:33 2016
OS/Arch: linux/amd64
Server:
Version: 1.10.0
API version: 1.22
Go version: go1.5.3
Git commit: 590d510
Built: Thu Feb 4 18:36:33 2016
OS/Arch: linux/amd64
</code></pre>
<p>docker info :</p>
<pre><code>Containers: 4
Running: 0
Paused: 0
Stopped: 4
Images: 20
Server Version: 1.10.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 44
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 3.19.0-49-generic
Operating System: Ubuntu 14.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 5.815 GiB
Name: ubuntu
ID: Y6OO:23T2:BAPU:DVQJ:HJCJ:USEP:T6EU:PMG4:O4M6:46C7:JKPC:BQHT
WARNING: No swap limit support
</code></pre>
<p>uname -a :</p>
<pre><code>Linux ubuntu 3.19.0-49-generic #55~14.04.1-Ubuntu SMP Fri Jan 22 11:24:31 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>
<p>I verify my "date" and everything is good. I don't know where this issue can come from.</p>
| <ubuntu><docker><x509certificate><pull><crt> | 2016-02-09 10:37:21 | HQ |
35,289,918 | Play Audio when device in silent mode - ios swift | <p>I am creating an application using xcode 7.1, swift. I want to play an audio. Everything is fine. Now my problem I want to hear sound when the device in silent mode or muted. How can I do it?</p>
<p>I am using the following code to play audio</p>
<pre><code>currentAudio!.stop()
currentAudio = try? AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("sample_audio", ofType: "mp3")!));
currentAudio!.currentTime = 0
currentAudio!.play();
</code></pre>
| <ios><swift><audio> | 2016-02-09 10:43:17 | HQ |
35,290,378 | understand use of require in perl | What is the use of the keyword 'require' in perl. I have referred http://perldoc.perl.org/functions/require.html but it is not very helpful. | <perl> | 2016-02-09 11:04:44 | LQ_EDIT |
35,290,605 | How remove spacebar in string in Oracle? | <pre><code>SELECT '17, 18' STRING_
FROM DUAL;
</code></pre>
<p>remove spacebar</p>
| <sql><oracle><plsql> | 2016-02-09 11:16:00 | LQ_CLOSE |
35,291,050 | Compare time in perl using subroutine | <p>I found the script to compare the time and get the return value. But that script not validating the following scenario properly. Please help me on this.</p>
<p>Script Path : <a href="http://perlprogramming.language-tutorial.com/2012/10/perl-function-to-compare-two-dates.html#recent" rel="nofollow">http://perlprogramming.language-tutorial.com/2012/10/perl-function-to-compare-two-dates.html#recent</a></p>
<pre><code>Input : 2015-07-01 00:50:00,2015-07-01 00:00:00, returns : 0
</code></pre>
| <perl> | 2016-02-09 11:36:01 | LQ_CLOSE |
35,291,117 | scrollToRowAtIndexPath:atScrollPosition causing table view to "jump" | <p>My app has chat functionality and I'm feeding in new messages like this:</p>
<pre><code>[self.tableView beginUpdates];
[messages addObject:msg];
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:messages.count - 1 inSection:1]] withRowAnimation:UITableViewRowAnimationBottom];
[self.tableView endUpdates];
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:messages.count - 1 inSection:1] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
</code></pre>
<p>However, my table view "jumps" weirdly when I'm adding a new message (either sending and receiving, result is the same in both):</p>
<p><a href="https://i.stack.imgur.com/3ZcEX.gif"><img src="https://i.stack.imgur.com/3ZcEX.gif" alt="enter image description here"></a></p>
<p>Why am I getting this weird "jump"?</p>
| <ios><uitableview><ios9> | 2016-02-09 11:39:14 | HQ |
35,291,520 | Docker and --userns-remap, how to manage volume permissions to share data between host and container? | <p>In docker, files created inside containers tend to have unpredictable ownership while inspecting them from the host. The owner of the files on a volume is root (uid 0) by default, but as soon as non-root user accounts are involved in the container and writing to the file system, owners become more or less random from the host perspective.</p>
<p>It is a problem when you need to access volume data from the host using the same user account which is calling the docker commands. </p>
<p>Typical workarounds are </p>
<ul>
<li>forcing users uIDs at creation time in Dockerfiles (non portable) </li>
<li>passing the UID of the host user to the <code>docker run</code> command as an environment variable and then running some <code>chown</code> commands on the volumes in an entrypoint script. </li>
</ul>
<p>Both these solutions can give some control over the actual permissions outside the container.</p>
<p>I expected user namespaces to be the final solution to this problem. I have run some tests with the recently released version 1.10 and --userns-remap set to my desktop account. However, I am not sure that it can make file ownership on mounted volumes easier to deal with, I am afraid that it could actually be the opposite.</p>
<p>Suppose I start this basic container</p>
<pre><code>docker run -ti -v /data debian:jessie /bin/bash
echo 'hello' > /data/test.txt
exit
</code></pre>
<p>And then inspect the content from the host : </p>
<pre><code>ls -lh /var/lib/docker/100000.100000/volumes/<some-id>/_data/
-rw-r--r-- 1 100000 100000 6 Feb 8 19:43 test.txt
</code></pre>
<p>This number '100000' is a sub-UID of my host user, but since it does not correspond to my user's UID, I still can't edit test.txt without privileges. This sub-user does not seem to have any affinity with my actual regular user outside of docker. It's not mapped back.</p>
<p>The workarounds mentioned earlier in this post which consisted of aligning UIDs between the host and the container do not work anymore due to the <code>UID->sub-UID</code> mapping that occurs in the namespace.</p>
<p>Then, is there a way to run docker with user namespace enabled (for improved security), while still making it possible for the host user running docker to own the files generated on volumes? </p>
| <docker> | 2016-02-09 11:58:40 | HQ |
35,291,710 | InnoSetup Uninstall Caption | How to change the title of the window at the uninstall ?
http://www.fotolink.su/v.php?id=174c19d3d19cd7985b40553d524f9e56
| <inno-setup><pascalscript> | 2016-02-09 12:08:09 | LQ_EDIT |
35,291,764 | Is it possible to bring the variable value even if is there some mismatch in variable in ruby | <pre><code>variable_123_abc = 20
</code></pre>
<p>If I search with variable_345_abc it should bring the value 20 is it possible in ruby?</p>
| <ruby> | 2016-02-09 12:11:19 | LQ_CLOSE |
35,292,001 | How to get ABI (Application Binary Interface) in android | <p>It may be a duplicated question, but i'm unable to find it.
I wonder how we can get what's the ABI of a phone, using code. I know that there's different Interface that may dictated in gradle file. But the problem is how i can get exactly the ABI of a certain device, so that i can manually copy it to system/lib/ folder using SuperSU.
Thank you.</p>
<pre><code>android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" @
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
</code></pre>
| <android><abi> | 2016-02-09 12:23:40 | HQ |
35,292,067 | How it is possible to initialize an array in this form with null values? (Java) | <p>How it is possible to initialize an array in this form with null values in Java?</p>
<pre><code>int array[][] = {
{1, 6, 4, 1,-1},
{6, 3, 3, 3, 9},
{6, 3, 3, 3, 9},
{6, 3, 3, 3, 9},
{6, 3, 3, 3, 9}
};
</code></pre>
<p>I tried that, but it doesn't work (is that possible?):</p>
<pre><code>int array[][] = {
{1, 6, 4, 1,-1},
{6, null, 3, 3, 9},
{6, 3, 3, 3, 9},
{6, 3, 3, null, 9},
{6, 3, 3, 3, 9}
};
</code></pre>
<p>Thanks</p>
| <java><arrays> | 2016-02-09 12:26:57 | LQ_CLOSE |
35,292,397 | ASP.Net Core SAML authentication | <p>I am trying to add SAML 2.0 authentication to an ASP.Net Core solution. I can't find any documentation on the subject, so I am unsure where to start. There is probably documentation out there, but I don't want to spend 3 days becoming an expert on this.</p>
<p>From what I can see ASP.Net Core has changed something from the old OWIN assemblies/namespaces. There are third party libraries to simplify SAML 2.0 implementation such as <a href="https://github.com/KentorIT/authservices" rel="noreferrer">Kentor.AuthServices</a>.</p>
<p>I am unsure how to combine this with ASP.Net 5 RC 1 / ASP.Net Core. For example making use of the AspNet* tables in SQL.</p>
<p>ASP.Net 5 RC 1 comes with several libraries to implement authentication (client).</p>
<p>For example:</p>
<ul>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.OAuth" rel="noreferrer">Microsoft.AspNet.Authentication.OAuth</a></li>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Facebook" rel="noreferrer">Microsoft.AspNet.Authentication.Facebook</a></li>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Google" rel="noreferrer">Microsoft.AspNet.Authentication.Google</a></li>
<li><a href="https://github.com/aspnet/Security/tree/1.0.0-rc1/src/Microsoft.AspNet.Authentication.Twitter" rel="noreferrer">Microsoft.AspNet.Authentication.Twitter</a></li>
</ul>
<p>Implementing these is a matter of calling a simple extension method in <code>Startup.cs</code>:</p>
<pre><code>app.UseIdentity()
.UseFacebookAuthentication(new FacebookOptions
{
AppId = "ID",
AppSecret = "KEY"
})
.UseGoogleAuthentication(new GoogleOptions
{
ClientId = "ID",
ClientSecret = "SECRET"
})
.UseTwitterAuthentication(new TwitterOptions
{
ConsumerKey = "KEY",
ConsumerSecret = "SECRET"
});
</code></pre>
<p>Once that is done the ASP.Net sample project automatically shows social buttons for login/manage account:</p>
<p><a href="https://i.stack.imgur.com/QHpeA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QHpeA.png" alt="Social buttons"></a></p>
<p>In the backend code the authentication providers are retrieved using <code>var otherLogins = _signInManager.GetExternalAuthenticationSchemes().Where(auth => userLogins.All(ul => auth.AuthenticationScheme != ul.LoginProvider)).ToList();</code>. This means the authentication providers are registered somewhere that makes them available by calling <code>_signInManager.GetExternalAuthenticationSchemes()</code>.</p>
<p>How can I implement SAML 2.0 authentication in ASP.Net 5 RC1 / ASP.Net Core?</p>
| <asp.net-core><saml-2.0> | 2016-02-09 12:42:10 | HQ |
35,292,863 | Return makes integer from pointer without a cast (simple for loop) | <p>Why does this C code return the warning in the title?</p>
<pre><code>char n_zeroes(int n) {
char str[n];
int i;
for (i = 0; i < n; i++) {
str[i] = '0';
}
return str;
}
</code></pre>
| <c><pointers><for-loop><char> | 2016-02-09 13:05:56 | LQ_CLOSE |
35,293,117 | npm install that requires node-gyp fails on Windows | <p>I have a NPM project that uses <code>bufferutils</code> and <code>utf-8-validate</code>, both requiring node-gyp to install them. When I do <code>npm install</code>, I get following error:</p>
<pre><code>> bufferutil@1.2.1 install C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil
> node-gyp rebuild
C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil {git}{hg}
{lamb} if not defined npm_config_node_gyp (node "C:\Users\Marek\AppData\Roaming\npm\node_modules\npm\bin\node-g
yp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
bufferutil.cc
C:\Users\Marek\.node-gyp\5.1.1\include\node\v8.h(18): fatal error C1083: Cannot open include file: 'stddef.h':
No such file or directory [C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil\build\bufferutil.vcx
proj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Marek\AppData\Roaming\npm\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Marek\\AppData\\Roaming\\npm\\node_modules\\
npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil
gyp ERR! node -v v5.1.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil@1.2.1 Exit status 1
</code></pre>
<p>Previously it failed because of Python 2.7 not installed, now it is this. It's causing me headaches. What should I do about this?</p>
| <node.js><npm><node-gyp> | 2016-02-09 13:17:17 | HQ |
35,293,379 | UITextField secureTextEntry toggle set incorrect font | <p>I have an <code>UITextField</code> which I use as a password field. It has by default <code>secureTextEntry</code> set to <code>true</code>.
I also have a <code>UIButton</code> to toggle the show/hide of the password.</p>
<p>When I change the textfield from <code>secureTextEntry</code> set to <code>true</code> to <code>false</code>, the font gets weird. Seems it becomes Times New Roman or similar.</p>
<p>I have tried re-setting the font to system with size 14, but it didn't change anything. </p>
<p>Example of what happens (with initial <code>secureTextEntry</code> set to <code>true</code>):
<a href="https://i.stack.imgur.com/ab5sy.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/ab5sy.gif" alt="Example"></a></p>
<p>My code:</p>
<pre><code>@IBAction func showHidePwd(sender: AnyObject) {
textfieldPassword.secureTextEntry = !textfieldPassword.secureTextEntry
// Workaround for dot+whitespace problem
if !textfieldPassword.secureTextEntry {
let tempString = textfieldPassword.text
textfieldPassword.text = nil
textfieldPassword.text = tempString
}
textfieldPassword.font = UIFont.systemFontOfSize(14)
if textfieldPassword.secureTextEntry {
showHideButton.setImage(UIImage(named: "EyeClosed"), forState: .Normal)
} else {
showHideButton.setImage(UIImage(named: "EyeOpen"), forState: .Normal)
}
textfieldPassword.becomeFirstResponder()
}
</code></pre>
| <ios><swift><uitextfield> | 2016-02-09 13:30:16 | HQ |
35,293,470 | Checking if a type is a map | <p>I sometimes find the need to write general routines that can be applied to a container of objects, or a map of such containers (i.e. process each container in the map). One approach is to write separate routines for map types, but I think it can be more natural and less verbose to have one routine that works for both types of input:</p>
<pre><code>template <typename T>
auto foo(const T& items)
{
return foo(items, /* tag dispatch to map or non-map */);
}
</code></pre>
<p>What is a safe, clean way to do this tag dispatch?</p>
| <c++><dictionary><c++14><typetraits> | 2016-02-09 13:35:26 | HQ |
35,293,707 | subset dataframe with sqldf | i try to subset dataframe using sqlfd but it don't work.can someone explain what don't work?i have processed like this.
> library(sqldf)
>dataf <- read.csv("zert.csv")
>agep, pwgt1 are columns of dataf
> dd <- sqldf("select * from dataf where AGEP < 50 and pwgtp1")
>Error in .local(drv, ...) :
>Failed to connect to database: Error: Access denied for user 'rodrigue'@'localhost' (using password: NO)
Error in !dbPreExists : invalid argument type
| <r><sqldf> | 2016-02-09 13:46:54 | LQ_EDIT |
35,293,922 | how to sort an array that contain second order in python? | for instance, I have an array like:
[[1,1,0],[1,0,1],[0,0,0]
first to sort the first element, and then if the first element are same ,sort the second element, and then if the second elements are same sort for third, forth....
the result should like this:
[[0,0,0],[1,0,1],[1,1,0]
obviously, the `sorted` function cannot solve this problem easily even if use `key=...` | <python><list><sorting> | 2016-02-09 13:57:43 | LQ_EDIT |
35,294,503 | div.my-class vs. .my-class any benefits? | <p>If I am to only use this class on a div. Is there any benefit to using the first over the second?</p>
<pre><code>div.my-class
.my-class
</code></pre>
| <html><css> | 2016-02-09 14:25:40 | LQ_CLOSE |
35,294,854 | How can we check the whole sql database for login username and password in mvc3 c# | I have more than one table in my sql server database.each table is for each users named developers, designers, users and so on.my home page contain a login screen.when user try to login with their username and password then it automatically check whether the username and password belongs to the database.if yes it redirect to a page else prompt an error.I need whole database check instead of one table because there is only one login page for all users.thanks | <c#><sql-server><asp.net-mvc-3> | 2016-02-09 14:42:13 | LQ_EDIT |
35,295,090 | Possible to bring the app from background to foreground? | <p>When running an XCT UI test it is possible to put the application under test in the background with:</p>
<pre><code>XCUIDevice().pressButton(XCUIDeviceButton.Home)
</code></pre>
<p>It it possible in some way to bring the app back to foreground (active state) without relaunching the application?</p>
| <ios><swift><xcode7><xcode-ui-testing> | 2016-02-09 14:53:03 | HQ |
35,295,115 | Android ProgressBar styled like progress view in SwipeRefreshLayout | <p>I use <code>android.support.v4.widget.SwipeRefreshLayout</code> in my Android app. It wraps a <code>ListView</code>. The content of the list view is downloaded from a server.</p>
<p>A progress view is shown when user swipes down in order to reload data from server. The progress view looks like a piece of circle that grows and shrinks during the animation. It seems that the style of this progress view cannot be customized much. However, I am fine with its built-in style.</p>
<p>I also show the same progress animation during initial data loading. This can be achieved by calling <code>mySwipeRefreshLayout.setRefreshing(true)</code>. That's perfectly OK too.</p>
<p>However, I would like to show the same progress indication through the whole app. Consider e.g. another activity that looks like a form with submit button. There is neither a <code>ListView</code> nor a <code>SwipeRefreshLayout</code> in this form activity. Some progress indication should be displayed while the submitted data are transferred to the server. I want to show a progress bar with the same animation like in SwipeRefreshLayout.</p>
<p>Is there a simple and clean way to have the same progress indicator for both a <code>SwipeRefreshLayout</code> and a form activity that does not contain any list view and refresh layout and does not support any swipe gesture?</p>
<p>Thanks.</p>
| <android><progress-bar><android-styles> | 2016-02-09 14:54:39 | HQ |
35,296,680 | How to configure "git pull --ff-only" and "git merge --no-ff" | <p>A typical git workflow for me is to clone a remote repository and use git pull to keep it up-to-date. I don't want merge commits when I pull, so i use the --ff-only option.</p>
<p>I also make local branches for feature work. I want to preserve the branch history, so when I merge the local branch back to my local clone, I use the --no-ff option.</p>
<p>How can I configure git to use those options by default? Currently my .gitconfig looks like this:</p>
<pre><code>[merge]
ff = false
[pull]
ff = only
</code></pre>
<p>However, git pull (which is really git fetch and git merge) seems to be picking up the merge option and therefore creating merge.</p>
| <git><git-merge><git-pull><git-config> | 2016-02-09 16:07:35 | HQ |
35,297,574 | Data format: transform row to colum in R | This is my code but I want to format the data put it down in a web page.
library(XML)
noria=readHTMLTable("http://www.fundacionguanajuato.com/CGI-BIN/Clima/Actual.php?Est=noria")
raws.data <- readLines(noria, warn="F")
str(noria)
noria
#I get the result but I can't see the correct format when I export it to .csv
Best regards.**Rene.** | <r><web-scraping> | 2016-02-09 16:49:15 | LQ_EDIT |
35,298,291 | run modeler stream inside spss statistics | I have an SPSS syntax file that I am trying to make as automatic as possible. I am looking for a way, inside SPSS Statistics, to do basically the following: open SPSS Modeler and run stream. But, my SPSS syntax has to wait for the file to be created and exported in the Modeler stream before my SPSS syntax can proceed. Is there a way to do this with Python? | <python><spss><spss-modeler> | 2016-02-09 17:24:26 | LQ_EDIT |
35,298,647 | Java - How to determine if there's a run of characters in an array? | Say we have an array:
array = [1, 0, 0, 0, 1, 0, 1, 1, 1];
And we want to find a "run" of duplicate numbers where there are at least three in a row. In this case, it would be the set of 0, 0, 0, and 1, 1, 1.
How can I determine which indices contain the "runs" of three or more? I hope this makes sense.
| <java><android><arrays><integer> | 2016-02-09 17:44:23 | LQ_EDIT |
35,298,724 | Google Docs Viewer occasionally failing to load content in iframe | <p>I'm having an issue with the Google Docs viewer that is causing a nightmare to solve because it only happens intermittently. I'm looking for guidance on how to make the content in the iframe load everytime without issue as it should. </p>
<p>Steps to reproduce
1) This page is a basic HTML page with a h1 tag and an iframe containing a link to a PDF on the same server</p>
<p><a href="http://bit.ly/1mqbuf7" rel="noreferrer">http://bit.ly/1mqbuf7</a></p>
<p>2) When you load the page, the pdf document will load in the iframe 60% of the time. </p>
<p>3) If you hit refresh 10 or so times, at least once it will fail to appear. Google returns a 307 first (Which it also does when it works) and then returns a 204 - no content. When it works, it returns a 200, with the content you see in the viewer.</p>
<p>I'm struggling to understand why it only does this some of the time with no visible errors. This has been tested and failed on Google Chrome v 48.0.2564.103 (PC) and Internet Explorer Edge v25.10586 (PC) with the same results and frequency of failure. </p>
<p>Any guidance would be greatly appreciated. </p>
| <html><iframe><google-docs> | 2016-02-09 17:49:01 | HQ |
35,298,935 | Else statement does not get executed in Javascript | <p>Hello I've been trying to write a function to validate a string value. My code is below</p>
<pre><code>function verifyPassword(){
passW = prompt ("Password:");
if (passW = 'Pass123'){
document.write ('Your password is correct');
}
else {
document.write ('Your password is incorrect');
}
}
verifyPassword();
</code></pre>
<p>But here I always seem to get the result as 'Your password is correct', no matter what I put. </p>
<p>Please can someone help me to resolve this issue?</p>
| <javascript> | 2016-02-09 18:00:06 | LQ_CLOSE |
35,298,986 | How can I use nested formulas in arrayfomula functions in google sheets? | I am new to posting in this community but have found solutions here many times.
I need google sheets to compute sums for each row using the arrayformula() function.
I know I can manualy enter somthing like;
=ARRAYFORMULA(A:A + B:B + C:C)
but I need the use of the functions to do it.
I've tried many things including;
=ARRAYFORMULA(sum(A:A,C:C))
Here is a sample file that I could use help with.
https://docs.google.com/spreadsheets/d/15ehNnTjAbuIUo_KNz363zLXjqlk-0InIspZAQm9yhB8/edit#gid=0
Thank you. | <google-sheets><array-formulas> | 2016-02-09 18:02:35 | LQ_EDIT |
35,299,733 | How to get text from a number in a select query | <p>there I have MYSQL DB, and it has an ID INT, however this identifier has a meaning in the system, I would like to get the meaning instead of the number for example something like this.</p>
<pre><code>select ID from payments;
if(ID==0)
returns "No payment made"
else if(ID==1)
returns "Payment made accordingly"
</code></pre>
<p>Is it possible to do that ? or should I do it programatically? in the system?,
I'm using a datagridview in C# and that is why I want to get the result as a text and not a number from the query</p>
| <c#><mysql> | 2016-02-09 18:42:57 | LQ_CLOSE |
35,300,419 | Redux, Do I have to import store in all my containers if I want to have access to the data? | <p>Perhaps I am not wrapping my head around redux, but all the examples I've seen don't really access state too much between containers and so I haven't seen much usage of store.getState(), but even if you want to dispatch, you need access to store, right?</p>
<p>So, other than importing
import store from 'path/to/store/store'</p>
<p>in every file that I want to getState() or "dispatch", how do I get access to that state because if I don't include it, store is undefined.</p>
| <reactjs><redux> | 2016-02-09 19:18:36 | HQ |
35,301,256 | How to have a file or string available to multiple computers and be able to changed and rewritten in C#? | <br>
I have a bit of an issue/question. <br>
I am trying to write a program that generates a specific serial number but it will be able to be accessed by multiple computers in different locations. <br>
The serial number will look something like this:<br>
(2 letters)AA(month)02(year)16(four numbers)0000<br>
Full thing: AA02160000<br>
The last 4 digits will increment by one every time the user clicks a button.
I need to be able to get that serial number from multiple computers in different locations not on the same network and edit it and rewrite it. I can't have any sort of overlap being a serial number and unique to a specific item. I also can't use a guid for the number otherwise it would be much easier.
What is the best way to do this in C#?
I have considered making a server for it but I was running into problems when trying to create directories to pull the number from because of the drive letter.
Can I access a website that is hosted on a computer in one location and have it grab that serial number and increment it and then place the new value on the website?
Quite honestly I'm spinning in circles with a million ways to do and not knowing the proper/best way to do it. A bit of help here would be much appreciated.
| <c#><serialization> | 2016-02-09 20:11:01 | LQ_EDIT |
35,301,828 | Image read/write in Java without imageio between local file systems | <p>I'm very new to Java and I'm recently making a program which reads image files(jpg) from one directory, and write(copy) them to another directory.</p>
<p>I can't use imageio or move/copy methods and I also have to check the time consuming caused by the R/W operation.</p>
<p>The problem is I wrote some codes below and it runs, but all of my output image files in the destination have 0 byte and have no contents at all.
I can see only black screens which have no bytes when I open the result images.</p>
<pre><code>public class image_io {
public static void main(String[] args)
{
FileInputStream fis = null;
FileOutputStream fos = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
// getting path
File directory = new File("C:\\src");
File[] fList = directory.listFiles();
String fileName, filePath, destPath;
// date for time check
Date d = new Date();
int byt = 0;
long start_t, end_t;
for (File file : fList)
{
// making paths of source and destination
fileName = file.getName();
filePath = "C:\\src\\" + fileName;
destPath = "C:\\dest\\" + fileName;
// read the images and check reading time consuming
try
{
fis = new FileInputStream(filePath);
bis = new BufferedInputStream(fis);
do
{
start_t = d.getTime();
}
while ((byt = bis.read()) != -1);
end_t = d.getTime();
System.out.println(end_t - start_t);
} catch (Exception e) {e.printStackTrace();}
// write the images and check writing time consuming
try
{
fos = new FileOutputStream(destPath);
bos = new BufferedOutputStream(fos);
int idx = byt;
start_t = d.getTime();
for (; idx == 0; idx--)
{
bos.write(byt);
}
end_t = d.getTime();
System.out.println(end_t - start_t);
} catch (Exception e) {e.printStackTrace();}
}
}
</code></pre>
<p>}</p>
<p>Is FileInput/OutputStream doesn't support image files?
Or is there some mistakes in my code?</p>
<p>Please, somebody help me..</p>
| <java><fileinputstream><fileoutputstream><image-file> | 2016-02-09 20:45:23 | LQ_CLOSE |
35,302,274 | How to reload a page in PHP before exit function? | <p>I got some code like this and the header is not working</p>
<pre><code> if ($variable > 0) {
header('Location: mypage.php');
exit;
}
</code></pre>
<p>And I need exit function, is this a bad idea?</p>
| <php><exit> | 2016-02-09 21:12:05 | LQ_CLOSE |
35,302,368 | Why does changing int to long speed up the execution? | <p>I was trying to solve <a href="https://projecteuler.net/problem=14" rel="noreferrer">problem #14 from Project Euler</a>, and had written the following C#...</p>
<pre><code>int maxColl = 0;
int maxLen = 0;
for (int i = 2; i < 1000000; i++) {
int coll = i;
int len = 1;
while (coll != 1) {
if (coll % 2 == 0) {
coll = coll / 2;
} else {
coll = 3 * coll + 1;
}
len++;
}
if (len > maxLen) {
maxLen = len;
maxColl = i;
}
}
</code></pre>
<p>Trouble was, it just ran and ran without seeming to stop.</p>
<p>After searching for other people's solution to the problem, I saw one looking very similar, except that he had used long instead of int. I didn't see why this should be necessary, as all of the numbers involved in this problem are well within the range of an int, but I tried it anyway.</p>
<p>Changing int to long made the code run in just over 2 seconds.</p>
<p>Anyone able to explain this to me?</p>
| <c#> | 2016-02-09 21:18:47 | HQ |
35,302,414 | Adding local plugin to a Gradle project | <p>I have a Gradle plugin that compiles and works as expected. I would like to distribute with the source code an example application using the Gradle plugin which would also allow me to test changes to the plugin easily. Now to do this I must add a classpath dependency to the <code>buildScript</code> block. Is it possible to add a dependent local plugin that will be compiled with the example project? The main issue I'm having now is that the plugin does not exist when trying to sync the example project resulting in a failure.</p>
| <java><gradle> | 2016-02-09 21:21:27 | HQ |
35,302,760 | How to change the colour of the 'Cancel' button on the UISearchBar in Swift | <p>I have added a <code>UISearchBar</code> to the top of my <code>PFQueryTableViewController</code>. I have changed the colour of the searchBar to be the colour of my app, but in doing this, it seems to have also changed the colour of the 'Cancel' button to the right of it to the same colour. Ideally, I want the colour to be White. </p>
<p>This image shows how it currently looks:</p>
<p><a href="https://i.stack.imgur.com/Xppcm.png"><img src="https://i.stack.imgur.com/Xppcm.png" alt=""></a></p>
<p>It looks like there is no 'Cancel' button, but there is, its just the same colour as the searchBar (You can still press it etc)</p>
<p>Is there a way for me to change the colour of this 'Cancel button to white? Everything i've tried seems to make no difference. </p>
<p>Code i've used to make the <code>UISearchBar</code> this colour is:</p>
<pre><code>UISearchBar.appearance().barTintColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
UISearchBar.appearance().tintColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
</code></pre>
<p>And in the storyboard i've set these:</p>
<p><a href="https://i.stack.imgur.com/ZfTy2.png"><img src="https://i.stack.imgur.com/ZfTy2.png" alt="enter image description here"></a></p>
<p>And finally, to make the placeholder, and text white inside the SearchBar, i've used:</p>
<pre><code>for subView in self.filmSearchBar.subviews {
for subsubView in subView.subviews {
if let searchBarTextField = subsubView as? UITextField {
searchBarTextField.attributedPlaceholder = NSAttributedString(string: NSLocalizedString("Search Cinevu film reviews", comment: ""), attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()])
searchBarTextField.textColor = UIColor.whiteColor()
}
}
}
</code></pre>
<p>Thanks for any help! :)</p>
| <ios><swift><uisearchbar> | 2016-02-09 21:42:14 | HQ |
35,303,370 | Mocha only running one test file | <p>My Mocha tests were working fine, but when I added a new module (and test), mocha stopped running all of my test files and now only runs the single new test.</p>
<p>My test script:</p>
<pre><code>env NODE_PATH=$NODE_PATH:$PWD/src mocha --recursive --compilers js:babel-core/register src/**/*.test.js --require babel-polyfill
</code></pre>
<p>My project is structured like this:</p>
<pre><code>/src
/components
/component-name
index.js
component.js
component-name.test.js
style.scss
/util
/module-name
index.js
module-name.test.js
/some-other-module
index.js
some-other-module.test.js
</code></pre>
<p>I had several tests in <code>/components</code> and <code>/util</code> and everything worked fine, but when I place a module into <code>/src</code> (like <code>/some-other-module</code>) with a <code>.test.js</code> file in it, Mocha only runs that test file and none of the others.</p>
| <javascript><testing><mocha><babeljs> | 2016-02-09 22:23:39 | HQ |
35,303,374 | How can I Retrive the json Object Array Value using javascruipt | My Json Object Array is something like this:
country:[{ id: "1", name:"ajith", country:"india"},
{id: "2", name:"chandru", country:"india"},
{id:"3", name:"gane", country:"india"}]
how can i retrive these key and value, and how can i display in html table.
please anyone can please me. it's urgent. | <javascript><html><json> | 2016-02-09 22:23:54 | LQ_EDIT |
35,303,675 | What is the difference between id and tagname? | <p>An Interviewer asked this question in selenium webdriver
Please let me know the answer of this question</p>
<p>Thanks
Srinu Marri</p>
| <selenium><selenium-webdriver><webdriver> | 2016-02-09 22:44:18 | LQ_CLOSE |
35,303,773 | Returning a 1 or 0 for checkbox , wheter checked or unchecked in HTML5 | I declared a var and want to pass the status of the checkbox to the dhcp_addr variable and set it to 1 when the checkbox is checked and 0 when its unchecked. Need some help in returning a value to the variable.
var dhcp_addr = $('#dhcp').change(function(){
if(dhcp.checked){
console.log("checked");
}
else{
console.log("unchecked");
}
});
| <javascript><jquery><html><checkbox> | 2016-02-09 22:51:32 | LQ_EDIT |
35,304,252 | Elixir: rationale behind allowing rebinding of variables | <p>What is the rationale behind allowing rebinding of variables in Elixir, when Erlang doesn't allow that?</p>
| <erlang><elixir> | 2016-02-09 23:32:08 | HQ |
35,304,343 | CircleCI with no tests | <p>I want to use CircleCI just to push my docker image to Dockerhub when I merge with master. I am using CircleCI in other projects where it is more useful and want to be consistent (as well as I am planning to add tests later). However all my builds fail because CircleCI says: "NO TESTS!", which is true. How can I disable CircleCI from checking for tests presence.</p>
| <circleci> | 2016-02-09 23:39:21 | HQ |
35,304,367 | Regex or any string method | <p>Hi I am trying to validate a string e.g. AA2016MY and I want to validate that the string position from 3 to 6 is a numeric value.</p>
<p>How to do this is simple java way.</p>
| <java><string> | 2016-02-09 23:41:14 | LQ_CLOSE |
35,304,448 | Laravel: Change base URL? | <p>When I use <code>secure_url()</code> or <code>asset()</code>, it links to my site's domain <strong><em>without</em></strong> "www", i.e. "example.com".</p>
<p>How can I change it to link to "www.example.com"?</p>
| <laravel><laravel-4> | 2016-02-09 23:49:52 | HQ |
35,305,170 | What's the difference between Prometheus and Zabbix? | <p>Just as the title said, can you tell me the differences between Prometheus and Zabbix?</p>
| <zabbix><prometheus> | 2016-02-10 01:08:38 | HQ |
35,305,492 | Cache docker images on Travis CI | <p>Is it possible to cache docker images on Travis CI? Attempting to cache the <code>/var/lib/docker/aufs/diff</code> folder and <code>/var/lib/docker/repositories-aufs</code> file with cache.directories in the travis.yml doesn't seem to work since they require root.</p>
| <performance><caching><docker><continuous-integration><travis-ci> | 2016-02-10 01:45:29 | HQ |
35,305,649 | How to read in words from file into a string | <p>for a lab i am working on, we are supposed to read in words from a file and get the length of each, and then store it in an array. Would reading in each word into a string and then storing the length in the array be the best way of going about this? And if so, could someone give me a pointer on how to do this? I am a bit lost..</p>
<p>Thanks!</p>
| <java> | 2016-02-10 02:03:52 | LQ_CLOSE |
35,305,875 | Progress bar while loading image using Glide | <p>Can I load a spinner in placeholder with rotating animation until the image is loaded using Glide?</p>
<p>I am trying to do that using .placeholder(R.Drawable.spinner) no animation is coming up?</p>
<p>It would be great if somebody could help me out?</p>
<p>Thanks!</p>
| <android><android-glide> | 2016-02-10 02:34:26 | HQ |
35,306,309 | Call dotNET from Delphi and return a string | <p>How does a Delphi application call an exported function (non-COM) dotNET assembly and have the function return a string?</p>
<p>COM is not a possible solution for my particular application. I have control over both ends of the call.</p>
<h2>What I have tried so far - Delphi client side</h2>
<pre><code>type
TStrProc = procedure( var x: widestring); stdcall;
function TryIt: string;
var
Handle: THandle;
Proc: TStrProc;
InData: widestring;
OutData: widestring;
begin
Handle := LoadLibrary( 'DelphiToDotNet.dll');
if Handle = 0 then exit;
@Proc := GetProcAddress( Handle, 'StrProc');
if @Proc <> nil then
begin
InData := 'input';
Proc( InData);
OutData := InData;
end;
FreeLibrary( Handle);
result := OutData
end;
</code></pre>
<h2>dotNET dll side</h2>
<pre><code>public class DotNetDllClass
{
[DllExport]
public static string StrProc(ref string s)
{
return "Hello from .Net " + s;
}
}
</code></pre>
<h2>What works</h2>
<p>I can successfully pass integers into and out of dotNET procedures.
I can successfully pass strings (widestring on the Delphi side) into dotNET procedures.</p>
<h2>What doesn't work</h2>
<p>In the above two listings, the string parameter returned is junk. Accessing it causes an AV.</p>
<h2>Environment</h2>
<p>Delphi XE7, dotNET 4, Win 7, 32 bit application and dll.</p>
| <c#><delphi><interop> | 2016-02-10 03:28:05 | HQ |
35,306,500 | R: data.table count !NA per row | <p>I am trying to count the number of columns that do not contain NA for each row, and place that value into a new column for that row.</p>
<p>Example data:</p>
<pre><code>library(data.table)
a = c(1,2,3,4,NA)
b = c(6,NA,8,9,10)
c = c(11,12,NA,14,15)
d = data.table(a,b,c)
> d
a b c
1: 1 6 11
2: 2 NA 12
3: 3 8 NA
4: 4 9 14
5: NA 10 15
</code></pre>
<p>My desired output would include a new column <code>num_obs</code> which contains the number of non-NA entries per row:</p>
<pre><code> a b c num_obs
1: 1 6 11 3
2: 2 NA 12 2
3: 3 8 NA 2
4: 4 9 14 3
5: NA 10 15 2
</code></pre>
<p>I've been reading for hours now and so far the best I've come up with is looping over rows, which I know is never advisable in R or data.table. I'm sure there is a better way to do this, please enlighten me.</p>
<p>My crappy way:</p>
<pre><code>len = (1:NROW(d))
for (n in len) {
d[n, num_obs := length(which(!is.na(d[n])))]
}
</code></pre>
| <r><data.table> | 2016-02-10 03:51:45 | HQ |
35,306,573 | I need help creating a for loop for document.querySelectorAll | <p>I need help creating a for loop for document.querySelectorAll(".suit"). I'm trying to create a form where you input the birthday and the output is a total of 365 options. The example output put is in the HTML.</p>
<pre><code> <html>
<head>
<style type="text/css">
.suit {
display: none;
}
.suit.visible {
display: block;
}
</style>
<script type="text/javascript">
window.onload = function() {
var monthSelection = document.querySelector("#month");
var daySelection = document.querySelector("#day");
var submitButton = document.querySelector("#submit");
submitButton.onclick = function() {
document.querySelectorAll(".suit").setAttribute("class", "suit visible");
// TODO hide everything else
}
}
</script>
</head>
<body>
Date Of Birth: <br>
<select id="month" name="month">
<option value="na">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="day" name="day">
<option value="na">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<button id="submit">Submit</button>
<div class="suit" month="8" day="27">Queen of Hearts, 10 of clubs</div>
<!-- TODO content -->
</code></pre>
<p></p>
<p></p>
| <javascript><forms><loops> | 2016-02-10 04:01:50 | LQ_CLOSE |
35,308,148 | You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings | [This is my pycharm settings and my django app manage.py, view.py and wsgi.py][1]
[1]: http://i.stack.imgur.com/BGPEV.png | <python><django><environment-variables><pycharm> | 2016-02-10 06:15:58 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.