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
40,045,857
Live video streaming with HTML 5?
<p>I want to make <strong>live video streaming</strong>. For example there is discussion. And somebody is recording it. I want the video record to appear on my web page. I want to do this with <strong>HTML 5</strong>. I don't know if it's possible, but has anyone tried ? <strong><em>Thank you in advance!</em></strong></p>
<html><video-streaming><html5-video><live-streaming>
2016-10-14 14:39:00
HQ
40,045,920
Laravel 5.3 - htmlspecialchars() expects parameter 1 to be string
<p>I am new to laravel and I am enjoying it. While working on a social media project I got this error: <code>htmlspecialchars() expects parameter 1 to be string, object given (View: C:\wamp64\www\histoirevraie\resources\views\user\profile.blade.php)</code></p> <p>I have checked some questions on this site but I have not found a question that solves my problem.</p> <p>this is what my <code>profile.blade.php</code> is made of:</p> <pre><code>&lt;ul class="profile-rows"&gt; &lt;li&gt; &lt;span class="the-label"&gt;Last visit: &lt;/span&gt; &lt;span class="the-value mark green"&gt;{{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $user-&gt;lastVisit)-&gt;diffForHumans(\Carbon\Carbon::now())}}&lt;/span&gt; &lt;/li&gt; &lt;li&gt; &lt;span class="the-label"&gt;Member since: &lt;/span&gt; &lt;span class="the-value mark light-gray"&gt;{{ $user-&gt;created_at-&gt;format('F Y') }}&lt;/span&gt; &lt;/li&gt; &lt;li&gt; &lt;span class="the-label"&gt;Profile views: &lt;/span&gt; &lt;span class="the-value mark light-gray"&gt;5146&lt;/span&gt; &lt;/li&gt; &lt;li&gt; &lt;span class="the-label"&gt;Living In: &lt;/span&gt; &lt;span class="the-value"&gt;{{ $user-&gt;town }}&lt;/span&gt; &lt;/li&gt; &lt;li&gt; &lt;span class="the-label"&gt;Website: &lt;/span&gt; &lt;span class="the-value"&gt;&lt;a href="{{ url($user-&gt;website) }}"&gt;{{ $user-&gt;website }}&lt;/a&gt;&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>All the information about the user are given by a controller:</p> <pre><code>public function index($username){ $user = User::where('username', $username)-&gt;first(); return view('user.profile', compact('user')); } </code></pre> <p>Kindly help me solve this problem!</p>
<php><laravel-5.3>
2016-10-14 14:41:23
HQ
40,046,598
MSAL or ADAL library for use with Azure AD B2C and Xamarin
<p>As of October 2016, is it still the case that the Microsoft Authentication Library (MSAL - NuGet package: <em>Microsoft.Identity.Client</em>) is the correct/only library to use with Xamarin (iOS/Android) and the Azure AD B2C service? This library (MSAL) is only available as an alpha and does not appear to be in a state of being actively maintained or developed (since April).</p> <p>There are indications that the Active Directory Authentication Library (ADAL - NuGet package: <em>Microsoft.IdentityModel.Clients.ActiveDirectory</em>) is intended as Microsoft's "one-Azure-authentication-library-to-rule-them-all", and it supports Xamarin; it is also being actively maintained and is not in "alpha" or "beta" status.</p> <p>Understanding that Microsoft has in the past pointed Azure AD B2C developers towards using the MSAL library, is it possible to authenticate Azure AD B2C users in a Xamarin app using the ADAL library instead? Are there blogs or sample code that someone could point me to, that would demonstrate how to do this?</p>
<azure><authentication><xamarin><adal><msal>
2016-10-14 15:16:24
HQ
40,046,764
Is it possible to have a comment inside a es6 Template-String?
<p>Let's say we have a multiline es6 Template-String to describe e.g. some URL params for a request:</p> <pre><code>const fields = ` id, message, created_time, permalink_url, type `; </code></pre> <p>Is there any way to have comments inside that backtick Template-String? Like:</p> <pre><code>const fields = ` // post id id, // post status/message message, // ..... created_time, permalink_url, type `; </code></pre>
<javascript><ecmascript-6><backticks><template-strings>
2016-10-14 15:24:30
HQ
40,046,786
Windows Bash (WSL) - sudo: no tty present and no askpass program specified
<p>After following <a href="http://www.omgubuntu.co.uk/2016/08/upgrade-bash-windows-10-ubuntu-16-04-lts" rel="noreferrer">this tutroial</a> I get the following error when trying to run the commands as user or even sudo:</p> <blockquote> <p>sudo: no tty present and no askpass program specified</p> </blockquote> <p>The comments from <a href="http://www.omgubuntu.co.uk/2016/08/upgrade-bash-windows-10-ubuntu-16-04-lts#post-2819669254" rel="noreferrer">Lurdan</a> in this article state that you need to run </p> <pre><code>sudo -S &lt;YOUR_COMMAND&gt; chmod 0666 /dev/tty </code></pre> <p><code>chmod</code> doesn't work but <code>sudo -S</code> does, but surely there's another fix?</p>
<linux><bash><ubuntu><ubuntu-16.04><windows-subsystem-for-linux>
2016-10-14 15:25:29
HQ
40,046,861
php html dynamicly add to end of list items
i have some data on server side on database like person info. i like to at the first view, show e.g 3 person info on list like placement. OK i can do this by write query for read from database and write "for" in php and write html code and echo to fill 3 list item. OK now i need add link like "more persons" below this tree output and when user clicked this link php shows other persons info at the end of previous 3 person info without refresh page or redirecting. how can do that? thanks and sorry for English grammar mistakes
<php><list>
2016-10-14 15:28:45
LQ_EDIT
40,047,297
How can I manage my own page with facebook graph api?
<p>I'm building a website, and the website has a running facebook page. I want to be able to post to my page from my cms.</p> <p>The problem is that for getting those permissions I must approve my facebook app the they require things like a screencast of how users are going to login to my app etc.</p> <p>Is there a simple way to generate an access token for my own page so I can make api calls to manage it?</p> <p>Daniel.</p>
<php><facebook><facebook-graph-api>
2016-10-14 15:50:52
LQ_CLOSE
40,047,347
I receive NULL values when trying to send Ajax Jquerry parameters in POST request - MVC CORE
so i'm a little new to MVC core. My requirement is the following: I have a "Contact.cshtml" view which contains a contact form. After the user fills the contact form and clicks the "submit" button, I want to send the entered form parameters to the controller with the Ajax Jquerry Post method, and then send feedback back to the user without refreshing the page. My Controller Method: [HttpPost] public IActionResult Contact(string name, string email, string subject, string message) { // Future code will be entered here and do some logic with the parameters // This will be replaced with a call to a partial View which contains a success message return View(); } Part of my Contact.cshtml file: <form method="post" role="form" id="contactForm"> <div class="form-group"> <label for="name">השם שלך</label> <input type="text" class="form-control" id="name"> </div> <div class="form-group"> <label for="email">כתובת מייל</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="subject">נושא</label> <input type="text" class="form-control" id="subject"> </div> <div class="form-group"> <label for="message">הודעה</label> <textarea class="form-control" id="message" rows="3"></textarea> </div> <button type="submit" class="btn btn-theme">שלח</button> </form> @section scripts { <script> $('#contactForm').submit(function () { $.post('', { "name": $('#message').toString(), "email": $('#email').toString(), "subject": $('#subject').toString(), "message": $('#message').toString() }).done(function (response) { alert("success"); }) }); </script> } **I spent Hours on this issue, but I always, and i mean always, receive NULL values for ALL of the form fields in the controller handling method, so please help me, thanks**
<jquery><ajax><post><asp.net-core><asp.net-core-mvc>
2016-10-14 15:52:47
LQ_EDIT
40,047,622
Failed to load list of databases
<p>I want to connect to a remote database using Robomongo. I can connect to to database but an error says that:<br> Failed to load list of databases<br> <a href="https://i.stack.imgur.com/insQh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/insQh.png" alt="enter image description here"></a></p> <p>What should I do?</p>
<mongodb><robo3t>
2016-10-14 16:09:18
HQ
40,047,679
return ture if first string contain all letters of second string
<p>I have to check if one string contain all letters of other string . example : string 1 = "mary"; string 2 = "aarmy"; should return true; I tried to indexOf method but this will check only entire string in same order. please suggest me any solution.</p>
<javascript><string>
2016-10-14 16:12:13
LQ_CLOSE
40,047,758
how to convert string with format HH:MM:SS to NSDate objective c?
Stored time in the string format HH:MM:SS from json responce. I want to convert it NSDate for local notification. tried NSString *datestr = @"21:00:00"; NSDateFormatter *dateformat = [[NSDateFormatter alloc]init]; [dateformat setDateFormat:@"hh:mm:ss"]; NSDate *date = [dateformat dateFromString:datestr]; NSLog(@"time is %@",date); Getting Null time . I have time format from json is in 21:00:00 format only no date . Want to set this time for Local Notification everyday . Thanks In Advance.
<ios><objective-c><nsdateformatter>
2016-10-14 16:17:28
LQ_EDIT
40,048,800
Can i program games with unity by python ?? I don't know c#
<p>I want to start 3d games programming , should I start 2d first ? please give me useful course . Does unity accept python ? If not , what do you prefer( directpython, openlg,panda3d ) Please give me useful course . I'm beginner Sorry about my bad English And what is game engine</p> <p>If you know only one answer please answer :) </p>
<python><pygame><game-engine><panda3d><gameplay3d>
2016-10-14 17:24:10
LQ_CLOSE
40,049,454
Login with Node.js
<p>I want to do a POST action with node.js with a command line application. The goal is to login to <a href="http://hbeta.net" rel="nofollow">http://hbeta.net</a> (I want to create a application that post the username and the password automaticly) thanks ;)</p>
<javascript><node.js>
2016-10-14 18:04:16
LQ_CLOSE
40,049,877
Dynamically creating list in a dictionary using Python
<p>I have thousands of products with ingredients of each for example:</p> <pre><code>ProductID | Ingredients 00001 | itemA, itemB, itemC, itemD 00002 | itemF, itemD, itemG, itemA, itemI 00003 | itemH, itemI, itemD, itemF, itemT,itemB, itemC </code></pre> <p>........ and so on.</p> <p>I want to make a unique list of ingredients and make a map that what ingredients are in which product. So For example I want the resulting output in the following way:</p> <pre><code>{itemA: [00001,00011, 00005,00007]} {itemB: [00003, 00002, 000056]} {itemC: [00009, 00087, 00044, 00647, 00031, 00025]} </code></pre> <p>So the list size will be different for each item. Can somebody help me out in solving this problem? Thanks</p>
<python><dictionary>
2016-10-14 18:30:36
LQ_CLOSE
40,050,753
ASP.NET Core MVC scheduled task
<p>I need to run a scheduled task on every new day in asp.net mvc core application. Can I do it, and how?!</p> <p>thnx</p>
<asp.net-core><scheduled-tasks>
2016-10-14 19:33:08
HQ
40,051,113
I would like to combine output of below script in one text file - Powershell
enter code here Write-Host "Drive information for $env:ComputerName" Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DriveType -ne 5} | Sort-Object -Property Name | Select-Object Name, VolumeName, VolumeSerialNumber,SerialNumber, FileSystem, Description, VolumeDirty, ` @{"Label"="DiskSize(GB)";"Expression"={"{0:N}" -f ($_.Size/1GB) -as [float]}}, ` @{"Label"="FreeSpace(GB)";"Expression"={"{0:N}" -f ($_.FreeSpace/1GB) -as [float]}}, ` @{"Label"="%Free";"Expression"={"{0:N}" -f ($_.FreeSpace/$_.Size*100) -as [float]}} | Format-Table -AutoSize =========================== gcim Win32_OperatingSystem | f1 * | f1 > info.txt; notepad.exe info.txt
<powershell>
2016-10-14 20:00:16
LQ_EDIT
40,051,183
sendBeacon request stuck as "(pending)" when attached to unload event
<p>When I call navigator.sendBeacon directly in the console, I immediately see the request in the Chrome dev tools Network pane complete successfully.</p> <p>When I use code like what's below to attach sendBeacon to the beforeunload event and then navigate away from the page, I see a row added to the Network pane but its status stays stuck at "(pending)" and never sends.</p> <p>What am I doing wrong?</p> <pre><code> window.addEventListener('beforeunload', function() { navigator.sendBeacon( 'https://www.example.com/sendBeacon-data-collector', 'Sent by a beacon!'); }, false); </code></pre>
<javascript>
2016-10-14 20:04:55
HQ
40,051,226
what does this mean "public static ImageResource makeGray(ImageResource inImage)"
<p>public static ImageResource makeGray(ImageResource inImage){}</p> <p>ImageResource is a class.</p> <p>makeGray is a method.</p> <p>why put a class in front of method?</p>
<java><class><methods>
2016-10-14 20:08:04
LQ_CLOSE
40,055,439
Check if Logged in - React Router App ES6
<p>I am writing a <strong>React</strong>.js application (v15.3) using <strong>react-router</strong> (v2.8.1) and <strong>ES6 syntax</strong>. I cannot get the router code to intercept all transitions between pages to check if the user needs to login first.</p> <p>My top level render method is very simple (the app is trivial as well):</p> <pre><code> render() { return ( &lt;Router history={hashHistory}&gt; &lt;Route path="/" component={AppMain}&gt; &lt;Route path="login" component={Login}/&gt; &lt;Route path="logout" component={Logout}/&gt; &lt;Route path="subject" component={SubjectPanel}/&gt; &lt;Route path="all" component={NotesPanel}/&gt; &lt;/Route&gt; &lt;/Router&gt; ); } </code></pre> <p>All the samples on the web use ES5 code or older versions of react-router (older than version 2), and my various attempts with mixins (deprecated) and willTransitionTo (never gets called) have failed.</p> <p>How can I set up a global 'interceptor function' to force users to authenticate before landing on the page they request?</p>
<javascript><authentication><reactjs><ecmascript-6><react-router>
2016-10-15 05:42:02
HQ
40,055,764
Setting arrays in Firebase using Firebase console
<p>I am using Firebase console for preparing data for a demo app. One of the data item is attendees. Attendees is an array. I want to add a few attendees as an array in Firebase. I understand Firebase does not have arrays, but object with keys (in chronological order). How do I do that for preparing sample data? My current Firebase data looks like the below. <a href="https://i.stack.imgur.com/bfoeC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bfoeC.png" alt="enter image description here"></a></p>
<arrays><firebase><firebase-realtime-database><firebase-console>
2016-10-15 06:28:14
HQ
40,056,150
Remove label section from paper-textarea
<p>I'd like to remove the extra space that the label takes up in a polymer text-area. Is this possible? Thank you.</p>
<css><polymer-1.0>
2016-10-15 07:09:28
LQ_CLOSE
40,056,330
sql query to get all rows if there is no matching row in left join
I've table structure like this: person (pid, pname) personSamples(sid,pid,sampleName) groups(gid,groupName) groupPersons(gpid,gid,pid) grouppersonSamples(gpsid,gid,sid) Whenever a person is added to a group i.e. in groupPersons table, I add some selected samples of person in grouppersonSamples table. The requirement is, if I do not insert any row in grouppersonSamples then select all from personSamples for a given person and group. What I have to do is left join with grouppersonSamples and check if there is no matching row in grouppersonSamples then execute another query to select all from personSamples for given pid. Is there any way to get all in single query?
<mysql><sql>
2016-10-15 07:27:52
LQ_EDIT
40,056,341
golang: How do you connect to multiple MySQL databases in Go?
<p>operating 3 or more database at the same time, Read/Write Splitting, have connection pool.</p>
<mysql><go>
2016-10-15 07:29:02
LQ_CLOSE
40,056,813
What does the following segment do - Pyhon
I have a problem with the following function.. I can't understand what it does, because I'm new to Python, can you help me, please. Thanks in advance. def foo(limit): a = [True] * limit a[0] = a[1] = False for (i,b) in enumerate(a): if b: yield i for n in xrange(i*i,limit,i): a[n] = False
<python>
2016-10-15 08:26:51
LQ_EDIT
40,056,923
What is the logic of ATM machines?
<p>I am developing some basic applications.But i want to learn about the systems like ATM machines. There is PC in it and it's always running the bank's application and there is no desktop,no main menu,no other things except the choosen application. <br> So what is the OS generally used for this systems? Is it linux? <br> Are they building OS from scracth ? <br> What is the general names of this systems ? Is it "embedded systems"?</p>
<linux><embedded>
2016-10-15 08:40:30
LQ_CLOSE
40,057,130
About inheritance of java
<p>/** * Created by zhangzhongzheng on 2016/10/15. */</p> <p>public class ExtendsTest {</p> <pre><code>static Dog d = new Dog(); public static void main(String[] args) { Animal a = d; System.out.println(a instanceof Animal);//true System.out.println(a instanceof Dog);//true System.out.println(d instanceof Animal);//true System.out.println(d instanceof Dog);//true } static class Animal { } static class Dog extends Animal { } </code></pre> <p>}</p> <p>why all true??????</p>
<java>
2016-10-15 09:04:48
LQ_CLOSE
40,057,476
php Laravel- A non well formed numeric value encountered (on string)
<p>I have two function in my controller and service. I want to call a function in service. Here is my code : </p> <p><strong>Controller:</strong></p> <pre><code>public function findNeighborhoodGet(): array { $regionCenter = Request::get('region_center'); $distanceService = \App::make('App\web\one\Infrastructure\Service\Google\Map'); try { $userPoint = $distanceService-&gt;getOriginPoint($regionCenter); } . . . return $result } </code></pre> <p><strong>my service (Map.php) :</strong></p> <pre><code>public function getOriginPoint(string $origin):Point { dd($origin); return $this-&gt;getPointObject($origin); } </code></pre> <p>Actually , I get an error :</p> <pre><code>A non well formed numeric value encountered </code></pre> <p>at this line: <em>public function getOriginPoint(string $origin):Point</em></p> <p>How to solve it?</p>
<php><laravel>
2016-10-15 09:43:42
HQ
40,057,798
Firebase Token Authentication error
<p>I am using firebase storage to upload files , but when I upload I am getting this error</p> <pre><code>E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.android.gms.internal.zzand: Please sign in before trying to get a token. </code></pre> <p>I googled it but couldn't get answer for it! I have signed in, in firebase.</p>
<android><firebase><firebase-realtime-database><firebase-storage>
2016-10-15 10:18:18
HQ
40,057,854
What do JSONSerialization options do and how do they change jsonResult?
<p>I am using <code>JSONSerialization</code> quite often in my project. Here is an example of my <code>JSONSerialization</code> code:</p> <pre><code>let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String: Any] </code></pre> <p><strong>Note</strong>: Options are missing for purpose and I normally have them in my project.</p> <p>My problem is that I am not pretty sure what do these <code>options: []</code> do? </p> <p><strong>What I have found about options:</strong></p> <p><strong>NSJSONReadingMutableContainers:</strong> </p> <blockquote> <p>Specifies that arrays and dictionaries are created as mutable objects.</p> </blockquote> <p><strong>NSJSONReadingMutableLeaves:</strong></p> <blockquote> <p>Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.</p> </blockquote> <p><strong>NSJSONReadingAllowFragments:</strong></p> <blockquote> <p>Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary.</p> </blockquote> <p><strong>Note2</strong>: I found those definitions on : <a href="https://developer.apple.com/reference/foundation/nsjsonreadingoptions" rel="noreferrer">https://developer.apple.com/reference/foundation/nsjsonreadingoptions</a></p> <p><strong>My question is</strong>: Can someone please explain me differences between those options , what should I use them for and if you could show me some code example of those options it would be perfect :).</p> <p>Any help appreciated.</p> <p>Thanks.</p>
<ios><json><swift><swift3>
2016-10-15 10:24:18
HQ
40,058,407
Newline Text Node
i have this code and i want to new line in Text Node. its now working :( your help please....... <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> // Create a new list item when clicking on the "Add" button function newElement() { var li = document.createElement("li"); var inputText = document.getElementById("myInput").value + document.createElement("br") + "ddd" ; var t = document.createTextNode(inputText); li.appendChild(t); li.value = document.getElementById("myValue").value; if (inputText === '') { alert("You must write something!"); } else { updateLI(li); document.getElementById("myUL").appendChild(li); } document.getElementById("myInput").value = ""; document.getElementById("myValue").value = ""; } <!-- end snippet -->
<javascript><textnode>
2016-10-15 11:23:06
LQ_EDIT
40,059,107
How to iterate array inside array in java script
<p>Can anybody tell how to iterate array inside array in java script</p> <p>eg Var a =[1,3,[6],7,[8]] </p> <p>Thanks</p>
<javascript><angularjs>
2016-10-15 12:37:34
LQ_CLOSE
40,059,151
Can you export/migrate users out of AWS cognito, does it cause vendor lock-in?
<p>This is a question about vendor lock in and AWS cognito. Can user data and encrypted/hashed passwords be exported out of cognito if we ever move off of AWS?</p> <p>Can/does cognito use standard hashing or configurable hashing of the user passwords or allow export of things like tokens?</p>
<amazon-web-services><amazon-cognito>
2016-10-15 12:41:54
HQ
40,059,745
NGINX: connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory)
<p>I'm trying to follow <a href="https://www.digitalocean.com/community/tutorials/how-to-deploy-a-basic-php-application-using-ansible-on-ubuntu-14-04" rel="noreferrer">this Ansible tutorial</a> while adjusting it for Ubuntu 16.04 with php7. Below this message you'll find my Ansible file. After running it and trying to visit the page in the browser I get a 404, and the following in the nginx error logs:</p> <blockquote> <p>2016/10/15 13:13:20 [crit] 28771#28771: *7 connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 93.xxx.xxx.xx, server: 95.xx.xx.xx, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.0-fpm.sock:", host: "95.xx.xx.xx"</p> </blockquote> <p>So I checked if the socket file exists, and it seems to exist, but <code>ls</code> behaves weird:</p> <pre><code>$ sudo ls -l /var/run/php total 4 -rw-r--r-- 1 root root 5 Oct 15 13:00 php7.0-fpm.pid srw-rw---- 1 www-data www-data 0 Oct 15 13:00 php7.0-fpm.sock $ sudo ls -l /var/run/php7 ls: cannot access '/var/run/php7': No such file or directory $ sudo ls -l /var/run/php7.0-fpm.sock ls: cannot access '/var/run/php7.0-fpm.sock': No such file or directory </code></pre> <p>Why can <code>ls</code> find the socket file if I search it by part of the name <code>php</code> while it cannot find the socket file when I list more than that <code>php7</code> or even the full name <code>php7.0-fpm.sock</code>?</p> <p>And most importantly, how can I make this work with nginx? All tips are welcome!</p> <p>below I pasted my Ansible file</p> <pre><code>--- - hosts: php become: true tasks: - name: install packages apt: name={{ item }} update_cache=yes state=latest with_items: - git - mcrypt - nginx - php-cli - php-curl - php-fpm - php-intl - php-json - php-mcrypt - php-mbstring - php-sqlite3 - php-xml - sqlite3 - name: enable mbstring shell: phpenmod mbstring notify: - restart php7.0-fpm - restart nginx - name: create /var/www/ directory file: dest=/var/www/ state=directory owner=www-data group=www-data mode=0700 - name: Clone git repository git: &gt; dest=/var/www/laravel repo=https://github.com/laravel/laravel.git update=no become: true become_user: www-data register: cloned - name: install composer shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer args: creates: /usr/local/bin/composer - name: composer create-project composer: command=create-project working_dir=/var/www/laravel optimize_autoloader=no become: true become_user: www-data when: cloned|changed - name: set APP_DEBUG=false lineinfile: dest=/var/www/laravel/.env regexp='^APP_DEBUG=' line=APP_DEBUG=false - name: set APP_ENV=production lineinfile: dest=/var/www/laravel/.env regexp='^APP_ENV=' line=APP_ENV=production - name: Configure nginx template: src=nginx.conf dest=/etc/nginx/sites-available/default notify: - restart php5-fpm - restart nginx handlers: - name: restart php7.0-fpm service: name=php7.0-fpm state=restarted - name: restart nginx service: name=nginx state=restarted - name: reload nginx service: name=nginx state=reloaded </code></pre>
<php><linux><sockets><nginx><ansible>
2016-10-15 13:42:41
HQ
40,059,929
Cannot find the UseMysql method on DbContextOptions
<p>I am playing around with the dotnet core on linux, and i am trying to configure my DbContext with a connection string to a mysql Server. </p> <p>my DbContext looks like so:</p> <pre><code>using Microsoft.EntityFrameworkCore; using Models.Entities; namespace Models { public class SomeContext : DbContext { //alot of dbSets... public DbSet&lt;SomeEntity&gt; SomeDbSet { get; set; } public EsportshubContext(DbContextOptions&lt;SomeContext&gt; options) : base(options) { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseMysql //Cannot find this method } protected override void OnModelCreating(ModelBuilder modelBuilder) { //using modelBuilder to map some relationships } } } </code></pre> <p>My dependencies looks like so:</p> <pre><code>"dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" }, "Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Configuration.CommandLine": "1.0.0", "Microsoft.AspNetCore.Mvc":"1.0.0", "Microsoft.EntityFrameworkCore": "1.0.1", "MySql.Data.Core": "7.0.4-ir-191", "MySql.Data.EntityFrameworkCore": "7.0.4-ir-191" }, </code></pre> <p>I also tried to use the mysql server in my Startup.cs in the following code</p> <pre><code>public class Startup { public void ConfigureServices(IServiceCollection services) { var connection = @"Server=(localdb)\mssqllocaldb;Database=EFGetStarted.AspNetCore.NewDb;Trusted_Connection=True;"; services.AddDbContext&lt;EsportshubContext&gt;(options =&gt; options.UseMysql); //Cannot find UseMysql* } </code></pre> <p>I tried to change my directive from </p> <pre><code>using Microsoft.EntityFrameworkCore; </code></pre> <p>to </p> <pre><code>using MySQL.Data.EntityFrameworkCore; </code></pre> <p>Which makes sense? maybe? but then all of the references to DbContext and DbSet is gone, so i suppose the solution is a mix of sorts??</p>
<c#><mysql><entity-framework><asp.net-core>
2016-10-15 13:58:54
HQ
40,061,129
How to create higher order components in Angular 2
<p>Higher Order Components (HOC) is a pattern common among React community. See <a href="https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e#.m111af95l" rel="noreferrer">this article</a> if you don't know what's a HOC</p> <p>Do they make sense in Angular 2? How to make a HOC? Any examples?</p>
<angular>
2016-10-15 15:51:56
HQ
40,061,755
R define breaks
<p>I want to define the following 6 breaks in R:</p> <pre><code>[00,10) [10,20) [20,30) [30,40) [40,50) [50,60) </code></pre> <p>If I write <code>breaks=seq(from = 0, to = 60, by = 10)</code> I get the following </p> <pre><code>(0,10] (10,20] (20,30] (30,40] (40,50] (50,60] </code></pre> <p>How could I get it?</p>
<r>
2016-10-15 16:54:45
LQ_CLOSE
40,062,298
"resolved attribute(s) missing" when performing join on pySpark
<p>I have the following two pySpark dataframe:</p> <pre><code>&gt; df_lag_pre.columns ['date','sku','name','country','ccy_code','quantity','usd_price','usd_lag','lag_quantity'] &gt; df_unmatched.columns ['alt_sku', 'alt_lag_quantity', 'country', 'ccy_code', 'name', 'usd_price'] </code></pre> <p>Now I want to join them on common columns, so I try the following:</p> <pre><code>&gt; df_lag_pre.join(df_unmatched, on=['name','country','ccy_code','usd_price']) </code></pre> <p>And I get the following error message:</p> <pre><code>AnalysisException: u'resolved attribute(s) price#3424 missing from country#3443,month#801,price#808,category#803,subcategory#804,page#805,date#280,link#809,name#806,quantity#807,ccy_code#3439,sku#3004,day#802 in operator !EvaluatePython PythonUDF#&lt;lambda&gt;(ccy_code#3439,price#3424), pythonUDF#811: string;' </code></pre> <p>Some of the columns that show up on this error, such as price, were part of another dataframe from which <code>df_lag</code> was built from. I can't find any info on how to interpret this message, so any help would be greatly appreciated.</p>
<apache-spark><pyspark><spark-dataframe>
2016-10-15 17:47:16
HQ
40,063,460
How do BluRay players or washing machine run Java programs?
<p>What OS do they use for example and how to they boot up so quickly (compared to a raspberry pi)?</p>
<java>
2016-10-15 19:42:35
LQ_CLOSE
40,063,649
Swift: create object from primitive value
<p>I'm not entirely sure that what I want to do is possible to implement currently, however I hope that it is.<br> Basically, I would like to have some mechanism for a bit shorter object creation for primitive. Let me explain. Consider we have some kind of wrapper around Int:</p> <pre><code>class Wrapper { var value: Int = 0 init(value: Int) { self.value = value } } </code></pre> <p>And then instead of creating object with init, i.e:</p> <pre><code>let wrapper = Wrapper(value: -1) </code></pre> <p>I would like to do something like this:</p> <pre><code>let wrapper: Wrapper = -1 </code></pre> <p>Or:</p> <pre><code>var array = [Wrapper]() array.append(-1) </code></pre> <p>It would short declarations quite heavily, especially in case with arrays.<br> Interesting note: I've tested code above with CGFloat i.e:</p> <pre><code>let val: CGFloat = 0.0 var array = [CGFloat]() array.append(0.0) </code></pre> <p>and all seems to be working fine. However I'm not entirely sure that there is way in language that allow to create such behaviour for custom object and it's why I'm asking about it basically. I've reviewed sources of CGFloat, but didn't saw anything that seems to be related to functionality that i want to achieve (beside NativeType alias may be, but I didn't understand how it would work).</p>
<swift>
2016-10-15 20:01:35
LQ_CLOSE
40,064,474
Multiple if Statments issue
I am having a problem with multiple if statements. I am using && but it seems to only work for the first statement. The code is like such: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> global $post; $args = array( 'post_id' => $post->ID ); $comment = get_comments( $args ); $user = wp_get_current_user(); if ( 3 <= count( $comment ) && $post->post_author == $user->ID) { echo do_shortcode( '[button]' ); } else { comment_form(); } <!-- end snippet --> It basically stats that if there is less than 3 comments then show the comment form but if there is more than 3 and is the post author then show a button. The button shows but only if there are more than 3 comments. It doesn't check if it is only the post author or not, like i want it to.
<php><if-statement><statements>
2016-10-15 21:37:28
LQ_EDIT
40,064,654
Trying to create a image slider without jquery
So trying to get this image slider to work without jquery. using font awesome icons as my next and previous buttons.When i change the value of the imgCounter variable the image changes however i cant get it to work properly. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var $= function(id){ return document.getElementById(id); } var imgCounter=0; var next = function(){ if(imgCounter<6){ imgCounter++; } else{ imgCounter=0; } } window.onload=function(){ // where image will display var imageNode = $('display'); var slideNode=$('slides'); // gathers all the images in an array var slides = document.getElementsByClassName('img'); `` //to target a specific index imgCounter= imgCounter% slides.length; var image= slides[imgCounter]; //to switch the current photo with the next one in the array imageNode.src=image.src; $('right').onclick= next; }; <!-- language: lang-html --> <section id="slider"> <img id="display" src=""> <i id="left"class="fa fa-arrow-left fa-4x"aria-hidden="true" ></i> <i id="right" class="fa fa-arrow-right fa-4x" aria-hidden="true"></i> <div id="slides"> <img class="img" src="images/20anniversary-large.png"> <img class="img"src= "images/53rd.jpg"> <img class="img"src="images/Award.png"> <img class="img"src="images/rotator-03-lg.jpg"> <img class="img"src= "images/rotator01lg.jpg"> <img class="img"src="images/rotator-02-lg.jpg"> </div> </div> </section> <!-- end snippet -->
<javascript>
2016-10-15 21:59:49
LQ_EDIT
40,064,779
Google Maps GMSMapView on custom UIView
<p>I want to display google maps on a view that's then added to <code>self.view</code>, rather than drawing the map directly on <code>self.view</code>. Therefore, I created a view in storyboard and changed its class to <code>GMSMapView</code>. I also created an outlet connection to that view called <code>gmView</code>. </p> <p>I am using the following code that does unfortunately not show the map:</p> <pre><code>let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: GMSCameraPosition.camera(withLatitude: 51.050657, longitude: 10.649514, zoom: 5.5)) gmView = mapView </code></pre> <p>Also, I tried adding the <code>mapView</code> to <code>self.view</code> as a subview, like this:</p> <pre><code>self.view.addSubview(mapView) </code></pre> <p>...and inserting it:</p> <pre><code>self.view.insertSubview(mapView, at: 0) </code></pre> <p>Note that I'm using Auto Layout if that changes anything.</p> <p>None of these approaches seem to work for me.<br> Any ideas?</p>
<ios><swift><google-maps><uiview>
2016-10-15 22:12:21
HQ
40,065,188
Get size of each installed formula in homebrew?
<p>I am doing some cleanup of packages not needed anymore and want to figure out how to do this with homebrew. Also it will be nice to know if some package depends on another package which I plan to delete.</p>
<macos><homebrew>
2016-10-15 23:14:30
HQ
40,065,794
Returning values from a separate function in C++?
<p>I am doing a programming assignment in my CS class using C++ that is giving me problems. The assignment is to write a program that asks the user to input a Fahrenheit temperature. The program must then output the Celsius equivalent of that temperature and the Celsius equivalents of the next 20 Fahrenheit temperatures. This must all be done using a separate function to complete the conversion calculation as well as a function prototype. </p> <p>I got everything to work except my Celsius outputs all show a value of 0. I cannot seem to find any errors or figure out what is wrong...Please Help!</p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std; double Celsius(double temp); int main() { double fTemp, cTemp; cout &lt;&lt; "Please input a temperature in degrees Fahrenheit: "; cin &gt;&gt; fTemp; cout &lt;&lt; "F Temp" &lt;&lt; " " &lt;&lt; "C Temp"&lt;&lt; endl; cout &lt;&lt; "-------------------" &lt;&lt; endl; for(int count=1; count&lt;= 20; count++){ cTemp = Celsius(fTemp); cout &lt;&lt; setw(6) &lt;&lt; fTemp &lt;&lt; setw(12) &lt;&lt; cTemp&lt;&lt; endl; fTemp++; } return 0; } //*************Celsius Function****************// double Celsius(double temp){ double newC; newC = (temp-32) * (5/9); return newC; } //************************************************ </code></pre>
<c++>
2016-10-16 01:01:22
LQ_CLOSE
40,066,188
How to add an edit text on a button
<p>I was wondering how to have the user be able to edit the text on a button in Android programming? I tried to put the edit text on top of the button but it is not working. How should I do this?</p>
<android><button>
2016-10-16 02:22:45
LQ_CLOSE
40,066,267
Angular 2 with CLI - build for production
<p>I have freshly installed angular-cli 1.0.0.beta.17 (latest one), start new project, able to serve project on port 4200 with no problems - just standard "app works!" message.</p> <p>However when I try to build for production this empty and generic application by using command <code>ng build --prod</code> I do not have main.*.js file created at all and have a few screens of warnings like:</p> <ul> <li>Dropping unused function...</li> <li>Site effects in initialization...</li> <li>etc</li> </ul> <p>This is a brand new empty project - I did not have a chance to break anything yet...</p> <p>How to build production version ?</p>
<angular><build><production><angular-cli>
2016-10-16 02:38:44
HQ
40,066,305
insert a node at nth position in c ; whats wrong in this
Node* InsertNth(Node *head, int data, int position) { int i; struct Node *h=head; struct Node *p=(struct Node *)malloc(sizeof(struct Node)); p->data=data; for(i=0;i<position ;i++){ h=h->next; } p->next=h; h=p; if(position==0){ return h; } else return head; }
<c><linked-list>
2016-10-16 02:46:08
LQ_EDIT
40,066,444
On function expressions - immediately self-invoking anonymous function
<p>I tried this and it works :</p> <pre><code>a = function(){alert("Hello World")}; a(); </code></pre> <p>However this not :</p> <pre><code>function(){alert("Hello World")}(); </code></pre> <p>It's strange for me because i though it's the same.</p>
<javascript>
2016-10-16 03:12:20
LQ_CLOSE
40,066,515
What is the size of pointers in c++?
<p>What is the size of pointers in c++?</p> <pre><code>char a; char *b=a; cout&lt;&lt;sizeof(b); </code></pre> <p>Output is 2 I don't know why.</p> <pre><code>cout&lt;&lt;sizeof(const); //o/p is 2 cout&lt;&lt;sizeof(NULL); //o/p is 2 </code></pre>
<c++><null><constants><sizeof>
2016-10-16 03:26:50
LQ_CLOSE
40,066,837
pandas get average of a groupby
<p>I am trying to find the average monthly cost per user_id but i am only able to get average cost per user or monthly cost per user. </p> <p>Because i group by user and month, there is no way to get the average of the second groupby (month) unless i transform the groupby output to something else.</p> <p>This is my df:</p> <pre><code> df = { 'id' : pd.Series([1,1,1,1,2,2,2,2]), 'cost' : pd.Series([10,20,30,40,50,60,70,80]), 'mth': pd.Series([3,3,4,5,3,4,4,5])} cost id mth 0 10 1 3 1 20 1 3 2 30 1 4 3 40 1 5 4 50 2 3 5 60 2 4 6 70 2 4 7 80 2 5 </code></pre> <p>I can get monthly sum but i want the average of the months for each user_id. </p> <pre><code>df.groupby(['id','mth'])['cost'].sum() id mth 1 3 30 4 30 5 40 2 3 50 4 130 5 80 </code></pre> <p>i want something like this:</p> <pre><code>id average_monthly 1 (30+30+40)/3 2 (50+130+80)/3 </code></pre>
<python><pandas><dataframe><group-by>
2016-10-16 04:29:39
HQ
40,067,190
Python - remainder operator
<p>Although I know there is a built in <code>str()</code> <code>function</code> in <code>python</code>, I'm trying to understand its logic.</p> <pre><code>def intToStr(i): digits = '0123456789' if i == 0: return '0' result = '' while i &gt; 0: result = digits[i%10] + result i = i/10 return result </code></pre> <p>what I don't get is the part in the <code>loop</code> where <code>[i%10]</code>. </p> <p>How do I get a remainder when <code>i</code> <code>&lt;</code> <code>10</code>?</p>
<python>
2016-10-16 05:32:09
LQ_CLOSE
40,067,645
How to convert batch to exe programmatically
<p>I want to know how I can convert a .bat file to a .exe file programmatically in Java, I'mm trying to make a Batch IDE.</p> <p>Thanks!</p>
<java><exe>
2016-10-16 06:45:32
LQ_CLOSE
40,067,852
In a Promise, what's the difference between using catch and the 2nd argument of then?
<p>What exactly is the difference between these two statements?</p> <pre><code>funcThatReturnsAPromise() .then(() =&gt; { /* success */ }) .catch(() =&gt; { /* fail */ }); funcThatReturnsAPromise() .then(() =&gt; { /* success */ }, () =&gt; { /* fail */ }); </code></pre>
<javascript><promise>
2016-10-16 07:15:24
HQ
40,068,330
Cannot watch Kotlin variable in android studio
<p>I am not able to get android studio display the value of a calculation in the watches window.</p> <p>I use Kotlin for development and when i try to add a value to watches, i get a message which says "An exception occurs during evaluate expression".</p> <p>e.g.</p> <pre><code> val model = MyModel() val pos = model.position </code></pre> <p>Now if I add <code>model.position</code> to watches, then it gives the above error and the value of the expression is not displayed.</p> <p>How can I fix this?</p>
<debugging><android-studio><kotlin>
2016-10-16 08:19:59
HQ
40,069,429
What does java equals() return
<p>I have this code:</p> <pre><code>if(!((s.substring(s.length() - 1)).equals(";"))){ s = s + ";"; } </code></pre> <p>This code should be checking if the last character of a string is ";" and should add a semicolon to it if it is not the case, only it's doing the exact opposite, it adds a semicolon if the string already ends with one. My code works if I take out the exclamation mark. How is that possible, I read the documentation and .equals() should return true if the two expressions are equal. Am I missing something? Thanks</p>
<java><equals>
2016-10-16 10:49:58
LQ_CLOSE
40,069,455
Basic vue.js 2 and vue-resource http get with variable assignment
<p>I'm really struggling to get the most basic REST functionality to work in vue.js 2.</p> <p>I'd like to get data from some endpoint and assign the returned value to a variable of my Vue instance. Here's how far I got.</p> <pre><code>var link = 'https://jsonplaceholder.typicode.com/users'; var users; Vue.http.get(link).then(function(response){ users = response.data; }, function(error){ console.log(error.statusText); }); new Vue ({ el: '#user-list', data: { list: users } }); </code></pre> <p>Inside the promise, I can access the response data, but I cannot seem to assign it to users or even to data of the Vue instance.</p> <p>Needless to say, I'm completely new to vue.js and thankful for any help.</p> <p>Stack: vue.js 2.03, vue-resource 1.0.3</p> <p>Cheers!</p>
<javascript><vue.js><vue-resource>
2016-10-16 10:53:18
HQ
40,069,638
Why do both Promise's then & catch callbacks get called?
<p>I have the following code and when it's executed, it returns both "<strong>rejected</strong>" and "<strong>success</strong>":</p> <pre><code>// javascript promise var promise = new Promise(function(resolve, reject){ setTimeout(function(){reject()}, 1000) }); promise .catch(function(){console.log('rejected')}) .then(function(){console.log('success')}); </code></pre> <p>Could anyone explain <strong>why success is logged?</strong></p>
<javascript><ecmascript-6><es6-promise>
2016-10-16 11:16:49
HQ
40,069,831
Accessing bootstrap scss variables in angular 2 component
<p>I'm working on a new Angular2 project built using Angular CLI and have configured the project to use SCSS. I have Bootstrap 4 successfully loaded into my <code>styles.scss</code> file however if I try and access any of Bootstrap's (or my own variables defined in <code>styles.scss</code> from within a component I get <code>Undefined Variable</code> build error. </p> <p>Are the style files for components compiled before the main entry in the <code>styles</code> node of <code>angular-cli.json</code>? How can I make is so that any variables defined at that global level are available to all components in the application? Thanks!</p> <p><strong>angular-cli.json</strong></p> <pre><code>"apps": [ { ... "styles": [ "styles/styles.scss" ], ... } ] </code></pre> <p><strong>styles.scss</strong></p> <pre><code>// Bootstrap $enable-flex: true; // Enable Flexbox mode @import "../../node_modules/bootstrap/scss/bootstrap"; </code></pre> <p><strong>component</strong></p> <pre><code>.navbar { background: $brand-primary; // Undefined variable here } </code></pre>
<angular><sass>
2016-10-16 11:41:09
HQ
40,071,236
how to set string b to equal a when a has spaces in it c
<p>I have a string called that can continue a value with spaces for it as an example</p> <pre><code>char *a="this is a test" </code></pre> <p>I want to declare another string</p> <pre><code>char *b=NULL; </code></pre> <p>so I can then assign the value of a to b such as </p> <pre><code>b=a; </code></pre> <p>however currently b will only hold any characters up to the first space (in this example b= "this"). How do I get it to hold the entire string </p>
<c>
2016-10-16 14:10:28
LQ_CLOSE
40,071,837
Xcode Swift AutoLayout Not Working
In my storyboard auto layout is producing this [result][1] I wanted a result like [this][2].The problem this that the result I want is without auto layout. [1]: https://i.stack.imgur.com/5AWJp.png [2]: https://i.stack.imgur.com/Z6Q0f.png [3]: https://i.stack.imgur.com/5PdEl.png
<ios><autolayout>
2016-10-16 15:11:43
LQ_EDIT
40,072,369
display inline doesnt work but display flex does
so i am able to get a horizontal nav bar one way but not the other and i am getting confused as to why. strange things happen when i use float left as well so im not sure if ive got my elements labelled in the best format. the relevant html and css are below: <nav class="main-nav"> <ul class="navtext"> <li><a href="index.html">Index</a></li> <li><a href="p2.html">P2</a></li> <li><a href="p3.html">P3</a></li> </ul> </nav> .main-nav{ padding-top: 0px; padding-bottom: 0px; padding-left: 60px; padding-right: 60px; background-image: url("images/navimage.jpg"); text-align: center; border: solid 10px black; font-size: 20px; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; .navtext{ list-style: none; padding: 3rem; margin: none; display: flex;} ive tried doing the whole nav as main-nav but then list style: none has no effect
<html><css><flexbox>
2016-10-16 16:07:19
LQ_EDIT
40,072,610
C++ code compiles but doesn't run
<p>I am currently writing a Texas Hold'em code in order to learn more about c++ and gain experience. But I recently ran into a problem in which I have no idea what to do.My code compiles just fine without errors but once I make it run and it arrive at a specific function it just stops working (as in I get an error from CodeBlock saying your program has stopped working). I have tried cutting out parts such as loops in the function to see which specific part is the problem but after a couple of days im still at a stop. Here is the function and class that I believe is the problem:</p> <pre><code>class Player{ string name; int bank=100; static string cards[53]; static string final_card[2][6]; static string table_cards[5]; public: void set_name(string a){name=a;} string print_name(){return name;} void card_generator(); string set_cards(int c){return cards[c];} int print_bank(){return bank;} void set_final_card(int i, int max_i); void print_cards(){for(int i=0;i&lt;6;i++){cout&lt;&lt;final_card[0][i]&lt;&lt;endl;}} }; void Player::set_final_card(int i, int max_i){ srand(time(NULL)); int tempV = 17;//create temp cards string tempCards[tempV]; int randNB[tempV]; int check1 = 0, tmp; while (check1==0){ for(int g=0; g&lt;tempV;g++){ tempCards[g]=cards[rand()%53]; check1=1; tmp = g - 1; for(int o=tmp; o!=0; o--){ if (tempCards[g]==tempCards[o]){ check1=0; } } } } int p=0,k; while(p&lt;6){ k=0; final_card[0][k]=tempCards[p]; k++; p++; } while(p&lt;12){ k=0; final_card[1][k]=tempCards[p]; k++; p++; } while(p&lt;17){ k=0; table_cards[k]=tempCards[p]; k++; p++; } } </code></pre> <p>Here is the full code in case I am wrong of the source of the problem:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;stdlib.h&gt; #include &lt;ctime&gt; using namespace std; class Player{ string name; int bank=100; static string cards[53]; static string final_card[2][6]; static string table_cards[5]; public: void set_name(string a){name=a;} string print_name(){return name;} void card_generator(); string set_cards(int c){return cards[c];} int print_bank(){return bank;} void set_final_card(int i, int max_i); void print_cards(){for(int i=0;i&lt;6;i++){cout&lt;&lt;final_card[0][i]&lt;&lt;endl;}} }; string Player::cards[53]; string Player::final_card[2][6]; string Player::table_cards[5]; int main () { int choice1=0, i, max_i, tempV; string username; cout&lt;&lt; "Welcome to Texas Hold'Em!\n1-Play\n2-Quit\n";//menu while((choice1!=1)&amp;&amp;(choice1!=2)){//Makes sure that user enters correct input``` cin&gt;&gt;choice1; if ((choice1!=1)&amp;&amp;(choice1!=2)){ cout&lt;&lt;"Invalid Input!\nTry again!\n"; } } system ("cls"); if (choice1==2){//End Program return 0; } cout&lt;&lt;"How many players?[2-6]"&lt;&lt;endl; while((i!=2)&amp;&amp;(i!=3)&amp;&amp;(i!=4)&amp;&amp;(i!=5)&amp;&amp;(i!=6)){//Makes sure that user enters correct input cin&gt;&gt;i; if ((i!=2)&amp;&amp;(i!=3)&amp;&amp;(i!=4)&amp;&amp;(i!=5)&amp;&amp;(i!=6)){ cout&lt;&lt;"Invalid Input!\nTry again!\n"; } } Player player[i];//creating array of players player[0].card_generator(); max_i = i;//max_i is nb of players i--;//since arrays start at 0 system("cls"); player[0].set_final_card(i,max_i); player[0].print_cards(); if (choice1==1) {//SET NAMES OF ALL PLAYERS for(i=0; i&lt;max_i; i++){ cout&lt;&lt; "Whats your name?\n"; cin&gt;&gt;username; player[i].set_name(username); cout&lt;&lt;"Your name is "&lt;&lt; player[i].print_name()&lt;&lt; " and you have "&lt;&lt; player[i].print_bank()&lt;&lt;"$\n"; tempV=i+1;//used bc arrays start at 0 if(tempV!=max_i){ cout&lt;&lt; "Give PC to player "&lt;&lt; i+2 &lt;&lt;endl; } _sleep(3000); system("cls"); } } return 0; } void Player::set_final_card(int i, int max_i){ srand(time(NULL)); int tempV = 17;//create temp cards string tempCards[tempV]; int randNB[tempV]; int check1 = 0, tmp; while (check1==0){ for(int g=0; g&lt;tempV;g++){ tempCards[g]=cards[rand()%53]; check1=1; tmp = g - 1; for(int o=tmp; o!=0; o--){ if (tempCards[g]==tempCards[o]){ check1=0; } } } } int p=0,k; while(p&lt;6){ k=0; final_card[0][k]=tempCards[p]; k++; p++; } while(p&lt;12){ k=0; final_card[1][k]=tempCards[p]; k++; p++; } while(p&lt;17){ k=0; table_cards[k]=tempCards[p]; k++; p++; } } void Player::card_generator(){ string card_value[13]; card_value[0]="1"; card_value[1]="2"; card_value[2]="3"; card_value[3]="4"; card_value[4]="5"; card_value[5]="6"; card_value[6]="7"; card_value[7]="8"; card_value[8]="9"; card_value[9]="10"; card_value[10]="J"; card_value[11]="Q"; card_value[12]="K"; string card_type[4]; card_type[0]="of hearts"; card_type[1]="of diamonds"; card_type[2]="of clubs"; card_type[3]="of spades"; string card[53]; int x=0; fill_n(card,53,0); for (int j=0;j&lt;4;j++){ for (int q=0;q&lt;13;q++){ card[x]=card_value[q]+" "+card_type[j]; cards[x]=card[x]; x++; } } } </code></pre> <p>If you have any criticism about the code itself even if not directly linked to problem feel free to tell me as I'm doing this to learn :D. Thank you in advance!!</p>
<c++>
2016-10-16 16:31:31
LQ_CLOSE
40,072,873
Why do we need locks for threads, if we have GIL?
<p>I believe it is a stupid question but I still can't find it. Actually it's better to separate it into two questions:</p> <p>1) Am I right that we could have a lot of threads but because of GIL in one moment only one thread is executing?</p> <p>2) If so, why do we still need locks? We use locks to avoid the case when two threads are trying to read/write some shared object, because of GIL twi threads can't be executed in one moment, can they?</p>
<python><multithreading>
2016-10-16 16:54:29
HQ
40,072,908
I have this Probleme ,please some one help me
Error:com.android.builder.internal.aapt.AaptException: Failed to crunch file C:\Users\SONY\Desktop\Project tango\zip folder Project Tango\tango-examples-java-master\Solution\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.4.0\res\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png into C:\Users\SONY\Desktop\Project tango\zip folder Project Tango\tango-examples-java-master\Solution\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png Error:Execution failed for task ':app:mergeDebugResources'. > Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file C:\Users\SONY\Desktop\Project tango\zip folder Project Tango\tango-examples-java-master\Solution\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.4.0\res\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png into C:\Users\SONY\Desktop\Project tango\zip folder Project Tango\tango-examples-java-master\Solution\app\build\intermediates\res\merged\debug\drawable-xhdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png
<android>
2016-10-16 16:59:04
LQ_EDIT
40,073,053
Get invalid value from input type number
<p>I am using input type number. How can I get the value from this when its not valid. For example using type number and printing just 'e' thats not valid by itself.</p> <p>I am using React but I think this question is very general. </p> <pre><code>onChange(event) { console.log(event.target.value) //is empty string when not using number } &lt;form novalidate&gt; &lt;input type="number" onChange={this.onChange}&gt; &lt;/form&gt; </code></pre>
<javascript><html><reactjs>
2016-10-16 17:13:03
HQ
40,073,164
Typescript: is not assignable to type error
<p>I am new to using typescript with angular 2. I am using version 1 of angular 2-cli. When compiling, I get this error saying "is not assignable to type Assignment[]". I looked at the data types and it looks okay so far, but I am not sure what the error is exactly. Thanks for your help. </p> <p><strong>Here is a photo of the error from the console.</strong> <a href="https://i.stack.imgur.com/O37l4.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/O37l4.jpg" alt="enter image description here"></a></p> <p><strong>data.ts file - these are two of the items that appear in the array</strong></p> <pre><code>export const Assignments: Assignment[] = [ { "a_type": "one", "a_title": "Assignment 1", "symbol": 1, "show": false, "tooltip": { "left": 82 }, "buttonPos":{ "left": 130 }, "printTop": 0, "instructions": "Instructions here", "due_date": "sept-15.png", "percentage": "10.png", "taskA": { "name": "Option A", "a_title": "Task A", "information": "Instructions for task A", "selectA": true } }, { "a_type": "two", "a_title": "Assignment 2", "symbol": 2, "show": false, "sub_a_title": "Assignment Information", "tooltip": { "left": 200 }, "buttonPos":{ "left": 250 }, "printTop": 250, "instructions": "Instructions here", "due_date": "29.png", "percentage": "10.png", "taskA": { "a_title": "Assignment 2 info", "name": "Option A", "information": "Instructions for task A", "selectA": false }, "taskB": { "a_title": "Assignment 2 info", "name": "Option B", "information": "Instructions for task B", "selectB": false } } ] </code></pre> <p><strong>assignment.ts - here's the data types</strong></p> <pre><code>export class Assignment { a_type: string; a_title: string; symbol: any; show: boolean; tooltip: any; left: number; buttonPos:any; printTop: number; instructions: string; due_date: string; percentage: string; taskA: any; name: string; information: string; selectA: boolean; taskB: any; selectB: boolean; } </code></pre>
<javascript><angular><typescript><angular2-cli>
2016-10-16 17:21:42
HQ
40,073,546
Rewrite Javascript to Python
<p>I struggling to understand this javascript code and would like to rewrite it to python.</p> <pre><code>function rotateRight(e, t) { for (var n, i = 0; (t &gt; i); i++) n = (1 &amp; e), e &gt;&gt;= 1, n &lt;&lt;= 31, e += n; return e } </code></pre> <p>My biggest struggle is to understand how is the <code>e</code> being influenced by <code>n</code>.</p> <p>Thank you for help</p>
<javascript><python>
2016-10-16 17:58:07
LQ_CLOSE
40,073,651
regex: check if two phone numbers differ at most by 1 number
<p>I have a dataset of phone numbers that I want to check against each other. Basically the regex should throw a match if two phone numbers are at most 1 digit apart. For example, we have the following phone numbers:</p> <ul> <li>+31612345678</li> <li>+31612245678</li> </ul> <p>These numbers are the same apart from position number 7 (first number has a 3 while the second number has a 2). As these phone number differ by 1 digit, the regex should throw a match. It stands to reason that the regex should also throw a match if the phone numbers are exactly the same. In the following case (see below), the regex should however not throw at match as the phone numbers differ by more than 1 digit:</p> <ul> <li>+31612345678</li> <li>+31611145678</li> </ul> <p>Does anyone have a good regex in mind? I am writing the regex using the re module in python. </p>
<python><regex>
2016-10-16 18:07:37
LQ_CLOSE
40,073,743
How to log to a file without using third party logger in .Net Core?
<p>How to log to a file <strong>without</strong> using third party logger <em>(serilog, elmah etc.)</em> in <strong>.NET CORE</strong>?</p> <pre><code>public void ConfigureServices(IServiceCollection services) { services.AddLogging(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); } </code></pre>
<c#><asp.net-core><.net-core>
2016-10-16 18:16:38
HQ
40,074,058
Javascript Mental Jumpstart
<p>I need some help on a assignment for school, and I'm kinda stuck. This question defines the ones following and I need a mental "jumpstart;" I can't seem to remember what to do to begin.</p> <pre><code>function get_longest_word(){ //Task 1, complete this function to find the longest word //from the text entered into the textarea. //Once the longest word is found display the longest word in an alert. //Hint use the split(" ") method to split the string into an array of words. var str = document.getElementById('input_text').value;//str is the string from the input text area var longest_word = "not yet implementd"; alert(longest_word); </code></pre>
<javascript>
2016-10-16 18:42:22
LQ_CLOSE
40,074,494
counting howmany numbers greater than 5 in a given array
#having an error saying that prototype not terminated at filename.txt line #number 113 where as line number 113 belongs to a different program which is #running successfully. sub howmany( my @H = @_; my $m = 0; foreach $x (@H) { if ( $x > 5 ) { $m +=1; } else { $m +=0; } print"Number of elements greater than 5 is equal to: $m \n"; } howmany(1,6,9);
<arrays><perl>
2016-10-16 19:26:08
LQ_EDIT
40,074,665
How can I Handle Socket.IO rooms with cluster?
<p>I have a server working with cluster and to make that work with socke.IO I am using sticky-session, but I have a problem with my rooms (I don't know if the way I did is the best option): The cluster is instantiating processes and each process has a specific number of rooms. </p> <ul> <li>Server <ul> <li>Process 1 <ul> <li>Room1 </li> <li>Room2</li> <li>Room N</li> </ul></li> <li>Process 2 <ul> <li>Room1 </li> <li>Room2</li> <li>Room N</li> </ul></li> </ul></li> </ul> <p>The way I did to connect some user to the rooms (with only one process) is using the route, where the user access a page and when he tries to make a connection with Socket.io I check the URL and with that information I insert him in a room.</p> <p>My problem is implementing this server with cluster I can not insert the user in specific rooms because there is some rooms that only exist in specific processes and sticky session put him in another process. How can I put an user in a room that is in another process ? Also The use can only to see the routes of the process he is in the server and I would like to show every rooms in the page.</p> <p>I already has read about Redis-Adapter but I didn't find solutions on github using Socket.io + Cluster(Sticky-session + redis-adapter) + rooms.</p> <p>Follow my code to share what I have done:</p> <pre><code>//Cluster.Master with simplified Code if (cluster.isMaster) { var workers = []; // Spawn workers. for (var i = 0; i &lt; num_processes; i++) { spawn(i); } // Create the outside facing server listening on our port. var server = net.createServer({ pauseOnConnect: true }, function(connection) { // We received a connection and need to pass it to the appropriate // worker. Get the worker for this connection's source IP and pass // it the connection. var worker = workers[worker_index(connection.remoteAddress, num_processes)]; worker.send('sticky-session:connection', connection); }).listen(process.env.PORT); } else { console.log('I am worker #' + cluster.worker.id); var app = new express(); //view engine app.set('views', './views'); app.set('view engine', 'pug'); //statics app.use(express.static(path.join(__dirname, 'public'))); //rooms app.use('/', rooms); var server = app.listen(0, 'localhost'), io = sio(server); io.adapter(sio_redis({ host: 'localhost', port: 6379 })); //This File has the socket events (socket.on('messageX', function(){})) // And there I am var realtime = require('./realtime/socketIOEvents.js')(io); // Listen to messages sent from the master. Ignore everything else. process.on('message', function(message, connection) { if (message !== 'sticky-session:connection') { return; } // Emulate a connection event on the server by emitting the // event with the connection the master sent us. server.emit('connection', connection); connection.resume(); }); } </code></pre>
<javascript><node.js><websocket><socket.io><node-cluster>
2016-10-16 19:43:17
HQ
40,075,836
What packages/functions are imported by default in Kotlin?
<p>In Java the <code>java.lang</code> package is imported by default.<br> In kotlin a number of functions and classes are available without being imported, like <code>println</code> and kotlins <code>Array</code>, <code>Int</code>, etc types.<br> What else is imported by default and where is it defined?</p>
<kotlin>
2016-10-16 21:47:35
HQ
40,075,969
Testing if blocks with Mockito
<p>I have void function that does not return return anything with a if block inside. Is there a way while unit testing to verify if the "if" block is touched? </p> <p>for example to test the "if" inside the following funtion: </p> <pre><code>public void doSomething(){ if(someCondition){ int foo = doThis(); } // ---- // remaining code } private int doThis(){ return 100; } </code></pre>
<java><unit-testing><testing><mockito><verify>
2016-10-16 22:04:02
LQ_CLOSE
40,076,047
What types are special to the Scala compiler?
<p>Scala makes a big deal about how what seem to be language features are implemented as library features.</p> <p>Is there a list of types that are treated specially by the language?</p> <p>Either in the specification or as an implementation detail?</p> <p>That would include, for example, optimizing away matches on tuples.</p> <p>What about special conventions related to pattern matching, for comprehensions, try-catch blocks and other language constructs?</p> <p>Is String somehow special to the compiler? I see that String enhancement is just a library implicit conversion, and that String concatenation is supported by <code>Predef</code>, but is that somehow special-cased by the language?</p> <p>Similarly, I see questions about <code>&lt;:&lt;</code> and <code>classOf</code> and <code>asInstanceOf</code>, and it's not clear what is a magical intrinsic. Is there a way to tell the difference, either with a compiler option or by looking at byte code?</p> <p>I would like to understand if a feature is supported uniformly by implementations such as Scala.JS and Scala-native, or if a feature might actually prove to be implementation-dependent, depending on the library implementation.</p>
<scala>
2016-10-16 22:13:35
HQ
40,076,186
csharp string comparision error
I am trying to check if value exists in a string array. The below one works but when I tried the next code block,it failed. bool exixts; string toCheck= "jupiter"; string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"}; if(printer.Contains(toCheck)) { exists = true; } How can I check for trim and casesensitivity I tried this bool exixts; string toCheck= "jupiter "; string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"}; if(printer.Contains(toCheck.Trim(),StringComparison.InvariantCultureIgnoreCase))) { exists = true; }
<c#><string-comparison>
2016-10-16 22:29:37
LQ_EDIT
40,076,573
Adding timestamp to each line on Zsh
<p>I just fresh installed Sierra and wanted to use zsh with oh-my-zsh and power shell...</p> <p>I ended up with a terminal like this:</p> <p><a href="https://i.stack.imgur.com/M9lh1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M9lh1.png" alt="enter image description here"></a></p> <p>But I want to add a timestamp to every output. Semething linke:</p> <p><code>[14:23] acytryn ~ Projects %</code></p> <p>Is there a way to do this with zsh?</p>
<macos><terminal><zsh><oh-my-zsh>
2016-10-16 23:21:13
HQ
40,077,142
What is the difference betwen @Input and @Output in Angular2
<p>I am just learning Angular2 and I came across @Input and @Output. What is the difference between the two.</p>
<angular>
2016-10-17 00:57:13
HQ
40,077,355
Changing router-outlet with *ngIf in app.component.html in angular2
<p>I am using angular 2.0 final. I am trying to change the location of the <strong>router-outlet</strong> in the main app.component.html. The template is updating fine display wise except, the first time I use router.navigate the component won't display in the new router-outlet, and there is no error. The second and every time after I use router.navigate it works properly.</p> <p><strong>example template of app.component.html</strong></p> <pre><code> &lt;div *ngIf="authenticated() == false"&gt; &lt;h1&gt;not logged in&lt;/h1&gt; &lt;router-outlet&gt; &lt;/router-outlet&gt; &lt;/div&gt; &lt;div *ngIf="authenticated()"&gt; &lt;h1&gt;logged in&lt;/h1&gt; &lt;router-outlet&gt; &lt;/router-outlet&gt; &lt;/div&gt; </code></pre>
<angular><angular2-routing><angular2-template>
2016-10-17 01:37:10
HQ
40,078,793
Why aren't my widgets and buttons showing up on physical device but show up in Android Studio?
I am learning Android Studio for the first time and I'm stuck trying to run a program on a physical android device. The problem I'm having is that none of my content (widgets, textview, buttons) appear on the screen on my device. Is there something wrong with the computer I'm using? I can see and manipulate widgets in the editor but a lot of the things on screen I create don't show up in the correct spot except on the blueprint. I've attached images of everything so you guys can take a look. I'm running this on an AMD A10- 9600p Radeon R5. Thanks for the help. [Image from Android Device][1] [Android Studio Screenshot][2] [1]: https://i.stack.imgur.com/kc6KU.png [2]: https://i.stack.imgur.com/lLdpJ.png
<android><android-studio><android-studio-2.2><android-constraintlayout>
2016-10-17 05:04:03
LQ_EDIT
40,079,200
How to declare collection name and model name in mongoose
<p>I have 3 kind of records,</p> <pre><code>1)Categories, 2)Topics and 3)Articles </code></pre> <p>In my mongodb, i have only 1 colection named 'categories' in which i stroe the above 3 types of documents.</p> <p>For these 3 modules,i wrote 3 models(one each) in such a way like below,</p> <pre><code>mongoose.model('categories', CategorySchema); mongoose.model('categories', TopicSchema) mongoose.model('categories', ArticlesSchema) </code></pre> <p>like....mongoose.model('collection_name', Schema_name)</p> <p>but when i run my code ,it throws error that </p> <pre><code>Cannot overwrite `categories` model once compiled. </code></pre> <p>If i change the above models like this,</p> <pre><code>mongoose.model('category','categories', CategorySchema); mongoose.model('topics','categories', TopicSchema) mongoose.model('articles','categories', ArticlesSchema) </code></pre> <p>It is creating 2 collections named topics and articles which i dont want. This is my issue right now,can anyone suggest me help.....Thanks....</p>
<node.js><mongodb><mongoose>
2016-10-17 05:41:24
HQ
40,079,214
How to enable cross origin requests in ASP.NET MVC
<p>I am trying to create a web application which works with cross-origin requests (CORS) in MVC 5. I have tried everything without any result.</p> <p><strong>With an attribute</strong> </p> <pre><code>public class AllowCrossSiteJsonAttribute: ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*"); base.OnActionExecuting(filterContext); } } </code></pre> <p><strong>With EnableCors attribute</strong> </p> <pre><code> [EnableCors("*")] </code></pre> <p>Nothing works I'm starting to think that it is impossible</p>
<c#><asp.net><asp.net-mvc><cors>
2016-10-17 05:42:43
HQ
40,079,970
How to get height of UITableView when cells are dynamically sized?
<p>I have a UITableView with cells that are dynamically sized. That means I have set:</p> <pre><code>tableView.estimatedRowHeight = 50.0 tableView.rowHeight = UITableViewAutomaticDimension </code></pre> <p>Now I want to get the height of the whole table view. I tried getting it through <code>tableView.contentSize.height</code> but that only returns the estimated row height, and not the actual dynamic height of the table view.</p> <p>How do I get the dynamic height of the whole table view?</p>
<ios><swift><uitableview>
2016-10-17 06:41:07
HQ
40,080,473
Using JSON.stringify in conjunction with TypeScript getter/setter
<p>I am using getter/setter accessors in TypeScript. As it is not possible to have the same name for a variable and method, I started to prefix the variable with a lower dash, as is done in many examples:</p> <pre><code>private _major: number; get major(): number { return this._major; } set major(major: number) { this._major = major; } </code></pre> <p>Now when I use the JSON.stringify() method to convert the object into a JSON string, it will use the variable name as the key: _major.</p> <p>As I don't want the JSON file to have all keys prefixed with a lower dash, is there any possibility to make TypeScript use the name of the getter method, if available? Or are there any other ways to use the getter/setter methods but still produce a clean JSON output?</p> <p>I know that there are ways to manually modify the JSON keys before they are written to the string output. I am curious if there is simpler solution though.</p> <p><a href="https://jsfiddle.net/7d7tndhh/1/" rel="noreferrer">Here is a JSFiddle</a> which demonstrates the current behaviour.</p>
<json><typescript><getter-setter>
2016-10-17 07:15:36
HQ
40,080,508
Swift: UnsafeMutablePointer.deinitialize fatal error with negative count when appending to array
<p>The code below generates this error (appending to <code>exporters</code>):</p> <blockquote> <p>fatal error: UnsafeMutablePointer.deinitialize with negative count</p> </blockquote> <pre><code> var exporters = [AVAssetExportSession]() let exporter = AVAssetExportSession(asset: mainComposition, presetName: AVAssetExportPresetHighestQuality)! exporter.videoComposition = videoComposition exporter.outputFileType = AVFileTypeMPEG4 exporter.outputURL = exportURL exporter.shouldOptimizeForNetworkUse = true exporters.append(exporter) </code></pre> <p>The other posts on StackOverflow regarding <code>UnsafeMutablePointer.deinitialize</code> do not shed much light on the issue, which doesn't happen consistently.</p> <p>Any ideas?</p>
<ios><swift><video><avassetexportsession>
2016-10-17 07:17:50
HQ
40,080,706
Is there a WORKING qrCode reader in Js/Jquery out there?
<p>So, there are just a few Js plugins to read a barcode in browser windows from a smartphone.</p> <p>I have tried:<br> <a href="https://serratus.github.io/quaggaJS/" rel="nofollow">https://serratus.github.io/quaggaJS/</a><br> <a href="http://atandrastoth.co.uk/main/pages/plugins/webcodecamjs/" rel="nofollow">http://atandrastoth.co.uk/main/pages/plugins/webcodecamjs/</a><br> <a href="https://dwa012.github.io/html5-qrcode/" rel="nofollow">https://dwa012.github.io/html5-qrcode/</a><br> <a href="https://webqr.com/" rel="nofollow">https://webqr.com/</a><br></p> <p>I got the camera work for QuaggaJs, but i cannot run the scanner.<br> So is there anyone using a working Barcode reader plugin, who can point me in the right direction?</p> <p>I need to read the code live with my phone, in my browser.</p>
<javascript><jquery><html>
2016-10-17 07:29:29
LQ_CLOSE
40,081,211
How to know will nuget package work on .NET Core?
<p>I would expect some kind of filter to exists on website or in console.</p>
<nuget><.net-core>
2016-10-17 08:00:15
HQ
40,081,417
How to delete a record in databse C#
How do I remove a record? I need to remove a record that I found by using the foreign key. I stored it as a var but now I can't delete it. Any suggestions? // POST: Account/Delete/5 [HttpPost] [ValidateAntiForgeryToken] public ActionResult Delete(int id, Leerling ll) { var login = from l in db.myLogin where id == l.leerlingId select l; db.myLogin.Remove(login???); db.Entry(ll).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Index");// het record verwijderen en redirecten als het gelukt is }
<c#><asp.net-mvc>
2016-10-17 08:11:51
LQ_EDIT
40,081,732
Can touch out side a View Component be detected in react native?
<p>My React native application screen has View component with few text inputs. How can touch be detected on screen outside that View? Please help.</p> <p>Thanks</p>
<javascript><reactjs><mobile><react-native>
2016-10-17 08:30:35
HQ
40,081,747
Android PDF Viewer libray for eclipse
I want to include the an,droid pdf library to an android project using eclipse and I found this solution that seems to be a good one and it is based on Pdfium an Apache licenced project. The main problem I am facing now is that the project is under Gradle/Maven dependecy controls and I want to download a jar or library project to include it to the project, is there any solution to convert a gradle dependency to jar library or something in this way ? The link of the library : https://github.com/barteksc/AndroidPdfViewer Thank you
<android><pdf-viewer>
2016-10-17 08:31:42
LQ_EDIT
40,082,259
Docker compose yml static IP addressing
<p>I have such docker-compose.yml (not a full list here):</p> <pre><code>version: '2' services: nginx: build: ./nginx/ ports: - 8080:80 links: - php volumes_from: - app networks: app_subnet: ipv4_address: 172.16.1.3 php: build: ./php/ expose: - 9000 volumes_from: - app networks: app_subnet: ipv4_address: 172.16.1.4 networks: app_subnet: driver: bridge ipam: config: - subnet: 172.16.1.0/24 gateway: 172.16.1.1 </code></pre> <p>After <code>docker-compose up</code> I got such an error:</p> <blockquote> <p>User specified IP address is supported only when connecting to networks with user configured subnets</p> </blockquote> <p>So I'm creating subnet with <code>docker network create --gateway 172.16.1.1 --subnet 172.16.1.0/24 app_subnet</code></p> <p>But this doesn't solve the problem because docker-compose creates the subnet with name dev_app_subnet on the fly. And my subnet is not used - I'm getting the same error. The main purpose of doing this is to assign static IP for nginx service - open my project web url from etc/hosts file.</p>
<docker-compose><docker-networking>
2016-10-17 09:01:15
HQ
40,082,567
for security purpose i want to encode source code of my html page
<p>i want to design my html page such that; if some body wants to copy my source code from browser it should appear as in encoded format. Is it possible? Thank you.</p>
<html>
2016-10-17 09:17:41
LQ_CLOSE
40,082,608
How to delete interface docker0
<p>I would like to remove the interface docker0. It would be better to avoid creating the interface docker0 when starting the service and using directly the eth0. </p>
<docker>
2016-10-17 09:19:44
HQ
40,082,896
WCF как вмешаться в работающий метод и ограничить доступ строго 1 клиентом
Доброго дня. Стоит задача организовать WCF сервер для управления измерительной аппаратурой. В процессе изучения новой для меня темы WCF возникли начальные вопросы: 1. Как организовать аварийное прерывание работы со стороны клиента? Настроил асинхронные вызовы, нажимаю в клиенте кнопку "адски нагрузить сервер" - на стороне сервера в рамках реализации контракта запускаю ` while (!stop) i++; ` Нажимаю кнопку с предложением серверу перекинуть `static bool stop = false` в `true` - и безответно. Требуется понимание способов вмешательства в процесс вычислений - как грамотно извне на него повлиять, и в частности - прервать? Писать мультипоточный запуск еще и на стороне сервера и рубить его по запросу от клиента? Или можно проще? 2. Ну и до кучи, требуется ограничить доступ к управляющему аппаратурой серверу строго до 1 клиента. Пляски с бубном вроде найденного здесь же на форуме вараинта `[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]` и `<behavior name="Throttled"> <serviceThrottling maxConcurrentCalls="1" maxConcurrentSessions="1" maxConcurrentInstances="1" /> </behavior>` никак не мешают параллельно запущенному окошку клиента управлять сервером, что недопустимо. Рыть в сторону авторизации клиента, или все же есть счастливая строчка, решающая проблему? :)
<c#><wcf>
2016-10-17 09:33:09
LQ_EDIT
40,083,451
Converting Time how can I improve my code?
<p>Just started programming so any suggestion or constructive criticism would be much appreciated. I'm pretty sure there are ways to shorten this I just don't know how, especially the use of functions.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int input, check = 1, ans; int menu (); int convert24(int hour, int min, int sec, int meridiem); int convert12(int hour, int min, int sec, int meridiem); int result(int hour, int min, int sec, int meridiem); void processAnother(); int main() { do { menu(); processAnother(); system("cls"); }while (ans = 'y'); } int menu () { int hour, min, sec, meridiem; printf("[1] Convert to 24-hour notation\n"); printf("[2] Convert to 12-hour notation\n"); printf("[3] Quit\n"); scanf("%d", &amp;input); switch(input) { case 1 : { printf("Enter hours (1-12):minute(1-59):seconds(1-59): "); scanf("%d %d %d", &amp;hour, &amp;min, &amp;sec); printf("[1] AM or [2] PM: "); scanf(" %d", &amp;meridiem); return convert24(hour, min, sec, meridiem); break; } case 2 : { printf("Enter hours(1-24):minute(1-59):seconds(1-59): "); scanf("%d %d %d", &amp;hour, &amp;min, &amp;sec); printf("[1]AM or [2]PM: "); scanf(" %d", &amp;meridiem); return convert12(hour, min, sec, meridiem); break; } default : { printf("Goodbye :)"); exit(0); } } } int convert24(int hour, int min, int sec, int meridiem) { if ((hour &gt; 12 || hour &lt; 0)) { printf("\nError! Invalid Hour\n"); check = 0; } if ((min &gt;= 60 || min &lt;0)) { printf("\nError! Invalid Minute\n"); check = 0; } if ((sec &gt;= 60 || sec &lt;0)) { printf("\nError! Invalid Second\n"); check = 0; } if (meridiem &gt; 2 || meridiem &lt; 0) { printf("\nError! Invalid Meridiem\n"); check = 0; } if (check == 1) { if (meridiem == 1) { if (hour == 12) { hour = 0; result(hour, min, sec, meridiem); } else { result(hour, min, sec, meridiem); } } else if (meridiem == 2) { if (hour == 12) { hour = 12; result(hour, min, sec, meridiem); } else { hour+=12; result(hour, min, sec, meridiem); } } } processAnother(); } int convert12(int hour, int min, int sec, int meridiem) { if ((hour &gt; 24 || hour &lt; 0)) { printf("\nError! Invalid Hour\n"); check = 0; } if ((min &gt;= 60 || min &lt;0)) { printf("\nError! Invalid Minute\n"); check = 0; } if ((sec &gt;= 60 || sec &lt;0)) { printf("\nError! Invalid Second\n"); check = 0; } if (meridiem &gt; 2 || meridiem &lt; 0) { printf("\nError! Invalid Meridiem\n"); check = 0; } if (check == 1) { if (meridiem == 1) { if (hour &lt;= 12) { result(hour, min, sec, meridiem); } else { hour -= 12; result(hour, min, sec, meridiem); } } else if (meridiem == 2) { if (hour &lt;= 12) { result(hour, min, sec, meridiem); } else { hour -= 12; result(hour, min, sec, meridiem); } } } processAnother(); } int result(int hour, int min, int sec, int meridiem) { char *x; int y; if(meridiem == 1) { x = "AM"; } else if (meridiem == 2) { x = "PM"; } if (input == 1) { y = 24; } else if (input == 2) { y = 12; } printf("The %d-hr Notation is : %d:%d:%d %s\n",y, hour, min, sec, x); return; } void processAnother() { printf("Process another [y/n]"); scanf("%c", &amp;ans); return; } </code></pre> <p>Thank you very much.</p>
<c>
2016-10-17 10:00:37
LQ_CLOSE
40,083,517
How to remove lag when using more than 50,000 options in <select> tag in html??
<p>I am fetching options for the dropdown menu from database. I have already used select2.js but it is not working. Whenever I click on the dropdown menu the page stops responding.</p>
<javascript><html><css><select2>
2016-10-17 10:04:10
LQ_CLOSE
40,085,608
how to pass data from one fragment to previous fragment?
<p>I am going FragmentA->FragmentB. Now From FragmentB I want to pass data to FragmentA.So How can I do that??</p> <p>Currently am going FragmentB->FragmentA with <code>getCustomFragmentManager().popBackStack();</code> but not passing any value.</p>
<android>
2016-10-17 11:47:50
HQ
40,086,236
How to get float by integer / integer C lang
<p>I wanna get 1.666667 by dividing 2*n+1 by 3 (n=2). and it always creates 1.000000 but i want 1.666667. I tried printing (2*n+1)/3 as a float but it doesn't work.</p>
<c>
2016-10-17 12:19:44
LQ_CLOSE
40,086,257
The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files
<p>I am following the tutorial at <a href="https://spring.io/guides/gs/actuator-service/" rel="noreferrer">spring.io</a> to build a spring app using spring boot.</p> <p>I can get the program to run perfectly on one computer. When I try on a different computer I get the following error</p> <blockquote> <p>The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files</p> </blockquote> <p>I have tried deleting and adding my JRE Systems Library (JDK 1.8), as well as cleaning and updating the project using maven, and even deleting and re-importing the entire project. All of these methods have shown no success.</p> <p>My pom file is</p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;1.4.1.RELEASE&lt;/version&gt; &lt;/parent&gt; &lt;groupId&gt;test.api&lt;/groupId&gt; &lt;artifactId&gt;api.test&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;name&gt;api.test Maven Webapp&lt;/name&gt; &lt;url&gt;http://maven.apache.org&lt;/url&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;properties&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;/properties&gt; &lt;build&gt; &lt;finalName&gt;api.test&lt;/finalName&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>The class that is giving me the error is the HelloWorldConfiguration.java class</p> <pre><code>package hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class HelloWorldConfiguration { public static void main(String[] args) { SpringApplication.run(HelloWorldConfiguration.class, args); } } </code></pre> <p>Any help would be greatly appreciated. Thank you.</p>
<java><spring><maven><spring-boot><pom.xml>
2016-10-17 12:20:47
HQ
40,086,749
Can I create an alias of a type in Golang?
<p>I'm struggling with my learning of Go.</p> <p>I found this neat implementation of a Set in go: <a href="https://github.com/fatih/set" rel="noreferrer">gopkg.in/fatih/set.v0</a>, but I'd prefer naming my sets with a more explicit name that <code>set.Set</code>, doing something like:</p> <pre><code>type View set.Set </code></pre> <p>In essence, I want my <code>View</code> type to inherit <code>set.Set</code>'s methods. Because, well, <code>View</code> <strong>is a</strong> <code>set.Set</code> of descriptors. But I know Go is pretty peaky on inheritance, and typing in general.</p> <p>For now I've been trying the following <em>kinda</em> inheritance, but it's causing loads of errors when trying to use some functions like <code>func Union(set1, set2 Interface, sets ...Interface) Interface</code> or <code>func (s *Set) Merge(t Interface)</code>:</p> <pre><code>type View struct { set.Set } </code></pre> <p>I'd like to know if there's a way to achieve what I want in a Go-like way, or if I'm just trying to apply my good-ol' OO practices to a language that discards them, please.</p>
<go><types><alias>
2016-10-17 12:45:33
HQ