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,234,527
How do I get a PHP array to an angular variable?
<p>I'm coding a website that uses PHP to get information about a match from the database into an array. However, I want to display this information using angular. How could I get the array from the PHP to the angular? </p>
<php><arrays><angularjs>
2016-02-05 22:19:35
LQ_CLOSE
35,234,718
How to unit test express Router routes
<p>I'm new to Node and Express and I'm trying to unit test my routes/controllers. I've separated my routes from my controllers. How do I go about testing my routes?</p> <p><strong>config/express.js</strong></p> <pre><code> var app = express(); // middleware, etc var router = require('../app/router')(app); </code></pre> <p><strong>app/router/index.js</strong></p> <pre><code> module.exports = function(app) { app.use('/api/books', require('./routes/books')); }; </code></pre> <p><strong>app/router/routes/books.js</strong></p> <pre><code> var controller = require('../../api/controllers/books'); var express = require('express'); var router = express.Router(); router.get('/', controller.index); module.exports = router; </code></pre> <p><strong>app/api/controllers/books.js</strong></p> <pre><code>// this is just an example controller exports.index = function(req, res) { return res.status(200).json('ok'); }; </code></pre> <p><strong>app/tests/api/routes/books.test.js</strong></p> <pre><code> var chai = require('chai'); var should = chai.should(); var sinon = require('sinon'); describe('BookRoute', function() { }); </code></pre>
<javascript><node.js><unit-testing><express><chai>
2016-02-05 22:34:25
HQ
35,234,995
how to implement any genetic ant finding food in Push,Clojush,Clojure?
<p>I am trying to use Push,Clojush,Clojure to implement an ant finding food in a 2d map, but I am not sure how to represent map? Could someone give me a example? Thank you.</p>
<clojure><clojure-java-interop><clojure-contrib><clojure-core.logic>
2016-02-05 23:00:39
LQ_CLOSE
35,235,014
Rails 4 - JS for dependent fields with simple form
<p>I am trying to make an app in Rails 4.</p> <p>I am using simple form for forms and have just tried to use gem 'dependent-fields-rails' to hide or show subset questions based on the form field of a primary question.</p> <p>I'm getting stuck.</p> <p>I have added gems to my gem file for:</p> <pre><code>gem 'dependent-fields-rails' gem 'underscore-rails' </code></pre> <p>I have updated my application.js to:</p> <pre><code>//= require dependent-fields //= require underscore </code></pre> <p>I have a form which has:</p> <pre><code>&lt;%= f.simple_fields_for :project_date do |pdf| %&gt; &lt;%= pdf.error_notification %&gt; &lt;div class="form-inputs"&gt; &lt;%= pdf.input :student_project, as: :radio_buttons, :label =&gt; "Is this a project in which students may participate?", autofocus: true %&gt; &lt;div class="js-dependent-fields" data-radio-name="project_date[student_project]" data-radio-value="true"&gt; &lt;%= pdf.input :course_project, as: :radio_buttons, :label =&gt; "Is this a project students complete for credit towards course assessment?" %&gt; &lt;%= pdf.input :recurring_project, as: :radio_buttons, :label =&gt; "Is this project offered on a recurring basis?" %&gt; &lt;%= pdf.input :frequency, :label =&gt; "How often is this project repeated?", :collection =&gt; ["No current plans to repeat this project", "Each semester", "Each year"] %&gt; &lt;/div&gt; &lt;div class='row'&gt; &lt;div class="col-md-4"&gt; &lt;%= pdf.input :start_date, :as =&gt; :date_picker, :label =&gt; "When do you want to get started?" %&gt; &lt;/div&gt; &lt;div class="col-md-4"&gt; &lt;%= pdf.input :completion_date, :as =&gt; :date_picker, :label =&gt; "When do you expect to finish?" %&gt; &lt;/div&gt; &lt;div class="col-md-4"&gt; &lt;%= pdf.input :eoi, :as =&gt; :date_picker, :label =&gt; 'When are expressions of interest due?' %&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;% end %&gt; &lt;script type="text/javascript"&gt; $('.datetimepicker').datetimepicker(); &lt;/script&gt; &lt;script&gt; $(document).ready(function() { DependentFields.bind() }); &lt;/script&gt; </code></pre> <p>I don't know much about javascript. </p> <p>I"m not sure if the final script paragraph is necessary or if the gem puts that into the code for you. I'm not sure if it's supposed to be expressed inside script tags and I also don't know how to give effect to this requirement (which is set out on the gem page for dependent-fields):</p> <pre><code>"Be sure to include underscorejs and jquery in your page." </code></pre> <p>How do you include underscorejs and jQuery in a page? I have them in my gem file. Is that enough or is something else required to make this work?</p> <p>Currently, when I try this form, nothing is hidden. I have tried swapping the true value to 'yes' but that doesnt make any difference either.</p> <pre><code>&lt;div class="js-dependent-fields" data-radio-name="project_date[student_project]" data-radio-value="true"&gt; &lt;div class="js-dependent-fields" data-radio-name="project_date[student_project]" data-radio-value="yes"&gt; </code></pre> <p>Can anyone see where I've gone wrong? </p>
<javascript><jquery><ruby-on-rails><underscore.js><simple-form>
2016-02-05 23:01:50
HQ
35,235,400
Getting absolute value from binary int using bitwise
flt32 flt32_abs (flt32 x) { int mask=x>>31; printMask(mask,32); puts("Original"); printMask(x,32); x=x^mask; puts("after XOR"); printMask(x,32); x=x-mask; puts("after x-mask"); printMask(x,32); return x; } Heres my code, the value -32 is returning .125. I'm confused because it's a pretty straight up formula for abs on bits, but I seem to be missing something. Any ideas? Thanks y'all.
<c><bit-manipulation><mask><absolute-value>
2016-02-05 23:40:58
LQ_EDIT
35,235,597
Julia function argument by reference
<p>The docs say</p> <blockquote> <p>In Julia, all arguments to functions are passed by reference.</p> </blockquote> <p>so I was quite surprised to see a difference in the behaviour of these two functions:</p> <pre><code>function foo!(r::Array{Int64}) r=r+1 end function foobar!(r::Array{Int64}) for i=1:length(r) r[i]=r[i]+1 end end </code></pre> <p>here is the unexpectedly different output:</p> <pre><code>julia&gt; myarray 2-element Array{Int64,1}: 0 0 julia&gt; foo!(myarray); julia&gt; myarray 2-element Array{Int64,1}: 0 0 julia&gt; foobar!(myarray); julia&gt; myarray 2-element Array{Int64,1}: 1 1 </code></pre> <p>if the array is passed by reference, I would have expected foo! to change the zeros to ones.</p>
<reference><pass-by-reference><julia>
2016-02-06 00:05:56
HQ
35,236,189
PHP online store, looping buttons & databases
<p>So I am writing this code and I want to make it by getting the data of the database using a loop. The problem that I got is that I can't seem to find a way to push through a value to the database from the buttons that I got. I am open to ideas. Thanks !</p> <pre><code>&lt;!Doctype HTML&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="style.css" type="text/css"/&gt; &lt;title&gt;Online Catalog&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="" method="get"&gt; &lt;?php session_start(); require('database.php'); echo "&lt;h1&gt;&lt;a href=". 'index.php' ."&gt;Catalog&lt;/a&gt;&lt;/h1&gt; &lt;b id=".cart."&gt;&lt;a href=". 'cart.php' ."&gt;Show cart&lt;/a&gt;&lt;/b&gt;"; if ($result = $connection-&gt;query("SELECT * FROM `store`")) { $row_cnt = $result-&gt;num_rows; while ($row = $result-&gt;fetch_assoc()) { echo "&lt;p&gt; &lt;table&gt; &lt;th&gt; &lt;img src=".$row[img_path].'/'.$row[img_name]."&gt; &lt;/th&gt; &lt;td&gt; &lt;h2&gt;". $row[name] ."&lt;/h2&gt;&lt;br&gt; ". $row[description] ."&lt;br&gt;&lt;br&gt; Price : ". $row[price] ."$&lt;br&gt; &lt;/td&gt; &lt;td &gt; &lt;input type='submit' name='add".$row[id]."' value='Add to cart'/&gt; &lt;/td&gt; &lt;/table&gt; &lt;/p&gt; "; if(isset($_GET['add.$row[id].'])){ $cart=1; if(mysqli_query($connection, "INSERT INTO `store-project`.`store` (`incart`) VALUES ('$cart')")){ mysqli_close($connection); header("Location: cart.php"); } } } $result-&gt;close(); } ?&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><a href="http://i.stack.imgur.com/9HJdg.png" rel="nofollow">Here is the database</a></p> <p><a href="http://i.stack.imgur.com/cr58y.png" rel="nofollow">And here is how it generally looks</a></p>
<php><shopping-cart>
2016-02-06 01:19:03
LQ_CLOSE
35,236,475
Cocoapods error: linker command failed with exit code 1 (use -v to see invocation)
<p>First time using cocoa pods (latest version) for dependencies in the latest Xcode 7.2.1 with Swift 2.1. I initialize my project folder and then edit the podfile and add my dependencies. When I run <code>pod install</code> it runs without a hitch until I open my project and try to build. I've tried this with two separate projects (one being brand new for testing) and I get <code>linker command failed with exit code 1 (use -v to see invocation)</code> for both. My pod file looks like this:</p> <pre><code>platform :ios, '8.0' #8.0 is minimum supported, right? use_frameworks! target 'Testing Frameworks' do pod 'Alamofire', '~&gt; 3.0' end </code></pre>
<xcode><cocoa><swift2>
2016-02-06 02:00:03
HQ
35,236,735
NPM warn message about deprecated package
<p>I am installing a module globally</p> <pre><code>$ npm install -g X </code></pre> <p>and NPM says</p> <blockquote> <p>"npm WARN deprecated lodash@1.0.2: lodash@&lt;3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0"</p> </blockquote> <p>how can I find out which module has an dependency on this old version of lodash?</p> <p>The warning message from NPM doesn't seem to give me any clue which module references this old version (I believe that the module X does not have a direct dependency on this old version of lodash.).</p>
<node.js><npm>
2016-02-06 02:41:59
HQ
35,236,782
Promises not working on IE11
<p>I'm new to Promises on javascript so I hope some can help me with this issue.</p> <p><strong>Problem:</strong> Promise not being execute on IE11, works fine on Chrome and FireFox</p> <p><strong>Frameworks used:</strong> I tried using es6-promise.d.ts and bluebird.d.ts same result.</p> <p>Code:</p> <pre><code>static executeSomething(): Promise&lt;any&gt; { console.log("inside executeSomething"); var test= new Promise((resolve, reject)=&gt; { console.log("inside Promise"); }).catch(function(error){console.log("error")}); console.log("after promise"); return test; } </code></pre> <p><strong>Results:</strong> on chrome and Firefox I can see all the logs but on IE11 I only see "Inside executeSomething" which means the problem is while creating the promise.</p> <p>I thought it was because IE11 didn't support es6 but I get the same result using bluebird, I hope some can bring some light to my issue.</p>
<javascript><typescript><promise><bluebird><es6-promise>
2016-02-06 02:49:32
HQ
35,236,834
'goto *foo' where foo is not a pointer. What is this?
<p>I was playing around with <a href="https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html">labels as values</a> and ended up with this code. </p> <pre><code>int foo = 0; goto *foo; </code></pre> <p>My C/C++ experience tells me <code>*foo</code> means <code>dereference foo</code> and that this won't compile because <code>foo</code> isn't a pointer. But it does compile. What does this actually do?</p> <p><code>gcc (Ubuntu 4.9.2-0ubuntu1~12.04) 4.9.2</code>, if important.</p>
<c++><c><gcc><language-lawyer><goto>
2016-02-06 02:58:14
HQ
35,237,709
Recommended way to locate parent element in Protractor
<p>According to the newly published <a href="https://github.com/angular/protractor/blob/master/docs/style-guide.md#never-use-xpath">Style Guide</a>, <em>using the <code>by.xpath()</code> locators is considered a bad practice</em>. I'm actually trying to follow the suggestion, but stuck on getting a parent element.</p> <p>Currently we are using <code>..</code> XPath expression to get to the element's parent:</p> <pre><code>this.dashboard = element(by.linkText("Dashboard")).element(by.xpath("..")); </code></pre> <p>How can I locate the element's parent using <em>other</em> built into Protractor/WebDriverJS locators?</p>
<javascript><selenium><xpath><selenium-webdriver><protractor>
2016-02-06 05:27:22
HQ
35,237,897
How to choose multiple batch commands to run in Visual Basic?
I have written a code in Visual Basic. It works, but i want to be able to choose how many times a batch file will be opened. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim command As String command = "ping " + "-l " + TextBox2.Text + " /t " + TextBox1.Text Shell("cmd.exe /k" & command, 0) End Sub So i have a TextBox called "TextBox3" where i wanna be able to write from 1-100, how many times the command will run.
<vb.net><cmd>
2016-02-06 05:56:55
LQ_EDIT
35,238,221
Converting Text Files
<p>I have a text file containing these. I will load it in created form.</p> <pre><code>5JB01141570J4450901 1000 1051 2000 01161501B10G610M0350M200 0000006 </code></pre> <p>to produce this.</p> <pre><code>106262,5,JB,2015-01-14,70J4450901 ,1000 ,1051 ,2000 ,2015-01-16,0,1,B10G610M0350M200 ,6,, ,0,1/14/2015 3:06:16 PM </code></pre> <p>how can it converted to it?</p> <p>the first column is the row counts and the last column indicates datetime when generated..</p>
<c#><text-files>
2016-02-06 06:44:58
LQ_CLOSE
35,238,406
Something Wrong with QuickSort algorithm
<p>Quick Sort Java Implementation- I have made a program to implement QuickSort algorithm, but it is not showing the sorted sequence properly, It is also showing array out of bound Index exception. can someone tell what is wrong with code or logic?</p> <pre><code>import java.util.*; public class QuickSort{ int num,arrayQS[],i; public void quicksort(int ar[],int start,int end){ if(start&lt;end){ int pindex=partition(ar,start,end); System.out.println(pindex); quicksort(ar,start,pindex-1); quicksort(ar,pindex+1,end); } } public int partition(int pAR[],int start, int end){ //partition function int key; int swapper; int pivot=pAR[end]; int pIndex=start; for(i=0;i&lt;end;i++){ if(pAR[i]&lt;=pivot){ //swapiing key=pAR[pIndex]; pAR[pIndex]=pAR[i]; pAR[i]=key; pIndex++; } } //swap swapper=pAR[pIndex]; pAR[pIndex]=pAR[end]; pAR[end]=swapper; return pIndex; } public void arrayInputFn(){ Scanner in=new Scanner(System.in); System.out.println("enter the number you want to insert in an array"); num=in.nextInt(); arrayQS=new int[num]; System.out.println("enter the elements in an array: "); for(i=0;i&lt;num;i++){ arrayQS[i]=in.nextInt(); } quicksort(arrayQS,0,arrayQS.length-1); for(i=0;i&lt;arrayQS.length;i++){ System.out.print(arrayQS[i]); } } public static void main(String[] args){ QuickSort qs=new QuickSort(); qs.arrayInputFn(); } } </code></pre>
<java><arrays><data-structures><java.util.scanner><quicksort>
2016-02-06 07:11:44
LQ_CLOSE
35,238,596
How could I hide the minimap bar on sublimetext 3
<p>It takes too much space on the window,</p> <p>I tried some option in the configuration</p> <p>It seems not working, any idea ?</p> <h1>User setting</h1> <pre><code>"draw_minimap_border": false, "draw_minimap": false, "hide_minimap": true, "always_show_minimap_viewport": false </code></pre> <p><img src="https://i.imgur.com/mnYTOuL.png=300x" alt="inline" title="Title"></p>
<sublimetext3>
2016-02-06 07:36:27
HQ
35,238,689
Form Switching In C#
How can I lock (and make it look faded) a parent form while the child form is active? I tried to make the child form topmost but that just made it always visible and I can still edit the parent form. I want to be unable to operate on the main form while the child form is running in VS2012, C#. This is the code I used to call the second form... private void checkButton_Click(object sender, EventArgs e) { Form2 newForm = new Form2(this); newForm.Show(); }
<c#><.net><winforms>
2016-02-06 07:51:27
LQ_EDIT
35,239,000
parsley.js is not working in my django form validation
This code in django does not show any validation error.Am i missing any syntax or tag ? ` <head> <link rel="stylesheet" type="text/css" href="/static/css/side_file.css"> <script type="text/javascript" src="/static/js/parsley.js"> </script> <link rel="stylesheet" type="text/css" href="/static/css/side_file.css"> <script type="text/javascript" src="/static/js/parsley.js"> </script> </head>` ` <body> <form data-parsley-validate method="POST"> {{form}} </form> </body>`
<javascript><html><django><parsley.js>
2016-02-06 08:31:49
LQ_EDIT
35,239,102
why is string matching not working?
<pre><code> String [] P = K.split(" "); //NB: the value of K is "malaria zika AIDS" for (int x=0;x&lt; P.length; x++) { if (P[x]=="zika") { System.out.println( "This is zika virus P[x]="+ P[x]); }else{ System.out.println( "This is NOT zika virus P[x]="+P[x]); } } </code></pre> <h2>Expecting</h2> <pre><code>This is NOT zika virus P[x]=Malaria This is zika virus P[x]=zika This is NOT zika virus P[x]=AIDS </code></pre> <h2>But Getting</h2> <pre><code>This is NOT zika virus P[x]=Malaria This is NOT zika virus P[x]=zika This is NOT zika virus P[x]=AIDS </code></pre> <p>What am I missing? I believe that this is the part with the problem. <code>if (P[x]=="zika")</code></p>
<java><string><comparison>
2016-02-06 08:45:27
LQ_CLOSE
35,240,278
How to remove all Docker containers
<p>I want to remove all of my docker containers at once. I tried to use $ docker rm [container_id] to do so, but it removed only one container, not all.</p> <p>Is there any way to remove all docker containers using one single line of code?</p>
<linux><docker>
2016-02-06 11:08:45
HQ
35,240,414
Laravel 5 PDOException Could Not Find Driver
<p>I have a problem using Laravel 5. When I run "php aritsan migrate", I got this error</p> <pre><code>************************************** * Application In Production! * ************************************** Do you really wish to run this command? [y/N] y [PDOException] could not find driver </code></pre> <p>I could run the application, but when database connection needed, I got this error</p> <pre><code>PDOException in Connector.php line 55: could not find driver in Connector.php line 55 at PDO-&gt;__construct('mysql:host=localhost;dbname=mydb', 'root', '', array('0', '2', '0', false, false)) in Connector.php line 55 at Connector-&gt;createConnection('mysql:host=localhost;dbname=mydb', array('driver' =&gt; 'mysql', 'host' =&gt; 'localhost', 'database' =&gt; 'mydb', 'username' =&gt; 'root', 'password' =&gt; '', 'charset' =&gt; 'utf8', 'collation' =&gt; 'utf8_unicode_ci', 'prefix' =&gt; '', 'strict' =&gt; false, 'name' =&gt; 'mysql'), array('0', '2', '0', false, false)) in MySqlConnector.php line 22 </code></pre> <p>How to fix it?</p>
<php><mysql><laravel><laravel-5>
2016-02-06 11:22:50
HQ
35,240,469
How to mock the imports of an ES6 module?
<p>I have the following ES6 modules:</p> <p><strong>network.js</strong></p> <pre><code>export function getDataFromServer() { return ... } </code></pre> <p><strong>widget.js</strong></p> <pre><code>import { getDataFromServer } from 'network.js'; export class Widget() { constructor() { getDataFromServer("dataForWidget") .then(data =&gt; this.render(data)); } render() { ... } } </code></pre> <p>I'm looking for a way to test Widget with a mock instance of <code>getDataFromServer</code>. If I used separate <code>&lt;script&gt;</code>s instead of ES6 modules, like in Karma, I could write my test like:</p> <pre><code>describe("widget", function() { it("should do stuff", function() { let getDataFromServer = spyOn(window, "getDataFromServer").andReturn("mockData") let widget = new Widget(); expect(getDataFromServer).toHaveBeenCalledWith("dataForWidget"); expect(otherStuff).toHaveHappened(); }); }); </code></pre> <p>However, if I'm testing ES6 modules individually outside of a browser (like with Mocha + babel), I would write something like: </p> <pre><code>import { Widget } from 'widget.js'; describe("widget", function() { it("should do stuff", function() { let getDataFromServer = spyOn(?????) // How to mock? .andReturn("mockData") let widget = new Widget(); expect(getDataFromServer).toHaveBeenCalledWith("dataForWidget"); expect(otherStuff).toHaveHappened(); }); }); </code></pre> <p>Okay, but now <code>getDataFromServer</code> is not available in <code>window</code> (well, there's no <code>window</code> at all), and I don't know a way to inject stuff directly into <code>widget.js</code>'s own scope.</p> <h1>So where do I go from here?</h1> <ol> <li><strong>Is there a way to access the scope of <code>widget.js</code>, or at least replace its imports with my own code?</strong></li> <li><strong>If not, how can I make <code>Widget</code> testable?</strong></li> </ol> <hr> <h2>Stuff I considered:</h2> <h3>a. Manual dependency injection.</h3> <p>Remove all imports from <code>widget.js</code> and expect the caller to provide the deps.</p> <pre><code>export class Widget() { constructor(deps) { deps.getDataFromServer("dataForWidget") .then(data =&gt; this.render(data)); } } </code></pre> <p>I'm very uncomfortable with messing up Widget's public interface like this and exposing implementation details. No go.</p> <hr> <h3>b. Expose the imports to allow mocking them.</h3> <p>Something like:</p> <pre><code>import { getDataFromServer } from 'network.js'; export let deps = { getDataFromServer }; export class Widget() { constructor() { deps.getDataFromServer("dataForWidget") .then(data =&gt; this.render(data)); } } </code></pre> <p>then:</p> <pre><code>import { Widget, deps } from 'widget.js'; describe("widget", function() { it("should do stuff", function() { let getDataFromServer = spyOn(deps.getDataFromServer) // ! .andReturn("mockData"); let widget = new Widget(); expect(getDataFromServer).toHaveBeenCalledWith("dataForWidget"); expect(otherStuff).toHaveHappened(); }); }); </code></pre> <p>This is less invasive but requires me to write a lot of boilerplate for each module, and there's still a risk of me using <code>getDataFromServer</code> instead of <code>deps.getDataFromServer</code> all the time. I'm uneasy about it, but that's my best idea so far.</p>
<javascript><unit-testing><mocha><ecmascript-6>
2016-02-06 11:28:39
HQ
35,240,690
How to scroll all spreadsheet sheets together. (Or other ~3D-like ideas)
I have a simple idea of what I'm looking for, but I'm not sure how to explain it clearly, so apologies in advance! I would like a "3D" spreadsheet, with the aim of having main entries in the normal 2D cells and then (potentially just-as-important) entries in a third dimension above each cell. This is what the multiple sheets already allow for, the problem is that I cannot easily see all the 3rd dimension cells at once. I was first hoping to find some sophisticated method of using actual 3D sheets but with no luck so far. I realised that if I could only make sure the other sheets would line up with my first sheet then that would be good enough, so I could "scroll" along the third dimension by switching between sheets. So, is there any way to scroll all the sheets together? Such that if I scroll down on sheet 1 to see cell 123 A, when I switch to sheet 2, cell 123 A is in the same position on the screen, and so on for sheets 3 and up. If this is impossible but anyone has suggestions for a different solution that would be great. Many thanks!
<scroll><3d><libreoffice-calc>
2016-02-06 11:54:15
LQ_EDIT
35,241,053
Meaning of Zero Before Number in Java
<p>I have a code like this, but I don't know why result variable have false value after execution the code</p> <pre><code>int x = 234; boolean result = (x&lt;0250); </code></pre> <p>and also why the following code doesn't work properly?</p> <pre><code>System.out.println(0250); </code></pre> <p>it prints 168 !! why?!</p>
<java>
2016-02-06 12:34:14
LQ_CLOSE
35,243,492
Firebase android : make username unique
<p>Parse will shut down at the end of the year, so I decided to start using Firebase. I need to implement a register process with 3 fields : email, username, password (<strong>Email &amp; username</strong> must be unique for my app). </p> <p>Since, Firebase is not providing an easy way to manage username like Parse, I decided to use only the email/password registration and save some additional data like username. Here is my users data structure :</p> <pre><code>app : { users: { "some-user-uid": { email: "test@test.com" username: "myname" } } } </code></pre> <p>But, what I want to do is to make the username unique and to check it before creating an account. These are my rules :</p> <pre><code>{ "rules": { ".read": true, ".write": true, "users": { "$uid": { ".write": "auth !== null &amp;&amp; auth.uid === $uid", ".read": "auth !== null &amp;&amp; auth.provider === 'password'", "username": {".validate": "!root.child('users').child(newData.child('username').val()).exists()"} } } } } </code></pre> <p>Thank you very much for your help</p>
<android><firebase><firebase-security><firebase-authentication>
2016-02-06 16:37:48
HQ
35,243,813
Interrupted windows 2008 server R2 install
<p>I interrupted an install of Windows 2008 server on a fast machine that was taking too long with the intentional of using an alternative boot media to the USB flash drive I was using. (It kept showing me a message saying it was preparing my computer for first time use for nearly 2 hrs). I therefore removed the USB drive and surprisingly it then came up with the message asking to either start in safe mode or a normal start. I choose a normal start and it booted fine. Should I have confidence in using this as a production server or should I just go for a clean install ?</p>
<windows-server-2008-r2>
2016-02-06 17:05:27
LQ_CLOSE
35,244,037
VM error while starting Wildfly (JBoss) server
<p>I have wildfly-10.0.0.Final available with PATH variable set. I am using Ubuntu. Also I have jdk1.7.0_79. I am facing the problem that as when I am trying to start server that is executing standalone.sh then I am getting the error,</p> <p><code>Unrecognized VM option 'MetaspaceSize=96M' </code> <code>Error: Could not create the Java Virtual Machine. </code> <code>Error: A fatal exception has occurred. Program will exit.</code></p>
<java><jboss>
2016-02-06 17:25:46
HQ
35,245,361
Add leading zeroes to number in Dart
<p>I want to add some leading zeroes to a string. For example, the total length may be eight characters. For example:</p> <pre><code>123 should be 00000123 1243 should be 00001234 123456 should be 00123456 12345678 should be 12345678 </code></pre> <p>What is an easy way to do this in Dart?</p>
<dart>
2016-02-06 19:22:23
HQ
35,245,768
Load reCAPTCHA dynamically
<p>There are several ways to load reCAPTCHA using javascript such as below:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Loading captcha with JavaScript&lt;/title&gt; &lt;script src="https://code.jquery.com/jquery-1.12.0.min.js"&gt;&lt;/script&gt; &lt;script type='text/javascript'&gt; var captchaContainer = null; var loadCaptcha = function() { captchaContainer = grecaptcha.render('captcha_container', { 'sitekey' : 'Your sitekey', 'callback' : function(response) { console.log(response); } }); }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="captcha_container"&gt;&lt;/div&gt; &lt;input type="button" id="MYBTN" value="MYBTN"&gt; &lt;script src="https://www.google.com/recaptcha/api.js?onload=loadCaptcha&amp;render=explicit" async defer&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This code load captcha on pageload. I want load reCAPTCHA just when clicked on "MYBTN". So the code changes into:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Loading captcha with JavaScript&lt;/title&gt; &lt;script src="https://code.jquery.com/jquery-1.12.0.min.js"&gt;&lt;/script&gt; &lt;script type='text/javascript'&gt; $('#MYBTN').on('click',function(){ var captchaContainer = null; var loadCaptcha = function() { captchaContainer = grecaptcha.render('captcha_container', { 'sitekey' : 'Your sitekey', 'callback' : function(response) { console.log(response); } }); }; }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="captcha_container"&gt;&lt;/div&gt; &lt;input type="button" id="MYBTN" value="MYBTN"&gt; &lt;script src="https://www.google.com/recaptcha/api.js?onload=loadCaptcha&amp;render=explicit" async defer&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But this code didn't work when I click on "MYBTN" and reCAPTCHA not load. Help me plz. Thanks.</p>
<javascript><jquery><recaptcha>
2016-02-06 19:58:26
HQ
35,246,167
ES6 import syntax with Angular 1.5 UI Router
<p>I'm trying to combine Angular 1.5, UI Router using ES6 import modules syntax with Babel &amp; Webpack.</p> <p>In my app.js I have:</p> <pre><code>'use strict'; import angular from 'angular'; import uiRouter from 'angular-ui-router'; ... import LoginCtrl from './login/login.ctrl.js' const app = angular.module("app", [ uiRouter, ... ]) .config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('login', { url: '/login', templateUrl: '...', controller: LoginCtrl, controllerAs: 'login' }) }); </code></pre> <p>In login/login.ctrl.js I have:</p> <pre><code>'use strict'; export default app.controller("LoginCtrl", function() { //code here }); </code></pre> <p>When I started my app I have following error message:</p> <pre><code>ReferenceError: app is not defined bundle.js:35422:2 Error: [$injector:modulerr] Failed to instantiate module app due to: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. </code></pre> <p>And second question. How can I use controller: "loginCtrl as login" syntax with ES6 import/export?</p>
<javascript><angularjs><angular-ui-router><ecmascript-6><es6-module-loader>
2016-02-06 20:36:22
HQ
35,246,208
C# program runs but than terminates?
I'm using visual studios 2012 and I'm creating a program that prompts the user to enter the number of wheels their car has, the color of their car, the mileage etc.. and will display 'the starting point of the car, the mileage, and the color of the car once the user inputs their values. But, once I start the program and I enter the number of wheels, the program terminates and doesn't go to the next step. ' public class Car { private int NumbofWheels; private int Mileage; private String Color; private double point; private double newPoint; private String owner; static void Main(string[] args) { Console.WriteLine("****************************************"); Console.WriteLine("* WELCOME TO CAR MANAGER *"); Console.WriteLine(); Console.WriteLine("* BY: MOHAMED SHIRE *"); Console.WriteLine("* *"); Console.WriteLine("* *"); Console.WriteLine("* **************************************"); Console.Write("ENTER THE # OF WHEELS OF A CAR: "); Console.ReadKey(); } public Car() { Mileage = 0; NumbofWheels = 4; point = 1000000; } public Car(int mile) { Mileage = mile; } public Car(int n, String c) { Mileage = 0; NumbofWheels = n; Color = c; point = 1000000; } public void setPoint( int p) { point = p; } public double getPoint() { return point; } public void setMileage(int m) { Mileage = m; } public int getMileage() { return Mileage; } public void setWheels(int w) { NumbofWheels = w; } public int getWheels() { return NumbofWheels; } public void setColor(String c) { Color = c; } public String getColor() { return Color; } public void setOwner(String o) { owner = o; } public String getOwner() { return owner; } public void calPoint() { newPoint = point - Mileage * 0.5; } public double getnPoint() { return newPoint; } } } '
<c#>
2016-02-06 20:40:24
LQ_EDIT
35,246,212
Is there an actual 8-bit integer data type in C++
<p>In c++, specifically the cstdint header file, there are types for 8-bit integers which turn out to be of the char data type with a typedef. Could anyone suggest an actual 8-bit integer type?</p>
<c++><integer>
2016-02-06 20:41:10
HQ
35,246,453
Use rle to group by runs when using dplyr
<p>In R, I want to summarize my data after grouping it based on the runs of a variable <code>x</code> (aka each group of the data corresponds to a subset of the data where consecutive <code>x</code> values are the same). For instance, consider the following data frame, where I want to compute the average <code>y</code> value within each run of <code>x</code>:</p> <pre><code>(dat &lt;- data.frame(x=c(1, 1, 1, 2, 2, 1, 2), y=1:7)) # x y # 1 1 1 # 2 1 2 # 3 1 3 # 4 2 4 # 5 2 5 # 6 1 6 # 7 2 7 </code></pre> <p>In this example, the <code>x</code> variable has runs of length 3, then 2, then 1, and finally 1, taking values 1, 2, 1, and 2 in those four runs. The corresponding means of <code>y</code> in those groups are 2, 4.5, 6, and 7.</p> <p>It is easy to carry out this grouped operation in base R using <code>tapply</code>, passing <code>dat$y</code> as the data, using <code>rle</code> to compute the run number from <code>dat$x</code>, and passing the desired summary function:</p> <pre><code>tapply(dat$y, with(rle(dat$x), rep(seq_along(lengths), lengths)), mean) # 1 2 3 4 # 2.0 4.5 6.0 7.0 </code></pre> <p>I figured I would be able to pretty directly carry over this logic to dplyr, but my attempts so far have all ended in errors:</p> <pre><code>library(dplyr) # First attempt dat %&gt;% group_by(with(rle(x), rep(seq_along(lengths), lengths))) %&gt;% summarize(mean(y)) # Error: cannot coerce type 'closure' to vector of type 'integer' # Attempt 2 -- maybe "with" is the problem? dat %&gt;% group_by(rep(seq_along(rle(x)$lengths), rle(x)$lengths)) %&gt;% summarize(mean(y)) # Error: invalid subscript type 'closure' </code></pre> <p>For completeness, I could reimplement the <code>rle</code> run id myself using <code>cumsum</code>, <code>head</code>, and <code>tail</code> to get around this, but it makes the grouping code tougher to read and involves a bit of reinventing the wheel:</p> <pre><code>dat %&gt;% group_by(run=cumsum(c(1, head(x, -1) != tail(x, -1)))) %&gt;% summarize(mean(y)) # run mean(y) # (dbl) (dbl) # 1 1 2.0 # 2 2 4.5 # 3 3 6.0 # 4 4 7.0 </code></pre> <p>What is causing my <code>rle</code>-based grouping code to fail in <code>dplyr</code>, and is there any solution that enables me to keep using <code>rle</code> when grouping by run id?</p>
<r><dplyr><run-length-encoding>
2016-02-06 21:05:51
HQ
35,246,702
bootstrap grid col overflowing
<p>I am starting to learn Bootstrap, I could not understand this behaviour.</p> <p>Text of a <code>.col</code> element inside a <code>.row</code> is overflowing to enter next <code>col</code> why is it happening and What can i do to wrap the text up.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt; &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /&gt; &lt;h1&gt;Heading&lt;/h1&gt; &lt;div class="row"&gt; &lt;div class="col-md-6"&gt; HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHel &lt;/div&gt; &lt;div class="col-md-6"&gt; man &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
<html><css><twitter-bootstrap>
2016-02-06 21:30:30
LQ_CLOSE
35,246,713
Node.js, Mongo find and return data
<p>I’m new to node and mongo after 15 years of VB6 and MySql. I’m sure this is not what my final program will use but I need to get a basic understanding of how to call a function in another module and get results back.</p> <p>I want a module to have a function to open a DB, find in a collection and return the results. I may want to add a couple more functions in that module for other collections too. For now I need it as simple as possible, I can add error handlers, etc later. I been on this for days trying different methods, module.exports={… around the function and with out it, .send, return all with no luck. I understand it’s async so the program may have passed the display point before the data is there.</p> <p>Here’s what I’ve tried with Mongo running a database of db1 with a collection of col1.</p> <pre><code>Db1.js var MongoClient = require('mongodb').MongoClient; module.exports = { FindinCol1 : function funk1(req, res) { MongoClient.connect("mongodb://localhost:27017/db1", function (err,db) { if (err) { return console.dir(err); } var collection = db.collection('col1'); collection.find().toArray(function (err, items) { console.log(items); // res.send(items); } ); }); } }; app.js a=require('./db1'); b=a.FindinCol1(); console.log(b); </code></pre> <p>Console.log(items) works when the 'FindinCol1' calls but not console.log(b)(returns 'undefined') so I'm not getting the return or I'm pasted it by the time is returns. I’ve read dozens of post and watched dozens of videos but I'm still stuck at this point. Any help would be greatly appreciated.</p>
<node.js><mongodb>
2016-02-06 21:31:28
HQ
35,246,822
does not contain a definition for " " and no extension method accepting a first argument
<pre><code>i am having trouble with my set and gets in my test class. it says it does not </code></pre> <p>contain a definition for ______ and no extension method accepting a first argument. i have read similar problems but i can not fix these errors. how can i fix this? Specifically it says my Car class does not contain a definition </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Homework1 { class Car { private string color; private int numOfWheels; private int startingPoint; private int mileage; private int currentSpeed; public Car() { color = ""; NumOfWheels = 4; StartingPoint = 100000; CurrentSpeed = 0; Mileage = 0; } public Car(string color, int numOfWheels, int startingPoint, int currentSpeed, int mileage) { Color = color; NumOfWheels = numOfWheels; StartingPoint = startingPoint; CurrentSpeed = currentSpeed; Mileage = mileage; } public virtual string Color { get { return color; } set { color = value; } } public virtual int NumOfWheels { get { return numOfWheels; } set { numOfWheels = value; } } public virtual int StartingPoint { get { return startingPoint; } set { startingPoint = value; } } public virtual int CurrentSpeed { get { return currentSpeed; } set { currentSpeed = value; } } public virtual int Mileage { get { return mileage; } set { mileage = value; } } public override string ToString() { return (" color " + color + " numOfWheels" + numOfWheels + "startingPoint " + startingPoint + "mileage" + mileage + "current speed" + currentSpeed); } } } ******************************************************************************** ///this is the test program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Homework1 { class CarTest { static void Main(string[] args) { Car myCar = new Car(); Console.WriteLine("*****************************"); Console.WriteLine("* *"); Console.WriteLine("* WELCOME TO CAR MANAGER *"); Console.WriteLine("* By &lt;&lt;my Name&gt;&gt; *"); Console.WriteLine("* *"); Console.WriteLine("*****************************"); Console.WriteLine("\nEnter the number of wheels of a car"); int numOfWheels = Console.Read(); myCar.setNumOfWheels(numOfWheels); Console.WriteLine("Enter the color of the car"); String color = Console.ReadLine(); Console.WriteLine("Current mileage will be set to zero"); Console.WriteLine("The current starting point will be set to 100000"); Console.Write("The current status of your car \n{0:D} Wheels, \n{1}, \n{2:D} Miles and \nCAR POINT = {3:D}", myCar.getNumOfWheels, myCar.getColor, myCar.getMileage, myCar.getStartingPoint); Console.WriteLine("\nEnter the owner's name"); String name = Console.ReadLine(); Console.WriteLine("Enter the miles the car ran in this week"); int milesThisWeek = Console.ReadLine(); myCar.setMileage(Mileage); Console.WriteLine("This car is owned by n{1}", name); Console.WriteLine("===&gt;The current status of your car:"); Console.WriteLine("Wheels: " + myCar.getWheels()); Console.WriteLine("Color: " + myCar.getColor()); Console.WriteLine("Current Mileage: " + myCar.getMileage()); Console.WriteLine("Starting Point: " + myCar.getStartingPoint()); Console.WriteLine("************ Thank you for using CAR MANAGER *************"); Console.WriteLine("----------------------------------------------------------"); Console.WriteLine("----------------------------------------------------------"); Console.WriteLine("Press ENTER to close console……."); } } } </code></pre>
<c#>
2016-02-06 21:41:20
LQ_CLOSE
35,247,033
Using 'rvest' to extract links
<p>I am trying to scrap data from Yelp. One step is to extract links from each restaurant. For example, I search restaurants in NYC and get some results. Then I want to extract the links of all the 10 restaurants Yelp recommends on page 1. Here is what I have tried:</p> <pre><code>library(rvest) page=read_html("http://www.yelp.com/search?find_loc=New+York,+NY,+USA") page %&gt;% html_nodes(".biz-name span") %&gt;% html_attr('href') </code></pre> <p>But the code always returns 'NA'. Can anyone help me with that? Thanks!</p>
<r><web-scraping><yelp><rvest>
2016-02-06 22:04:58
HQ
35,247,243
Is it possible for a hacker to find the value of a session variable on my server ?
<p>Is it possible for someone (hacker), to somehow get a hold of the value of a session variable that is active.</p>
<php><variables><cookies><server>
2016-02-06 22:24:47
LQ_CLOSE
35,247,586
Change default test class name suffix in Intellij IDEA
<p>By default when I generate test class in IDEA it has "Test" suffix. As I usually use Spock I want to change it to be "Spec" by default. Is it somehow possible?</p>
<intellij-idea>
2016-02-06 23:05:06
HQ
35,247,624
Parse error: syntax error, unexpected T_IF on line 115
<p>when trying to run a php script I get the error 'Unexpected T_IF' Yes, it is a botnet script, however I am just researching about networking, I have no intentions to use it. And yes, I did try putting a semi colon, no luck. Full script: <a href="https://github.com/Visgean/Zeus/blob/translation/source/server%5Bphp%5D/install/index.php" rel="nofollow">https://github.com/Visgean/Zeus/blob/translation/source/server%5Bphp%5D/install/index.php</a></p> <pre><code>"`r_reports_db` bool NOT NULL default '1', ". "`r_reports_db_edit` bool NOT NULL default '1', ". "`r_reports_files` bool NOT NULL default '1', ". "`r_reports_files_edit` bool NOT NULL default '1', ". /*EVAL_BEGIN*/if (configBool('jabber_notifier'))return /*THIS IS ERROR*/ "\"`r_reports_jn` bool NOT NULL default '1', \"."; /*EVAL_END*/ "`r_system_info` bool NOT NULL default '1', ". "`r_system_options` bool NOT NULL default '1', ". "`r_system_user` bool NOT NULL default '1', ". "`r_system_users` bool NOT NULL default '1'"; //RЎRєSЂReRїS, C &lt;P ± RѕS, P ° Rј. $_TABLES['botnet_scripts'] = </code></pre>
<php>
2016-02-06 23:09:41
LQ_CLOSE
35,247,724
How to do editText like password
<p>I want to do this code in c to Android I dont use passwordtext I need to use editText ty</p> <pre><code> ph=getch(); if(ph!='\r'){ pass[i]=ph; printf("*"); </code></pre>
<java><android><c>
2016-02-06 23:20:59
LQ_CLOSE
35,247,847
Bad Request - Invalid Hostname ASP.net Visual Studio 2015
<p>After debugging my website in Visual Studio 2015, I can visit it via localhost:50544. I would like to visit my website on a different computer from which it is being served upon that is also on the same network. To do this I should be able to visit that computers address which is 192.168.1.13:50544.</p> <p>However when visiting this address I get a 'Bad request, invalid host name' error. Even if I visit it on the same machine as the website is being served on.</p> <p>Following the advice <a href="https://stackoverflow.com/questions/22044470/bad-request-invalid-hostname-while-connect-to-localhost-via-wifi-from-mobile-ph">here</a> I have created the following windows firewall rule and have also tried turning the firewall off entirely. <a href="https://i.stack.imgur.com/p30Oj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/p30Oj.png" alt="picture of firewall rule"></a></p> <p>I'm using IIS express and so have added to the '~\Documents\IISExpress\config\applicationhost.config' file</p> <pre><code>&lt;binding protocol="http" bindingInformation=":8080:localhost" /&gt; //original rule &lt;binding protocol="http" bindingInformation="*:50544:192.168.1.13" /&gt; </code></pre> <p>But visiting 192.168.1.13:50544 on any machine still results in the 'Bad Request' error. </p>
<asp.net><iis><port>
2016-02-06 23:33:41
HQ
35,248,007
VSCode editor - Restart NodeJs server when file is changed
<p>I am using Visual Studio Code as my editor for NodeJS project.</p> <p>Currently I need to manually restart server when I change files in my project.</p> <p>Is there any plugin or configuration change in VSCode that can restart NodeJS server automatically when I make change in files.</p>
<node.js><visual-studio-code>
2016-02-06 23:53:25
HQ
35,248,310
Add some basic markers to a map in mapbox via mapbox gl js
<p>I have a map styled with mapbox studio, however I'm having difficulty adding even a basic marker to it, however text is appearing where the marker should be which suggests that the marker would be there.</p> <p>So here's the code with that map style:</p> <pre><code>mapboxgl.accessToken = 'pk.eyJ1Ijoic21pY2tpZSIsImEiOiJjaWtiM2JkdW0wMDJudnRseTY0NWdrbjFnIn0.WxGYL18BJjWUiNIu-r3MSA'; var map = new mapboxgl.Map({ container: 'map', style: "mapbox://styles/smickie/cikb3fhvi0063cekqns0pk1f1", center: [-30.50, 40], zoom: 2, interactive: false }); </code></pre> <p>And here some markers being added from an example in the api:</p> <pre><code>map.on('style.load', function () { map.addSource("markers", { "type": "geojson", "data": { "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [-77.03238901390978, 38.913188059745586] }, "properties": { "title": "Mapbox DC", "marker-symbol": "monument" } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-122.414, 37.776] }, "properties": { "title": "Mapbox SF", "marker-color": "#ff00ff" } }] } }); map.addLayer({ "id": "markers", "type": "symbol", "source": "markers", "layout": { "icon-image": "{marker-symbol}-15", "text-field": "{title}", "text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"], "text-offset": [0, 0.6], "text-anchor": "top" } }); }); </code></pre> <p>However only the text and not the icons appear.</p> <p>Question is: how would I add just a normal basic colored marker to this map, not even one of the special icon ones?</p> <p>Thanks.</p>
<javascript><mapbox>
2016-02-07 00:30:20
HQ
35,248,509
Android Sudio - Basic Calculator - app shows unfortunately stopped
I am a newbie at android studio. Tried this code and builded and generated an unsigned apk. I tried in on Samsung galaxy trend GT-s7392 and Asus Zenfone 5, also tried in bluestacks. But when the app is opened , It shows - " Unfortunately Calculator has stopped.?" Additionally, It never asks for for any permission upon installation. Should i need to modify the android manifest.xml or any other file <!-- begin snippet: js hide: false --> <!-- language: lang-html --> package in.harisree.calculator; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public abstract class MainActivity extends AppCompatActivity implements OnClickListener { public Button btnAdd,btnSub,btnMul,btnDiv; public TextView tvResult; public EditText etNum1,etNum2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { btnAdd=(Button)findViewById(R.id.btnAdd); btnSub=(Button)findViewById(R.id.btnSub); btnMul=(Button)findViewById(R.id.btnMul); btnDiv=(Button)findViewById(R.id.btnDiv); etNum1=(EditText)findViewById(R.id.etNum1); etNum2=(EditText)findViewById(R.id.etNum2); tvResult=(TextView)findViewById(R.id.tvResult); btnAdd.setOnClickListener(this); btnSub.setOnClickListener(this); btnMul.setOnClickListener(this); btnDiv.setOnClickListener(this); } public void onClick(View view) { String a= String.valueOf(etNum1.getText()); String b= String.valueOf(etNum1.getText()); switch (view.getId()) { case R.id.btnAdd: tvResult.setText(String.valueOf(Integer.parseInt(a)+Integer.parseInt(b))); break; case R.id.btnSub: tvResult.setText(String.valueOf(Integer.parseInt(a)-Integer.parseInt(b))); break; case R.id.btnMul: tvResult.setText(String.valueOf(Integer.parseInt(a)*Integer.parseInt(b))); break; case R.id.btnDiv: tvResult.setText(String.valueOf(Integer.parseInt(a)/Integer.parseInt(b))); break; } } } <!-- end snippet -->
<android>
2016-02-07 00:59:40
LQ_EDIT
35,248,546
How to make a Round Toolbar for a Website
<p>I'v searched the whole time for about 3 days to make a round toolbar then i'v tried to do it myselt but i could'nt. Then my friend said to me about Stackoverflow that they are amazing at answering html Questions. And this what i want to do: <a href="http://i.stack.imgur.com/JtJ5x.jpg" rel="nofollow">Round Toolbar</a></p>
<html>
2016-02-07 01:05:16
LQ_CLOSE
35,249,108
How to make my enum inherit from a class?
Before: enum EMagicAbility{ Fireball, IceBolt, BlackMagic }; enum EPhysicalAbility{ SwordLance, FearlessBlow, RagnarokRage }; enum ERangedAbility{ Snipe, RainOfArrows, CrossbowShot }; enum EBiologicalAbility{bla,bla,bla}; enum Eblabla{}; enum Eevenmore{}; ... There are many more abilities ... ... //Each EMagicAbility can only have either zero or one Ability value. Dictionary<EMagicAbility,Ability> myMagicAbilityDictionary; //Each EPhysicalAbility can only have either zero or one Ability value. Dictionary<EPhysicalAbility,Ability> myPhysicalAbilityDictionary; //Each EPhysicalAbility can only have either zero or one Ability value. Dictionary<ERangedAbility,Ability> myRangedAbilityDictionary; //Each EBiologicalAbility can only have either zero or one Ability value. Dictionary<EBiologicalAbility,Ability> myBiologicalAbilityDictionary; //Each Eblabla can only have either zero or one Ability value. Dictionary<Eblabla,Ability> myBlablaAbilityDictionary; //Each Eevenmore can only have either zero or one Ability value. Dictionary<Eblabla,Ability> myBlablaAbilityDictionary; ... keeps going on... ... After: enum class EAbility{} enum EMagicAbility:EAbility{ Fireball, IceBolt, BlackMagic }; enum EPhysicalAbility:EAbility{ SwordLance, FearlessBlow, RagnarokRage }; enum ERangedAbility:EAbility{ Snipe, RainOfArrows, CrossbowShot }; enum EBiologicalAbility:EAbility{bla,bla,bla}; enum Eblabla:EAbility{}; enum Eevenmore:EAbility{}; ... There are many more abilities ... ... //Each any enum derived from Eability can only have either zero or one Ability value. Dictionary<EAbility,Ability> myAbilityDictionary; //I don't have to create another dictionary when I create a new category of Abilities! Yay! This is probably a super similar to this question: http://stackoverflow.com/questions/35191235/what-variable-type-should-i-use-to-store-types-of-a-non-sealed-class-or-interfac/35191505#35191505 In which I would use this instead: //I can remove all enumerations have such a clean, one-line code <3<3 Dictionary<typeof(Ability),Ability> myAbilityDictionary; EDIT: After doing some more research, I found out that this may be a viable option for me: http://stackoverflow.com/questions/518442/enum-subset-or-subgroup-in-c-sharp The problem with this is that I will have a behemoth amount of lines of code, which I rather find a more sane way to solve this. Also, an up vote would be really, really helpful since I can't access some features in stackoverflow, thank you.
<c#><enums><base-class>
2016-02-07 02:43:30
LQ_EDIT
35,249,204
Node already installed, it's just not linked
<p>I tried to fix the error where you have to use sudo when running npm. I blindly followed a link to uninstall node, the code was from this <a href="https://gist.github.com/nicerobot/2697848" rel="noreferrer">gist</a></p> <p>After running the command and I tried to install it back with brew: <code>brew install node</code>. Which gave me the following error:</p> <pre><code>Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/doc/node/gdbinit /usr/local/share/doc/node is not writable. You can try again using: brew link node </code></pre> <p>Trying to run <code>brew link node</code>, I got:</p> <pre><code>Linking /usr/local/Cellar/node/5.4.0... Error: Could not symlink share/systemtap/tapset/node.stp /usr/local/share/systemtap/tapset is not writable. </code></pre> <p>Then when I write <code>brew install npm</code>, I get:</p> <pre><code>Warning: node-5.4.0 already installed, it's just not linked </code></pre> <p>When I write <code>npm -v</code> I get:</p> <pre><code>env: node: No such file or directory </code></pre> <p>Any ideas on how to solve this?</p>
<node.js><macos><homebrew>
2016-02-07 03:01:20
HQ
35,249,774
Remove all elements from array that match specific string
<p>What is the easiest way to remove all elements from array that match specific string? For example:</p> <p><code>array = [1,2,'deleted',4,5,'deleted',6,7];</code></p> <p>I want to remove all <code>'deleted'</code> from the array.</p>
<javascript>
2016-02-07 04:35:00
HQ
35,250,080
laravel 5.2 - Model::all() order by
<p>I get the full collection of a Model with the following:</p> <p><code>$posts = Post::all();</code></p> <p>However I want this is reverse chronological order.</p> <p>What is the best way to get this collection in the desired order?</p>
<laravel><eloquent>
2016-02-07 05:26:02
HQ
35,250,591
Working at django templates without django forms
<p>I need simple example , Creating django templates without creating django forms which I can enter some information at templates and I need to save in mongo db at views part. Currently I am using pymongo.</p> <p>Please post some examples</p>
<django><django-templates><pymongo>
2016-02-07 06:45:17
LQ_CLOSE
35,251,135
Difference between word-wrap: break-word and word-break: break-word
<p>I needed to fix some CSS somewhere because my text wasn't wrapping around and was instead going on indefinitely if it was an extremely long word.</p> <p>Like in most cases, I tried <code>word-wrap: break-word;</code> in my CSS file and it did not work.</p> <p>Then, to my surprise, and by the suggestion of Google Chrome Developer Tools, I tried <code>word-break: break-word;</code> and it fixed my problem. I was shocked by this so I've been googling to know the difference between these two but I have seen nothing on the subject.</p> <p>Further, I don't think <code>word-break: break-word;</code> is documented behavior seeing as how <a href="http://www.w3schools.com/cssref/css3_pr_word-break.asp" rel="noreferrer">W3</a> has no mention of it. I tested it on Safari and Chrome, and it works perfectly on both, but I'm hesitant to use <code>word-break: break-word;</code> because I see no mention of it anywhere.</p>
<html><css><word-wrap><word-break>
2016-02-07 08:00:33
HQ
35,251,410
C safely taking absolute value of integer
<p>Consider following program (C99):</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;inttypes.h&gt; int main(void) { printf("Enter int in range %jd .. %jd:\n &gt; ", INTMAX_MIN, INTMAX_MAX); intmax_t i; if (scanf("%jd", &amp;i) == 1) printf("Result: |%jd| = %jd\n", i, imaxabs(i)); } </code></pre> <p>Now as I understand it, this contains easily triggerable <em>undefined behaviour</em>, like this:</p> <pre><code>Enter int in range -9223372036854775808 .. 9223372036854775807: &gt; -9223372036854775808 Result: |-9223372036854775808| = -9223372036854775808 </code></pre> <p>Questions:</p> <ol> <li><p>Is this really undefined behaviour, as in "code is allowed to trigger any code path, which any code that stroke compiler's fancy", when user enters the bad number? Or is it some other flavor of not-completely-defined?</p></li> <li><p>How would a pedantic programmer go about guarding against this, <em>without</em> making any assumptions not guaranteed by standard?</p></li> </ol> <p>(There are a few related questions, but I didn't find one which answers question 2 above, so if you suggest duplicate, please make sure it answers that.)</p>
<c><undefined-behavior><absolute-value>
2016-02-07 08:41:39
HQ
35,252,162
how to add json file and print in console
i am new to ios. And this is my first post. I know how to create a dummy json data and to print them in console.like below code: NSArray *jsonObject; jsonObject = @[@{@"Id1":@"mad", @"people1":@"300"}, @{@"Id2":@"normal", @"people2":@"9",@"total2":@"300"}]; NSError *err; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonObject options:NSJSONWritingPrettyPrinted error:nil]; NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options: NSJSONReadingMutableContainers error: &err]; NSLog(@"%@,%@",jsonArray); But wha i need is i have one file name **Areafiles.JSON**. In that file i have some json data.Now i directly drag and drop in my project. Now how can i read and print in my console like my above example. Please help me in code explain.Because i am stared learning.So it will help full to know how to code . Thanks!
<ios><objective-c><json>
2016-02-07 10:12:15
LQ_EDIT
35,252,229
How to get the list of all ismlaic events of current year using eventkit.framwork in ios
I want to get the list of all Islamic events of current year using Eventkit framework. Used the given below code from stackoverflow: NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]]; NSArray *calendarArray1 = [NSArray arrayWithObject:calendar]; NSPredicate *fetchCalendarEvents = [eventStore predicateForEventsWithStartDate:[NSDate date] endDate:endDate calendars:calendarArray1]; NSArray *eventList = [eventStore eventsMatchingPredicate:fetchCalendarEvents]; for(int i=0; i < eventList.count; i++){ NSLog(@"Event Title:%@", [[eventList objectAtIndex:i] title]); } but app crashes at NSPredicate line. Thanks.
<ios><eventkit>
2016-02-07 10:19:46
LQ_EDIT
35,252,544
How to get the HTTP method in AWS Lambda?
<p>In an AWS Lambda code, how can I get the HTTP method (e.g. GET, POST...) of an HTTP request coming from the AWS Gateway API? </p> <p>I understand from the <a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html" rel="noreferrer">documentation</a> that <strong>context.httpMethod</strong> is the solution for that. </p> <p>However, I cannot manage to make it work. </p> <p>For instance, when I try to add the following 3 lines:</p> <pre><code> if (context.httpMethod) { console.log('HTTP method:', context.httpMethod) } </code></pre> <p>into the AWS sample code of the "microservice-http-endpoint" blueprint as follows:</p> <pre><code>exports.handler = function(event, context) { if (context.httpMethod) { console.log('HTTP method:', context.httpMethod) } console.log('Received event:', JSON.stringify(event, null, 2)); // For clarity, I have removed the remaining part of the sample // provided by AWS, which works well, for instance when triggered // with Postman through the API Gateway as an intermediary. }; </code></pre> <p>I never have anything in the log because <strong>httpMethod is always empty</strong>. </p>
<amazon-web-services><aws-lambda><aws-api-gateway><http-method>
2016-02-07 10:52:32
HQ
35,253,396
Returning fun messages to different injections
<p>I am developing an web application. Where there is an input box to track the orders and its open for anyone. I want to return funny messages if somebody tries to inject vulnerable scripts. For example, if anyone tries the old school trick</p> <pre><code>' OR '1'='1 </code></pre> <p>it may return <strong>'Seems you're a beginner! Please study more and try again'</strong>. Will I have to check the inputs with RegEx ? or there is other nicer way? Anybody developed some scripts like this?</p>
<php>
2016-02-07 12:21:09
LQ_CLOSE
35,254,598
Import .data file in Python
<p>I have .data file contains tab separated list. I want to import this .data file into Python, I've seen there are so many libraries offer this feature, but can't really find one that easily to implement. Can you guys tell me how to load it, or any kind of library(best library) that could help me and how to use it? Thanks.</p>
<python><python-2.7>
2016-02-07 14:19:22
LQ_CLOSE
35,255,226
How can I create this image with pure CSS?
[![enter image description here][1]][1] [1]: http://i.stack.imgur.com/PkfBD.png Ideally, I'd like a background shadow effect too. Thanks in advance.
<css><svg><css-shapes>
2016-02-07 15:17:23
LQ_EDIT
35,255,276
UWP: Alternative to Grid.IsSharedSizeScope and SharedSizeGroup
<p>I got the same issue as described in the following, old, forum post: <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/66de600a-a409-44bc-945b-96a895edbe38/list-view-item-template-alignment?forum=wpf">Issue on MSDN</a><br> However, for some reason Microsoft decided to remove the functionalities in the answer described there.</p> <p>What I'm looking for is a ListView with 2+ columns, with the first column containing random data (thus random width elements), making the width of the first column the same as the widest element inside.</p>
<c#><wpf><uwp>
2016-02-07 15:21:22
HQ
35,255,728
number even or odd
<p>How can I call a function in javascripf where find number even or odd.</p>
<html>
2016-02-07 16:05:21
LQ_CLOSE
35,256,008
AutoMapper Migrating from static API
<p><a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API" rel="noreferrer">https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API</a></p> <p>this change breaks my system.</p> <p>Before update, I use:</p> <p>===> Startup.cs</p> <pre><code>public class Startup { public Startup(IHostingEnvironment env) { ... MyAutoMapperConfiguration.Configure(); } } </code></pre> <p>===> MyAutoMapperConfiguration.cs</p> <pre><code>public class MyAutoMapperConfiguration { public static void Configure() { Mapper.Initialize(a =&gt; { a.AddProfile&lt;AbcMappingProfile&gt;(); a.AddProfile&lt;XyzMappingProfile&gt;(); a.AddProfile&lt;QweMappingProfile&gt;(); }); } } </code></pre> <p>===> AbcMappingProfile.cs</p> <pre><code>public class AbcMappingProfile : Profile { protected override void Configure() { Mapper.CreateMap&lt;AbcEditViewModel, Abc&gt;(); Mapper.CreateMap&lt;Abc, AbcEditViewModel&gt;(); ... } } </code></pre> <p>ERROR:</p> <p>'Mapper.CreateMap()' is obsolete: 'The static API will be removed in version 5.0. Use a MapperConfiguration instance and store statically as needed. Use CreateMapper to create a mapper instanace.'</p> <p>I can use Mapper.Map. Now How can I use it</p>
<c#><asp.net><automapper>
2016-02-07 16:29:36
HQ
35,256,145
how must i write this code withoud error
i want to write a code thats write somthing into a file but it says it cant but how i must fix this please help. Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load yes.Visible = False no.Visible = False Label1.Visible = False ProgressBar1.Visible = False Label2.Visible = False Label3.Visible = False TextBox1.Visible = False TextBox2.Visible = False apply.Visible = False back.Visible = False End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Button1.Visible = False yes.Visible = True no.Visible = True Label1.Visible = True setings.Visible = False End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles yes.Click Label1.Text = "dowloading" no.Visible = False yes.Visible = False End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles no.Click yes.Visible = False no.Visible = False Label1.Visible = False Button1.Visible = True setings.Visible = True End Sub Private Sub setings_Click(sender As Object, e As EventArgs) Handles setings.Click Label2.Visible = True Label3.Visible = True TextBox1.Visible = True TextBox2.Visible = True apply.Visible = True back.Visible = True Button1.Visible = False setings.Visible = False End Sub Private Sub back_Click(sender As Object, e As EventArgs) Handles back.Click Label2.Visible = False Label3.Visible = False TextBox1.Visible = False TextBox2.Visible = False apply.Visible = False back.Visible = False Button1.Visible = True setings.Visible = True End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub apply_Click(sender As Object, e As EventArgs) Handles apply.Click Dim forgepath = TextBox1.Text Dim savefolder = Path.Combine(TextBox2.Text, "crazydolphininstaller") Directory.CreateDirectory(savefolder) Dim configfolder = Path.Combine(savefolder, "config") Directory.CreateDirectory(configfolder) Dim configfile = Path.Combine(configfolder, "config.txt") File.Create(configfile) Using writer = New StreamWriter(configfile) writer.WriteLine(forgepath) writer.WriteLine(savefolder) End Using End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub End Class
<visual-studio>
2016-02-07 16:41:35
LQ_EDIT
35,256,673
C# Win Forms text box format
This may be a vague question but I am trying to find a function that sets all text boxes on a form to a currency format. On my form I have some preset boxes but many will be dynamic with the push of a button. The information in these text boxes will come from Access. I have a sample function for clearing text boxes, I'm curious if there is something similar for what I'm asking. private void RecursiveClearTextBoxes(Control.ControlCollection cc) // clear all textboxes,combos and keep date on form { foreach (Control ctrl in cc) { System.Windows.Forms.TextBox tb = ctrl as System.Windows.Forms.TextBox; if (tb != null) tb.Clear(); else RecursiveClearTextBoxes(ctrl.Controls); } }
<c#><winforms>
2016-02-07 17:30:29
LQ_EDIT
35,257,891
What is the output?
<p>What is displayed by Line 1 Below? BlueJ prints out A@18fea98, but I don't think this is correct. Please help, thank you.</p> <pre><code>class A{ private int x; public A(){ x=0; } } //test code in client program A test = new A(); out.println(test);//LINE 1 </code></pre>
<java><output><bluej>
2016-02-07 19:16:00
LQ_CLOSE
35,258,619
Why does casting this double to an int give me 0?
<p>Sorry this has been confusing me for hours and nothing comes up on google about this. I'm programming in C, trying to convert decimal to binary, and I'm confused as to why this keeps giving me the right amount as input but the integer value is always 0.</p> <p>even if I properly cast input as an int, it doesn't work (ie: int integer = (int) input;</p> <pre><code>main() { double input; scanf("%d", &amp;input); printf("input: %d \n", input); // this will print fine int integer = input; // stores nums before decimal printf("integer:%i\n", integer); // this always prints 0 </code></pre>
<c><casting>
2016-02-07 20:20:45
LQ_CLOSE
35,259,327
How to speed up a .py script refering to millions of files?
<p>I have about 2.5M files to process with a .py script. </p> <p>I'm using super calculator but I the problem is not the power, its the python process itself that open and close every time and loosing time.</p> <p>I'm using a loop to get every files in a folder that I want to convert with the script. So the ${line} refers to a file where every line is referring to every files of the folder.</p> <p>Is there a way to process all files after opening the .py script instead of looping the python script? </p> <p>There is my loop code :</p> <pre><code>### LOOP ### while : do pythonsh ${RAMDISK}/script.py -l ${RAMDISK}/${line}.pdb -U '' -A hydrogens done exit </code></pre> <p>The python script is only a tool to convert .pdb to .pdbqt files that I've found from AutodockTools which comes with Autodock4.</p>
<python><bash>
2016-02-07 21:27:44
LQ_CLOSE
35,259,387
Wuestion about iTextSharp
I am coding a program that i need to save texts(from a rich text box) to a pdf. I use iTextSharp and the code that i use is this: Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("TitleOfPdf.pdf", FileMode.Create));//textBox1(in the form) assign here the title of the document doc.Open(); //open the document in order to write inside. Paragraph paragraph = new Paragraph(richTextBox1.Text); // Now adds the above created text using different class object to our pdf document doc.Add(paragraph); doc.Close(); Now the problem is that i would like the title of the file to be "flexible" and be assigned by the user(from a text box). The problem is that if i change the line: PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("TitleOfPdf.pdf", FileMode.Create)); To: PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(textBox1.Text, FileMode.Create)); Works fine. BUT the file it hasnt extension .pdf It is only a random file. How i can make the title of the document "flexible" so the user can assign it, and the extension will be .pdf ?? Thanks !!
<c#>
2016-02-07 21:33:59
LQ_EDIT
35,259,705
How to create a boolean function that returns true if 's' is immediately followed by the letter 't' in a string
<p>I've just started to learn how to write code using Java and am trying to make a boolean function that takes a string and returns true is a character 's' in a string is always followed(somewhere) by the character 't', and false otherwise. So for example, "stay" should return true; "tta" should return false; "cc" should return true because 's' does not appear at all therefore any 's' IS preceded by an 't', there just are no 't's.How would I go about this? </p>
<java><string><boolean>
2016-02-07 22:05:23
LQ_CLOSE
35,260,061
ComboBox Items via Scene Builder?
<pre><code> &lt;ComboBox fx:id="schaltung" layoutX="347.0" layoutY="50.0" prefHeight="63.0" prefWidth="213.0"&gt; &lt;items&gt; &lt;FXCollections fx:factory="observableArrayList"&gt; &lt;String fx:id="reihe" fx:value="Reihenschaltung" /&gt; &lt;String fx:id="parallel" fx:value="Parallelschaltung" /&gt; &lt;/FXCollections&gt; &lt;/items&gt; &lt;/ComboBox&gt; </code></pre> <p>I added this to my FXML file because I couldnt figure out where I could add Items to my ComboBox in the SceneBuilder. Is it possible to add items via the SceneBuilder, or do I have to do it manually?</p>
<java><javafx>
2016-02-07 22:40:26
HQ
35,260,443
How to fill in [x]% of a 2d array with the values of another array
<p>I have 2 two-dimensional arrays, one is filled and one is to be filled, both of the same size (n x m). I need to fill in [some random]% of my second array with the exact same values as my first array. So let's say</p> <pre><code>int[][] arr1 = new int[][] {{0, 1, 0, 1}, {1, 0, 1, 0}, {0, 0, 1, 1}, {1, 1, 0, 0}}; </code></pre> <p>I want arr2 to be filled with 25% of arr1's values in the same spot with the other spots just remaining null..</p> <pre><code>int[][] arr2 = new int[4][4]; // where arr2 = something like {{0,1,0,1}, // { , , , }, // { , , , }, // { , , , }} </code></pre> <p>Eventually, the program will call on the user to fill in the missing values, which I can do, just for some reason this part seems to not want to work for me. This is for a school assignment and the teacher isn't being very helpful with answering questions.</p> <p>Here's my code: noting that (variable names are in French..)</p> <ol> <li>nbCases = total number of elements in the 2d array</li> <li>nbARemplir = number of elements in the 2nd array to have values assigned to them (based on nbCases * nbPourc where nbPourc is the percentage of the 2nd array to be assigned values)</li> <li>grille[][] = original array</li> <li><p>gui = second "array" (it's actually a 2d array of JButtons that the teacher wrote..syntax to add a value : gui.setValeur(i, j, value) )</p> <pre><code>int nbCases = grille.length * grille[0].length; int nbARemplir = (int)(nbCases * nbPourc); do{ for(int i = 0; i &lt; grille.length; i++) { for(int j = 0; j &lt; grille[i].length; j++) { if(rand.nextInt(2) == 1 &amp;&amp; nbARemplir &gt; 0) { gui.setValeur(i, j, "" + grille[i][j]); nbARemplir--; } } } } while(nbARemplir &gt; 0); </code></pre></li> </ol> <p>Thanks for your help! :)</p>
<java><arrays>
2016-02-07 23:20:07
LQ_CLOSE
35,260,779
Visual Studio C++ difference between Managed Test Project and Native Unit Test Project
<p>I'm new to visual studio, what are some of the differences between Managed Test Project and Native Unit Test Project. Most of the unit test information available on the internet just says to make a native unit test, but what's the actual difference?</p>
<c++><unit-testing><visual-studio-2015>
2016-02-08 00:06:05
HQ
35,260,903
Eclipse can't find or load main class
<p>Ahhhhhh! I was messing with Eclipse trying to run C programs and after giving up along the way I screwed up everyone of my Java projects.The error message states <a href="https://i.stack.imgur.com/uf8Nx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uf8Nx.png" alt="enter image description here"></a></p> <p>So, after alot of research and searching around, it looked like I needed to add my classpath and project files back into the build path, which I did <a href="https://i.stack.imgur.com/FZJh4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FZJh4.png" alt="enter image description here"></a></p> <p>Please tell me I didn't just ruin everyone of my Java projects. Any help would be so much appreciated, thanks!</p>
<java><eclipse><path><ide>
2016-02-08 00:26:41
LQ_CLOSE
35,261,056
An unknown bug in my simple inline assembly code
inline void addition(double * x, const double * vx,uint32_t size){ /*for (uint32_t i=0;i<size;++i){ x[i] = x[i] + vx[i]; }*/ __asm__ __volatile__ ( "1: \n\t" "vmovupd -32(%0), %%ymm1\n\t" "vmovupd (%0), %%ymm0\n\t" "vaddpd -32(%1), %%ymm0, %%ymm0\n\t" "vaddpd (%1), %%ymm1, %%ymm1\n\t" "vmovupd %%ymm0, -32(%0)\n\t" "vmovupd %%ymm1, (%0)\n\t" "addq $128, %0\n\t" "addq $128, %1\n\t" "addl $-8, %2\n\t" "jne 1b" : : "r" (x),"r"(vx),"r"(size) : "ymm0", "ymm1" ); } I am practicing assembly(AVX instructions) right now so I write the above piece of code in inline assembly to replace the c code in the original function(which is commented out). The compiling process is successful but when I try to run the program, An error happens: `Bus error: 10` Any thoughts to this bug? I didn't know what's wrong here. The compiler version is clang 602.0.53. Thank you!
<c><assembly><x86><inline-assembly><avx>
2016-02-08 00:54:57
LQ_EDIT
35,261,153
Make absolute paths relative to the project root in Webpack
<p>I find that I need to type <code>../</code> a lot to <code>require()</code> files. My directory structure includes these:</p> <pre><code>js/ components/ ... actions/ ... </code></pre> <p>From the components folder, I need to do <code>import foo from '../actions/fooAction'</code>. Is it possible to make the root directory the root of the project? I.e. I want to do <code>import foo from '/actions/fooAction'</code> instead. I tried setting Webpack's <code>resolve.root</code> option, but it didn't seem to do anything.</p>
<webpack>
2016-02-08 01:10:18
HQ
35,261,379
JSON Decode into php array
<p>I am using JSON square brackets and would like to decode this into a two multidimensional array.</p> <p>This is the JSON:</p> <pre><code>"results" : [[ /* WINNER BRACKET */ [[3,5], [2,4], [6,3], [2,3], [1,5], [5,3], [7,2], [1,2]], [[1,2], [3,4], [5,6], [7,8]], [[9,1], [8,2]], [[1,3]] ], [ /* LOSER BRACKET */ [[5,1], [1,2], [3,2], [6,9]], [[8,2], [1,2], [6,2], [1,3]], [[1,2], [3,1]], [[3,0], [1,9]], [[3,2]], [[4,2]] ], [ /* FINALS */ [[3,8], [1,2]], [[2,1]] ]] </code></pre> <p>And I am looking to decode the above into this type of PHP array as shown below:</p> <pre><code>$winner_results = array ( array("match1",3,5), array("match2",2,4), array("match3",6,3), array("match4",2,3), array("match5",1,5), array("match6",5,3), array("match7",7,2), array("match8",1,2), array("match9",1,12), array("match10",3,4), array("match11",5,6), array("match12",7,8), array("match13",9,1), array("match14",8,2), array("match15",1,3) ); $loser_results = array ( array("match16",5,1), array("match17",1,2), array("match18",3,2), array("match19",6,9), array("match20",8,2), array("match21",1,2), array("match22",6,2), array("match23",1,3), array("match24",1,2), array("match25",3,1), array("match26",3,0), array("match27",1,9), array("match28",3,2), array("match29",4,2) ); $finals_results = array ( array("match30",3,8), array("match31",1,2), array("match32",2,1) ); </code></pre> <p>And would it possible to encode the above PHP array into the exact same JSON format as shown?</p> <p>Many thanks for any help!</p>
<php><arrays><json><decode><encode>
2016-02-08 01:46:43
LQ_CLOSE
35,261,606
Convert decimal number to binary in C
<p>For an assignment I need to convert a 16-bit decimal number to a binary number. So for example the number 9 should print 0000000000001001. My professor started us with this code:</p> <pre><code>void printBinary(short n) { } int main(int argc, char **argv) { short n; printf("Enter number: "); scanf("%hd", &amp;n); printBinary(n); } </code></pre> <p>I am very confused as to where to go from here. I really would appreciate anyone helping me understand what to do, as I am very new to coding. Thanks in advance.</p>
<c><binary>
2016-02-08 02:30:50
LQ_CLOSE
35,261,831
What is the method variable? in C#
<p>I use C#.</p> <p>When I defined <code>Hoge</code> method below,</p> <pre><code>void Hoge(bool isBar){} </code></pre> <p>I get the Hoge method like below</p> <pre><code>var methodName = this.Hoge as Action&lt;bool&gt;).Method.Name; </code></pre> <p>However, I can't understand what does <code>this.Hoge</code> type. Because, it can assign and casting.</p> <p>but, it can't give me method name directly. <code>this.Hoge.Method.Name;</code></p> <p>and, it also error. <code>typeof(this.Hoge)</code></p> <p>what is method variable exactly?</p>
<c#><variables><methods>
2016-02-08 03:09:25
LQ_CLOSE
35,262,099
Android Studio "Unfortunately 'the program' has stopped"
public void onClick(View v) { if (v == buttonOne) { TextView output = (TextView)findViewById(R.id.output); output.append("1"); } else if (v == buttonTwo) { TextView output = (TextView)findViewById(R.id.output); output.append("2"); } else if (v == buttonThree) { TextView output = (TextView)findViewById(R.id.output); output.append("3"); } else if (v == buttonFour) { TextView output = (TextView)findViewById(R.id.output); output.append("4"); } else if (v == buttonFive) { TextView output = (TextView)findViewById(R.id.output); output.append("5"); } else if (v == buttonSix) { TextView output = (TextView)findViewById(R.id.output); output.append("6"); } else if (v == buttonSeven) { TextView output = (TextView)findViewById(R.id.output); output.append("7"); } else if (v == buttonEight) { TextView output = (TextView)findViewById(R.id.output); output.append("8"); } else if (v == buttonNine) { TextView output = (TextView)findViewById(R.id.output); output.append("9"); } else if (v == buttonZero) { TextView output = (TextView)findViewById(R.id.output); output.append("0"); } else if(v == buttonEnter) { TextView output = (TextView)findViewById(R.id.output); temp = Integer.parseInt(output.getText().toString()); compareNumber(temp); output.setText(""); } } Hi, I am trying to compare number using button. For example, if I press buttonOne it append 1 to stack. if buttonTwo is pressed, it append 2 to stack. and For example if I press buttonOne and buttonTwo, it should store number 12(twelve). I tried this using parseInt as you can see in buttonEnter statement but when I run it the application stops. Please help!
<java><android>
2016-02-08 03:52:59
LQ_EDIT
35,262,686
Genymotion virtualization engine not found/plugin loading aborted on Mac
<p>I downloaded Genymotion but cannot get it to work. I keep on getting "virtualization engine not found, plugin loading aborted". I have uninstalled and reinstalled it, force quit and restarted it, and looked at other solutions to no avail. It seems to hit a snag <a href="https://i.stack.imgur.com/whAtk.png" rel="noreferrer">here</a>.</p> <p>I am running on a Mac, OSX Yosemite version 10.10.5.</p>
<android><macos><virtual-machine><genymotion>
2016-02-08 05:09:47
HQ
35,262,949
SWIFT -- Alamofire “Info.plist” couldn’t be opened because there is no such file
I'M USING ALAMOFIRE IN MY PROJECT. BUT I'M NOT USING IT WITH COCOAPODS. I JUST DRAG AND DROPPED IT IN MY PROJECT AS SHOW IN ALAMOFIREGITHUB TUTORIAL. NOW I'M FACING AN ISSUE THAT WHILE COMPILING THE PROJECT IT'S SHOWING "Alamofire “Info.plist” couldn’t be opened because there is no such file". I TRIED DELETING DERIVED DATA AND EVERYTHING WHICH WAS SHOWN IN WEB. PLEASE GIVE ME SOLUTION FOR THIS
<ios><alamofire>
2016-02-08 05:35:26
LQ_EDIT
35,263,770
Unnecessary code generating in HTML website
<p>I developed HTML website. Used HTML and CSS only.</p> <p>While looking into view source, it is showing unnecessary code at the end of the page and files too.</p> <p>How can i solve this?</p> <p><a href="https://i.stack.imgur.com/fT4G4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fT4G4.png" alt="enter image description here"></a></p>
<html><css>
2016-02-08 06:45:11
LQ_CLOSE
35,264,086
How to disable the disabling of an android application (which can be done through settings)?
<p>All android apps in settings can be disabled. But I want to make an application which cant be disabled from settings. What can be done for that?</p>
<android>
2016-02-08 07:09:44
LQ_CLOSE
35,264,666
I have a query in java
What does parseInt do exactly? Because my second argument was roll no. Which was not parsed but third argument was marks , which was parsed . Why so?
<java><parsing><int>
2016-02-08 07:50:32
LQ_EDIT
35,264,692
Multiple data-toggle not working correctly
I have the following page: http://mindspyder.com/newline/my-account.html And the following code on that page: <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a class="btn btn-primary btn-sm" href="#" role="button"><i class="fa fa-search-plus"></i> View</a> </li> <li class="nav-item"> <span data-toggle="modal" data-target="#myModal"><a class="btn btn-primary btn-sm" href="#delete" role="tab" data-toggle="tab"><i class="fa fa-times"></i> Delete</a></span></li> <li class="nav-item"> <a class="btn btn-primary btn-sm" href="#download" role="tab" data-toggle="tab">Settings</a> </li> </ul> <!-- /Nav tabs --> <!-- Tab panes --> <div class="tab-content"> <div role="tabpanel" class="tab-pane active" id="review"></div> <div role="tabpanel" class="tab-pane" id="edit"></div> <div role="tabpanel" class="tab-pane" id="delete">hello</div> <div role="tabpanel" class="tab-pane" id="download"> <p> <form> <p> <label> <input type="checkbox" name="CheckboxGroup1" value="Invoice" id="CheckboxGroup1_0"> Invoice</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Establishment Kit" id="CheckboxGroup1_1"> Establishment Kit</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Declaration of Custody Trust" id="CheckboxGroup1_2"> Declaration of Custody Trust</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Trustee Minutes" id="CheckboxGroup1_3"> Trustee Minutes</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Compliance Letter" id="CheckboxGroup1_4"> Compliance Letter</label> <br> </p> </form> </p> <p> <button type="button" class="btn btn-success btn-sm">Download Selected <i class="fa fa-arrow-down"></i></button> </p> </div> </div> <!-- /Tab panes --> <!-- end snippet --> Now, if you go to the page and click the blue Delete button, everything works perfectly. Now if you click Cancel, and click on one of the other tabs, it still works as it should. The problem is you click Delete again, it doesn't switch back to the Delete tab when opening the modal, but leaves it on the previous tab. What am I doing wrong?
<bootstrap-modal><twitter-bootstrap-4><bootstrap-4>
2016-02-08 07:52:19
LQ_EDIT
35,265,420
Multiple NSPredicates for NSFetchRequest in Swift?
<p>Currently, I have a simple NSFetchRequest with an associated NSPredicate. However, Im hoping there is a way you can append multiple predicates. I've seen examples in Objective C, but none for Swift.</p> <p>Can you define a list of NSPredicate's or append multiple NSPredicate objects to a single NSFetchRequest somehow?</p> <p>Thanks!</p>
<swift><nspredicate>
2016-02-08 08:45:38
HQ
35,265,855
How to stop IntelliJ IDEA from expanding the "External Libraries" with "Autoscroll from Source" enabled?
<p>I'm using IntelliJ with Java and the "Autoscroll from Source" function enabled.</p> <p>I like when the IDE jumps to the class in the package list, but it will also expand the "External Liubraries" making the whole "Project" view pretty messy.</p> <p>Is there a way to stop IntelliJ from expanding External Libraries?</p>
<java><intellij-idea><view><project>
2016-02-08 09:11:45
HQ
35,265,958
Replace in angularJS
This is string: 1<div>2</div><div>3</div><div>4</div> After replace var descriptionVal = desc.replace('<div>', '-').replace('</div>', '-'); only replace first div! 1-2</div><div>3</div><div>4</div> how replace all div?
<javascript><html><replace>
2016-02-08 09:17:22
LQ_EDIT
35,266,455
MySQL Workbench: Reconnecting to database when "MySQL server has gone away"?
<p>I have a lot of tabs and queries open in MySQL workbench. I left it open before I went to sleep, but this morning I am getting an error <code>MySQL server has gone away</code> when trying to run queries.</p> <p>The database is up, and I am able to connect to it if I open a new connection on MySQL workbench, but the current connection is dead. How do I reconnect?</p> <p>I don't want to open a new connection as I would have to copy my queries and tabs over.</p>
<mysql-workbench>
2016-02-08 09:45:11
HQ
35,267,786
how can i make this view in objective c
<p>i want to make this type of for my view in my app . <a href="https://i.stack.imgur.com/Mtkfw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mtkfw.png" alt="enter image description here"></a></p> <p>where i show user list and user can select them after then user can recommend something on text view like Facebook ,Can any one suggest me or any example . Thanks in advance </p>
<objective-c><iphone><uiview>
2016-02-08 10:49:27
LQ_CLOSE
35,268,377
How to concat time with present date in MSSQl while converting from mysql
Here is **Mysql code:** select concat(date_format(now(),'%Y/%m/%d'),' ','06:00:00 AM') Trying to concat date with time, getting error like: required two parameters to concat. **sql:** select concat((CONVERT(varchar,getdate(),102),' ','06:00:00 AM')); *not working while converting from mysql to sql*
<mysql><sql><sql-server><sql-server-2008><sql-server-2012>
2016-02-08 11:18:40
LQ_EDIT
35,268,482
Chaining RxJS Observables from http data in Angular2 with TypeScript
<p>I'm currently trying to teach myself Angular2 and TypeScript after happily working with AngularJS 1.* for the last 4 years! I have to admit I am hating it but I am sure my eureka moment is just around the corner... anyway, I have written a service in my dummy app that will fetch http data from a phoney backend I wrote that serves JSON.</p> <pre><code>import {Injectable} from 'angular2/core'; import {Http, Headers, Response} from 'angular2/http'; import {Observable} from 'rxjs'; @Injectable() export class UserData { constructor(public http: Http) { } getUserStatus(): any { var headers = new Headers(); headers.append('Content-Type', 'application/json'); return this.http.get('/restservice/userstatus', {headers: headers}) .map((data: any) =&gt; data.json()) .catch(this.handleError); } getUserInfo(): any { var headers = new Headers(); headers.append('Content-Type', 'application/json'); return this.http.get('/restservice/profile/info', {headers: headers}) .map((data: any) =&gt; data.json()) .catch(this.handleError); } getUserPhotos(myId): any { var headers = new Headers(); headers.append('Content-Type', 'application/json'); return this.http.get(`restservice/profile/pictures/overview/${ myId }`, {headers: headers}) .map((data: any) =&gt; data.json()) .catch(this.handleError); } private handleError(error: Response) { // just logging to the console for now... console.error(error); return Observable.throw(error.json().error || 'Server error'); } } </code></pre> <p>Now in a Component I wish to run (or chain) both <code>getUserInfo()</code> and <code>getUserPhotos(myId)</code> methods. In AngularJS this was easy as in my controller I would do something like this to avoid the "Pyramid of doom"...</p> <pre><code>// Good old AngularJS 1.* UserData.getUserInfo().then(function(resp) { return UserData.getUserPhotos(resp.UserId); }).then(function (resp) { // do more stuff... }); </code></pre> <p>Now I have tried doing something similar in my component (replacing <code>.then</code> for <code>.subscribe</code>) however my error console going crazy! </p> <pre><code>@Component({ selector: 'profile', template: require('app/components/profile/profile.html'), providers: [], directives: [], pipes: [] }) export class Profile implements OnInit { userPhotos: any; userInfo: any; // UserData is my service constructor(private userData: UserData) { } ngOnInit() { // I need to pass my own ID here... this.userData.getUserPhotos('123456') // ToDo: Get this from parent or UserData Service .subscribe( (data) =&gt; { this.userPhotos = data; } ).getUserInfo().subscribe( (data) =&gt; { this.userInfo = data; }); } } </code></pre> <p>I'm obviously doing something wrong... how would I best with Observables and RxJS? Sorry if I am asking stupid questions... but thanks for the help in advance! I have also noticed the repeated code in my functions when declaring my http headers...</p>
<typescript><angular><observable><rxjs>
2016-02-08 11:24:08
HQ
35,269,776
Telegram Bot How to delete or remove a message or media from a channel or group
<p>I want to know an example of removing message or file like a photo</p> <p>I did not find any functional tutorial in this regard,</p>
<telegram><telegram-bot>
2016-02-08 12:32:46
HQ
35,270,135
HttpParams is deprecated. What should I do?
<p>I'm trying to make a Login and register on my android app. I'm having trouble with HttpParams. I am following a tutorial on Youtube by Tonikami. I'm just new with Android Studio. This is just the process I know. Your help with be very appreciated. :(</p> <pre><code>public class ServerRequests { ProgressDialog progressDialog; public static final int CONNECTION_TIMEOUT = 1000 * 15; public static final String SERVER_ADDRESS = "http://mywebsite.com/"; public ServerRequests(Context context) { progressDialog = new ProgressDialog(context); progressDialog.setCancelable(false); progressDialog.setTitle("Processing..."); progressDialog.setMessage("Please wait..."); } public void storeUserDataInBackground(User user, GetUserCallback userCallBack) { progressDialog.show(); new StoreUserDataAsyncTask(user, userCallBack).execute(); } public void fetchUserDataAsyncTask(User user, GetUserCallback userCallBack) { progressDialog.show(); new fetchUserDataAsyncTask(user, userCallBack).execute(); } /** * parameter sent to task upon execution progress published during * background computation result of the background computation */ public class StoreUserDataAsyncTask extends AsyncTask&lt;Void, Void, Void&gt; { User user; GetUserCallback userCallBack; public StoreUserDataAsyncTask(User user, GetUserCallback userCallBack) { this.user = user; this.userCallBack = userCallBack; } @Override protected Void doInBackground(Void... params) { ArrayList&lt;NameValuePair&gt; dataToSend = new ArrayList&lt;&gt;(); dataToSend.add(new BasicNameValuePair("name", user.name)); dataToSend.add(new BasicNameValuePair("username", user.username)); dataToSend.add(new BasicNameValuePair("password", user.password)); dataToSend.add(new BasicNameValuePair("age", user.age + "")); HttpParams httpRequestParams = getHttpRequestParams(); HttpClient client = new DefaultHttpClient(httpRequestParams); HttpPost post = new HttpPost(SERVER_ADDRESS + "Register.php"); try { post.setEntity(new UrlEncodedFormEntity(dataToSend)); client.execute(post); } catch (Exception e) { e.printStackTrace(); } return null; } private HttpParams getHttpRequestParams() { HttpParams httpRequestParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpRequestParams, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(httpRequestParams, CONNECTION_TIMEOUT); return httpRequestParams; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); progressDialog.dismiss(); userCallBack.done(null); } } public class fetchUserDataAsyncTask extends AsyncTask&lt;Void, Void, User&gt; { User user; GetUserCallback userCallBack; public fetchUserDataAsyncTask(User user, GetUserCallback userCallBack) { this.user = user; this.userCallBack = userCallBack; } @Override protected User doInBackground(Void... params) { ArrayList&lt;NameValuePair&gt; dataToSend = new ArrayList&lt;&gt;(); dataToSend.add(new BasicNameValuePair("username", user.username)); dataToSend.add(new BasicNameValuePair("password", user.password)); HttpParams httpRequestParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpRequestParams, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(httpRequestParams, CONNECTION_TIMEOUT); HttpClient client = new DefaultHttpClient(httpRequestParams); HttpPost post = new HttpPost(SERVER_ADDRESS + "FetchUserData.php"); User returnedUser = null; try { post.setEntity(new UrlEncodedFormEntity(dataToSend)); HttpResponse httpResponse = client.execute(post); HttpEntity entity = httpResponse.getEntity(); String result = EntityUtils.toString(entity); JSONObject jObject = new JSONObject(result); if (jObject.length() != 0){ Log.v("happened", "2"); String name = jObject.getString("name"); int age = jObject.getInt("age"); returnedUser = new User(name, age, user.username, user.password); } } catch (Exception e) { e.printStackTrace(); } return returnedUser; } @Override protected void onPostExecute(User returnedUser) { super.onPostExecute(returnedUser); progressDialog.dismiss(); userCallBack.done(returnedUser); } } </code></pre> <p>}'</p>
<android>
2016-02-08 12:51:32
LQ_CLOSE
35,270,404
Android: GridLayout spacing between items
<p>I have a grid layout which is filled with buttons, now i want the buttons to be more distant from each other, what code should i write? i tried to search it but only found a solution for GridView, not GridLayout.</p>
<android><android-gridlayout>
2016-02-08 13:06:03
HQ
35,270,650
Java typical usage of Void autoboxing type
<p>What is the practical usage of Void reference type in java? How can it help me in practical programming?</p>
<java>
2016-02-08 13:17:41
LQ_CLOSE
35,270,790
Unfortunately App has stopped? Please help me
I am new to android development. I m trying to create a create account form through SQLITE database but when i am trying to run on phone or Emulator it shows "Unfortunately APP has stopped" . this si my Mnifest File code <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mubbasher.howdy" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.AppCompat" > <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> this is my MainActivity public class MainActivity extends AppCompatActivity { DatabaseHelper myDb; EditText editName, editPassword, editEmail; Button buttonRegister; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myDb=new DatabaseHelper(this); editName = (EditText) findViewById(R.id.edit_name); editEmail = (EditText) findViewById(R.id.edit_email); editPassword = (EditText) findViewById(R.id.edit_password); buttonRegister = (Button) findViewById(R.id.ButtonRegister); Reg(); } public void Reg(){ buttonRegister.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { boolean isInserted=myDb.insertData(editName.getText().toString(), editEmail.getText().toString(), editPassword.getText().toString()); if(isInserted==true) Toast.makeText(MainActivity.this, "Data Inserted", Toast.LENGTH_SHORT).show(); else Toast.makeText(MainActivity.this,"Data not Inserted",Toast.LENGTH_SHORT).show(); } } ); } } And this is my DatabaseHelper Class public class DatabaseHelper extends SQLiteOpenHelper { private static final int DATABASE_VERSION=1; private static final String DATABASE_NAME="USER.db"; private static final String TABLE_NAME="USER"; private static final String COL_1="ID"; private static final String COL_2="NAME"; private static final String COL_3="EMAIL"; private static final String COL_4="PASS"; SQLiteDatabase db; public DatabaseHelper(Context context) { super(context,DATABASE_NAME,null,DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("create table" + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, EMAIL TEXT, PASS TEXT)"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXIST"+TABLE_NAME); onCreate(db); } public boolean insertData(String name, String email, String pass) { SQLiteDatabase db=this.getWritableDatabase(); ContentValues values=new ContentValues(); ContentValues contentValues=new ContentValues(); contentValues.put(COL_2,name); contentValues.put(COL_3,email); contentValues.put(COL_4,pass); long result=db.insert(TABLE_NAME, null, contentValues); if (result==-1) return false; else return true; } } this is my XML FILE <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/activity_main" tools:context=".MainActivity"> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:text="Name" android:ems="10" android:id="@+id/edit_name" android:layout_alignParentTop="true" android:layout_alignParentStart="true" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:ems="10" android:id="@+id/edit_password" android:hint="Password" android:layout_below="@+id/edit_email" android:layout_alignParentStart="true" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textEmailAddress" android:ems="10" android:id="@+id/edit_email" android:layout_below="@+id/edit_name" android:layout_alignParentStart="true" android:hint="Email" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Register" android:id="@+id/ButtonRegister" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> </RelativeLayout>
<android>
2016-02-08 13:25:55
LQ_EDIT
35,271,009
Why bcp query not work in the c#?
I'm beginner in c#,i want use the bcp utilities in c#,write this code:<br/> string connstr = "Data Source=192.168.50.172;Initial Catalog=CDRDB;User ID=CDRLOGIN;Password=beh1368421"; //string connstr = "Enter your connection string here"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = "bcp"; proc.StartInfo.Arguments = @"select * from CDRTABLE"" queryout c:\filename.csv -S 192.168.50.172 -U CDRLOGIN -P beh1368421 -f -w"; proc.Start(); <br/> that's code run but ,`filename.csv` not create in my c drive,what happen?how can i solve that problem?
<c#><bcp>
2016-02-08 13:36:33
LQ_EDIT
35,271,374
Changing the www. part of the url
This may be simple, but im not sure how I can change my sites www. To something else. For example: www.netflix.com help.netflix.com Please let me know how I can change it for a specific directory. Thanks
<html><url><web>
2016-02-08 13:55:01
LQ_EDIT
35,272,403
Camera Result always returns RESULT_CANCELED
<p>I want to take pictures with my camera. I just need them temporally so i do the following:</p> <pre><code>private void takePicture() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(this.getActivity().getPackageManager()) != null) { try { this.imageFile = File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir()); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(this.imageFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); this.startActivityForResult(intent, Globals.REQUEST_TAKE_PHOTO); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>Unfortunately the result code <code>RESULT_CANCELED</code> in my <code>onActivityResult</code></p> <pre><code>@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v("PictureEdit", "onActivityResult"); super.onActivityResult(requestCode, resultCode, data); if(resultCode == Activity.RESULT_OK) { if(requestCode == Globals.REQUEST_TAKE_PHOTO) { Log.v("PictureEdit", "onActivityResult take photo"); this.startCropImage(Uri.fromFile(this.imageFile)); } else if (requestCode == Globals.REQUEST_PICK_PHOTO) { Log.v("PictureEdit", "onActivityResult pick photo"); this.startCropImage(data.getData()); } else if (requestCode == Globals.REQUEST_CROP_PHOTO) { Log.v("PictureEdit", "onActivityResult crop photo"); this.imageEncoded = data.getStringExtra(Globals.KEY_IMAGE_ENCODED); this.imageView.setImageBitmap(Images.decodeImage(imageEncoded)); this.buttonSave.setEnabled(true); } else { Log.v("PictureEdit", "onActivityResult requestCode: " + requestCode + ", result: " + resultCode); } } else { Log.v("PictureEdit", "onActivityResult resultCode is not ok: " + resultCode); } } </code></pre> <p>Every solutions i found so far on stackoverflow and in the web did not solve my problem. I use the cache directory for creating a temp file:</p> <pre><code>File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir()); </code></pre> <p>And i have the correct permissions:</p> <pre><code>&lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; </code></pre> <p>Picking images from my smartphone always works fine:</p> <pre><code>private void pickPicture() { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); this.startActivityForResult(intent, Globals.REQUEST_PICK_PHOTO); } </code></pre> <p>So why is the camera always returning <code>RESULT_CANCELED</code>? </p> <p>It is appearing on Nexus 4 with Android 6.0 and on Samsung Galaxy S III with Android 4.2.</p>
<android><android-camera>
2016-02-08 14:46:43
HQ