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
36,002,979
XMLHttpRequest cannot load and Response for preflight has invalid HTTP status code 405
<p>I am using ionic framework and angularjs I use chrome for viewing my logs but here i am doing a login page I am trying to post the user entered data to serve but i am getting this error like .</p> <pre><code> OPTIONS http://aflaree.com/qrcodeservice/Service1.svc/login </code></pre> <p>and this one is next error <code>XMLHttpRequest cannot load http://aflaree.com/qrcodeservice/Service1.svc/login Response for preflight has invalid HTTP status code 405</code> after reading some blog i figure there is a CORS extention from from which allows ajax request i tried that also but i am not able to find why this two error is appearing. here is my code</p> <p><a href="https://plnkr.co/edit/Dz0aFsLqoQcnCxht00z3?p=preview">https://plnkr.co/edit/Dz0aFsLqoQcnCxht00z3?p=preview</a></p> <p>my code work fine in device but I am getting error in chrome if any one knows why please help me</p>
<angularjs><ajax><ionic-framework>
2016-03-15 04:57:14
HQ
36,004,054
Genarating time in 5 seconds interval
Hello am kindly asking on how to generate time with a 5 seconds interval where the user selects a date then a specific time interval maybe from 11:00:00 to 12:00:00 then the program generates a record like this 1. date time random number 2. 23/01/2016 11:01:02 030 3. 23/01/2016 11:02:07 035 4. 23/01/2016 11:02:12 054 5. 23/01/2016 11:02:17 062 6. 23/01/2016 11:02:22 058 7. 23/01/2016 11:02:27 056 8. 23/01/2016 12:00:01 059 After it has generated it saves generated values in a plain text file.
<c#><random>
2016-03-15 06:23:50
LQ_EDIT
36,004,431
find all substrings between ${ and } in javascript
<p>i have collections of text with some text between ${ and } like "this is ${test} string ${like}". How can I extract all there strings. Output : test,like</p>
<javascript><regex>
2016-03-15 06:50:13
LQ_CLOSE
36,005,988
How to make an asp.net website where we can login using MS ID and Password?
<p>I have created a website which is to be used internally in my company. Log-in Id and password to be used should be the same (Microsoft)MS ID/Password employees use to log-in their computer. How to put this functionality in the website ?</p>
<c#><asp.net>
2016-03-15 08:29:39
LQ_CLOSE
36,006,029
Disabling Spring Security headers does not work
<p>I need to disable the cache control headers in my Spring Security conf.</p> <p>According to the documentation a simple <code>http.headers.disable()</code> should do it, but I still see the</p> <pre><code>Cache-Control:no-cache, no-store, max-age=0, must-revalidate Expires:0 Pragma:no-cache </code></pre> <p>headers in responses.</p> <p>My current security config is:</p> <pre><code>http.antMatcher("/myPath/**") // "myPath" is of course not the real path .headers().disable() .authorizeRequests() // ... abbreviated .anyRequest().authenticated(); </code></pre> <p><strong>Things I've tried so far:</strong></p> <p><strong>application.properties</strong></p> <p>I added the <code>security.headers.cache=false</code> line, but that made no difference.</p> <p><strong>Using a filter</strong></p> <p>I tried the following filter:</p> <pre><code>@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, new HttpServletResponseWrapper((HttpServletResponse) response) { @Override public void setHeader(String name, String value) { if (name.equalsIgnoreCase("Cache-Control")) { value = ""; } else if (name.equalsIgnoreCase("Expires")) { value = ""; } else if (name.equalsIgnoreCase("Pragma")) { value = ""; } super.setHeader(name, value); } }); } </code></pre> <p>After adding logging I saw that this filter only writes the <code>X-XSS-Protection</code> header, all the cache headers are written somewhere later and this filter doesn't have access to "override" them. This happens even if I add this filter at the last position of the security filter chain.</p> <p><strong>Using an interceptor</strong></p> <p>I tried the following interceptor:</p> <pre><code>@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { String requestUri = request.getRequestURI(); response.setHeader("Cache-Control", "max-age=3600"); response.setHeader("Expires", "3600"); response.setHeader("Pragma", ""); } </code></pre> <p>This (quite predictably) just added the headers, meaning that the original <code>no-cache</code> headers still appear in addition to the ones added by the interceptor.</p> <p>I'm at my wits end here. How do I get rid of the cache control header set by Spring security?</p>
<java><security><caching><spring-security><spring-boot>
2016-03-15 08:31:15
HQ
36,006,053
Installing drupal7 on ibm bluemix
How to install drupal7 on IBM blue mix ? I tried to install using cf but not able to connect with mysql or any db.
<drupal-7><ibm-cloud>
2016-03-15 08:32:17
LQ_EDIT
36,007,406
Amazon aws ec2 windows ebs and bandwidth charges
I would like to know how the amazon aws ec2 charge for EBS and the bandwidth for windows and I want to know the how many tomcat web servers and mysql servers can be placed in once ec2 server. Thanks.
<amazon-web-services><amazon-ec2>
2016-03-15 09:35:50
LQ_EDIT
36,007,686
How to parse a csv that uses ^A (i.e. \001) as the delimiter with spark-csv?
<p>Terribly new to spark and hive and big data and scala and all. I'm trying to write a simple function that takes an sqlContext, loads a csv file from s3 and returns a DataFrame. The problem is that this particular csv uses the ^A (i.e. \001) character as the delimiter and the dataset is huge so I can't just do a "s/\001/,/g" on it. Besides, the fields might contain commas or other characters I might use as a delimiter.</p> <p>I know that the spark-csv package that I'm using has a delimiter option, but I don't know how to set it so that it will read \001 as one character and not something like an escaped 0, 0 and 1. Perhaps I should use hiveContext or something?</p>
<scala><apache-spark><hive><delimiter><spark-csv>
2016-03-15 09:47:00
HQ
36,007,785
Using PHP to write query string values to a .txt file and save
<p>I am able to take the values from a URL's query string and store them in some variables, however I would also like to print or write these values to a single line in a .txt document, and save that document in a given directory on the server.</p> <p>Each time the page is loaded with a new query string, a new line will be added to that .txt file with the string values, and the file re-saved.</p> <p>Can this be done? Struggling to find answers to this in my searches.</p> <p>Many thanks in advance.</p>
<php><query-string>
2016-03-15 09:51:30
LQ_CLOSE
36,007,911
RxJs: poll until interval done or correct data received
<p>How do i execute the following scenario in the browser with RxJs:</p> <ul> <li>submit data to queue for processing</li> <li>get back the job id</li> <li>poll another endpoint every 1s until result is available or 60seconds have passed(then fail)</li> </ul> <p>Intermediate solution that i've come up with:</p> <pre><code> Rx.Observable .fromPromise(submitJobToQueue(jobData)) .flatMap(jobQueueData =&gt; Rx.Observable .interval(1000) .delay(5000) .map(_ =&gt; jobQueueData.jobId) .take(55) ) .flatMap(jobId =&gt; Rx.Observable.fromPromise(pollQueueForResult(jobId))) .filter(result =&gt; result.completed) .subscribe( result =&gt; console.log('Result', result), error =&gt; console.log('Error', error) ); </code></pre> <ol> <li>Is there a way without intermediate variables to stop the timer once the data arrives or error occurs? I now i could introduce new observable and then use <code>takeUntil</code></li> <li>Is <code>flatMap</code> usage here semantically correct? Maybe this whole thing should be rewritten and not chained with <code>flatMap</code> ?</li> </ol>
<javascript><rxjs><reactive-extensions-js>
2016-03-15 09:56:45
HQ
36,008,117
sum up an array of integers in C#
<p>I want the sum of the numbers in the array and does not exceed 1002 how can I fix it? it is not needful to sum all numbers, but only those who qualify</p> <p>I do it that way but I think it's not the right way</p> <pre><code> List&lt;int&gt; list = new List&lt;int&gt; { 4, 900, 500, 498, 4 }; int sum = list.Skip(2).Take(3).Sum(); Console.WriteLine(sum); Console.ReadLine(); </code></pre>
<c#>
2016-03-15 10:05:26
LQ_CLOSE
36,009,021
UWP: How to resize an Image
<p>I have a JPEG image stored in a Byte[] that I want to resize. This is my code:</p> <pre><code>public async Task&lt;byte[]&gt; ResizeImage(byte[] imageData, int reqWidth, int reqHeight, int quality) { var memStream = new MemoryStream(imageData); IRandomAccessStream imageStream = memStream.AsRandomAccessStream(); var decoder = await BitmapDecoder.CreateAsync(imageStream); if (decoder.PixelHeight &gt; reqHeight || decoder.PixelWidth &gt; reqWidth) { using (imageStream) { var resizedStream = new InMemoryRandomAccessStream(); BitmapEncoder encoder = await BitmapEncoder.CreateForTranscodingAsync(resizedStream, decoder); double widthRatio = (double) reqWidth/decoder.PixelWidth; double heightRatio = (double) reqHeight/decoder.PixelHeight; double scaleRatio = Math.Min(widthRatio, heightRatio); if (reqWidth == 0) scaleRatio = heightRatio; if (reqHeight == 0) scaleRatio = widthRatio; uint aspectHeight = (uint) Math.Floor(decoder.PixelHeight*scaleRatio); uint aspectWidth = (uint) Math.Floor(decoder.PixelWidth*scaleRatio); encoder.BitmapTransform.InterpolationMode = BitmapInterpolationMode.Linear; encoder.BitmapTransform.ScaledHeight = aspectHeight; encoder.BitmapTransform.ScaledWidth = aspectWidth; await encoder.FlushAsync(); resizedStream.Seek(0); var outBuffer = new byte[resizedStream.Size]; uint x = await resizedStream.WriteAsync(outBuffer.AsBuffer()); return outBuffer; } } return imageData; } </code></pre> <p>The problem is that outBuffer just contains zeros although the correct number of Bytes have been written.</p>
<c#><image-processing><win-universal-app>
2016-03-15 10:45:09
HQ
36,009,038
In what situations unit testing should be avoided?
<p>When is unit testing harmful? it can't be used in all situations and it should be selective, do you know situations when it should be avoided?</p>
<unit-testing>
2016-03-15 10:45:44
LQ_CLOSE
36,009,141
I have to validate a date input if it is in mm/dd/yyyy format in C#
<p>I have date field in my Windows form and that is a user input. I need to validate if that date input is in mm/dd/yyyy format and need to throw an error if it is not. How Do I do that. I have no idea how to do that.</p> <p>Please help.</p>
<c#>
2016-03-15 10:50:35
LQ_CLOSE
36,009,725
Swift sometimes calls wrong method
<p>I noticed strange behaviour during working with Swift projects. I can't explain it other than Swift sometimes calls wrong method. It is very rare and even adding blank lines to the code could lead that this error is gone.</p> <p>Let me explain in screenshots what I mean, next I use CoreData example of SwiftDDP project that can be found on Github, but such issues I was able to see in my own projects.</p> <p>Here we at <code>Todos.swift:74</code> where you can see breakpoint, I expect that next call should be <code>getId()</code> method of <code>MeteorClient</code> class because it was already instantiated:</p> <p><a href="https://i.stack.imgur.com/7F4mM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7F4mM.png" alt="Screenshot 1"></a></p> <p>After Step Into as you can see the <code>ping()</code> of the same instance is called:</p> <p><a href="https://i.stack.imgur.com/mMsDg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mMsDg.png" alt="Screenshot 2"></a></p> <p>The next two steps into lead to <code>EXC_BAD_ACCESS</code> exception:</p> <p><a href="https://i.stack.imgur.com/SGdYE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SGdYE.png" alt="Screenshot 3"></a></p> <p>In my project I saw this issue fairly often before I stopped using singletons, so it could be related to Swift static memory usage or I don't understand something that is not surprising as I have little experience with multithreading and memory management.</p> <p>My environment is:</p> <ul> <li>AppCode OC-145.184.11</li> <li>Xcode Version 7.2.1 (7C1002)</li> <li>iOS 9.2 SDK</li> <li>Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)</li> </ul> <p><strong>NOTE</strong>: Here I use AppCode but the same behavior I was able see in Xcode, and even more if the same issue that reproduces in Xcode could not reproduce in AppCode and vice versa.</p> <p>Would be thankful if someone can explain this strange behaviour to me.</p> <p>Thanks!</p>
<ios><swift>
2016-03-15 11:16:23
HQ
36,010,564
How to bypass keyboard input verification using JS
Example <textarea id="keystroke-auth-textarea" data-js="keystroke-auth-input" spellcheck="false" class="c-keystroke-auth-textarea"></textarea> [enter image description here][1] [1]: http://i.stack.imgur.com/voqxF.png
<javascript>
2016-03-15 11:52:07
LQ_EDIT
36,010,689
How find data type of premtive variable in java
<p>How get premtive variable data type in print statment . tell method that tell about data type of variable?</p>
<java>
2016-03-15 11:57:40
LQ_CLOSE
36,010,984
Spark SQL - How to write DataFrame to text file?
<p>I am using <code>Spark SQL</code> for reading parquet and writing parquet file.</p> <p>But some cases,i need to write the <code>DataFrame</code> as text file instead of Json or Parquet.</p> <p>Is there any default methods supported or i have to convert that DataFrame to <code>RDD</code> then use <code>saveAsTextFile()</code> method?</p>
<java><apache-spark-sql>
2016-03-15 12:10:55
HQ
36,011,595
Docker named volumes vs DOC (data-only-containers)
<p>Up to recent version of Docker (v1.10), we were thought that we can use DOC: <em>data-only containers</em>. So I would create such DOC (based on e.g. busybox) and use <code>--volumes-from</code> to link it to my container. You can still read about this in <a href="https://docs.docker.com/engine/userguide/containers/dockervolumes/#creating-and-mounting-a-data-volume-container">Docker documentation</a>.</p> <p>With new version of docker, it is said that instead of DOC we should use <code>named volumes</code>. Here is an example of <code>docker-compose.yml</code>:</p> <pre><code>version: '2' services: elasticsearch: image: elasticsearch:2.2.0 command: elasticsearch -Des.network.host=0.0.0.0 ports: - "9201:9200" volumes: - "es-data:/usr/share/elasticsearch/data" volumes: es-data: </code></pre> <p>Here we created and use named volume <code>es-data</code>.</p> <p>There is still not much documentation on this new feature. I am asking:</p> <ul> <li>Can we replace DOC with named containers? How long volume is persisted? What if I remove the container that is using it?</li> <li>How can we e.g. backup now? Previously, I could <code>docker run --rm --volumes-from es-data ...</code> and then <code>tar</code> it.</li> </ul>
<docker><docker-compose>
2016-03-15 12:38:06
HQ
36,011,686
it's 2016, why do I still have to use P/Invoke?
<p>I've been out of the programming game for almost 20 years now but every once in a while I write a app with Visual Studio. </p> <p>My question is, given .NET has been with us for about 13 years, why should I <strong><em>ever</em></strong> have to use the native API aka P/Invoke? Why hasn't everything been converted to official .NET managed assemblies?</p> <p>Just recently I ran into a situation where I simply want to toggle my Wifi connection on and off without using the mouse. The keyboard is always faster (for me), yet there is no standard Windows keyboard shortcut for it. So great, a very simple C# program for me to write. Imagine my surprise when I found I would have to dip into the native API to this. I remember having to do this in the early days of .NET --sure, a new technology needs a few years to catch up, right? Well now it's 2016. </p> <p>I suppose I just don't see the big picture. Someone please illuminate me.</p>
<c#><pinvoke>
2016-03-15 12:42:49
LQ_CLOSE
36,012,273
php extract text between nth and nth character
<p>How can I use php to get the sting bewteen the 7th and 8th /</p> <pre><code>http://uk.soccerway.com/matches/2015/01/01/england/premier-league/stoke-city-fc/manchester-united-fc/1703889/?ICID=HP_MS_01_01 </code></pre> <p>so the above would grab england</p>
<php>
2016-03-15 13:09:49
LQ_CLOSE
36,012,422
Trigger database backup on a django view
<p>I'm trying to trigger a database backup from a button in a custom view I have created in Django. The thing is that in all the information I have found about database backups, the command is triggered automatically or from a manage.py command.</p> <p>Any ideas about how to solve it? It's even possible to execute a manage.py command from a view?</p>
<python><django><view><database-backups><manage.py>
2016-03-15 13:15:49
LQ_CLOSE
36,012,528
send image and different data (integer,string) to server via REST API in adnroid
I am making an application and using Rest API to get and send data to server .now i want to send different type of data as image and string and integer and using POST method .So please write code for this. Thank you.
<android><rest>
2016-03-15 13:20:26
LQ_EDIT
36,014,073
Make custom button on Tab Bar rounded
<p>Here is what I am trying to do: <a href="https://i.stack.imgur.com/abwu9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/abwu9.png" alt="enter image description here"></a></p> <p>Note: The screenshot is taken from an earlier version of iOS</p> <p>What I have been able to achieve: <a href="https://i.stack.imgur.com/N8LtN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N8LtN.png" alt="enter image description here"></a></p> <p>Code:</p> <pre><code> override func viewWillAppear(animated: Bool) { // Creates image of the Button let imageCameraButton: UIImage! = UIImage(named: "cameraIcon") // Creates a Button let cameraButton = UIButton(type: .Custom) // Sets width and height to the Button cameraButton.frame = CGRectMake(0.0, 0.0, imageCameraButton.size.width, imageCameraButton.size.height); // Sets image to the Button cameraButton.setBackgroundImage(imageCameraButton, forState: .Normal) // Sets the center of the Button to the center of the TabBar cameraButton.center = self.tabBar.center // Sets an action to the Button cameraButton.addTarget(self, action: "doSomething", forControlEvents: .TouchUpInside) // Adds the Button to the view self.view.addSubview(cameraButton) } </code></pre> <p>I did try to create a rounded button in the normal way, but this was the result:</p> <p><a href="https://i.stack.imgur.com/HR104.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HR104.png" alt="enter image description here"></a></p> <p>Code Snippet for rounded button:</p> <pre><code>//Creation of Ronded Button cameraButton.layer.cornerRadius = cameraButton.frame.size.width/2 cameraButton.clipsToBounds = true </code></pre>
<ios><swift><uibutton><uitabbar>
2016-03-15 14:26:00
HQ
36,014,161
Angular2 HTTP GET - Cast response into full object
<p>I have this simple Component</p> <pre><code>import {Component} from 'angular2/core'; import {RouterLink, RouteParams} from 'angular2/router'; import {Http, Response, Headers} from 'angular2/http'; import {User} from '../../models/user'; import 'rxjs/add/operator/map'; @Component({ template: ` &lt;h1&gt;{{user.name}} {{user.surname}}&lt;/h1&gt; `, directives: [RouterLink], }) export class UserComponent { user: User; constructor(private routeParams: RouteParams, public http: Http) { this.user = new User(); this.http.get('http://localhost:3000/user/' + this.routeParams.get('id')) .map((res: Response) =&gt; res.json()) .subscribe((user: User) =&gt; this.user = user); console.log(this.user); } } </code></pre> <p>Why does <code>subscribe</code> not cast the response into a full <code>User</code> object. When I am logging the <code>user</code> variable my console say <code>User {_id: undefined, name: undefined, surname: undefined, email: undefined}</code>. But nevertheless binding to <code>.name</code> and <code>.surname</code> in the view is working..</p> <p>What happens here? Where is the user actually stored? </p>
<typescript><angular>
2016-03-15 14:30:06
HQ
36,014,270
Web specifications and standards
<p>can anyone give me few examples of web specifications standards as i don't understand what are they.</p> <p>I have looked at <a href="https://www.w3.org/" rel="nofollow">https://www.w3.org/</a> , but i still don't pick anything that would make sense to me.</p> <p>Thanks for your help.</p>
<html><css><web>
2016-03-15 14:34:53
LQ_CLOSE
36,015,192
I understand the distinct/group by function - SQL Server 2008
Here is an short example what I have in my BDD : Ref | NameContact | CODE SF005 | Toto | SF SF006 | Titi | BC SF005 | Toto | SF SF007 | Foo | FB SF006 | Bar | BC SF005 | Tata | SF SF005 | Tata | SF I like to get this : Ref | NameContact |CODE SF005 | Toto | SF SF005 | Tata | SF I've tried to use Distinct but it doesn't work correctly but it'work when i use Group By with all named column with MAX() but i've many columns and the query is very big. There is a better solution ? SELECT MAX(Ref),NameContact,Code FROM MyTable WHERE CODE = 'SF' GROUP BY NameContact,Code
<sql><sql-server><sql-server-2008>
2016-03-15 15:14:16
LQ_EDIT
36,016,398
sql make time in datetime 12 pm
I have datetime field as <pre> 03/04/2016 08:00:00 AM 03/15/2016 04:00:00 AM </pre> I want to keep it as date time but make all the time to 12 am.So the result should be <pre> 03/04/2016 12:00:00 AM 03/15/2016 12:00:00 AM </pre> No t-sql or declaring variables. Please advice.
<sql><sql-server>
2016-03-15 16:04:55
LQ_EDIT
36,017,017
<?php ?> syntax error
<p>I hope you are doing great I have been faced with a strange syntax error. when I write the syntax it says: unexpected end of file or reached end while parsing. If you know for this error. that's a general question. not for the project</p> <p>code smaple:</p> <pre><code>&lt;?php include 'Footer.php'; ?&gt; </code></pre> <p>I wonder if you could help me with that. thanks in advance. cheers,</p>
<php><html>
2016-03-15 16:33:57
LQ_CLOSE
36,017,290
How to echo correctly a html line using php
<p>I want to print this using php:</p> <pre><code>&lt;input onfocusout="function("stringarg")" /&gt; </code></pre> <p>The ' are not printing properly.</p>
<javascript><php><html>
2016-03-15 16:46:42
LQ_CLOSE
36,017,691
Iptables: Reasons for choosing pre-up/up/post-up rsp. pre-down/down/post-down
<p>Setting up iptables rules, what are the specific reasons for pre-up/up/post-up rsp. pre-down/down/post-down? </p> <p>E.g setting Default Policies in pre-up and explicit rules in up/post-up?</p> <p>In my understanding, if I only want to setup e.g iptables-save &lt; ..., it doesn't matter. Am I wrong?</p>
<linux><iptables>
2016-03-15 17:05:19
LQ_CLOSE
36,017,724
Can I have multiple GOPATH directories?
<p>I set my GOPATH to</p> <pre><code>/Users/me/dev/go </code></pre> <p>and I have</p> <pre><code>/Users/me/dev/go/src/client1 /Users/me/dev/go/src/client2 /Users/me/dev/go/src/client3 </code></pre> <p>and also</p> <pre><code>/Users/me/dev/client1/rails_project /Users/me/dev/client2/php_project etc. </code></pre> <p>I don't like how in my root dev folder I'm forced to have this general "go" dir that holds many different client's go projects.</p>
<go>
2016-03-15 17:07:04
HQ
36,018,072
Replacing whitespace in all column names in spark Dataframe
<p>I have spark dataframe with whitespaces in some of column names, which has to be replaced with underscore.</p> <p>I know a single column can be renamed using <code>withColumnRenamed()</code> in sparkSQL, but to rename 'n' number of columns, this function has to chained 'n' times (to my knowledge).</p> <p>To automate this, i have tried:</p> <pre><code>val old_names = df.columns() // contains array of old column names val new_names = old_names.map { x =&gt; if(x.contains(" ") == true) x.replaceAll("\\s","_") else x } // array of new column names with removed whitespace. </code></pre> <p>Now, how to replace df's header with <code>new_names</code></p>
<scala><apache-spark><apache-spark-sql><spark-dataframe>
2016-03-15 17:24:36
HQ
36,018,146
Ionic 2 responsive grid
<p>How can I make a responsive grid in Ionic 2? Ionic 1 supported reserved classes like <code>responsive-md</code> or <code>responsive-sm</code> that made grids responsive, but they don't seem to work in Ionic 2.</p> <p>In my case I have an <code>&lt;ion-row&gt;</code> with three <code>&lt;ion-col&gt;</code>. I would like the columns to drop below each other when the display width drops below a threshold. Is it possible to do this with Ionic 2? </p>
<ionic-framework><ionic2>
2016-03-15 17:28:38
HQ
36,018,812
HTACCESS rules error
In my htaccess file I have added a rule to redirect url/abc/xyz to url/abc/xyz.php so now even when I try to access url/abc.php it redirects me to url/abc/ Help me with this.. My code now : # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\s [NC] RewriteRule ^ %1 [R,L] ## To internally forward /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{QUERY_STRING} ^$ RewriteRule ^(.*?)/?$ $1.php [L]
<php><.htaccess><redirect>
2016-03-15 18:03:41
LQ_EDIT
36,018,851
Pandas Counting Unique Rows
<p>I have a pandas data frame similar to:</p> <pre><code>ColA ColB 1 1 1 1 1 1 1 2 1 2 2 1 3 2 </code></pre> <p>I want an output that has the same function as <a href="https://docs.python.org/2/library/collections.html#collections.Counter" rel="noreferrer">Counter</a>. I need to know how many time each row appears (with all of the columns being the same.</p> <p>In this case the proper output would be:</p> <pre><code>ColA ColB Count 1 1 3 1 2 2 2 1 1 3 2 1 </code></pre> <p>I have tried something of the sort:</p> <pre><code>df.groupby(['ColA','ColB']).ColA.count() </code></pre> <p>but this gives me some ugly output I am having trouble formatting</p>
<python><python-2.7><pandas><counter>
2016-03-15 18:06:04
HQ
36,019,394
how to call a bootstarp class into javascript using (document.get element by class)
how to call a bootstrap class into java script using HTML DOM getElementsByClassName() Method for eg:- document.getElementByClass=("has-error"); I need a the text box to turn into green if the data is valid and to red if the data is in valid using boot strap class **has-success and has-error**
<javascript><angularjs><twitter-bootstrap><dom>
2016-03-15 18:35:03
LQ_EDIT
36,019,478
How to fix this matlab error?
I got this error when I tried to capture image using my pc webcam. I am new to matlab. How can I fix this error? This is my code, obj =imaq.VideoDevice('dcam', 1, 'YUYV_320x240','ROI', [1 1 320 240]); set(obj,'ReturnedColorSpace', 'rgb'); figure('menubar','none','tag','webcam'); >> imaqhwinfo ans = InstalledAdaptors: {'dcam'} MATLABVersion: '8.6 (R2015b)' ToolboxName: 'Image Acquisition Toolbox' ToolboxVersion: '4.10 (R2015b)' >> webcamlist ans = 'Integrated Webcam'
<matlab>
2016-03-15 18:39:33
LQ_EDIT
36,019,534
Add an empty line at end of file according to PSR-2 on PhpStorm
<p>I use <a href="http://www.php-fig.org/psr/psr-2/" rel="noreferrer">PSR-2</a> for code styling my code.</p> <p>When I inspect a file using Codesniffer most of the times I get the following error.</p> <pre><code>332 | ERROR | [x] Expected 1 newline at end of file; 0 found </code></pre> <p>It's obvious how to fix this. What I need to know is if PhpStorm has a way to add the <code>1 newline at end of file</code></p> <p>I already loaded the predefined style from <code>Settings -&gt; Editor -&gt; Code Style -&gt; PHP -&gt; Set From -&gt; PSR-1/PSR-2</code> and also used the <code>Reformat Code</code> to change the CS accordingly.</p> <p>Everything is fixed except from the new line. Am I missing something?</p>
<php><phpstorm><codesniffer><phpcodesniffer><psr-2>
2016-03-15 18:42:37
HQ
36,019,788
Python Pandas: pivot only certain columns in the DataFrame while keeping others
<p>I am trying to re-arrange a DataFrame that I automatically read in from a json using Pandas. I've searched but have had no success.</p> <p>I have the following json (saved as a string for copy/paste convenience) with a bunch of json objects/dictionarys under the tag 'value'</p> <pre><code>json_str = '''{"preferred_timestamp": "internal_timestamp", "internal_timestamp": 3606765503.684, "stream_name": "ctdpf_j_cspp_instrument", "values": [{ "value_id": "temperature", "value": 9.8319 }, { "value_id": "conductivity", "value": 3.58847 }, { "value_id": "pressure", "value": 22.963 }] }''' </code></pre> <p>I use the function 'json_normalize' in order to load the json into a flattened Pandas dataframe.</p> <pre><code>&gt;&gt;&gt; from pandas.io.json import json_normalize &gt;&gt;&gt; import simplejson as json &gt;&gt;&gt; df = json_normalize(json.loads(json_str), 'values', ['preferred_timestamp', 'stream_name', 'internal_timestamp']) &gt;&gt;&gt; df value value_id preferred_timestamp internal_timestamp \ 0 9.83190 temperature internal_timestamp 3.606766e+09 1 3.58847 conductivity internal_timestamp 3.606766e+09 2 22.96300 pressure internal_timestamp 3.606766e+09 3 32.89470 salinity internal_timestamp 3.606766e+09 stream_name 0 ctdpf_j_cspp_instrument 1 ctdpf_j_cspp_instrument 2 ctdpf_j_cspp_instrument 3 ctdpf_j_cspp_instrument </code></pre> <p>Here is where I am stuck. I want to take the value and value_id columns and pivot these into new columns based off of value_id. </p> <p>I want the dataframe to look like the following:</p> <pre><code>stream_name preferred_timestamp internal_timestamp conductivity pressure salinity temperature ctdpf_j_cspp_instrument internal_timestamp 3.606766e+09 3.58847 22.96300 32.89470 9.83190 </code></pre> <p>I've tried both the pivot and pivot_table Pandas functions and even tried to manually pivot the tables by using 'set_index' and 'stack' but it's not quite how I want it.</p> <pre><code>&gt;&gt;&gt; df.pivot_table(values='value', index=['stream_name', 'preferred_timestamp', 'internal_timestamp', 'value_id']) stream_name preferred_timestamp internal_timestamp value_id ctdpf_j_cspp_instrument internal_timestamp 3.606766e+09 conductivity 3.58847 pressure 22.96300 salinity 32.89470 temperature 9.83190 Name: value, dtype: float64 </code></pre> <p>This is close, but it didn't seem to pivot the values in 'value_id' into separate columns.</p> <p>and </p> <pre><code>&gt;&gt;&gt; df.pivot('stream_name', 'value_id', 'value') value_id conductivity pressure salinity temperature stream_name ctdpf_j_cspp_instrument 3.58847 22.963 32.8947 9.8319 </code></pre> <p>Close again, but it lacks the other columns that I want to be associated with this line.</p> <p>I'm stuck here. Is there an elegant way of doing this or should I split the DataFrames and re-merge them to how I want?</p>
<python><pandas><pivot-table>
2016-03-15 18:55:52
HQ
36,019,849
text field in matrix layout in sap ui5
i can not able to place text field in matrix layout please check below code and please suggest how to check xml code errors? evary time i am stucking in design part with xml code please suggest me how to overcome that. enter code here <core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:l="sap.ui.commons.layout" controllerName="matrix.matrix" xmlns:html="http://www.w3.org/1999/xhtml"> <Page title="ytftfhgff"> <content> <l:MatrixLayout layoutFixed="true" columns="4" width="600px" widths="150px,150px,150px,150px"> <l:MatrixLayoutRow> <l:MatrixLayoutCell colSpan="4"> <Text text="Its a heading" /> </l:MatrixLayoutCell> </l:MatrixLayoutRow> <l:MatrixLayoutRow> <l:MatrixLayoutCell> <Label text="First Name"/> </l:MatrixLayoutCell> <l:MatrixLayoutCell> <TextField id="axscx" width="20em"></TextField> </l:MatrixLayoutCell> </l:MatrixLayoutRow> </l:MatrixLayout> </content> </Page> </core:View> thanks in advance, sriman.
<sapui5>
2016-03-15 18:59:32
LQ_EDIT
36,019,868
authority http header - in chrome dev tools
<p>chrome dev tools - displays some http header with a leading <code>:</code> (not sure why it does with some and not others). </p> <p>One of these is the http header <code>authority</code> which is displays as:</p> <p><code>authority:api.somedomain.com</code></p> <p>However this is listed in the list of http headers on Wikipedia. Is this a new HTTP2 header or is possible to define any new request field in the headers -or are these fixed?</p>
<http><google-chrome-devtools>
2016-03-15 19:00:41
HQ
36,020,702
Nightwatch to select option from select box
<p>I am trying to use nightwatch.js to select an option from a select box.</p> <p>I have the code:</p> <pre><code> this.browser.click('select[name="month"]') .pause(1000) .click('option[value="3"]') .click('select[name="day"]') .pause(1000) .click('option[value="6"]') .click('select[name="year"]') .pause(1000) .click('option[value="1989"]'); </code></pre> <p>It selects the correct month, year on the page but not the day. Here's the HTML for the select box for the day:</p> <pre><code>&lt;select aria-label="Day" id="day" name="day" data-validatorGroup="bday" data-component="selectbox"&gt; &lt;option selected="selected" value="" aria-label="Date of birth"&gt; Day&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt; &lt;option value="7"&gt;7&lt;/option&gt; &lt;option value="8"&gt;8&lt;/option&gt; &lt;option value="9"&gt;9&lt;/option&gt; &lt;option value="10"&gt;10&lt;/option&gt; &lt;option value="11"&gt;11&lt;/option&gt; &lt;option value="12"&gt;12&lt;/option&gt; &lt;option value="13"&gt;13&lt;/option&gt; &lt;option value="14"&gt;14&lt;/option&gt; &lt;option value="15"&gt;15&lt;/option&gt; &lt;option value="16"&gt;16&lt;/option&gt; &lt;option value="17"&gt;17&lt;/option&gt; &lt;option value="18"&gt;18&lt;/option&gt; &lt;option value="19"&gt;19&lt;/option&gt; &lt;option value="20"&gt;20&lt;/option&gt; &lt;option value="21"&gt;21&lt;/option&gt; &lt;option value="22"&gt;22&lt;/option&gt; &lt;option value="23"&gt;23&lt;/option&gt; &lt;option value="24"&gt;24&lt;/option&gt; &lt;option value="25"&gt;25&lt;/option&gt; &lt;option value="26"&gt;26&lt;/option&gt; &lt;option value="27"&gt;27&lt;/option&gt; &lt;option value="28"&gt;28&lt;/option&gt; &lt;option value="29"&gt;29&lt;/option&gt; &lt;option value="30"&gt;30&lt;/option&gt; &lt;option value="31"&gt;31&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Does anyone know why its not selecting the proper day?</p>
<javascript><jquery><nightwatch.js>
2016-03-15 19:44:31
HQ
36,021,587
Renaming table system unavailable SQL Azure
I have to perform the exchange of two tables and it's making my system unavailable for 20 minutes(are many data). My sample code: query = "DROP TABLE MY_TABLE; "; query += "EXEC sp_rename MY_TABLE_TEMP, MY_TABLE; "; query += "ALTER TABLE MY_TABLE ADD CONSTRAINT PK_MY_TABLE PRIMARY KEY CLUSTERED (ID ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]"; I wonder if it's like not to leave as Unavailable.
<sql-server><azure><azure-sql-database>
2016-03-15 20:36:23
LQ_EDIT
36,021,665
For loop only runs once c++
<p>Hi im trying to run the drunk walk problem which is similar to flipping a coin. I have the code written but it only enters the for loop once instead of 1,000,000 times like I want it to. I cant see what I did wrong so I hope you all can point me in the right direction, Thank you.</p> <pre><code> cout &lt;&lt; "enter the starting position.\n"; cin &gt;&gt; i; cout &lt;&lt; "At starting block " &lt;&lt; i &lt;&lt; endl; for(j = 1; j &lt; 1000000; j++) { while(i &lt; 8 &amp;&amp; i &gt; 1) { x = rand() % 3; if(x == 0) { i++; tot_mov++; } else { i--; tot_mov++; } } if(i == 1) { tot_pub++; } if(i == 8) { tot_hom++; } } avg_mov = tot_mov / 1000000; avg_pub = tot_pub / 1000000; avg_hom = tot_hom / 1000000; cout &lt;&lt; "Total moves " &lt;&lt; tot_mov &lt;&lt; endl; cout &lt;&lt; "Average moves " &lt;&lt; avg_mov &lt;&lt; endl; cout &lt;&lt; "Total Home " &lt;&lt; tot_hom &lt;&lt; endl; cout &lt;&lt; "Average home " &lt;&lt; avg_hom &lt;&lt; endl; cout &lt;&lt; "Total pub " &lt;&lt; tot_pub &lt;&lt; endl; cout &lt;&lt; "Average pub " &lt;&lt; avg_pub &lt;&lt; endl; return; </code></pre>
<c++><loops>
2016-03-15 20:40:28
LQ_CLOSE
36,021,906
What is the best method to seeding a Node / MongoDB application?
<p>So, I'm new to the MEAN stack, and I've hit a wall trying to seed MongoDB. I'm using Mongoose to communicate with the database, and there's a bunch of documentation suggesting I should be able to seed using populated JSON files.</p> <p>What I've tried:</p> <p><strong><a href="https://www.npmjs.com/package/node-mongo-seeds" rel="noreferrer">node-mongo-seed</a></strong>; Pretty straight forward, but consistently throws errors on the end of arrays. (Perhaps the missing bson module is at fault?)</p> <pre><code>{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version Seeding files from directory /Users/Antwisted/code/wdi/MEAN/seeds ---------------------- Seeding collection locations err = [SyntaxError: /Users/Antwisted/code/wdi/MEAN/seeds/locations.json: Unexpected token {] </code></pre> <p><strong><a href="https://www.npmjs.com/package/mongoose-seed" rel="noreferrer">mongoose-seed</a></strong>; Also pretty straight forward, basically puts the JSON objects into a variable before exporting to the database. Promising, but... more errors...</p> <pre><code>Successfully initialized mongoose-seed [ 'app/models/locationsModel.js' ] Locations collection cleared Error creating document [0] of Location model Error: Location validation failed Error creating document [1] of Location model Error: Location validation failed Error creating document [2] of Location model Error: Location validation failed... </code></pre> <p>So, my thoughts were that it was probably a syntax error within the JSON structure, but playing around with that has not yielded any real solutions (or maybe I'm missing it?). Sample of my JSON:</p> <pre><code>{ { "header": "Dan's Place", "rating": 3, "address": "125 High Street, New York, 10001", "cord1": -73.0812, "cord2": 40.8732, "attributes": ["Hot drinks", "Food", "Premium wifi"], "hours": [ { "days": "Monday - Friday", "hours": "7:00am - 7:00pm", "closed": false }, { "days": "Saturday", "hours": "8:00am - 5:00pm", "closed": false }, { "days": "Sunday", "closed": true } ], "reviews": [ { "rating": 4, "id": ObjectId(), "author": "Philly B.", "timestamp": "new Date('Feb 3, 2016')", "body": "It was fine, but coffee was a bit dull. Nice atmosphere." }, { "rating": 3, "id": ObjectId(), "author": "Tom B.", "timestamp": "new Date('Feb 23, 2016')", "body": "I asked for her number. She said no." } ] }, { "header": "Jared's Jive", "rating": 5, "address": "747 Fly Court, New York, 10001", "cord1": -73.0812, "cord2": 40.8732, "attributes": ["Live Music", "Rooftop Bar", "2 Floors"], "hours": [ { "days": "Monday - Friday", "hours": "7:00am - 7:00pm", "closed": false }, { "days": "Saturday", "hours": "8:00am - 5:00pm", "closed": false }, { "days": "Sunday", "closed": true } ], "reviews": [ { "rating": 5, "id": ObjectId(), "author": "Jacob G.", "timestamp": "new Date('Feb 3, 2016')", "body": "Whoa! The music here is wicked good. Definitely going again." }, { "rating": 4, "id": ObjectId(), "author": "Tom B.", "timestamp": "new Date('Feb 23, 2016')", "body": "I asked to play her a tune. She said no." } ] } } </code></pre> <p>Additionally, I'm not entirely sure how to specify subdocuments within the JSON (assuming I can get the seeding process to work correctly in the first place).</p> <p>Here's my model:</p> <pre><code>var mongoose = require('mongoose'); var subHoursSchema = new mongoose.Schema({ days: {type: String, required: true}, opening: String, closing: String, closed: {type: Boolean, required: true} }); var subReviewsSchema = new mongoose.Schema({ rating: {type: Number, required: true, min: 0, max: 5}, author: String, timestamp: {type: Date, "default": Date.now}, body: String }); var locationSchema = new mongoose.Schema({ name: {type: String, required: true}, address: String, rating: {type: Number, "default": 0, min: 0, max: 5}, attributes: [String], coordinates: {type: [Number], index: '2dsphere'}, openHours: [subHoursSchema], reviews: [subReviewsSchema] }); mongoose.model('Location', locationSchema); </code></pre> <p>Any insight on how to navigate these issues would be greatly appreciated. Thanks!</p>
<json><node.js><mongodb><mongoose>
2016-03-15 20:54:11
HQ
36,021,992
Javascript optgroup hiden dont working IExlorer
This code working in Opera, problem is IE end Android. Use hiden() javascript. First Option use value Mazda (mark) second shows us 'opera': only all models MAZDA (is good). 'IE': Shows us all model and all optgroup. Maybe is in JS problem? $(document).ready(function() { $('#model optgroup').hide();enter code here $('#Marka').change(function() { var text = $(this).val(); $('#model optgroup').hide(); $('#model').val(''); $('#model optgroup[label="' + text + '"]').css({ 'display': 'block' }); }); }); function usun() { document.getElementById("first").style.display = "none"; } [https://jsfiddle.net/p051m5u6/][1] [1]: https://jsfiddle.net/p051m5u6/
<javascript><jquery><internet-explorer><option><optgroup>
2016-03-15 20:58:32
LQ_EDIT
36,022,739
Is there any functional difference between AtomicInteger.updateAndGet() and AtomicInteger.accumulateAndGet()?
<p>Is there any scenario in which <code>AtomicInteger.accumulateAndGet()</code> can't be replaced with <code>AtomicInteger.updateAndGet()</code>, or is it just a convenience for method references?</p> <p>Here's a simple example where I don't see any functional difference:</p> <pre><code>AtomicInteger i = new AtomicInteger(); i.accumulateAndGet(5, Math::max); i.updateAndGet(x -&gt; Math.max(x, 5)); </code></pre> <p>Obviously, the same goes for <code>getAndUpdate()</code> and <code>getAndAccumulate()</code>.</p>
<java><lambda><java-8><atomic><atomicinteger>
2016-03-15 21:40:16
HQ
36,022,867
If we want use S3 to host Python packages, how can we tell pip where to find the newest version?
<p>we are trying to come up with a solution to have AWS S3 to host and distribute our Python packages. </p> <p>Basically what we want to do is using "python3 setup.py bdist_wheel" to create a wheel. Upload it to S3. Then any server or any machine can do "pip install $<a href="http://path/on/s3" rel="noreferrer">http://path/on/s3</a>". (including a virtualenv in AWS lambda) (We've looked into Pypicloud and thought it's an overkill.)</p> <p>Creating package and installing from S3 work fine. There is only one issue here: we will release new code and give them different versions. If we host our code on Pypi, you can upgrade some packages to their newest version by calling "pip install package --upgrade". </p> <p>But if you host your packages on S3, how do you let pip know there's a newer version exists? How do you roll back to an older version by simply giving pip the version number? Is there a way to let pip know where to look for different version of wheels on S3?</p>
<python><amazon-s3><pip>
2016-03-15 21:48:23
HQ
36,023,004
Java -NullPointerException thrown and I'm not sure why
<p>I am writing a program, in which, I have a method called "equals" to test whether two 2-dimensional arrays are "equal" to each other. equals returns whether the two args are equivalent in the sense that If both args are null, return true If one arg is null and the other isn't, return false; If the 2 arrays have a different number of rows, return false else, return whether each element in arr1 is equivalent to the corresponding element in arr2 in the sense that both elements are null, or both elements refer to arrays with the same number of ints with the same values in the same order.</p> <p>equals method definition:</p> <pre><code>public static boolean equals( int[][] arr1, int[][] arr2){ //both are null references if(arr1 == null &amp;&amp; arr2 == null) return true; //only one is a null reference if ((arr1 == null &amp;&amp; arr2 != null) || (arr1 == null &amp;&amp; arr2 != null)) return false; //number of rows not identical if( arr1.length != arr2.length ) return false; for(int i = 0 ; i &lt; arr1.length; i++){ //checking row equivalence if(arr1[i] == null &amp;&amp; arr2[i]==null){ //both null continue; } if(arr1[i] == null || arr2[i] == null) //one is null return false; else if(arr1[i].length != arr2[i].length){ return false; } else{ for(int j = 0; j &lt; arr1[i].length; i++){ //#of columns equal, compare them System.out.println(i + "," + j); //helps debug if(arr1[i][j] != arr2[i][j]) return false; } } } return true; } //equals </code></pre> <p>When I call </p> <pre><code>equals( new int[][]{{1,2},{3,4},null}, new int[][]{{1,2},null,{3,4}} ) </code></pre> <p>my program crashes, throwing the NullPointerException.</p> <p>Eclipse says that it failed at this line:</p> <pre><code>if(arr1[i][j] != arr2[i][j]) </code></pre> <p>The problem is, as far as I can tell, my program shouldn't be entering the enclosing for-loop where this line is located to begin with. It should return false at this point:</p> <pre><code>if(arr1[i] == null || arr2[i] == null) //one is null return false; </code></pre> <p>What am I doing wrong here? Thank you.</p>
<java><arrays>
2016-03-15 21:57:16
LQ_CLOSE
36,023,076
How does setTimeout work?
<p>-so i am obviously trying to get two functions to run automatically whilst on a timer using setTimeout. However i am not to sure how it works. All i can see when i search it up is it in a function. so how do i have it outside a function?</p> <pre><code>function ChangeImage() { if(position &lt; TrafficL.length) { document.getElementById("myImage").src = TrafficL[position]; position++ } } function RestartPos() { if (position==3) document.getElementById("myImage").src = TrafficL["position"] position=0 var setTimeout = (ChangeImage(),1500) var setTimeout = (RestartPos(),6000) </code></pre>
<javascript><settimeout><setinterval>
2016-03-15 22:02:52
LQ_CLOSE
36,023,236
undefined index - register form
<pre><code> &lt;?php $mysqli = mysqli_connect('localhost', 'test', 'test123', 'test'); if ($mysqli-&gt;connect_errno) { echo "&lt;p&gt;MySQL error no {$mysqli-&gt;connect_errno} : {$mysqli-&gt;connect_error}&lt;/p&gt;"; exit(); } global $mysqli; $username = $_POST['username']; $password = $_POST['password']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $exists = 0; $result = $mysqli-&gt;query("SELECT username from users WHERE username = '{$username}' LIMIT 1"); if ($result-&gt;num_rows == 1) { $exists = 1; $result = $mysqli-&gt;query("SELECT password from users WHERE password = '{$password}' LIMIT 1"); if ($result-&gt;num_rows == 1) $exists = 2; } else { $result = $mysqli-&gt;query("SELECT email from users WHERE email = '{$email}' LIMIT 1"); if ($result-&gt;num_rows == 1) $exists = 3; } if ($exists == 1) echo "&lt;p&gt;Username already exists!&lt;/p&gt;"; else if ($exists == 2) echo "&lt;p&gt;Username and Email already exists!&lt;/p&gt;"; else if ($exists == 3) echo "&lt;p&gt;Email already exists!&lt;/p&gt;"; else { # insert data into mysql database $sql = "INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`, `email`) VALUES (NULL, '{$username}', '{$password}', '{$firstname}', '{$lastname}', '{$email}')"; if ($mysqli-&gt;query($sql)) { //echo "New Record has id ".$mysqli-&gt;insert_id; echo '&lt;meta http-equiv="refresh" content="0; url=test.html"&gt;'; } else { echo "&lt;p&gt;MySQL error no {$mysqli-&gt;errno} : {$mysqli-&gt;error}&lt;/p&gt;"; exit(); } } ?&gt; </code></pre> <p>I am trying to create a register page, so when the user fills in the relevant details it register them to the database in MYSQL and stores details.</p> <p>Therfore they can then go ahead to login, the error I am having is 'Undefined index' showing on all variables - username, password, firstname, lastname and email.</p> <p>I have added all these variables to my backend db but still nothing..</p> <p>HTML code:</p> <pre><code>&lt;body&gt; &lt;div class="container"&gt; &lt;h1 class="text-center"&gt;Booking&lt;/h1&gt; &lt;form class="form-signin" method="POST" action="register.php"&gt; &lt;h2 class="form-signin-heading"&gt;Register&lt;/h2&gt; &lt;div id="all-form"&gt; &lt;h3&gt;User Details&lt;/h3&gt; &lt;input required type="text" class="form-control" placeholder="Name"&gt; &lt;input required type="text" class="form-control" placeholder="Email Address"&gt; &lt;h4&gt;Login Details&lt;/h4&gt; &lt;input required type="text" class="form-control" placeholder="Username"&gt; &lt;input required type="password" class="form-control" placeholder="Password"&gt; &lt;input required type="password" class="form-control" placeholder="Confirm Password"&gt; &lt;button class="btn btn-primary btn-sm" type="register"&gt;Register&lt;/button&gt; &lt;p&gt;&lt;a href="signup2.html"&gt;Already registered? Sign in here &lt;/a&gt;&lt;/p&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- /container --&gt; &lt;/body&gt; </code></pre>
<php><html><mysql><server>
2016-03-15 22:12:09
LQ_CLOSE
36,025,620
Find an easy web server framework for mobile game
<p>I need a web server to provide api interface like login/ranking for a mobile game, which web framework should I use, I primary program C++ before.</p>
<javascript><php><android><web-services>
2016-03-16 02:08:38
LQ_CLOSE
36,026,237
Convert SQL query to a Laravel query builder
Good day, I have this query: SELECT * FROM table WHERE ( name = '%alex%' OR address = '%alex%' OR lastname = '%alex%' ) AND id = '%alex%' AND email = '%alex%' How would I go about converting this SQL query using Laravel Query Builder? Thanks in advance.
<php><laravel-5>
2016-03-16 03:24:24
LQ_EDIT
36,028,253
Counting sub-strings
<p>If you want to count the number of occurrences of one string inside another, which approach is better in terms of simplicity and/or performance? - </p> <ul> <li>using <code>indexOf</code> in a <code>for</code>/<code>while</code> loop</li> <li>using a regular expression</li> </ul> <p>And if it is the latter, then what is the best way to do it?</p>
<javascript><regex>
2016-03-16 06:28:37
LQ_CLOSE
36,028,885
Confused between the usage of constructors and what to/what not to place in them.
<p>I had basics in C, and I've just started programming in c++ two weeks ago, and find 'classes' confusing. My question is how do i put a 'cin' to input the value to determine marks, and also how do i print the grades based on the below code? I'm only printing A to F and i'm so blur right now. And for some reason if i put 'else if' instead of just 'if' the error reads as missing ; before cout. Have way too many questions, sorry about that.. </p> <pre><code>#include &lt;iostream&gt; using namespace std; class StudentMark { private: float mark; public: StudentMark() //constructor { mark = 0.0; cout &lt;&lt; "Constructed an instance of class StudentMark\n"; } void SetMark(float markofstudent) { mark = markofstudent; } void IntroduceMark() { if (80&lt;mark&lt;100) cout &lt;&lt; "A" &lt;&lt; endl; if (65&lt;mark&lt;79) cout &lt;&lt; "B" &lt;&lt; endl; if (50&lt;mark&lt;64) cout &lt;&lt; "C" &lt;&lt; endl; if (40&lt;mark&lt;49) cout &lt;&lt; "D" &lt;&lt; endl; if (0&lt;mark&lt;39) cout &lt;&lt; "F" &lt;&lt; endl; } }; int main() { StudentMark FirstStudent; FirstStudent.SetMark(89); FirstStudent.IntroduceMark(); } </code></pre>
<c++><constructor>
2016-03-16 07:09:36
LQ_CLOSE
36,029,350
iOS app development on windows 10 64-bit
<p>I need to build a very simple app for iOS phone but after searching the IDEs for iOS phone development i found that one way to do we will need to install VMWare with OSX image. </p> <p>Now I am not sure it could be the ultimate solution and i hope there could be some other way to develop apps for iOS with.</p> <p>Please suggest me some lightweight IDE that could be able to run over windows OS... Thanks</p>
<ios><windows><ide>
2016-03-16 07:35:52
LQ_CLOSE
36,030,132
what to use between [] and {}
I need to make multiple objects of same element. I cant figure it out that which should I use between [] and {} to make my data structure. I am not clear about the difference between [] and {}.
<javascript><arrays><angularjs><object>
2016-03-16 08:18:04
LQ_EDIT
36,030,291
Please help me check if the email exists using pdo
This is the section I use to add users. <?php session_start(); if( isset($_SESSION['user_id']) ){ header("Location: ./index.php"); } require 'conn.php'; $message = ''; if(!empty($_POST['name']) &&!empty($_POST['email']) && !empty($_POST['password'])): // Enter the new user in the database $sql = "INSERT INTO users (name, email, password) VALUES (:name,:email, :password)"; $stmt = $conn->prepare($sql); $stmt->bindValue(':name', $_POST['name']); $stmt->bindValue(':email', $_POST['email']); $stmt->bindValue(':password', password_hash($_POST['password'], PASSWORD_BCRYPT)); if( $stmt->execute() ): $message = 'Successfully created new user'; else: $message = 'Sorry there must have been an issue creating your account'; endif; endif; ?> Thanks in advanced. Php NewBie
<php><pdo>
2016-03-16 08:28:59
LQ_EDIT
36,030,305
How to move first element if second is over it
Sorry for my bad english :) 1) Sidebar moves to the right (Start Left position = -270, End position = 0); 2) Header contains logo <div class="head-logo"></div> with position:absolute How to to move logo div to left if sidebar above the logo? [What I need][1] [1]: http://i.stack.imgur.com/t0rJl.png
<javascript><jquery><html>
2016-03-16 08:29:58
LQ_EDIT
36,030,829
Is this R bug real?
<p>I am quite confused... and thinking is this bug real? How can it be? I just want to make a vector of 0's and 1's.</p> <p>Here's the source and the outcome</p> <pre><code>n.subj=1000 prop.aber = 0.9 n.measure = 3 n.subj.norm = n.subj*(1-prop.aber) n.subj.aber = n.subj*prop.aber labE &lt;- rnorm(n.subj*n.measure, 0, 1) labT_ &lt;- c(rep(0, n.subj.norm), rep(1, n.subj.aber)); length(labT_) sum(labT_ == 0); sum(labT_ == 1) [1] 99 [1] 900 </code></pre> <p>My common sense tells me that it should be 100 and 900!!!!!!?!?!?????</p>
<r>
2016-03-16 08:58:17
LQ_CLOSE
36,031,087
How can dynamically generate some values in php?
<p>I want to store these values in an array</p> <pre><code>$hours = array("06:00", "06:15", "06:30"....etc ); </code></pre> <p>The last value is <code>23:45</code> </p> <p>I wish it to be stored in ascending order.</p> <p>My question is ... how I can automatically generate these values and add them in array?</p> <p>If you manually add them .... they are many and it is not good.</p> <p>You tell me please a method by which I could dynamically generate these values?</p> <p>Thanks in advance!</p>
<php><arrays>
2016-03-16 09:09:05
LQ_CLOSE
36,032,572
C# - Concantenate inside a loop
Is it possible to concatenate inside a C# loop? Below is my sample code: for (int i = 0; i <= metricCount; i++) { if (m.metrictNumber == i) { aggrgt.Add(new PlainBrgDataSummaryChartAggrgt { scoreWk6 = scoresPerDuration.scoresPerDuration.scoreWk6.metricScore1, scoreWk5 = scoresPerDuration.scoresPerDuration.scoreWk5.metricScore1, scoreWk4 = scoresPerDuration.scoresPerDuration.scoreWk4.metricScore1, scoreWk3 = scoresPerDuration.scoresPerDuration.scoreWk3.metricScore1, scoreWk2 = scoresPerDuration.scoresPerDuration.scoreWk2.metricScore1, scoreWk1 = scoresPerDuration.scoresPerDuration.scoreWk1.metricScore1 }); } } What I want is to concantename metricScore1. Something like this: scoreWk6 = scoresPerDuration.scoresPerDuration.scoreWk6.metricScore + i, Is that possible?
<c#><loops><concatenation>
2016-03-16 10:12:28
LQ_EDIT
36,032,965
Insert byte in a byte Array?
<p>byte[] myFile = File.ReadAllBytes("d:\123.xml"); I want insert some character after each byte in myFile byte array. If the myFile byte array length is 5000, after insert, it will become 10000. How can I write by c# ?</p>
<c#>
2016-03-16 10:27:50
LQ_CLOSE
36,033,554
Holding Temporary Data in ASP.NET MVC for Shopping Cart
<p>Which mechanism will be suitable for storing temporary data in Asp.net MVC? I dont want to hit to database everytime customer adds the product to cart.I read some of the articles and i am little bit confused. I want to know which mechanism would be better or any other options? 1) Cookies 2) Session 3) Text File</p>
<asp.net-mvc><asp.net-mvc-5>
2016-03-16 10:54:05
LQ_CLOSE
36,033,818
Java - How can I run the javascript in all my html rows
I am creating invoice form, I have written a Java Script to calculate Tax and Discount price as the user the value, But it is just working in one row how can I enable it to work on all the rows Javascript[Javascript to calculate discount and tax][1] [Html form][2] [1]: http://i.stack.imgur.com/ZkuWK.jpg [2]: http://i.stack.imgur.com/i2IPs.jpg
<javascript><html>
2016-03-16 11:04:40
LQ_EDIT
36,033,918
Submit button won't work in PHP [Addresbook]
<!-- begin snippet: js hide: false --> <!-- language: lang-html --> <?php if (!isset($_SESSION)) { session_start(); } include "connect.php"; include "functions.php"; if (!isset($_SESSION['login']) || $_SESSION['login'] !== true) { header('location: no_acces.php'); exit(); } else { $id_user = $_SESSION['userid']; $q_user = mysqli_query($conn, "SELECT * FROM users WHERE id = $id_user"); if (mysqli_num_rows($q_user) === 1) { $r_user = mysqli_fetch_assoc($q_user); } else { unset($_SESSION['login']); unset($_SESSION['userid']); header('location: no_acces.php'); exit(); } } $error = ""; $userQuery = mysqli_query($conn, "SELECT username FROM users"); $user = mysqli_fetch_assoc($userQuery); $id = $_GET['id']; if (isset($_POST['edit_contact'])) { $roepnaam = $_POST['roepnaam']; $naam = $_POST['naam']; $land = $_POST['land']; $bedrijf = $_POST['bedrijf']; $adres1 = $_POST['adres1']; $adres2 = $_POST['adres2']; $stad = $_POST['stad']; $postcode = $_POST['postcode']; $provincie = $_POST['provincie']; $telefoon = $_POST['telefoon']; $email = $_POST['email']; $captcha= $_POST['g-recaptcha-response']; if(!$captcha){ $error = "Er is een fout opgetreden"; } if ($error == "") { $insertUser = ("UPDATE address SET roepnaam = '$roepnaam', naam = '$naam', bedrijf = '$bedrijf', telefoon = '$telefoon', email = '$email', adres1 = '$adres1', adres2 = '$adres2', stad = '$stad', postcode = '$postcode', provincie = '$provincie', land = '$land' WHERE id = $id"); if (mysqli_query($conn, $insertUser)) { $_SESSION['edit_contact'] = true; header('location: address_book.php'); } else { $error = "Er is een fout opgetreden"; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css"> <link rel="stylesheet" href="css/stylesheet.css" type="text/css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src='https://www.google.com/recaptcha/api.js'></script> <script src="js/java.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Contact wijzigen</title> <style> .error { color: darkred; font-weight: bold; } </style> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.php">SBRM National Bank</a> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav"> <li><a href="index.php">Home</a></li> <li><a href="details.php">Gegevens</a><li> <li><a href="bankaccounts.php">Rekeningoverzicht</a><li> <li class="active"><a href="address_book.php">Contacten</a><li> </ul> <ul class="nav navbar-nav navbar-right"> <li class-"active"><a href="details.php"><span class="glyphicon glyphicon-user"></span> U bent ingelogd als <?php echo $user['username']; ?></a></li> <li><a href="logout.php"><span class="glyphicon glyphicon-log-out"></span> Uitloggen</a></li> </ul> </div> </div> </nav> <div class="container-fluid hero-slide"> <div class="row"> <div id="myCarousel" class="carousel slide " data-ride="carousel"> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="images/tempc.jpg" alt="Ad"> <div class="carousel-caption"> <h3 class="caption">Contact wijzigen</h3> </div> </div> </div> </div> </div> </div> <div class="container padding-top-10"> <div class="panel col-md-6"> <div class="panel-heading "><h5>Nieuwe gegevens:</h5></div> <div class="panel-body"> <form action="" method="post"> <?php if ($error !== "") { ?> <div class="row"> <div class="col-md-12 error"> <?php echo $error; ?> </div> </div> <?php } ?> <label for="firstName" class="control-label">Naam:</label> <div class="row "> <div class="col-md-6"> <input type="text" class="form-control" id="firstName" placeholder="Roepnaam" name="roepnaam" value="<?php if (isset($_POST['roepnaam'])) { echo $_POST['roepnaam']; } ?>" required/> </div> <div class="col-md-6"> <input type="text" class="form-control" id="lastName" placeholder="Naam" name="naam" value="<?php if (isset($_POST['naam'])) { echo $_POST['naam']; } ?>" required/> </div> </div> <label for="username" class="control-label">Bedrijf:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="username" placeholder="Bedrijf" name="bedrijf" value="<?php if (isset($_POST['bedrijf'])) { echo $_POST['bedrijf']; } ?>" required/> </div> </div> <label for="password" class="control-label">Telefoonnummer:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="password" placeholder="Telefoonnummer" name="telefoon" value="<?php if (isset($_POST['telefoon'])) { echo $_POST['telefoon']; } ?>" required/> </div> </div> <label for="email" class="control-label">Email:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="email" placeholder="E-mailadres" name="email" value="<?php if (isset($_POST['email'])) { echo $_POST['email']; } ?>" required/> </div> </div> <label for="adres1" class="control-label">Adres:</label> <div class="row"> <div class="col-md-12"> <input type="text" class="form-control" id="adres1" placeholder="Adres 1" name="adres1" value="<?php if (isset($_POST['adres1'])) { echo $_POST['adres1']; } ?>" required/> </div> </div> <div class="row padding-top-10"> <div class="col-md-12"> <input type="text" class="form-control" id="adres2" placeholder="Adres 2" name="adres2" value="<?php if (isset($_POST['adres2'])) { echo $_POST['adres2']; } ?>"/> </div> </div> <div class="row"> <div class="col-md-3"> <label for="postcode" class="control-label">Postcode:</label> </div> <div class="col-md-5"> <label for="city" class="control-label">Stad:</label> </div> <div class="col-md-4"> <label for="regio" class="control-label">Regio:</label> </div> </div> <div class="row "> <div class="col-md-3"> <input type="text" class="form-control" id="postcode" placeholder="Postcode" name="postcode" value="<?php if (isset($_POST['postcode'])) { echo $_POST['postcode']; } ?>" required/> </div> <div class="col-md-5"> <input type="text" class="form-control" id="city" placeholder="Stad" name="stad" value="<?php if (isset($_POST['stad'])) { echo $_POST['stad']; } ?>" required/> </div> <div class="col-md-4"> <input type="text" class="form-control" id="regio" placeholder="Provincie" name="provincie" value="<?php if (isset($_POST['provincie'])) { echo $_POST['provincie']; } ?>" required/> </div> </div> <label for="land" class="control-label">Land:</label> <div class="row "> <div class="col-md-12"> <input type="text" class="form-control" id="password" placeholder="Land" name="land" value="<?php if (isset($_POST['land'])) { echo $_POST['land']; } ?>" required/> </div> </div> <div class="row"> <div class="col-md-8 padding-top-10 "> <div class="g-recaptcha " data-sitekey="6LcCsBoTAAAAAK72uzyJSrgWwD8xuF6jFIfgFaHX"></div> </div> </div> <div class="row"> <div class="col-md-2 padding-top-10"> <input type="submit" name="edit_contact" class="btn btn-succes" value="Wijzigen"> </div> <div class="col-md-2 padding-top-10"> <input type="text" name="delete_contact" action="delete_contact.php" class="btn btn-succes" value="Contact verwijderen"> </div> </div> </form> </div> </div> </div> <footer> <div class="container"> <div class="row"> <div class="col-sm-3"> <h6>Copyright &copy; 2016</h6> <ul class="list-unstyled"> <li class="boss">Sander Bakker</li> <li class="unstyled">Bob Lansbergen</li> <li class="unstyled">Ronald van den Heuvel</li> <li class="unstyled">Max Donck</li> </ul> </div> <div class="col-sm-3"> <h6>Over Ons</h6> <p id="pfont">Dit is een website ontworpen om een banksysteem te simuleren met PHP en mySQL</p> </div> <div class="col-sm-2"> <h6>Navigatie</h6> <ul class="list-unstyled"> <li class="unstyled"><a href="#">Home</a></li> <li class="unstyled"><a href="#">Particulier</a></li> <li class="unstyled"><a href="#">Persoonlijk</a></li> <li class="unstyled"><a href="#">Privé</a></li> <li class="unstyled"><a href="#">Zakelijk</a></li> </uL> </div> <div class="col-sm-2"> <h6>Contact</h6> <ul class="list-unstyled"> <li class="unstyled"><a href="#">Google +</a></li> <li class="unstyled"><a href="#">Facebook</a></li> <li class="unstyled"><a href="#">Twitter</a></li> <li class="unstyled"><a href="#">YouTube</a></li> </uL> </div> </div> </div> </footer> </body> </head> </html> <!-- end snippet --> This is my html code <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <?php if (!isset($_SESSION)) { session_start(); } include "connect.php"; include "functions.php"; if (!isset($_SESSION['login']) || $_SESSION['login'] !== true || !isset($_SESSION['userid']) || $_SESSION['userid'] == "") { header('location: login.php'); exit(); } else { session_regenerate_id(); } $id = $_GET['id']; $query = "DELETE FROM address WHERE id= $id"; mysqli_query ($query); if (mysql_affected_rows() == 1) { header('location: addressbook.php'); } else { echo "Verwijderen mislukt"; } ?> <!-- end snippet --> This is my PHP code. I'm trying to make a delete button for my contacts within the addressbook. but everytime I click "Contact verwijderen" the webpage resets it self and the contact won't be deleted. Could anyone help me to fix this?
<php><mysql>
2016-03-16 11:09:07
LQ_EDIT
36,034,790
Post FB comment as page
<p>I have administrator account of a Facebook page, i would like to know whether it is possible to post a comment as page (the one i manage) using graph api and how to do it ?</p> <p>Thanks in advance </p>
<facebook><facebook-graph-api>
2016-03-16 11:46:24
LQ_CLOSE
36,036,570
can someone help me converting this sql query into a stored proc..I am new to sql
Select OpportunityId from opportunity AS c left JOIN ( select a.opportunitynameid from opportunity o JOIN ApprovalDocument a ON a.opportunitynameid=o.OpportunityId ) AS b ON c.OpportunityId=b.opportunitynameid Where b.opportunitynameid IS NULL and statecode=0
<stored-procedures>
2016-03-16 13:06:27
LQ_EDIT
36,038,118
For loop java not executing properly?
<pre><code>//Declared here the atributes int id and int [9][5] array. public String getPos(int id){ String res = ""; for(int i = 0; i &lt;9 ;i++ ){ for(int j = 0; j&lt;5 ;j++){ if(this.arr[i][j] == id) res = res + i + "," + j; } } return res; } </code></pre> <p>When I run getPos(1); the result is 8,2 but i want it to print 9,3. How i do that?</p>
<java><arrays><loops><for-loop><multidimensional-array>
2016-03-16 14:09:46
LQ_CLOSE
36,038,900
Multiple Lat/Long Coordinates to Miles
<p>I have a few x,y coordinates that I wanted to get the area of. I figured the best course of action is to convert the X,Y decimal coordinates into nautical miles and then do the area of a polygon. I've googled around, but really haven't found anything helpful for my problem. Not looking for the answer, but I just wanted to know how to approach this and what to potentially use for the conversion. </p> <p>These are the coordinates that are in an array:</p> <pre><code> Lat_Long = [60.8427194, -042.7969500; ... 60.8646972, -042.5323889; ... 60.7640417, -042.5178639; ... 60.5882139, -042.8185056; ... 60.8080111, -042.8507500; ... 60.8069889, -042.8374167; ... 60.8083028, -042.8278361; ... 60.8114056, -042.8186167; ... 60.8152306, -042.8117389; ... 60.8203694, -042.8055667; ... 60.8256528, -042.8013611; ... 60.8315167, -042.7985083; ... 60.8374056, -042.797078; ... 60.8427194, -042.7969500]; </code></pre>
<matlab><latitude-longitude>
2016-03-16 14:41:45
LQ_CLOSE
36,039,652
What matlab release do I need to be able to use `webread`?
<p>I have matlab R2010a installed on my computer. I tried to use <code>webread</code>to read content from RESTful web service. I can't found it in matlab R2010a. What matlab release do I need to be able to use <code>webread</code>? </p>
<matlab><web-services><rest>
2016-03-16 15:10:34
LQ_CLOSE
36,041,361
MATLAB - Finding Peaks and Valleys
<p>So I have 2 .wav files that was recorded frequency. One is the original audio and the other one is the filtered one. Both are stereo .wav files.</p> <p>Right now, I am supposed to find the peaks and valleys of these 2 .wav file. I was told to that I have to take 3 consecutive data and determine which of the 3 is the max or the min. If the middle one is the max or the min, then peak/valley have been found. Repeat this until there are no more data.</p> <p>How should I achieve the above?</p> <p>I was told to do a sliding window of size 3 and take 3 points by 3 points.</p> <p>I googled it but could not find how to start. Could anyone assist please. Thank You!</p>
<matlab><audio><signal-processing>
2016-03-16 16:22:00
LQ_CLOSE
36,044,032
Convert a string of characters to an unsigned integers C
I am searching a way to convert a string of characters into a string of unsigned integers. What i am trying to do is encrypting a text file using an algorithm that encrypts hexadecimal characters. I am reading an array of 16 characters from the file and i want to convert it to a hexadecimal array so i can encrypt it in my algorithm. Your support is highly appreciated.
<c><hex><unsigned><base-conversion>
2016-03-16 18:27:35
LQ_EDIT
36,045,639
PHP query not showing all results in html table
<p>So I have the following query to show all users from my database: </p> <pre><code>&lt;ul class="names"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Navn&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;th&gt;Score&lt;/th&gt; &lt;/tr&gt; &lt;?php $connection = mysql_connect('localhost', 'users', 'password'); //The Blank string is the password mysql_select_db('users'); $query = ("SELECT * FROM oneusers"); //You don't need a ; like you do in SQL $result = mysql_query($query); $row=mysql_fetch_array($result); while($row = mysql_fetch_array($result)){ //Creates a loop to loop through results echo "&lt;tr&gt;&lt;td&gt;" . $row['iUserName'] . "&lt;/td&gt;&lt;td&gt;" . $row['iUserEmail'] . "&lt;/td&gt;&lt;td&gt;" . $row['iUserCash'] . " DKK&lt;/td&gt;&lt;/tr&gt;"; //$row['index'] the index here is a field name } mysql_close(); //Make sure to close out the database connection ?&gt; &lt;/table&gt; &lt;/ul&gt; </code></pre> <p>But for some reason it doesnt show all the data. </p> <p>In only shows the user with iUserId 2 and not one. </p> <p>Does anyone have an idea of what might be wrong? </p> <p>I can log in with iUserId 1's credentials, and it shows fine the info on the login page. </p> <p>But not here :S</p>
<php><html><mysql>
2016-03-16 19:50:27
LQ_CLOSE
36,046,698
Register custom user model with admin auth
<p>In a Django project, I have a custom user model that adds one extra field:</p> <pre><code>class User(AbstractUser): company = models.ForeignKey(Company, null=True, blank=True) </code></pre> <p>This model is defined in my app, say <code>MyApp.models</code>.</p> <p>How can I get the new <code>User</code> model to show up under "Authentication and Authorization" as the original <code>django.contrib.auth</code> model? </p> <p><a href="https://i.stack.imgur.com/AZxiV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AZxiV.png" alt="enter image description here"></a></p>
<python><django><django-admin><django-authentication>
2016-03-16 20:52:32
HQ
36,047,211
Should i pass a parameter to the class constructor or every method that requires it
<p>I have a class that looks like the following</p> <pre><code>public class OrderBL { private _loggedInUserId; public OrderBL(int loggedInUserId) { _loggedInUserId = loggedInUserId; } public Order GetOrder() { //use logged in user id here } public List&lt;Order&gt; GetOrderList() { //use logged in user id here } public void DeleteOrder() { //use logged in user id here } public void SaveOrder(Order myOrder) { //DON'T use logged in user id here } } </code></pre> <p>Should i be passing the logged in user id to every method or pass it in once to the constructor like i have done?</p> <p>Most methods in my class require the logged in user id but not all.</p>
<java><c#><asp.net-mvc><design-patterns><business-logic>
2016-03-16 21:23:44
LQ_CLOSE
36,047,763
how to direct to a HTML page using a cookie?
<p>i'm working on a site currently that has a 15 second intro on the index.html - with a skip button (that leads to main.html) - and was wondering if it is possible to use a cookie to store info on user and thereby directing them straight to the main page on their second visit to the site?</p> <p>i've been doing webstuff for years but never had the need to use a cookie.</p> <p>anyone?</p>
<javascript><html><redirect><cookies><navigation>
2016-03-16 21:59:53
LQ_CLOSE
36,048,651
Java - Go To Non-Static Void From Static Void?
<p>Well as my code doesn't really help very much, I wont show any unless someone needs to see some.</p> <p>But I'll give an example of what I want to do.</p> <p>Example: "Class1.java"</p> <pre><code>class Class1 { int num = 3 + 2; public static void Main(String[] args) { Class2.Main2(); } } </code></pre> <p>Example: "Class2.java"</p> <pre><code>class Class2 { public void Main2() { System.out.println(Class1.num); // Would return as an error, as you cannot access static objects from non-static objects/methods. } } </code></pre> <p>Anyone know how to allow going from one static method to another non-static method, or vice versa?</p> <p>Thanks.</p>
<java><class><methods><static>
2016-03-16 23:05:30
LQ_CLOSE
36,048,713
3 Arguments - Calculating BMI - Phython
So basically Im trying to create a program which should do the following in phython: A Program that contains a function called calculate_bmi which when it is called, has three arguments - the first argument is an integer variable containing the height in feet, the second argument is an integer variable containing the height in inches, the third argument is the person's weight in pounds. The main program asks the user to enter feet, then inches, then pounds. These variables are then sent to the function. The function calculates and prints the BMI value. This is my code below im trying to do but no luck, i cannot seem to convert the height to feet as well. any help would really be appreciated. def calculate_bmi(): height_feet = int(input("Please enter height in feet")) height_inches = int(input("Please enter height in inches")) weight_pounds = int(input("Please enter weight in pounds")) calculate_bmi(height_feet,height_inches,weight_pounds) bmi = (weight_pounds / height_inches) * 703 print (bmi)
<python><function>
2016-03-16 23:10:25
LQ_EDIT
36,048,977
each letter is node in linked-list, unknown size of word retrieved from user
program is supposed to take word from user (of unknown lenght) then create linked-list, each node should contain one character. It works with pre-declarated word but i am having a problem with "Stack around the variable 'str' was corrupted." if i try to simply cin>>word; Any help would be welcome. #include <iostream> #include <iomanip> #include <stdio.h> using namespace std; struct slistEl { slistEl * next; char data; }; unsigned l_size(slistEl * head) { unsigned c = 0; slistEl * p = head; if (p) do { c++; p = p->next; } while (p != head); return c; } void l_printl(slistEl * head) { slistEl * p; cout << setw(3) << l_size(head) << " ["; p = head; if (p) do { p = p->next; cout << " " << p->data; } while (p != head); cout << " ]\n\n"; } void l_push(slistEl * & head, char v) { slistEl * p = new slistEl; p->data = v; if (head) { p->next = head->next; head->next = p; } else p->next = p; head = p; } void l_pop(slistEl * & head) { if (head) { slistEl * p = head->next; head->next = p->next; if (p->next == p) head = NULL; delete p; } } int main() { slistEl * head = NULL; char str[] = "abcdefgh"; // pre-declarated word //cin >> str; //program should take word from user for (int i = 0; str[i] != '\0'; i++) { l_push(head, str[i]); l_printl(head); } system("PAUSE"); return 0; }
<c++><arrays><list><linked-list>
2016-03-16 23:33:08
LQ_EDIT
36,049,621
Haskell extracting from tuples within a list
<p>I'm a beginner, any help will be appreciated. My goal is to be able to extract the ratings from any given <strong>Film</strong> as a <strong>Float</strong> so I can then manipulate the data properly, for instance give the "average rating" for a film.</p> <pre><code>type Title = String type Director = String type Year = Int type Mark = Int type Rating = (String, Float) -- Define Film type here type Film = (Title, Director, Year, [Rating]) </code></pre> <p>A typical <strong>Film</strong> looks like </p> <pre><code>("True Lies", "James Cameron", 1994, [("Dave",3), ("Kevin",10), ("Jo",0)]) </code></pre> <p>I have tried </p> <pre><code>extractRating :: Film -&gt; [(String, Float)] extractRating (_, _, _, rating) = rating </code></pre> <p>Then calling the function like this</p> <pre><code>putStrLn (extractRating "True Lies") </code></pre> <p>If it helps you help me here this the error dump</p> <pre><code>haskell.hs:82:21: Couldn't match type ‘(String, Float)’ with ‘Char’ Expected type: String Actual type: [(String, Float)] In the first argument of ‘putStrLn’, namely ‘(extractRating "True Lies")’ In a stmt of a 'do' block: putStrLn (extractRating "True Lies") haskell.hs:82:35: Couldn't match type ‘[Char]’ with ‘(Title, Director, Year, [Rating])’ Expected type: Film Actual type: [Char] In the first argument of ‘extractRating’, namely ‘"True Lies"’ In the first argument of ‘putStrLn’, namely ‘(extractRating "True Lies")’ In a stmt of a 'do' block: putStrLn (extractRating "True Lies") </code></pre>
<haskell><tuples>
2016-03-17 00:40:14
LQ_CLOSE
36,049,885
cannot have return value
<p>I'am trying to make code to make array to multidimensional array. I made 12 size of array B and also made array[3][4]. If call function value(B,3,1), it supposed to return value of array[3][1] or B[10]. But my code doesn't work. I cannot have return value. Help me !!</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int value(int *A, int j, int k); void main(void){ int n = 12; int *B; B=(int*)malloc(sizeof(int)*n); int i; printf("12개의 정수를 차례로 입력하시오.\n"); for(i=0; i&lt;n ;i++ ){ fflush(stdout); scanf("%d",&amp;B[i]); } value(B,3,1); //printf("call\n"); } int value(int *A, int j, int k) { int i; int array[4][3]; for(i=0; i&lt;12; i++){ array[i/3][i%3]=A[i]; } for(i=0; i&lt;12; i++){ printf("%d ",array[i/3][i%3]); } return array[j][k]; } </code></pre>
<c><arrays><function><return>
2016-03-17 01:05:46
LQ_CLOSE
36,050,363
Using classes in static main method
<p>So I'm writing a mini-board game program in Java.</p> <p>The program is going to read in standard input and construct a game as directed in the input.</p> <p>To help stay organized and progress my oo java skills, I am using a Cell class to act as a cell in a nxn game.</p> <p>For the board game, I need to have it all in one file, and it must run from static void main.</p> <p>Here's what my Cell class looks like</p> <pre><code>public class Cell{ public int x; public int y; . . . } </code></pre> <p>I want to read the input, and assign values to each cell and then add the cells to a list such as ArrayList allCells. However, I can not the use it in a static context.</p> <p>I understand that static is a single instance, so I'm confused how I would go about doing this. Is there anyway I can use a class-based system to solve this problem. Each cell is it's own individual object, so making it stat wouldn't work.</p> <p>Any sort-of explanation or alternative would be amazing! Hope I was clear enough in my description.</p>
<java><static><main>
2016-03-17 02:02:06
LQ_CLOSE
36,050,461
Is there a way to do css inside an html body?
<p>I'm trying to change the background color multiple times within one page. Is there a way to put CSS in an HTML body?</p>
<html><css><stylesheet>
2016-03-17 02:13:15
LQ_CLOSE
36,050,495
How to make iOS chat instant (real time)?
<p>a part of my app involves building a IM group chat. As right now, I have the whole chat working. However, the problem is that obviously is not instant. It updates in ViewDidLoad(). I know that making it instant is the hardest part in making an IM chat. I'm currently using Parse, and I initially thought of using push notifications to update the page, but Googling a little more I found out that people were saying that there are a few cons in doing that such as the fact that the user would get a crazy number of push notifications. Do you have any idea of how could I approach this problem or how I could get my chat to be in real time?</p> <p>Thanks in advance for the help.</p>
<ios><iphone><swift><parse-platform><chat>
2016-03-17 02:17:15
LQ_CLOSE
36,051,651
Vbscript Split or regex command to pull the task name and lastresult from text file
TaskName=YY_EF LastRunTime="3/14/2016 10:30:00 PM" LastResult=1 TaskCommand="C:\Windows\scripts\Tasks\FC_CREATE" TaskState=Enabled StartTime="10:30:00 PM" RunTime="00:15:00" Days="Every 1 day(s)"
<vbscript>
2016-03-17 04:24:13
LQ_EDIT
36,051,812
how to solve an array using search algorithm of an n elements?
<p>Suppose you have an array of 50 elements and you want to search a target item "x"</p> <p>1.write a search algorithm if each item are sorted using pseudo code </p> <p>2.write a search algorithm if each item are not sorted using pseudo code </p>
<java><data-structures>
2016-03-17 04:39:35
LQ_CLOSE
36,052,158
File handling: creating a single file, storing information (from an array) & retrieving information(from an array)
<p>I am taking a class in Java. I am currently writing a simple game that deals with file handling. One of the requirements is to keep track of player names &amp; scores using an array, storing the array in a file, and retrieving specific information from the array.</p> <p>For example: the game would consist of a persons name along with the amount of points they have. The game would save that to an array in a file. The file can either call that particular person's name &amp; points (to continue playing) OR display the top 10 high scores.</p> <p>How do I do this?</p>
<java><arrays>
2016-03-17 05:13:01
LQ_CLOSE
36,052,669
how to write code for backspace and space in vb .net
i am programming virtual keyboard with images, when i press the key it will display image but am not able to code space and backspace... Dim myDir As String = "C:\Users\ASUBUSU\Desktop\keyboard\java pgm\" Dim img As Image = Image.FromFile(myDir & "sna.png") Dim orgData = Clipboard.GetDataObject Clipboard.SetImage(img) Me.RichTextBox1.Paste() Clipboard.SetDataObject(orgData) how to write code for space and backspace.
<vb.net>
2016-03-17 05:54:35
LQ_EDIT
36,053,302
unable to update on server bt it is working fine on localhost
not working real server but its working fine on localhost > $res=mysql_query("UPDATE ".$table_name." SET item_name='".$name."' > ,item_description='".$item."' ,item_price='".$price."' WHERE > id='".$id."'");
<php><mysql>
2016-03-17 06:41:00
LQ_EDIT
36,054,794
Java Recursion Method That Doubles An Amount
<p>If you work for a month and first day you get paid 1 cent and day two 2 cents. Each day the amount doubles. And the user input a day and it will display how much money you will be paid in that day.</p> <p>How can this be done with recursion.</p> <p>Thank you.</p>
<java><recursion>
2016-03-17 08:09:25
LQ_CLOSE
36,056,170
I want to rename all my objects in maya but somethings is locked that I can t do it
[enter image description here][1] It is stocked in head one and it only transform Ghoul and SHJnt. In addition,I try to compile it by function one by one. and editor told me that I can t rename which is locked. How to solve this problem! thank u so much! [1]: http://i.stack.imgur.com/EbCNu.jpg
<python><maya>
2016-03-17 09:18:01
LQ_EDIT
36,056,400
I am not able to install XAMPP on my system windows 7 32 bit
I am not able to install XAMPP on my system windows 7 32 bit ...the problem is after installing everything is working okay but appache is not running or starting..it is just showing notification that apache is starting but it never does ...I think My system is missing Port 80 which is used by Apache server to run ...even i checked it on my system but there is no such port 80 on my system how to resolve this issue please somebody help me ASAP
<apache><xampp>
2016-03-17 09:27:53
LQ_EDIT
36,057,252
How to use array_slice in this type $_POST['MetaData']['video_title'][$index]
<p>How to use array_slice in this type of array $_POST['MetaData']['video_title'][$index]</p>
<php><arrays><yii><slice>
2016-03-17 10:04:23
LQ_CLOSE
36,057,368
Trying to convert from mysqli to pdo
<pre><code>try { $pdo = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbusername, $dbpassword); } catch (PDOException $e){ exit('Datebase error.'); } // db login info is already defined, just didnt post it here $username = $_GET["user"]; $password = $_GET["passwd"]; //$data = mysqli_query($mysqli, "SELECT * FROM users WHERE username='".$username."'"); //$hash = mysqli_fetch_object($data); $query = "SELECT username, password, loginreqkey, banned FROM users WHERE username='$username'"; //if (password_verify('rasmuslerdorf', $hash)) { if ($stmt = $pdo-&gt;prepare($query)) { $stmt-&gt;execute(array($username, $password, $loginreqkey, $banned)); //$stmt-&gt;bind_result($username, $password, $loginreqkey, $gbanned); // $result = $stmt-&gt;fetch(PDO::FETCH_LAZY); //$dt = $stmt-&gt;fetchAll() ; //$query-&gt;execute(array($username, $password)); if (password_verify($password, $result['password'])) { while($r = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC)){ echo "{"; echo '"state": "success",'; echo '"loginreqkey": "' . $r['loginreqkey'] . '",'; echo '"banstatus": "' . $r['banned'] . '"'; echo "}"; } /* close statement */ $stmt = null; } else { die("fake pw lol"); } /* close connection */ $pdo = null; } //} </code></pre> <p>Trying to convert my code from MySQLi to PDO and having issues.. trying to get all the information in query and verify the user password then echo the rest of the information, (for an unreal project) tried a couple of solutions on php documentation and stackoverflow but they were usually just for sending information to the mysql server.</p>
<php><mysql><mysqli><pdo>
2016-03-17 10:09:26
LQ_CLOSE
36,057,649
how to populate treeview two tables using vb.net
Hello i have this two table [Department Table][1] [subDepartment table][2] then i want this result using treeview **id** **department** **category** 1 MIS System 1 MIS Networking 1 MIS Programmer 2 Audit Operations 2 Audit DS 3 HRD PA 3 HRD PayBen 3 HRD PS 3 HRD PLD 4 Acounting Sup 4 Acounting FMCG 5 Procurement NULL or like this MIS -System -Networking -Programmer AUDIT -Operations -DS HRD -PA -PayBen -PS -PLD Acounting -Sup -FMCG can please guide me thank you. im having trouble finding any solution in the internet. and im newbei in vb.net language. [1]: http://i.stack.imgur.com/DwXUN.jpg [2]: http://i.stack.imgur.com/QIICZ.jpg [3]: http://i.stack.imgur.com/zy89e.jpg
<vb.net><treeview>
2016-03-17 10:21:48
LQ_EDIT
36,057,806
The ability to fight with Ad-Blocker
<p>I had searched by google and this forum-search and I didnt get any about this so I propose a new topic: WordPress with the ability to fight with Ad-Blocker.</p> <p>I am not an IT guy (subsea engineer) but I am having <a href="http://interresults2015.in/" rel="nofollow">website</a> with about 100 - 200 unique visitor/day now (according to adsense) as hobby (1%-4% using ad-blocker - I am lucky to have these ~97% my visitors).</p> <p>I just learn that ad-block users are about 300 mil and it is a huge problem to big publisher (they earn money from ads). Ad-blocker using bandwith, upload data to their server and some (one of them - I expect more of them) sell the data as anons.</p> <p>In accordance to the above idea, I have a question as a-non IT guys, is there a way to make WordPress to tackle ad-blocker (auto)?</p> <p>It may be a way to disarm ad-blocker. My website is like my home/house. You/Visitors can visit but please consider the owner.</p>
<php><html>
2016-03-17 10:28:22
LQ_CLOSE
36,058,570
swift - how to go to another view controller during pressing the button. I don't have storyboard. Pragmatically
i have a button which is located on superview let buttonSignUp = UIButton() self.view.addSubview(buttonSignUp) When I press this button I want to go to another view controller scene
<ios><swift><button>
2016-03-17 10:59:15
LQ_EDIT
36,058,621
how to include a csv file in matplotlib using pandas?
my csv file is very complex.. it contains numeric as well as string attributes. [enter image description here][1] this is how my csv file looks like I want to plot a histogram of processes versus the cpuid [1]: http://i.stack.imgur.com/EZOD8.png
<python><csv><pandas><matplotlib><histogram>
2016-03-17 11:01:05
LQ_EDIT