title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
AWS Cognito User Pool - "Value null at 'userName' failed to satisfy constraint: Member must not be null" - iOS
<p>I've been working with UserPools on AWS Mobile Hub. I have managed to make login with providers like Facebook and G+. However, when trying to login with AWS UserPools I can't manage to do so. I can Register successfully and connect to the UserPool perfectly (It recognizes wrong passwords 7 nonexistent users). When I login with the method shown below, I get the error: </p> <blockquote> <p>"1 validation error detected: Value null at 'userName' failed to satisfy constraint: Member must not be null"</p> </blockquote> <p>I don't really know whats happening as the username and password are actually right! (Even if hardcoded). Here you can see the code I'm using to login:</p> <pre><code> let pool = AWSCognitoIdentityUserPool(forKey: "UserPool") let user: AWSCognitoIdentityUser = pool.getUser(textFieldEmail.text!) user.getSession(textFieldEmail.text!, password: textFieldPassword.text!, validationData:nil, scopes: nil).continueWithBlock { (task:AWSTask) -&gt; AnyObject? in if task.error == nil { print("Got: \(task.result)") } else { print("Error while logging in: \(task.error?.userInfo["__type"]) with message: \(task.error?.userInfo["message"])") } return nil } </code></pre> <p>I would really appreciate some help! I've tried to add info on the validation data. Things like:</p> <pre><code>let userName:AWSCognitoIdentityUserAttributeType = AWSCognitoIdentityUserAttributeType() userName.name = "userName" iserName.value = textFieldEmail.text </code></pre> <p>But again, not working.</p> <p>Thanks!</p>
0
VPN over PPTP on mac os sierra
<p>Lately I discovered that connecting to a VPN via PPTP option has been removed in the new mac os - sierra. I tried multiple application to do so - all failed. How can I connect to my VPN over PPTP?</p> <p>ps. I don't want to use L2TP because I don't have a pre shared key (I also don't know what it is).</p>
0
Move GMSMarker on Google Map Like UBER
<p>I am developing some navigation tasks on google map. I have to move markers as vehicles moves with turns as uber does in their app. I have tried different solutions as offered on @SO but It is not working as I need. </p> <p>I am getting angle with previous lat/long with current lat/long and animating mapwithBearing with that rotation</p> <p>Here is code</p> <pre><code>[CATransaction begin]; [CATransaction setAnimationDuration:2.0]; NSDictionary *data = [[result objectForKey:@"returnData"] objectForKey:@"data"]; if (![data isEqual: [NSNull null]]) { driverLocationCoordinate = CLLocationCoordinate2DMake([[data objectForKey:@"lat"] doubleValue], [[data objectForKey:@"lng"] doubleValue]); driverMarker.position = driverLocationCoordinate; GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:driverLocationCoordinate.latitude longitude:driverLocationCoordinate.longitude zoom:16]; mapHomeView.camera = camera; if ([data objectForKey:@"preLat"] != [NSNull null] &amp;&amp; [data objectForKey:@"preLng"] !=[NSNull null]){ if ([[data objectForKey:@"preLat"] floatValue] != 0.0f &amp;&amp; [[data objectForKey:@"preLng"] floatValue] != 0.0f) { NSLog(@"pre_lat = %f and pre_lng = %f", [[data objectForKey:@"preLat"] floatValue], [[data objectForKey:@"preLng"] floatValue]); CLLocationCoordinate2D previousCoordinates = CLLocationCoordinate2DMake([[data objectForKey:@"preLat"] floatValue], [[data objectForKey:@"preLng"] floatValue]); driverMarker.rotation = [self DegreeBearing:previousCoordinates locationB:driverMarker.position]; [mapHomeView animateToBearing:driverMarker.rotation]; } } [CATransaction commit]; </code></pre> <p>I just taken degree code from another @SO post, It works when I'm on straight road but when car is still or turning, it gives flickering</p> <p>Here is code of getting angle from another SO post.</p> <pre><code>-(double) DegreeBearing:(CLLocationCoordinate2D) A locationB: (CLLocationCoordinate2D)B{ double dlon = [self ToRad:(B.longitude - A.longitude) ]; double dPhi = log(tan([self ToRad:(B.latitude)] / 2 + M_PI / 4) / tan([self ToRad:(A.latitude)] / 2 + M_PI / 4)); if (fabs(dlon) &gt; M_PI){ dlon = (dlon &gt; 0) ? (dlon - 2*M_PI) : (2*M_PI + dlon); } return [self ToBearing:(atan2(dlon, dPhi))]; } -(double) ToRad: (double)degrees{ return degrees*(M_PI/180); } -(double) ToBearing:(double)radians{ return [self ToDegrees:radians] + 360 % 360; } -(double) ToDegrees: (double)radians{ return radians * 180 / M_PI; } </code></pre> <p>Can anyone help on this or propose any other solution?</p>
0
How to get country code and Country name using IP
<p>Im new for android, I want to get country name and country code using ip address. Please anyone guide me.</p> <p>Below code for getting IP:</p> <pre><code>public String getLocalIpAddress() { WifiManager wifiMgr = (WifiManager) getActivity().getSystemService(context.WIFI_SERVICE); if(wifiMgr.isWifiEnabled()) { WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); int ip = wifiInfo.getIpAddress(); String wifiIpAddress = String.format("%d.%d.%d.%d", (ip &amp; 0xff), (ip &gt;&gt; 8 &amp; 0xff), (ip &gt;&gt; 16 &amp; 0xff), (ip &gt;&gt; 24 &amp; 0xff)); return wifiIpAddress; }else{ try { for (Enumeration&lt;NetworkInterface&gt; en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) { NetworkInterface intf = en.nextElement(); for (Enumeration&lt;InetAddress&gt; enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); Log.i("","111 inetAddress.getHostAddress(): "+inetAddress.getHostAddress()); //the condition after &amp;&amp; is missing in your snippet, checking instance of inetAddress if (!inetAddress.isLoopbackAddress() &amp;&amp; inetAddress instanceof Inet4Address) { Log.i("","111 return inetAddress.getHostAddress(): "+inetAddress.getHostAddress()); return inetAddress.getHostAddress(); } } } } catch (SocketException e) { e.printStackTrace(); } } return null; } </code></pre> <p>I dont know how to get country code and name using IP address.</p> <p>Thanks in advance!</p>
0
Ng-bootstrap Import Error Angular 2
<p>I try to run ng-bootstrap for angular 2 and I receive an error to install ng-bootstrap. I believe that is a path problem. This 404 error occur when i try to access page, and on start npm. When angular ng-bootstrap try to load I receive a 404 error on import module:</p> <pre><code>[1] 16.08.20 20:01:00 404 GET /@ng-bootstrap/ng-bootstrap </code></pre> <p>But this module is inside node_modules. Thanks</p>
0
print string by using Scanner class
<p>I am giving this input "Welcome to HackerRank's Java tutorials!" into but </p> <p>printing only "Welcome" string through scanner class.</p> <pre><code>import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d = scan.nextDouble(); String s = scan.nextLine(); scan.close(); // Write your code here. System.out.println("String: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); } } </code></pre> <p>How to resolve this?</p>
0
How to send Email using Logic App?
<p>In one of my project I want to send email using Logic Apps, for that I followed below link. <a href="https://azure.microsoft.com/en-in/documentation/templates/101-logic-app-sendgrid/" rel="nofollow noreferrer">https://azure.microsoft.com/en-in/documentation/templates/101-logic-app-sendgrid/</a></p> <p>From the above link i created the Logic App in my Azure Subscription and make designer in my logic app like this below figure. but i don't know which values can i gave in their text boxes.</p> <p>My designer will be like this below figures. <a href="https://i.stack.imgur.com/FozbJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FozbJ.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/t2dWB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t2dWB.png" alt="enter image description here"></a></p> <p>but i don't know how to send email from newly created logic app in my azure portal.</p> <p>Please tell me how can i achieve this.</p> <p>-Pradeep</p>
0
Eclipse neon "no staged files" error
<p>I am using Eclipse Neon for Github, to be able to push changes.</p> <p>I already have a Github account and made a specific repository just for trying, but nothing ends up in the repository, though I follow guides and do exactly the same without getting any errors, but ending up with an empty Github repository (except for the Readme file that I created along with the repository at the website).</p> <p>I've made several Java Projects with a simple <code>main</code> method, and a method for just writing a dummy message, simple, but doesn't exist in repository.<br> Then I right click the project, select <strong>Team</strong> -> <strong>Share Project</strong> and select:<br> <strong>Repository: NewGit - /home/jannik/NewGit.git</strong>, <strong>working tree: /home/jannik/NewGit</strong> and <strong>Path within repository: dummy</strong> and click my dummy project and press finish. </p> <p>Now I right click my project again and choose <strong>Remote</strong> -> <strong>Push</strong> and choose the default option called <strong>Configured remote repository</strong> which says <strong>origin: <a href="https://github.com/" rel="nofollow">https://github.com/</a>&lt; my-github-account>/eclipseTest.git</strong> which tells me that it links to my repository named eclipseTest (which I made on website). </p> <p>I then press Next and press <strong>*Add all Branches spec</strong> and clicks next, and then Finish. I then get a dialog saying that Master and NewGit branches are up-to-date, though my dummy project is missing.</p> <p>If I try the <strong>Commit</strong> option in Eclipse, I get an error saying that there're no staged files</p> <p>What am I doing wrong?</p>
0
Specified Argument was out of the range of valid values Parameter name : site
<p>I am Using Visual Studio 2015, with Windows 10 hp laptop. After I created an asp.net mvc application, build it and run it I get this error:</p> <blockquote> <p>Specified Argument was out of the range of valid values Parameter name : site<br> Description : An unhanded Exception occurred during the execution of the current web request<br> Stack Trace:<br> [ArgumentOutOfRangeException: Specified Argument was out of the range of valid values. Parameter Name: site]<br> System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags, hostingFlags, PolicyLevel, policylevel, Exception appDomainCreationException) +560<br> [HttpException (0x80004005): Specified Argument was out of the range of valid values. Parameter Name: site]<br> System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +765<br> System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95<br> System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerReuest wr, HttpContext context) +195 </p> </blockquote>
0
The following object is masked from ‘package:stats’:lowess
<p>When I use R ROCR package, I got error message.</p> <pre><code>Loading required package: ROCR Loading required package: gplots Attaching package: ‘gplots’ The following object is masked from ‘package:stats’: lowess </code></pre> <p>What should I do? I use R 3.1.3, OSX 10.11.6, and Rstudio 0.98.1103.</p>
0
Will php's json_encode() always use double quotes as string delimiter?
<p>I have a php associative array containing strings as values and I encode it to JSON and store it in an html-data attribute. That is read by some JS. </p> <p>So far so good. </p> <p>Now, I need to use single quotes for the data attribute, otherwise the context switches.</p> <pre><code>&lt;section id="settings" data-settings='{"some":"val"}'&gt; &lt;/section&gt; </code></pre> <p>The question is, can I rely on the <code>json_encode()</code> function of php to encode strings always with double quotes? Surprisingly, I can't seem to find information on this. I only find articles from people having issues with quotes in the array values. </p> <p>Thanks in advance.</p>
0
Generics in Swift - "Generic parameter 'T' could not be inferred
<p>I'd like to return a <code>UIViewController</code> conforming to <code>MyProtocol</code> from a method, so I'm using the method signature:</p> <pre><code>func myMethod&lt;T where T : UIViewController, T : MyProtocol&gt;() -&gt; T { </code></pre> <p>First thing I don't understand: if <code>myMethod</code> returns e.g. a <code>MyViewController</code> which has to following signature, I have to force cast it:</p> <pre><code>class MyViewController: UIViewController, MyProtocol </code></pre> <p>I cannot simply <code>return MyViewController()</code> but I need to cast it like this: <code>return MyViewController() as! T</code> - why is this necessary?</p> <p>And the second thing: how can I use this method somewhere? I cannot simply say</p> <pre><code>let x = myMethod() as? UIViewController </code></pre> <p>as I get the error</p> <pre><code>Generic parameter 'T' could not be inferred </code></pre> <p>How can I achieve something like this? If I cast it to <code>MyViewController</code> it works, but I would like to avoid that of course.</p> <p><strong>EDIT: Example</strong></p> <pre><code>class MyViewController : UIViewController, MyProtocol { } protocol MyProtocol { } func myMethod&lt;T&gt;() -&gt; T where T : UIViewController, T : MyProtocol { return MyViewController() as! T // why is the cast necessary? } </code></pre> <p>ok, I do get one part, but why is the cast to <code>T</code> necessary? <code>MyViewController</code> is a subclass of <code>UIViewController</code> and conforms to the protocol, so no cast should be necessary, right?</p>
0
how to get data from each li using jquery each function?
<p>I have a unordered list and each list element have "data-id" attribute, the idea is that using JQuery's each function iterate through each list element and get the "data-id" value and dynamically assign the position, ie to make a item slider that slides one item at a time. but on each the value of data I'm getting is <strong>"1"</strong>, ie its taking value from the first element only, how do I fix it??</p> <p><strong>HTML</strong></p> <pre><code>&lt;div class="explore_matches"&gt; &lt;p&gt;Recent Matches&lt;/p&gt; &lt;ul class="clearfix item-slider"&gt; &lt;li data-id="1" &gt;&lt;span&gt;1&lt;/span&gt;&lt;/li&gt; &lt;li data-id="2" &gt;&lt;span&gt;2&lt;/span&gt;&lt;/li&gt; &lt;li data-id="3" &gt;&lt;span&gt;3&lt;/span&gt;&lt;/li&gt; &lt;li data-id="4" &gt;&lt;span&gt;4&lt;/span&gt;&lt;/li&gt; &lt;li data-id="5" "&gt;&lt;span&gt;5&lt;/span&gt;&lt;/li&gt; &lt;li data-id="6" "&gt;&lt;span&gt;6&lt;/span&gt;&lt;/li&gt; &lt;li data-id="7" "&gt;&lt;span&gt;7&lt;/span&gt;&lt;/li&gt; &lt;li data-id="8" "&gt;&lt;span&gt;8&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;button name="pre"&gt;Pre&lt;/button&gt; &lt;button name="next"&gt;Next&lt;/button&gt; &lt;/div&gt; </code></pre> <p><strong>JavaScript</strong></p> <pre><code>var item_width = $('.item-slider').width(); var item_margin = (item_width-600)/5; var items = $('ul.item-slider&gt;li'); $.each(items,function(index){ var pos = $('.item-slider &gt; li').data('id') * 150; if(index === 0) $(this).css("left", pos); else $(this).css("left", pos + index * item_margin); console.log(pos); }) </code></pre>
0
Where is my sqlite data stored in iOS simulator?
<p>I created an iPad app on xCode(using PhoneGap) with sqlite plugin, stored data, and then when I want to view the data I stored I couldn't find where I saved it. According to my online research, it should be under /Library/Developer/CoreSimulator/Device</p> <p>However when I navigate to the /CoreSimulator file, I don't see a sub-folder "/Device", just "/Profiles/Runtimes"? </p> <p>When I reopen the app and wanted to check my stored data I couldn't see them aswell.</p>
0
How to make a custom progress bar in swift, iOS?
<p>I want to fill black color to <code>UIView</code>, based on percentage (10%, 30% 50%...)? <a href="https://i.stack.imgur.com/ge3We.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ge3We.png" alt="enter image description here"></a></p> <p>What is the right way to do this? </p>
0
execute multiple cucumber feature files
<p>When I submit a single feature file it works perfectly. I want to pass features folder path which has multiple feature files into runner script. Can anyone help to execute multiple feature files?</p> <p>All feature files have same steps but data is different and file name is different.</p> <pre><code>@RunWith(Cucumber.class) @CucumberOptions(format = {"pretty"}, features = "C:\\TESTER\\Execution\\uidata\\featurefiles\\", glue={"com.test.auto.stepdefs"},dryRun=false) public class CucumberTest { } </code></pre> <p>I appreciate you help.</p>
0
How can I remove the last word from a string?
<p>How can I remove the last word from a string?</p> <p>For example, with this input: <code>"I am from Tamil Nadu."</code></p> <p>I want this result: <code>"I am from Tamil."</code></p>
0
Fixed Search Box in Bootstrap Navbar
<p>I'm trying to figure out how to make the search box fixed in the navigation bar instead of being part of the dropdown menu. The final output would be something similar to the image below.</p> <p><a href="https://i.stack.imgur.com/oj3y4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oj3y4.png" alt="Bootstrap Nav"></a></p> <p></p> <pre><code>&lt;div class="container-fluid"&gt; &lt;!-- add header --&gt; &lt;div class="navbar-header"&gt; &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1"&gt; &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;!-- add menu --&gt; &lt;div class="collapse navbar-collapse" id="navbar1"&gt; &lt;ul class="nav navbar-nav"&gt; &lt;li class="active"&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/about.html"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/services.html"&gt;Services&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;!-- add search form --&gt; &lt;form class="navbar-form navbar-right" role="search"&gt; &lt;div class="input-group"&gt; &lt;input type="text" class="form-control" placeholder="Search this site"&gt; &lt;span class="input-group-btn"&gt; &lt;button type="submit" class="btn btn-default"&gt; &lt;span class="glyphicon glyphicon-search"&gt;&lt;/span&gt; &lt;/button&gt; &lt;/span&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <p>Here's the code I'm currently working on: <a href="http://www.bootply.com/fb311f2zSJ#" rel="nofollow noreferrer">http://www.bootply.com/fb311f2zSJ#</a></p>
0
Make dictionary read only in C#
<p>I have a <code>Dictionary&lt;string, List&lt;string&gt;&gt;</code> and would like to expose the member as read only. I see that I can return it as a <code>IReadOnlyDictionary&lt;string, List&lt;string&gt;&gt;</code>, but I can't figure out how to return it as an <code>IReadOnlyDictionary&lt;string, IReadOnlyList&lt;string&gt;&gt;</code>.</p> <p>Is there a way to do this? In c++ I'd just be using const, but C# doesn't have that.</p> <p>Note that simply using a <code>IReadOnlyDictionary</code> does not help in this case, because I want the values to be read only as well. It appears the only way to do this is build another IReadOnlyDictionary, and add IReadOnlyList to them.</p> <p>Another option, which I wouldn't be thrilled with, would be to create wrapper which implements the interface IReadOnlyDictionary>, and have it hold a copy of the original instance, but that seems overkill.</p>
0
How to make md-list-item active when selected during ng-repeat?
<p>Here is my scenario</p> <p>When i select any one item in list(<code>&lt;md-list-item&gt;</code>) an active class should be appended for the particular item. </p> <p>When iam trying to do it, active class getting appended for all the items. Please help me if anyone knows the solution. Iam new to material design.</p> <pre><code>&lt;md-list-item class="md-3-line" ng-repeat="review in oReviews" ng-click="fnReviewEmployeeId(review.empId)"&gt; &lt;img ng-src="https://x1.xingassets.com/assets/frontend_minified/img/users/nobody_m.original.jpg" class="md-avatar"&gt; &lt;div class="md-list-item-text" layout="column"&gt; &lt;h3&gt; {{review.name }} &lt;/h3&gt; &lt;span class="review-subtext"&gt;{{review.info}}&lt;/span &gt; &lt;p class="review-status"&gt;{{review.status}}&lt;/p&gt; &lt;/div&gt; &lt;md-divider&gt;&lt;/md-divider&gt; &lt;/md-list-item&gt; </code></pre>
0
Are booleans valid JSON
<p>Why do some JSON validators flag a boolean value as invalid JSON, and others as valid? That is, just <code>true</code> or <code>false</code> values (no object).</p> <p>Valid:</p> <ul> <li><a href="http://jsonlint.com/" rel="noreferrer">http://jsonlint.com/</a> </li> <li><a href="http://codebeautify.org/jsonvalidator" rel="noreferrer">http://codebeautify.org/jsonvalidator</a></li> </ul> <p>Invalid:</p> <ul> <li><a href="https://jsonformatter.curiousconcept.com/" rel="noreferrer">https://jsonformatter.curiousconcept.com/</a></li> </ul>
0
PHP GuzzleHttp . how to upload the image file using guzzlehttp in laravel 5.2?
<p>How make post request with GuzzleHttp( version 6.0 ). I am trying do the following and getting error</p> <p>i'm get the image value</p> <pre><code>Illuminate\Http\UploadedFile Object ( [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 1.53mb.jpg [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; image/jpeg [size:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 1607671 [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] =&gt; 0 [pathName:SplFileInfo:private] =&gt; C:\wamp\tmp\php32BB.tmp [fileName:SplFileInfo:private] =&gt; php32BB.tmp ) </code></pre> <p>here i'm using guzzlehttp using to upload the image</p> <pre><code>$response = $this-&gt;client-&gt;request('POST', url('/update_profile'), [ 'multipart' =&gt; [ [ 'name' =&gt; 'foo', 'contents' =&gt; fopen('C:\wamp\tmp\php32BB.tmp', 'r'),//this path is image save temperary path ] ] ]); </code></pre> <p>Now i get the error fopen(C:\wamp\tmp\php17BC.tmp): failed to open stream: No such file or directory.</p> <p>How to use the <strong>contents</strong> in multipart</p>
0
JQuery: Deferred loading of JQuery and '$ not defined'
<p>I cannot wrap my head around this issue and the vast offer of information I found on the net:</p> <p>On my project the JQuery is loaded with "defer". This I cannot change due to project standards.</p> <pre><code>&lt;script defer src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js'&gt;&lt;/script&gt; </code></pre> <p>Now I need to add some small functions to a page (currently inline):</p> <p>With this setup the browser will try to execute the inline scrip before jQuery loads => "Uncaught ReferenceError: $ is not defined"</p> <pre><code>&lt;body&gt; ... ... &lt;script&gt; $("#city").change(function() {...some stuff...}; $("#doctor").change(function() {...some stuff...}; &lt;/script&gt; &lt;/body&gt; </code></pre> <p>Whats the smart way to resolve this?</p>
0
Github Pull Request Checks
<p>Is it possible to create a Github Check for pull requests? I know there are WebHooks, but is there a way to also hook into the UI?</p> <p>Aim:</p> <ul> <li><p>Pull Request made. Perform validation and update pull request if valid.</p></li> <li><p>Pull Request merged. Create web call to URL. Update Github issue with confirmation.</p></li> </ul> <p>What's the best way to do this? Is it only via Web Hooks, API calls and getting write oAuth credentials?</p>
0
Where to get 64bit php_zip.dll extension for php 7.0?
<p>I've converted my web site from php 5.4 to php 7.0, and now create zip functionality is not working properly. ZIP file is always corrupted after process.</p> <p>LOG file shows following error warning : PHP Warning: PHP Startup: Unable to load dynamic library "C:\php\ext\php_zip.dll" </p> <p>I think I need 64bit php_zip.dll extension as I'm using 64 bit php 7.0. Can anyone redirect me to a link?</p> <p>Problem : ZIP is not created.</p>
0
Datatables and bootstrap tooltips
<p>I am adding Datatables to my Rails app. I have it working for the most part but I am stuck on a CSS / jQuery issue. I have a row cell defined as follows:</p> <pre><code>content_tag(:abbr, "#{record.od} mm", data: { container: 'body', toggle: 'tooltip', placement: 'bottom', html: 'true' }, title: 'test' ) </code></pre> <p>which renders:</p> <pre><code>&lt;abbr data-container="body" data-toggle="tooltip" data-placement="bottom" data-html="true" title="test"&gt;88.9 mm&lt;/abbr&gt; </code></pre> <p>In a non-datatable table the bootstrap tooltip works fine but fails on the datatable. From experience I gather it's because the datatable is rendered after the body completes etc.</p> <p>After some digging I tried this:</p> <pre><code>$ -&gt; $('#table').dataTable ajax: url: myurl processing: true serverSide: false responsive: true 'fnCreatedCell': (nTd, sData, oData, iRow, iCol) -&gt; $(nTd "abbr").tooltip() </code></pre> <p>This almost works... almost because I get a tooltip but I am guessing it's a datatable tooltip vs the bootstrap tooltip:</p> <p><a href="https://i.stack.imgur.com/qSdrV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qSdrV.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/q22IE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/q22IE.png" alt="enter image description here"></a></p> <p>Forget the tooltip content - the formatting etc. is the issue. The non-bootstrap tooltip also takes way longer to fade in.</p> <p>Is there perhaps an easy fix here?</p> <p>Thanks,</p> <p>Dan</p>
0
Why is it that parseInt(8,3) == NaN and parseInt(16,3) == 1?
<p>I'm reading <a href="http://jibbering.com/faq/notes/type-conversion/">this</a> but I'm confused by what is written in the <strong>parseInt with a radix argument</strong> chapter</p> <p><a href="https://i.stack.imgur.com/b8ABb.png"><img src="https://i.stack.imgur.com/b8ABb.png" alt="table of parseInt(_, 3) outcomes"></a></p> <p>Why is it that <code>parseInt(8, 3)</code> → <code>NaN</code> and <code>parseInt(16, 3)</code> → <code>1</code>?</p> <p>AFAIK 8 and 16 are not base-3 numbers, so <code>parseInt(16, 3)</code> should return <code>NaN</code> too</p> <p><a href="https://i.stack.imgur.com/RzkKJ.png"><img src="https://i.stack.imgur.com/RzkKJ.png" alt="the first ten base-3 natural numbers"></a></p>
0
What is /snap/bin directory in $PATH? Can I remove it from $PATH?
<p>I am working with environment value, $PATH. And I found that $PATH includes /snap/bin directory which does not exist. What does the path work? Can I remove it from $PATH or should I leave it? Please give me your suggestion. Thank you very much?</p>
0
Calculating Viewport Height on Chrome Android with CSS
<p>So I noticed that mobile Chrome calculates the address bar into the viewport height. Because of this using <code>height: 100vh</code> on an element doesn't work because when the address bar scrolls the viewport height changes. </p> <p>I was actually able to <a href="https://stackoverflow.com/questions/38280077/content-jumps-vertically-on-chrome-ios-with-viewport-sizing-when-address-bar-i">find a question</a> that had the same issue here on ios, but after investigating further I realized that this happens on all mobile Chrome browsers. When the address bar scrolls out of the viewport and then again when scrolls into the viewport, the viewport height changes. </p> <p>This causes any element using <code>vh</code> to recalculate which makes the page jump. It's extremely annoying when using a background image because it causes the image to resize on scrolling.</p> <p>Here's the code and <a href="http://s.codepen.io/bootstrapped/debug/qadPkz" rel="noreferrer">an example</a></p> <pre><code> .jumbotron { background-image: url(http://example.com/image.png); background-size: cover; background-position: top; background-repeat: no-repeat; height: 100vh; } </code></pre> <p>You'll only be able to see the issue when scrolling up and down using mobile chrome. </p> <p><strong>My question is</strong>, I would like to know is there any way around this or if not how to calculate full height on mobile chrome without causing the page to jump (css or js).</p> <p><a href="http://s.codepen.io/bootstrapped/debug/qadPkz" rel="noreferrer">http://s.codepen.io/bootstrapped/debug/qadPkz</a></p> <hr> <p><strong>Update:</strong> So as far as using jquery here's what I came up with which seems to work pretty well:</p> <pre><code>function calcVH() { $('.jumbotron').innerHeight( $(this).innerHeight() ); } $(window).on('load resize orientationchange', function() { calcVH(); }); </code></pre> <p><a href="http://s.codepen.io/bootstrapped/debug/pEJaBq" rel="noreferrer">Demo of working example above</a> </p> <p>I'd love to be able to do this without javascript though if someone has a CSS alternative that they know works.</p>
0
Android fitsSystemWindows not working when replacing fragments
<p>I have <code>SingleFramgnetActivity</code> whose purpose is only to hold and replace fragments inside it. </p> <p>layout looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:orientation="vertical" tools:context=".SingleFragmentActivity" &gt; &lt;include layout="@layout/toolbar"/&gt; &lt;FrameLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>I'm replacing the <code>Fragments</code> inside the FrameLayout. When I set the <code>fitsSystemWindows</code> to true on the <code>Fragment</code> layout, it is not responding. Actually it is working only when <code>Activity</code> is created, but once I replace the <code>Fragment</code> inside the <code>FrameLayout</code>, the <code>fitsSystemWindows</code> parameter is ignored and the layout is below the status bar and navigation bar. </p> <p>I found some <a href="https://stackoverflow.com/questions/31190612/fitssystemwindows-effect-gone-for-fragments-added-via-fragmenttransaction">solution</a> with custom FrameLayout which is using deprecated methods, but for some reason it is not working for me (same result as with normal FrameLayout) and I also do not like the idea to use deprecated methods. </p>
0
Techtalk.Specflow error: Could not load assembly file or assembly
<p>I have seen this question before but I believe it was not resolved. Basically my set up is this: VS 2015 Specflow ver 1.9.0 (I downgraded to this from 2.1.0 based on other question which didn't help)</p> <p>When I try to build my project, it comes with the follwoing error:</p> <pre>#error Generation error: Could not load file or assembly 'TechTalk.SpecFlow, Version=1.9.0.77, Culture=neutral, PublicKeyToken=0778194805d6db41' or one of its dependencies. The system cannot find the file specified.</pre>
0
How to test if a channel is close and only send to it when it's not closed
<p>In Go, if a channel <code>channel</code> is closed, I can still read from it using the following syntax and I can test <code>ok</code> to see if it's closed. </p> <pre><code>value, ok := &lt;- channel if !ok { // channel was closed and drained } </code></pre> <p>However, if I don't know whether a channel is closed and blindly write to it, I may got an error. I want to know if there is any way that I can test the channel and only write to it when it's not closed. I ask this question is because sometimes I don't know if a channel is closed or not in a goroutine.</p>
0
ANR Input dispatching timed out
<p><strong>ANR Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 60. Wait queue head age: 8503.2ms.)</strong></p> <p>Hi! I'm getting this strange ANR-report from several users. Unfortunately, I have very limited knowledge about ANR-reports, and I'm hoping that someone can help me to understand what the cause of this could be</p> <pre><code>"main" prio=5 tid=1 Suspended | group="main" sCount=1 dsCount=0 obj=0x74a20f90 self=0x557fe6f9d0 | sysTid=23849 nice=1 cgrp=top_visible sched=0/0 handle=0x7faf4f5000 | state=S schedstat=( 79111961552 2206905376 39235 ) utm=7534 stm=377 core=7 HZ=100 | stack=0x7fdaaf0000-0x7fdaaf2000 stackSize=8MB | held mutexes= at android.os.MessageQueue.removeMessages(MessageQueue.java:682) - locked &lt;0x08f02647&gt; (a android.os.MessageQueue) at android.os.Handler.removeMessages(Handler.java:652) at android.view.Choreographer.removeCallbacksInternal(Choreographer.java:418) - locked &lt;0x0bd41e74&gt; (a java.lang.Object) at android.view.Choreographer.removeCallbacks(Choreographer.java:406) at android.view.View.removeCallbacks(View.java:13179) at android.support.v4.widget.aa.a(unavailable:-1) at android.support.v4.widget.DrawerLayout.a(unavailable:-1) at android.support.v4.widget.DrawerLayout.onInterceptTouchEvent(unavailable:-1) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2108) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2525) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254) at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2461) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1777) at android.app.Activity.dispatchTouchEvent(Activity.java:2865) at android.support.v7.view.n.dispatchTouchEvent(unavailable:-1) at android.support.v7.view.n.dispatchTouchEvent(unavailable:-1) at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2422) at android.view.View.dispatchPointerEvent(View.java:9610) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4436) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4302) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3836) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3889) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3855) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3981) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3863) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4038) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3836) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3889) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3855) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3863) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3836) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6135) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6109) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6070) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6251) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:192) at android.os.MessageQueue.nativePollOnce(Native method) at android.os.MessageQueue.next(MessageQueue.java:330) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5546) at java.lang.reflect.Method.invoke!(Native method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684) </code></pre>
0
What is the most efficient way of sending files between NodeJS servers?
<h2>Introduction</h2> <p>Say that on the same local network we have two Node JS servers set up with Express: Server A for API and Server F for form.</p> <ul> <li>Server A is an API server where it takes the request and saves it to MongoDB database (files are stored as Buffer and their details as other fields)</li> <li>Server F serves up a form, handles the form post and sends the form's data to Server A.</li> </ul> <p>What is the most efficient way to send files between two NodeJS servers where the receiving server is Express API? Where does the file size matter?</p> <h2>1. HTTP Way</h2> <p>If the files I'm sending are PDF files (that won't exceed 50mb) is it efficient to send the whole contents as a string over HTTP? </p> <p>Algorithm is as follows:</p> <ul> <li>Server F handles the file request using <a href="https://www.npmjs.com/package/multer" rel="noreferrer">https://www.npmjs.com/package/multer</a> and saves the file</li> <li>then Server F reads this file and makes an HTTP request via <a href="https://github.com/request/request" rel="noreferrer">https://github.com/request/request</a> along with some details on the file</li> <li>Server A receives this request and turns the file contents from string to Buffer and saves a record in MongoDB along with the file details.</li> </ul> <p>In this algorithm, both Server A (when storing into MongoDB) and Server F (when it was sending it over to Server A) have read the file into the memory, and the request between the two servers was about the same size as the file. (Are 50Mb requests alright?)</p> <p>However, one thing to consider is that -with this method- I would be using the ExpressJS style of API for the whole process and it would be consistent with the rest of the app where the <code>/list</code>, <code>/details</code> requests are also defined in the routes. I like consistency.</p> <h2>2. Socket.IO Way</h2> <p>In contrast to this algorithm, I've explored <a href="https://github.com/nkzawa/socket.io-stream" rel="noreferrer">https://github.com/nkzawa/socket.io-stream</a> way which broke away from the consistency of the HTTP API on Server A (as the handler for socket.io events are defined not in the routes but the file that has <code>var server = http.createServer(app);</code>). </p> <p>Server F handles the form data as such in <code>routes/some_route.js</code>:</p> <pre><code>router.post('/', multer({dest: './uploads/'}).single('file'), function (req, res) { var api_request = {}; api_request.name = req.body.name; //add other fields to api_request ... var has_file = req.hasOwnProperty('file'); var io = require('socket.io-client'); var transaction_sent = false; var socket = io.connect('http://localhost:3000'); socket.on('connect', function () { console.log("socket connected to 3000"); if (transaction_sent === false) { var ss = require('socket.io-stream'); var stream = ss.createStream(); ss(socket).emit('transaction new', stream, api_request); if (has_file) { var fs = require('fs'); var filename = req.file.destination + req.file.filename; console.log('sending with file: ', filename); fs.createReadStream(filename).pipe(stream); } if (!has_file) { console.log('sending without file.'); } transaction_sent = true; //get the response via socket socket.on('transaction new sent', function (data) { console.log('response from 3000:', data); //there might be a better way to close socket. But this works. socket.close(); console.log('Closed socket to 3000'); }); } }); }); </code></pre> <p>I said I'd be dealing with PDF files that are &lt; 50Mb. However, if I use this program to send larger files in the future, is socket.io a better way to handle 1GB files as it's using stream?</p> <p>This method does send the file and the details across but I'm new to this library and don't know if it should be used for this purpose or if there is a better way of utilizing it.</p> <h2>Final thoughts</h2> <p>What alternative methods should I explore?</p> <ul> <li>Should I send the file over SCP and make an HTTP request with file details including where I've sent it- thus, separating the protocols of files and API requests?</li> <li>Should I always use streams because they don't store the whole file into memory? (that's how they work, right?)</li> <li>This <a href="https://github.com/liamks/Delivery.js" rel="noreferrer">https://github.com/liamks/Delivery.js</a> ?</li> </ul> <h2>References:</h2> <ul> <li><a href="https://stackoverflow.com/questions/22279922/file-data-transfer-between-two-node-js-servers">File/Data transfer between two node.js servers</a> this got me to try socket-stream way.</li> <li><a href="https://stackoverflow.com/questions/35612622/transfer-files-between-two-node-js-servers-over-http">transfer files between two node.js servers over http</a> for HTTP way</li> </ul>
0
rebase vs reset vs revert? I just want to roll back
<p>Let's say I make a number of commits, let's call them 1, 2, 3, 4, 5, and 6 (hashes).</p> <p>Let's say I'm on a commit with hash 6. All I want to do is to go back to hash 3, make it so the state of my codebase is as it was when I committed to hash 3 as if the other commits never happened.</p> <p>When I look at answers like <a href="https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-a-sha-hash-in-git">this</a>, it seems like everybody has a different answer. <code>reset</code>, <code>revert</code>, <code>rebase</code>? I'm not even sure that I know the difference between those three words in English.</p> <p>I just want to be at a previous commit. Can someone tell me how to do this?</p>
0
Angular2 RC 5. No component factory found for dynamically loaded components
<p>I'm trying to update my dynamic component loader from RC4 to RC5 since the ComponentResolver is deprecated. I've updated the loader to the following</p> <pre><code>@Component({ selector: 'component-dispatcher', template: `&lt;div #container&gt;&lt;/div&gt;` // Define the template here because of its brevity }) export class ComponentDispatcherComponent implements OnInit, OnDestroy { @Input() component:any; // Some dynamic component to render @Input() options:any; // Component configuration, optional @Input() data:any; // Data to render within the component // Inject the dynamic component onto the DOM @ViewChild("container", {read: ViewContainerRef}) container:ViewContainerRef; private componentReference:ComponentRef&lt;any&gt;; constructor(private resolver:ComponentFactoryResolver) { } ngOnInit() { // Create our component now we're initialised let componentFactory = this.resolver.resolveComponentFactory(this.component); this.componentReference = this.container.createComponent(componentFactory); this.componentReference.instance.data = this.data; this.componentReference.instance.options = this.options; } ngOnDestroy() { // If we have a component, make sure we destroy it when we lose our owner if (this.componentReference) { this.componentReference.destroy(); } } } </code></pre> <p>And attempt to dynamically load the following component into the DOM</p> <pre><code>@Component({ selector: 'text-cell', pipes: [IterableObjectPipe], templateUrl: './text-cell.component.html', styles: ['.fieldName { font-weight: bold; }'] }) export class TextCellComponent implements OnInit { // Data to render within the component @Input() data: any; @Input() record: any; // Configuration of what data to display @Input() options: { excludeFieldNames: boolean, translation: string }; constructor() { } ngOnInit() { setTimeout(() =&gt; { //console.log('***************************** ngOnInit...textCell ***********************'); this.options.translation = '' + (_.get(this.options, 'translation') || 'fields'); }); } } </code></pre> <p>Yet when I do this with my TextCellComponent or any other component within the app I get the following error</p> <pre><code>ORIGINAL EXCEPTION: No component factory found for TextCellComponent ORIGINAL STACKTRACE: Error: No component factory found for TextCellComponent at NoComponentFactoryError.BaseException [as constructor] (webpack:///./~/@angular/core/src/facade/exceptions.js?:27:23) at new NoComponentFactoryError </code></pre> <p>I've completed the steps in </p> <pre><code>https://angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html </code></pre> <p>but I seem to be missing something. I've tried adding the components to the bootstrapping and defining them globally with no luck. Any suggestions would be helpful. </p> <p><strong>EDIT</strong></p> <p>Adding the module definition</p> <pre><code>@NgModule({ imports: [ BrowserModule, HttpModule, FormsModule, ReactiveFormsModule, ...MATERIAL_MODULES ], declarations: [ ...APPLICATION_PIPES, ...APPLICATION_COMPONENTS, ...APPLICATION_DIRECTIVES, CygnusComponent, // Component declarations // TODO: refactor to appropriate modules ... ComponentDispatcherComponent, TextCellComponent, ... ], bootstrap: [ ApplicationComponent ], providers: [ ...APPLICATION_PROVIDERS, AppStore ] }) export class ApplicationComponent {} </code></pre>
0
MPDF problems with floated div widths
<p>I have a problem that I am struggling to resolve with MPDF6</p> <p>I have a web application created using codeigniter, which displays results of a questionnaire survey.</p> <p>I have generated simple stacked bar charts in html and used jquery to animate the bars to their final sizes. Works ok, and no problems.</p> <p>I want to be able to replicate the results in MPDF, so using the same theory of divs and sizing them accordingly, but this time I am setting the widths as inline style using php, and in most cases I have this working fine, however, if the value = 1, then for some reason mpdf goes funky, see example image below;</p> <p><a href="http://i.stack.imgur.com/ngRzN.png" rel="nofollow">Example of MPDF issue</a></p> <p>Here is an example of my php markup for the mpdf report</p> <pre><code>&lt;div class='survey'&gt; &lt;?php $nw = 390; $w = 400; $tot=0; $totpos=0; $score=0; $cat=0; foreach ($categories as $c) : ?&gt; &lt;p class='left question'&gt;&lt;?php echo $c-&gt;category_name; ?&gt;&lt;/p&gt; &lt;p class='left perc'&gt;&lt;?php echo number_format($summaryAnswers[$cat][6],1); ?&gt;%&lt;/p&gt; &lt;p class='left perc'&gt;&lt;?php echo number_format($summaryAnswers[$cat][7],2); ?&gt;&lt;/p&gt; &lt;div style='width: &lt;?php echo $w; ?&gt;px;' class='left chart'&gt; &lt;?php if ($summaryAnswers[$cat][0] &gt; 0) : ?&gt; &lt;div class='left barchart sagree' style='width: &lt;?php $width = $nw * $summaryAnswers[$cat][0]/$summaryAnswers[$cat][5]; echo $width; ?&gt;px;' tot='&lt;?php echo $summaryAnswers[$cat][5]; ?&gt;' val='&lt;?php echo $summaryAnswers[$cat][0]; ?&gt;' &gt;&lt;span class='label'&gt;&lt;?php echo $summaryAnswers[$cat][0]; ?&gt;&lt;/span&gt;&lt;/div&gt; &lt;?php endif; ?&gt; &lt;?php if ($summaryAnswers[$cat][1] &gt; 0) : ?&gt; &lt;div class='left barchart agree' style='width: &lt;?php $width = $nw * $summaryAnswers[$cat][1]/$summaryAnswers[$cat][5]; echo $width; ?&gt;px;' tot='&lt;?php echo $summaryAnswers[$cat][5]; ?&gt;' val='&lt;?php echo $summaryAnswers[$cat][1]; ?&gt;' &gt;&lt;span class='label'&gt;&lt;?php echo $summaryAnswers[$cat][1]; ?&gt;&lt;/span&gt;&lt;/div&gt; &lt;?php endif; ?&gt; &lt;?php if ($summaryAnswers[$cat][2] &gt; 0) : ?&gt; &lt;div class='left barchart neither' style='width: &lt;?php $width = $nw * $summaryAnswers[$cat][2]/$summaryAnswers[$cat][5]; echo $width; ?&gt;px;' tot='&lt;?php echo $summaryAnswers[$cat][5]; ?&gt;' val='&lt;?php echo $summaryAnswers[$cat][2]; ?&gt;' &gt;&lt;span class='label'&gt;&lt;?php echo $summaryAnswers[$cat][2]; ?&gt;&lt;/span&gt;&lt;/div&gt; &lt;?php endif; ?&gt; &lt;?php if ($summaryAnswers[$cat][3] &gt; 0) : ?&gt; &lt;div class='left barchart disagree' style='width: &lt;?php $width = $nw * $summaryAnswers[$cat][3]/$summaryAnswers[$cat][5]; echo $width; ?&gt;px;' tot='&lt;?php echo $summaryAnswers[$cat][5]; ?&gt;' val='&lt;?php echo $summaryAnswers[$cat][3]; ?&gt;' &gt;&lt;span class='label'&gt;&lt;?php echo $summaryAnswers[$cat][3]; ?&gt;&lt;/span&gt;&lt;/div&gt; &lt;?php endif; ?&gt; &lt;?php if ($summaryAnswers[$cat][4] &gt; 0) : ?&gt; &lt;div class='left barchart sdisagree' style='width: &lt;?php $width = $nw * $summaryAnswers[$cat][4]/$summaryAnswers[$cat][5]; echo $width; ?&gt;px;' tot='&lt;?php echo $summaryAnswers[$cat][5]; ?&gt;' val='&lt;?php echo $summaryAnswers[$cat][4]; ?&gt;' &gt;&lt;span class='label'&gt;&lt;?php echo $summaryAnswers[$cat][4]; ?&gt;&lt;/span&gt;&lt;/div&gt; &lt;?php endif; ?&gt; &lt;/div&gt; </code></pre> <p>I have tried both px width and %width both options give me the same result...</p> <p>here is the html that is generated by the script, you can see the values of each width look correct</p> <pre><code>&lt;div class='survey'&gt; &lt;p class='left question'&gt;Organisation and Culture&lt;/p&gt; &lt;p class='left perc'&gt;66.7%&lt;/p&gt; &lt;p class='left perc'&gt;2.92&lt;/p&gt; &lt;div style='width: 400px;' class='left chart'&gt; &lt;div class='left barchart sagree' style='width: 97.5px;' tot='24' val='6' &gt;&lt;span class='label'&gt;6&lt;/span&gt;&lt;/div&gt; &lt;div class='left barchart agree' style='width: 162.5px;' tot='24' val='10' &gt;&lt;span class='label'&gt;10&lt;/span&gt;&lt;/div&gt; &lt;div class='left barchart neither' style='width: 32.5px;' tot='24' val='2' &gt;&lt;span class='label'&gt;2&lt;/span&gt;&lt;/div&gt; &lt;div class='left barchart disagree' style='width: 81.25px;' tot='24' val='5' &gt;&lt;span class='label'&gt;5&lt;/span&gt;&lt;/div&gt; &lt;div class='left barchart sdisagree' style='width: 16.25px;' tot='24' val='1' &gt;&lt;span class='label'&gt;1&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;br class='clear' /&gt; </code></pre> <p>the css..</p> <pre><code>.survey { font-size: 10pt; } .survey .question { width: 47%; padding: 5px 0; } .survey .perc { width: 5%; margin: 0; padding: 5px 0; } .survey .no { width: 2%; margin: 0; padding: 5px 0; } .survey .chart { width: 40%; } .survey .barchart { padding: 5px 0; } .barchart .label { margin: 0 0 0 5px; } div.sagree { background: #2DCC00; } div.agree { background: #F2E930; } div.neither { background: #888; } div.disagree{ background: #FFA519; } div.sdisagree { background: #FF1919; } .right { float: right; } .left { float: left; } .clear { clear: both; } </code></pre> <p>anyone got any ideas why this is happening?</p> <p>cheers</p>
0
How to filter a nested dictionary (pythonic way) for a specific value using map or filter instead of list comprehensions?
<p>I've a nested dictionary.</p> <pre><code>&gt;&gt;&gt; foo = {'m': {'a': 10}, 'n': {'a': 20}} &gt;&gt;&gt; </code></pre> <p>I'd like to filter specific values, based on the values of 'a'.</p> <p>I can use list comprehensions for the purpose.</p> <pre><code>&gt;&gt;&gt; [foo[n] for n in foo if foo[n]['a'] == 10] [{'a': 10}] &gt;&gt;&gt; </code></pre> <p>Using list alone gives me the elements from foo (and not the values of the elements) - as expected:</p> <pre><code>&gt;&gt;&gt; list(filter(lambda x: foo[x] if foo[x]['a']==10 else None,foo)) ['m'] &gt;&gt;&gt; </code></pre> <p>Using map returns me unwanted 'None' values:</p> <pre><code>&gt;&gt;&gt; list(map(lambda x: foo[x] if foo[x]['a']==10 else None,foo)) [{'a': 10}, None] &gt;&gt;&gt; </code></pre> <p>Combining these two, I can fetch the desired value. But I guess foo is iterated twice - once each for filter and map. The list comprehension solution needs me to iterate just once.</p> <pre><code>&gt;&gt;&gt; list(map(lambda t: foo[t], filter(lambda x: foo[x] if foo[x]['a']==10 else None,foo))) [{'a': 10}] &gt;&gt;&gt; </code></pre> <p>Here's another approach using just filter. This gives me the desired values but I'm not sure if iterating over values of a dictionary is a good/pythonic approach:</p> <pre><code>&gt;&gt;&gt; list(filter(lambda x: x if x['a'] == 10 else None, foo.values())) [{'a': 10}] &gt;&gt;&gt; </code></pre> <p>I'd like to know if:</p> <ol> <li>What's the pythonic/recommended approach for this scenario?</li> <li>If the last example using filter on dictionary values is an acceptable?</li> </ol> <p>Regards</p> <p>Sharad</p>
0
Swift 'open' keyword & overridable method/properties in extension?
<p>With introduction of <code>open</code> keyword in Swift 3.0 (<a href="https://stackoverflow.com/questions/38947101/what-is-the-open-keyword-in-swift">What is the 'open' keyword in Swift?</a>).</p> <p>Note: Limited to extensions on <code>NSObject</code> derived classes or <code>@objc</code> attributed method/properties.</p> <p>Code which declared and used <code>public</code> (<code>class</code>) methods/properties in extension <em>across</em> modules/frameworks broke, as <code>public</code> is no longer means 'overridable' outside of defining module.</p> <p>Example:</p> <pre><code>public extension UIManagedDocument { public class func primaryDocumentName() -&gt; String { return &quot;Document&quot; } public class func primaryStoreURL() -&gt; URL { let documentsURL = FileManager.default.userDocumentsURL return URL(fileURLWithPath: self.primaryDocumentName(), isDirectory: false, relativeTo: documentsURL) } public class func primaryModelName() -&gt; String? { return &quot;Model&quot; } } </code></pre> <ul> <li>Original proposal (<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0117-non-public-subclassable-by-default.md" rel="nofollow noreferrer">SE-0117</a>) is focused on subclassing and doesn't mention extensions.</li> <li>Currently extensions do not support <code>open</code> keyword (you can't write <code>open extension NSObject</code> as well as <code>open func Method()</code>)</li> </ul> <p><strong>Question</strong>: Is there workaround to be able override extension provided methods/properties <em>across</em> modules/frameworks?</p>
0
How can I get Visual Studio to show merge conflicts under git?
<p>I'm using Visual Studio 2015 Pro and working with a Git repo. Let's say I did a pull or applied stashed changes or did something that causes my branch to become in conflict. For example, in this case I just applied a stash:</p> <p><a href="https://i.stack.imgur.com/rEt6W.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rEt6W.png" alt="enter image description here"></a></p> <p>As you can see, I have a bunch of changes but Web.config is in conflict. Why is it always the XML files that have the conflicts?</p> <p>Now, I go into Visual Studio and go to <em>Team Explorer->Changes</em>:</p> <p><a href="https://i.stack.imgur.com/PzYge.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PzYge.png" alt="enter image description here"></a></p> <p>Here, I see my staged changes, but there are <em>zero</em> unstaged changes. I'm wondering why Web.config doesn't show up here so I can resolve the conflicts.</p> <p>Two things:</p> <ol> <li>I <em>believe</em> if I were to do a <em>Pull</em> using Visual Studio, it would detect the conflicts that then run the merge tool. I haven't tried this yet, but I know it works that way for TFS. However, I'd like to know if I can use <em>git pull</em> from the command line and then use Visual Studio to resolve conflicts.</li> <li><code>git config --global merge.tool</code> is already <code>vsdiffmerge</code> so if I were to run <code>git mergetool</code> from the command line, it would <em>then</em> use Visual Studio to merge. However, doing this spawns a whole new instance of Visual Studio which is slow and annoying, and doesn't let me work in the context of the rest of my project.</li> </ol> <p>Anyone have any insight on this one? Thanks!</p>
0
Spark SQL saveAsTable is not compatible with Hive when partition is specified
<p>Kind of edge case, when saving parquet table in Spark SQL with partition, </p> <pre><code>#schema definitioin final StructType schema = DataTypes.createStructType(Arrays.asList( DataTypes.createStructField("time", DataTypes.StringType, true), DataTypes.createStructField("accountId", DataTypes.StringType, true), ... DataFrame df = hiveContext.read().schema(schema).json(stringJavaRDD); df.coalesce(1) .write() .mode(SaveMode.Append) .format("parquet") .partitionBy("year") .saveAsTable("tblclick8partitioned"); </code></pre> <p>Spark warns:</p> <blockquote> <p>Persisting partitioned data source relation into Hive metastore in Spark SQL specific format, which is NOT compatible with Hive</p> </blockquote> <p>In Hive:</p> <pre><code>hive&gt; describe tblclick8partitioned; OK col array&lt;string&gt; from deserializer Time taken: 0.04 seconds, Fetched: 1 row(s) </code></pre> <p>Obviously the schema is not correct - however if I use <code>saveAsTable</code> in Spark SQL without partition the table can be queried without problem.</p> <p>Question is how can I make a parquet table in Spark SQL compatible with Hive with partition info?</p>
0
Entity Framework Core 1.0 Connection Strings
<p>We are working on a vary large ASP.NET Core MVC 1.0 application. We have 4-tiers to each of our applications as follows:</p> <ol> <li>DTO </li> <li>Repository (Entity Framework - Code First)</li> <li>Service (Business Logic)</li> <li>MVC (UI-MVC)</li> </ol> <p>Currently, in our repositories, which handle all database operations we have hard coded the database connection strings in the DbContext as follows:</p> <pre><code>protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer("Data Source=somedatabase.database.windows.net;Initial Catalog=database;Integrated Security=False;User ID=username;Password=password;Connect Timeout=60;Encrypt=True;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;MultipleActiveResultSets=true"); } </code></pre> <p>This project is outside the MVC project as a standalone ASP.NET Core 1.0 project. It also has a empty Program.cs file in it which seems to be required to execute the code-to-database command lines (dotnet ef migrations add and dotnet ef database update).</p> <p>The reason we have a hard coded connection string in the DbConext is because when we use the following code, we get an object reference not set to an instance to an object exception, when executing the dotnet ef commands.</p> <pre><code> protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["StandardDatabase"].ConnectionString); } </code></pre> <p>However, since we have a Program.cs, if we add a Debug.WriteLine for the connection string and run the project, it does return the correct connections string and if we set the connection string in the appsettings.json file in the UI, the UI will successfully connect as well.</p> <p><strong>THE ISSUE:</strong> The above mentioned stack is what we use for several "Micro Apps", which means we have several projects that connect to several databases. We also want to take advantage of Development, Staging and Production connection strings.</p> <p>If we use Configuration Manager Connection String, everything is good for daily operations; however, when ever we want to utilize Entity Frameworks code to database command lines, we need to go in to each repository we want to update and change the DbContext to a hard coded connection string, execute the commands, then change them back to when done, which becomes quite troublesome.</p> <p><strong>THE QUESTION:</strong> Are we just doing this wrong, is there a preferred practice for setting up an Entity Framework Core 1.0 stack which allows us not to manually have to change the DbContext but take advantage of configuration files across the board?</p> <p>Any direction would be appreciated!</p>
0
Passport - "Unauthenticated." - Laravel 5.3
<p>I hope someone could explain why I'm <code>unauthenticated</code> when already has performed a successfull <code>Oauth 2</code> authentication process.</p> <p>I've set up the <code>Passport</code> package like in Laravel's documentation and I successfully get authenticated, receives a token value and so on. But, when I try to do a <code>get</code> request on, let say, <code>/api/user</code>, I get a <code>Unauthenticated</code> error as a response. I use the token value as a header with key name <code>Authorization</code>, just as described in the docs.</p> <pre><code>Route::get('/user', function (Request $request) { return $request-&gt;user(); })-&gt;middleware("auth:api"); </code></pre> <p>This function is suppose to give back my self as the authenticated user, but I'm only getting <code>Unauthenticated</code>. Likewise, if I just return the first user, I'm again getting <code>Unauthenticated</code>.</p> <pre><code>Route::get('/test', function(Request $request) { return App\User::whereId(1)-&gt;first(); })-&gt;middleware("auth:api"); </code></pre> <p>In a tutorial from <code>Laracast</code>, guiding through the setup of <code>Passport</code>, the guider <strong>doesn't</strong> have the <code>-&gt;middleware("auth:api")</code> in his routes. But if its not there, well then there's no need for authentication at all!</p> <p>Please, any suggestions or answers are more then welcome!</p>
0
is there any Algorithm to allocate continuous 3 seats in flight while having some booked seats?
<p>I would like to go through good Algorithm to allocate continuous 3 seats in flight while having some booked seats.</p> <p><strong>Basically I want to find no of possible 3 continuos free seats to book?</strong></p> <p>I have tried to go through greedy way where i check continuous 3 unbooked seats and then count total no of seats to allocate 3 continuous seats.</p>
0
How to enable all the permissions in android 6.0 when run the app using android studio
<p>I am using android 6.0 to build my app in android studio. When running the app, it seems all permissions for that app is not enabled automatically. Need to give the permission manually from <code>settings-&gt;apps-&gt;app_name</code> then enables specific permission.</p> <p>Is there any way to enable all the permission during running the app using android studio?</p>
0
path.join vs path.resolve with __dirname
<p>Is there a difference when using <em>both</em> <code>path.join</code> and <code>path.resolve</code> with <code>__dirname</code> for resolving absolute path in Node.js?</p> <p>Should one of them be preferred when being used like that (absolute path resolutions are 90% of use cases)?</p> <p>I.e.</p> <pre><code>const absolutePath = path.join(__dirname, some, dir); </code></pre> <p>vs.</p> <pre><code>const absolutePath = path.resolve(__dirname, some, dir); </code></pre> <p>Both methods normalize path.</p>
0
Migrating from non-partitioned to Partitioned tables
<p>In June the BQ team <a href="https://cloud.google.com/bigquery/docs/partitioned-tables" rel="noreferrer">announced support for date-partitioned tables</a>. But the guide is missing how to migrate old non-partitioned tables into the new style.</p> <p>I am looking for a way to update several or if not all tables to the new style.</p> <p>Also outside of DAY type partitioned what other options are available? Does the BQ UI show this, as I wasn't able to create such a new partitioned table from the BQ Web UI.</p>
0
got error "java.sql.SQLRecoverableException: IO Error: Socket read timed out" in intellij
<p>I'm getting an error in IntelliJ IDEA when im using a thin connection from java to oracle.</p> <p>My oracle database is in a server and I can ping the server but my code can't establish connection:</p> <pre><code> Class.forName("oracle.jdbc.driver.OracleDriver"); connection = DriverManager.getConnection("jdbc:oracle:thin:@server ip:1521:orcl","user","path"); System.out.println("Oracle Registered..."); </code></pre> <p>and error is:</p> <pre><code>java.sql.SQLRecoverableException: IO Error: Socket read timed out oracle.net.ns.NetException: Socket read timed out </code></pre>
0
Resolving network tunneling socket could not be established error
<p>While trying to install node-inspector, I am getting the error:</p> <pre><code>npm ERR! Linux 4.4.0-21-generic npm ERR! argv "/home/hira/.nvm/versions/node/v4.4.7/bin/node" "/home/hira/.nvm/versions/node/v4.4.7/bin/npm" "install" "-g" "node-inspector" npm ERR! node v4.4.7 npm ERR! npm v2.15.8 npm ERR! code ECONNRESET npm ERR! network tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:5002 npm ERR! network This is most likely not a problem with npm itself npm ERR! network and is related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' npm ERR! Please include the following file with any support request: </code></pre> <p>I basically had a project based on node's <a href="https://github.com/runk/node-thin" rel="nofollow">thin</a> module, that ran an http/https mitm proxy on 127.0.0.1:5002 </p> <p>Reading some answers on this issue, I have tried to remove the proxy settings by using:</p> <pre><code>npm config rm proxy npm config rm https-proxy </code></pre> <p>as well as</p> <pre><code>npm config set proxy = null </code></pre> <p>so when I do npm config ls -l it shows both settings as null. However, still it refuses to install. I have even tried to remove my systems Network Proxy settings. </p> <p>Could anyone help with this issue? I am running node <code>v4.4.7</code> and npm version <code>2.15.8</code> on Ubuntu 16.04 on Virtualbox. Thanks.</p>
0
How to make an AJAX call to an html element?
<p>What I want to do is pretty simple. I want to make an AJAX call to a specific html class, so that whenever the html page is loaded, jquery will make an AJAX call to that specific html <code>div class</code>.</p> <p>For example:</p> <pre><code>&lt;div class="targeted"&gt;&lt;/div&gt; </code></pre> <p>In jquery:</p> <pre><code>$('.targeted') </code></pre> <p>I know that the syntax to make an AJAX call is:</p> <pre><code>$.ajax({ type: "GET", url: "/api/something", success: function(data) { console.log(data); } }); </code></pre> <p>But how do I implement this AJAX call to the <code>$('.targeted')</code> whenever the page is loaded?</p> <p>Thanks</p>
0
python dataframe convert column to row
<p>Attempting to convert a single dataframe column into a row. I've seen multiple responses to similar questions, but most of the questions pertain to multiple columns and rows. I can't find the simple solution to converting the following:</p> <pre><code>value </code></pre> <p>0 A<br> 1 B<br> 2 C<br> 3 D<br> 4 E<br> 5 F<br> 6 G<br> 7 H<br> 8 I<br> 9 J<br> 10 K<br> 11 L</p> <p>to</p> <p>A B C D E F G H I J K L</p>
0
IntelliJ IDEA Buildtools 24.0.2 requires Java 1.8 or above. Current JDK version is 1.7
<p>After trying to build my project in Mac OS X El Capitan I've got this error:</p> <blockquote> <p>Error:Gradle: A problem occurred configuring project ':app'. Buildtools 24.0.2 requires Java 1.8 or above. Current JDK version is 1.7.</p> </blockquote> <p>I have project with <code>build.gradle</code> section like this:</p> <pre><code>android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } </code></pre> <p>Also:</p> <blockquote> <p>Project SDK 1.8.0_101</p> <p>App Module: android sdk 24, jdk 1.8,</p> <p>Root Module: android sdk 24, jdk 1.8</p> <p>compileSdkVersion 24</p> <p>buildToolsVersion '24.0.2'</p> <p>minSdkVersion 16</p> <p>targetSdkVersion 24</p> <p>retrolambda</p> </blockquote> <p>P.S.: I successfully built this project from command line.</p>
0
Saving file on IE11 with FileSaver
<p>I'm using FileSaver library ( <a href="https://github.com/eligrey/FileSaver.js" rel="nofollow noreferrer">https://github.com/eligrey/FileSaver.js</a>) and does not work on IE11, with other browsers I had no problem. </p> <p>The code is this:</p> <pre><code>var file = new File(["content"], "sample.xml", { type: "application/xml;charset=utf-8" }); saveAs(file); </code></pre> <p>I'm getting this error when the first instruction (new) executes:</p> <blockquote> <p>"the object does not accept this action"</p> </blockquote> <p>There's an open issue on git hub, but actually with no solution, I'm looking for a workaround that should work on IE11, like this:</p> <pre><code>try { var file = new File([msg.d], "test.xml", { type: "application/xml;charset=utf-8" }); saveAs(file); } catch (err) { // Code that works on IE11 .... } </code></pre> <p>Any help should be appreciated.</p>
0
How to run nodejs application in apache server
<p>I would like to run my nodejs application via subdomain on apache server. I created subdomain of primary domain in cpanel. My project having more than 3 subdomains and all subdomains points different nodejs application. Subdomain redirects me in proper folder but when I run an application via subdomain in browser, it does not run node application on apache server. It displays folder lists of project only.</p> <p>I refer following link for reference.</p> <p><a href="http://www.codingtricks.biz/run-nodejs-application-apache/" rel="noreferrer">http://www.codingtricks.biz/run-nodejs-application-apache/</a></p> <p><a href="https://stackoverflow.com/questions/14369865/running-node-js-in-apache">Running Node.js in apache?</a></p> <p><strong>Project Directory :</strong></p> <blockquote> <p>/home/abc/public_html/node</p> </blockquote> <p><strong>My primary domain is :</strong></p> <blockquote> <p><a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></p> </blockquote> <p><strong>I created sub-domain in cpanel :</strong></p> <blockquote> <p><a href="https://www.node.example.com" rel="noreferrer">https://www.node.example.com</a></p> </blockquote> <p><strong>I access sub-domain in browser :</strong></p> <blockquote> <p>node.example.com</p> </blockquote> <p><strong>I deployed my application on softlayer server.</strong></p> <p><strong>Following is apache configuration:</strong></p> <p><strong>File :</strong></p> <blockquote> <p>/usr/local/apache/conf/includes/abc_node.conf</p> </blockquote> <p><strong>Configuration:</strong></p> <pre><code>&lt;VirtualHost 132.159.25.21:80&gt; ServerAdmin [email protected] ServerName node.example.com ServerAlias www.node.example.com DocumentRoot /home/abc/public_html &lt;Directory /home/abc/public_html/node&gt; Options -Indexes +FollowSymLinks AllowOverride None Require all granted &lt;/Directory&gt; ProxyRequests Off ProxyPreserveHost On ProxyVia Full &lt;Proxy *&gt; Require all granted &lt;/Proxy&gt; &lt;Location /node&gt; ProxyPass http://132.159.25.21:8080 ProxyPassReverse http://132.159.25.21:8080 &lt;/Location&gt; ErrorLog /home/abc/public_html/node/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /home/abc/public_html/node/access.log combined &lt;/VirtualHost&gt; </code></pre> <p><strong>Command Summary:</strong></p> <p><strong>Command:</strong></p> <blockquote> <p>/usr/local/apache/bin/httpd -tD DUMP_VHOSTS</p> </blockquote> <p><strong>Output:</strong></p> <pre><code>AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:445 VirtualHost configuration: 127.0.0.1:80 wb01-development.example.com (/usr/local/apache/conf/httpd.conf:504) 127.0.0.1:443 wb01-development.example.com (/usr/local/apache/conf/httpd.conf:554) 132.159.25.21:443 is a NameVirtualHost default server example.com (/usr/local/apache/conf/httpd.conf:368) port 443 namevhost example.com (/usr/local/apache/conf/httpd.conf:368) alias www.example.com port 443 namevhost wb01-development.example.com (/usr/local/apache/conf/httpd.conf:554) wild alias cpanel.* wild alias whm.* wild alias webmail.* wild alias webdisk.* wild alias cpcalendars.* wild alias cpcontacts.* 132.159.25.21:80 is a NameVirtualHost default server 132.159.25.21 (/usr/local/apache/conf/httpd.conf:274) port 80 namevhost 132.159.25.21 (/usr/local/apache/conf/httpd.conf:274) port 80 namevhost example.com (/usr/local/apache/conf/httpd.conf:297) alias www.example.com port 80 namevhost node.example.com (/usr/local/apache/conf/httpd.conf:446) alias www.node.example.com port 80 namevhost wb01-development.example.com (/usr/local/apache/conf/httpd.conf:504) wild alias cpanel.* wild alias whm.* wild alias webmail.* wild alias webdisk.* wild alias cpcalendars.* wild alias cpcontacts.* port 80 namevhost node.example.com (/usr/local/apache/conf/includes/abc_node.conf:1) alias www.node.example.com *:* wb01-development.example.com (/usr/local/apache/conf/httpd.conf:286) </code></pre> <p><strong>Command</strong></p> <blockquote> <p>/usr/local/apache/bin/httpd -tD DUMP_MODULES</p> </blockquote> <p><strong>Output:</strong></p> <pre><code>AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:445 Loaded Modules: core_module (static) authn_file_module (static) authn_core_module (static) authz_host_module (static) authz_groupfile_module (static) authz_user_module (static) authz_core_module (static) access_compat_module (static) auth_basic_module (static) socache_shmcb_module (static) socache_dbm_module (static) so_module (static) include_module (static) filter_module (static) deflate_module (static) http_module (static) mime_module (static) log_config_module (static) logio_module (static) env_module (static) expires_module (static) headers_module (static) unique_id_module (static) setenvif_module (static) version_module (static) proxy_module (static) proxy_connect_module (static) proxy_http_module (static) slotmem_shm_module (static) ssl_module (static) mpm_prefork_module (static) unixd_module (static) status_module (static) autoindex_module (static) asis_module (static) suexec_module (static) cgi_module (static) negotiation_module (static) dir_module (static) actions_module (static) userdir_module (static) alias_module (static) rewrite_module (static) bwlimited_module (shared) suphp_module (shared) security2_module (shared) </code></pre> <p><strong>I run my node js application using following ip and port</strong></p> <blockquote> <p>132.159.25.21:3030</p> </blockquote> <p><strong>I defined my port in nodejs application in following way</strong></p> <blockquote> <p>var port = parseInt(process.env.PORT, 3030) || 8080;</p> </blockquote> <p>With the reference of this error : AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/httpd.conf:445 following code has been written. NameVirtualHost 132.159.25.21:80</p> <p>I put may vhosts file at the end of /usr/local/apache/conf/httpd.conf file, becuase in file they wrote a warning of "# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES."</p> <p>I required help to resolve this issue. Please let me know if you required further more to know about application.</p>
0
Skip specific rows using read.csv in R
<p>I wish to skip the 1st and 3rd rows of my csv file when importing the file into a data frame in R. </p> <p>In the original file my headers are on line 2. </p> <p>Using the skip argument in read.csv I can skip the 1st line and set the header argument to TRUE by I still have the 3rd line from the original file in my data frame. </p> <p>Can anyone suggest how to skip multiple specific rows in R, below is what I was able to cobble together?</p> <p>Can I pass a vector to the skip argument specifying the exact rows to ignore?</p> <pre><code>prach &lt;- read.csv("RSRAN104_-_PRACH_Propagation_Delay-PLMN-day-rsran_RU50EP1_reports_RSRAN104_xml-2016_08_23-21_33_03__604.csv", header = TRUE, sep = ",", stringsAsFactors = FALSE, skip = 1) </code></pre>
0
Java Reading large files into byte array chunk by chunk
<p>So I've been trying to make a small program that inputs a file into a byte array, then it will turn that byte array into hex, then binary. It will then play with the binary values (I haven't thought of what to do when I get to this stage) and then save it as a custom file.</p> <p>I studied a lot of internet code and I can turn a file into a byte array and into hex, but the problem is I can't turn huge files into byte arrays (out of memory).</p> <p>This is the code that is not a complete failure</p> <pre><code>public void rundis(Path pp) { byte bb[] = null; try { bb = Files.readAllBytes(pp); //Files.toByteArray(pathhold); System.out.println("byte array made"); } catch (Exception e) { e.printStackTrace(); } if (bb.length != 0 || bb != null) { System.out.println("byte array filled"); //send to method to turn into hex } else { System.out.println("byte array NOT filled"); } } </code></pre> <p>I know how the process should go, but I don't know how to code that properly.</p> <p>The process if you are interested:</p> <ul> <li>Input file using <code>File</code></li> <li>Read the chunk by chunk of the file into a byte array. Ex. each byte array record hold 600 bytes</li> <li>Send that chunk to be turned into a Hex value --> <code>Integer.tohexstring</code></li> <li>Send that hex value chunk to be made into a binary value --> <code>Integer.toBinarystring</code></li> <li>Mess around with the Binary value</li> <li>Save to custom file line by line</li> </ul> <p><strong>Problem</strong>:: I don't know how to turn a huge file into a byte array chunk by chunk to be processed. Any and all help will be appreciated, thank you for reading :)</p>
0
How can I kill all threads?
<p>In this script:</p> <pre><code>import threading, socket class send(threading.Thread): def run(self): try: while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((url,port)) s.send(b"Hello world!") print ("Request Sent!") except: s.close() except KeyboardInterrupt: # here i'd like to kill all threads if possible for x in range(800): send().start() </code></pre> <p>Is it possible to kill all threads in the except of KeyboardInterrupt? I've searched on the net and yeah, I know that it has been already asked, but I'm really new in python and I didn't get so well the method of these other question asked on stack.</p>
0
Post list of list of model object to Controller in ASP.NET MVC
<p>Form like this</p> <p><a href="https://i.stack.imgur.com/VREoG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VREoG.png" alt="enter image description here"></a></p> <p><strong>ViewModel:</strong></p> <pre class="lang-cs prettyprint-override"><code>public class ProductViewModel { public string Product { get; set; } public IEnumerable&lt;SizeColorQuantityViewModel&gt; SizeColorQuantities { get; set; } } public class SizeColorQuantityViewModel { public string ColorId { get; set; } public List&lt;SizeAndQuantity&gt; SizeAndQuantities { get; set; } } public class SizeAndQuantity { public int SizeId { get; set; } public int Quantity { get; set; } } </code></pre> <p><strong>View:</strong></p> <pre class="lang-cs prettyprint-override"><code>@model ProjectSem3.Areas.Admin.Models.ProductViewModel @{ ViewBag.Title = "Create"; Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml"; string[] ListColor = { "Red", "Blue" }; string[] ListSize = { "S", "M", "L", "XL" }; } @for (var i = 0; i &lt; ListColor.Length; i++) { &lt;div class="form-group"&gt; &lt;label class="col-md-2 control-label"&gt;Color:&lt;/label&gt; &lt;div class="col-md-2"&gt; @Html.TextBox("[" + i + "].ColorId", null, new { @Value = ListColor[i], @class = "form-control", @readonly = "readonly" }) &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="col-md-2 control-label"&gt;Size and Quantity:&lt;/label&gt; @for (var j = 0; j &lt; ListSize.Length; j++) { &lt;div class="col-md-2"&gt; @Html.TextBox("[" + i + "][" + j + "].SizeAndQuantities.SizeId", null, new { @class = "form-control", @style = "margin-bottom: 15px", @Value = ListSize[j], @readonly = "readonly" }) @Html.TextBox("[" + i + "][" + j + "].SizeAndQuantities.Quantity", null, new { @class = "form-control" }) &lt;/div&gt; } &lt;/div&gt; } </code></pre> <p><strong>Controller:</strong></p> <pre class="lang-cs prettyprint-override"><code>// GET: Admin/Product public ActionResult Create() { return View(); } // POST: Admin/Product [HttpPost] public ActionResult Create(ProductViewModel product, IEnumerable &lt;SizeColorQuantityViewModel&gt; sizeColorQuantity, IEnumerable &lt;SizeAndQuantity&gt; sizeAndQuantity) { return View(); } </code></pre> <p>I can get value which is passed from ViewModel <code>IEnumerable&lt;SizeColorQuantityViewModel&gt; sizeColorQuantity</code> to Controller. But with this model <code>IEnumerable&lt;SizeAndQuantity&gt; sizeAndQuantity</code>, I can't get any value. Cause this is 2-D Array so, I have no idea for this issues. Could you teach me how to bind value for <code>IEnumerable&lt;SizeAndQuantity&gt; sizeAndQuantity.</code></p>
0
In swift 3, how do you advance an index?
<p>I've trying to get a substring of a string starting from index 1 in iOS 10 beta 6, and its a headache as swifts strings are constantly changing and much documentation is out of date and useless.</p> <p>String has the substring(from:Index), but it can't accept an integer (which has been the case for a while), so I was planning to use startIndex and advance it by 1, but now Index has no advanceBy method, so I cannot do this:</p> <pre><code>let aString = "hello" let subString = aString.substring(from: aString.startIndex.advanceBy(1)) </code></pre> <p>How can I get a substring from index 1? How can you advance an index these days, and what is the point of the substring(from Index) method - how are you supposed to use it?</p>
0
Java Stream Using Previous Element in Foreach Lambda
<p>I have a list of numbers with some <code>0s</code> inside. Since <code>0</code> means invalid measure in my situation, I need change the <code>0</code> valued element with the first non 0 element that I can find in the previous positions.</p> <p>For example the list </p> <pre><code>45 55 0 0 46 0 39 0 0 0 </code></pre> <p>must become</p> <pre><code>45 55 55 55 46 46 39 39 39 39 </code></pre> <p>This is the implementation using the classic <code>for each</code></p> <pre><code> int lastNonZeroVal = 0; for (MntrRoastDVO vo : res) { if (vo.getValColor() &gt; 0) { lastNonZeroVal = vo.getValColor(); } else { vo.setValColor(lastNonZeroVal); } } </code></pre> <p>Is there a way to implement this with the Java Streams and Lambda Functions?</p> <p>Since I know that I must not change the source of the stream in the foreach lambda, actually the list is a list of object and I do not change the element of the list but I just assign new values.</p> <p>This was my first solution</p> <pre><code>int lastNonZeroVal = 1; resutl.stream().forEach(vo -&gt; { if(vo.getValColor()&gt;0){ lastNonZeroVal=vo.getValColor(); }else{ vo.setValColor(lastNonZeroVal); } }); </code></pre> <p>But I also read <a href="http://www.ibm.com/developerworks/library/j-java-streams-1-brian-goetz/index.html" rel="noreferrer">here</a></p> <blockquote> <p>It's best if the lambdas passed to stream operations are entirely side effect free. that is, that they don't mutate any heapbased state or perform any I/O during their execution.</p> </blockquote> <p>This is what is worryng me</p> <blockquote> <p>the data is partitioned, there's no guarantee that when a given element is processed, all elements preceding that element were already processed.</p> </blockquote> <p>Can this solution produce invalid results, maybe when the number of elements in the list are high? ? Event if I do not use <code>parallelStream()</code> ?</p>
0
Set and get session values in HttpContext.Current.Session in C#
<p>I have static class called CommoonHelper.</p> <pre><code> public static class CommonHelper { public static SessionObjects sessionObjects { get { if ((HttpContext.Current.Session["sessionObjects"] == null)) { return null; } else { return HttpContext.Current.Session["sessionObjects"] as SessionObjects; } } set { HttpContext.Current.Session["sessionObjects"] = value; } } } </code></pre> <p>In SessionObjects Class, I have defined properties for get /set like below.</p> <pre><code> public class SessionObjects { public int UserId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string UserName { get; set; } public string DisplayName { get { return FirstName + "" + LastName; } } } </code></pre> <p>When i try to assign an value like below.</p> <pre><code>CommonHelper.sessionObjects.LastName = "test"; </code></pre> <p>Its throwing the below exception.</p> <pre><code>System.NullReferenceException: Object reference not set to an instance of an object. </code></pre> <p>How do i fix this ?</p>
0
What is (function e(t,n,r){ ...}) in Javascript?
<p>I am studying the List.js Framework. This is a starting code. If I remove it(even remove the surrounding "()" of function e), Code is not working.</p> <p>What is this? I think it is already defined in Javascript method.</p> <pre><code>(function e(t,n,r){ function s(o,u){ if(!n[o]){ if(!t[o]){ var a=typeof require=="function"&amp;&amp;require; if(!u&amp;&amp;a) return a(o,!0); if(i)return i(o,!0); var f=new Error("Cannot find module '"+o+"'"); throw f.code="MODULE_NOT_FOUND",f } var l=n[o]={exports:{}}; t[o][0].call(l.exports,function(e){ var n=t[o][1][e]; return s(n?n:e) },l,l.exports,e,t,n,r) } return n[o].exports } var i=typeof require=="function"&amp;&amp;require; for(var o=0;o&lt;r.length;o++) s(r[o]); return s } ) </code></pre>
0
Datatables - How to load only a certain amount rows on page-load?
<p>I have a <a href="https://jsfiddle.net/bheng/cL8ej4fa/2/" rel="noreferrer">fiddle</a> that make an ajax to <a href="https://api.myjson.com/bins/1egsx" rel="noreferrer">URL</a> and rendering a table, but I want to defer and load only 10 rows during page load.</p> <h1>HTML</h1> <pre><code>&lt;table id=&quot;example&quot; class=&quot;display&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Account ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;/table&gt; </code></pre> <hr /> <h1>JS</h1> <pre><code>$(document).ready(function() { $('#example').DataTable( { &quot;bPaginate&quot;: true, &quot;processing&quot;: true, &quot;bServerSide&quot;: true, ajax: { url: 'https://api.myjson.com/bins/1egsx', dataSrc: 'data' }, columns: [ { data: 'account_id' }, { data: 'name' }, { data: 'email' } ], &quot;deferRender&quot;: true, &quot;deferLoading&quot;: 10, } ); }); </code></pre> <hr /> <p>I kept getting</p> <blockquote> <p>No matching records found</p> </blockquote>
0
largest sum of contiguous subarray No Larger than k
<p>For example, we have </p> <pre><code>{2,2,-1}, when k = 0, return -1. when k = 3, return 3. </code></pre> <p>This is even tricky because we have negative numbers and an additional variable k. k can be any value, negative, don't make any assumption.</p> <p>I cannot refer to <a href="https://en.wikipedia.org/wiki/Maximum_subarray_problem" rel="noreferrer">https://en.wikipedia.org/wiki/Maximum_subarray_problem</a> and <a href="https://www.youtube.com/watch?v=yCQN096CwWM" rel="noreferrer">https://www.youtube.com/watch?v=yCQN096CwWM</a> to solve this problem.</p> <p>Can any body help me? Better use Java or JavaScript.</p> <p>Here is a classic algorithm o(n) for the maximum(no variable k):</p> <pre><code>public int maxSubArray(int[] nums) { int max = nums[0]; int tsum = nums[0]; for(int i=1;i&lt;nums.length;i++){ tsum = Math.max(tsum+nums[i],nums[i]); max = Math.max(max,tsum); } return max; } </code></pre>
0
The type appears in two structurally incompatible initializations within a single LINQ to Entities query
<p>I'm trying to build something like conditional queries to get only needed data from the underlying database.</p> <p>Currently I have the following query (which works fine)</p> <pre><code>var eventData = dbContext.Event.Select(t =&gt; new { Address = true ? new AnonymousEventGetAddress { AddressLine1 = t.Address.AddressLine1, CityName = t.Address.AddressCityName } : new AnonymousEventGetAddress(), }); </code></pre> <p>If I change it to</p> <pre><code>var includeAddress = true; // this will normally be passed as param var eventData = dbContext.Event.Select(t =&gt; new { Address = includeAddress ? new AnonymousEventGetAddress { AddressLine1 = t.Address.AddressLine1, CityName = t.Address.AddressCityName } : new AnonymousEventGetAddress(), }); </code></pre> <p>I get the following error:</p> <blockquote> <p>The type 'AnonymousEventGetAddress' appears in two structurally incompatible initializations within a single LINQ to Entities query. A type can be initialized in two places in the same query, but only if the same properties are set in both places and those properties are set in the same order.</p> </blockquote> <p>What am I doing wrong here (as of with the <code>true</code> it's working) and how can this be fixed?</p> <p>I know that changing the <code>else</code>-part to</p> <pre><code>new AnonymousEventGetAddress { AddressLine1 = null, CityName = null } </code></pre> <p>will work. But if I change the order of the properties then, this will also fail.</p> <p>The class used is defined the following:</p> <pre><code>public class AnonymousEventGetAddress : BaseAnonymousObject&lt;AnonymousEventGetAddress&gt; { public string AddressLine1 { get; set; } public string CityName { get; set; } } </code></pre> <p>whereas <code>BaseAnonymousObject&lt;AnonymousEventGetAddress&gt;</code> is defined:</p> <pre><code>public abstract class BaseAnonymousObject&lt;TAnonymous&gt; where TAnonymous : BaseAnonymousObject&lt;TAnonymous&gt; { // this is used in case I have to return a list instead of a single anonymous object public static Expression&lt;Func&lt;IEnumerable&lt;TAnonymous&gt;&gt;&gt; Empty =&gt; () =&gt; new TAnonymous[]{}.AsEnumerable(); } </code></pre>
0
How can I select only one checkbox in Recyclerview and notifydataset changed
<p>In my code I have create recyclerview with check box and default one item selected already. now I want when select other item checkbox so deselect all other items mean one item select at time.</p> <p>My Adapter code:</p> <pre><code>public class SupportSchoolIdAdapter extends RecyclerView.Adapter&lt;SupportSchoolIdAdapter.ViewHolder&gt; { ArrayList&lt;SupportSchoolIdModel&gt; supportSchoolIdModels; DataPref mDataPref; String supportSchoolId; public SupportSchoolIdAdapter(List&lt;SupportSchoolIdModel&gt; supportSchoolIdModels) { this.supportSchoolIdModels = new ArrayList&lt;&gt;(supportSchoolIdModels); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); mDataPref = DataPref.getInstance(context); supportSchoolId = mDataPref.getSupportSchoolId(); View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.support_school_item, parent, false); return new ViewHolder(v); } @Override public void onBindViewHolder(final ViewHolder holder, int position) { final SupportSchoolIdModel event = supportSchoolIdModels.get(position); holder.bindData(supportSchoolIdModels.get(position)); //in some cases, it will prevent unwanted situations holder.checkbox.setOnCheckedChangeListener(null); //if true, your checkbox will be selected, else unselected holder.checkbox.setChecked(supportSchoolIdModels.get(position).isSelected()); holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { supportSchoolIdModels.get(holder.getAdapterPosition()).setSelected(isChecked); } }); if (supportSchoolIdModels.get(position).getPkSchoolId().equalsIgnoreCase(supportSchoolId)) { holder.checkbox.setChecked(true); } else { holder.checkbox.setChecked(false); } } @Override public int getItemCount() { return supportSchoolIdModels.size(); } // Provide a reference to the views for each data item // Complex data items may need more than one view per item, and // you provide access to all the views for a data item in a view holder public static class ViewHolder extends RecyclerView.ViewHolder { // each data item is just a string in this case private TextView schoolIdTxt; private TextView schoolNameTxt; private CheckBox checkbox; public ViewHolder(View v) { super(v); schoolIdTxt = (TextView) v.findViewById(R.id.schoolIdTxt); schoolNameTxt = (TextView) v.findViewById(R.id.schoolNameTxt); checkbox = (CheckBox) v.findViewById(R.id.checkbox); } public void bindData(SupportSchoolIdModel supportSchoolIdModel) { schoolIdTxt.setText(supportSchoolIdModel.getPkSchoolId()); schoolNameTxt.setText(supportSchoolIdModel.getSchoolName()); } } } </code></pre> <p>And Second problem is when I scroll recycle view why selected item unchecked. please help me.</p>
0
Merge CSV files using macro
<p>Any idea how to merge *.csv files from one folder?</p> <p>I have many *.csv files with same structure (count &amp; heading of columns) and I need to merge their content into one sheet.</p> <p>It's not so hard, I know. But When I add content from one table, I need to add new column with name of table where I copied this data from.</p> <p>Any help please?</p> <p>Thank you!</p>
0
VueJS $watch $refs
<p>Is it possible to <code>$watch</code> Vue <code>$refs</code>?</p> <p>I'm wanting to set logic against a child component that is nested inside my current Vue instance but inside the <code>ready</code> callback, <code>$refs.childcomponent</code> is initially <code>undefined</code> while it's processed.</p> <p><strong>inside <code>ready()</code></strong></p> <pre><code>this.$watch('$refs', function() { console.log("not firing"); }, { deep: true }); </code></pre> <p>Result: Error: Maximum call stack exceeded</p> <p><strong><code>watch</code> property of the instance</strong></p> <pre><code>watch: { '$refs': { handler: function() { console.log("hit"); }, deep: true } } </code></pre> <p>result: nothing.</p>
0
How to play a specific frequency with Javascript?
<p>I want a function that works like this:</p> <pre><code>playSound(345, 1000) </code></pre> <p>Which would play a tone of 345 hz for 1000 milliseconds. What is the simplest way to achieve this in JavaScript? I don't mind if it uses a sample (maybe of a sin wave, or piano), or uses the computer's hardware to generate the sound.</p>
0
What is the best way to realize a synchronization barrier between threads
<p>Having several threads running I need to guaranty that every of my threads reached a certain point before proceeding. I need to implement a kind of barrier. Consider a function <code>func</code> which can be run from several threads:</p> <pre><code>void func() { operation1(); // wait till all threads reached this point operation2(); } </code></pre> <p>What is best way to realise this barrier using C++ 11 and VS12, considering boost if needed.</p>
0
Write to a file with a specific encoding in Java
<p>This <em>might</em> be related to my <a href="https://stackoverflow.com/questions/39262555/interpret-a-string-from-one-encoding-to-another-in-java/39262819?noredirect=1#comment65861448_39262819">previous question</a> (on how to convert "för" to "för")</p> <p>So I have a file that I create in my code. Right now I create it by the following code:</p> <pre><code>FileWriter fwOne = new FileWriter(wordIndexPath); BufferedWriter wordIndex = new BufferedWriter(fwOne); </code></pre> <p>followed by a few</p> <pre><code>wordIndex.write(wordBuilder.toString()); //that's a StringBuilder </code></pre> <p>ending (after a while-loop) with a </p> <pre><code>wordIndex.close(); </code></pre> <p>Now the problem is later on this file is huge and I want (need) to jump in it without going through the entire file. The <code>seek(long pos)</code> method of <code>RandomAccessFile</code> lets me do this. </p> <p><strong>Here's my problem</strong>: The characters in the file I've created seem to be encoded with UTF-8 and the only info I have when I seek is the character-position I want to jump to. <code>seek(long pos)</code> on the other hand jumps in bytes, so I don't end up in the right place since an UTF-8 character can be more than one byte.</p> <p><strong>Here's my question</strong>: Can I, when I write the file, write it in ISO-8859-15 instead (where a character is a byte)? That way the <code>seek(long pos)</code> will get me in the right position. Or should I instead try to use an alternative to <code>RandomAccessFile</code> (is there an alternative where you can jump to a character-position?) </p>
0
What is pointer to object type in C?
<p>For example, </p> <pre><code>int x = 10; </code></pre> <p>Then the value <code>10</code> is saved somewhere in the memory. I have heard of "pointer to int object", but I have never heard of "pointer to object type". Does this mean that the object where <code>10</code> is stored saves information about the type of value stored in the object and value of "pointer to object type" shows where this information is stored in memory? </p>
0
Converting Double to NSNumber in Swift Loses Accuracy
<p>For some reason, certain Doubles in my Swift app are giving me trouble when converting to NSNumber, while some are not. My app needs to convert doubles with 2 decimal places (prices) to NSNumbers so they can be stored and retrieved using Core Data. For example, a few particular prices such as 79.99 would evaluate to 99.98999999999999 unless specifically formatted using NSNumber's doubleValue method. </p> <p>Here selectedWarranty.price = 79.99 as shown in debugger</p> <pre><code>// item.price: NSNumber? // selectedWarranty.price: Double? item.price = NSNumber(double: selectedWarranty.price!) </code></pre> <p>I programmed some print statements to show how the conversion works out</p> <pre><code>Original double: 79.99 Converted to NSNumber: 79.98999999999999 .doubleValue Representation: 79.99 </code></pre> <p>Can somebody explain if there is a reason why the initializer cannot surely keep 2 decimal places for every number? I would really like to store the prices in Core Data like they should be. Formatting every time it is displayed doesn't sound very convenient. </p> <p><strong>UPDATE</strong>: Converted Core Data object to type NSDecimalNumber through data model, 79.99 and 99.99 no longer a problem, but now more manageable issue with different numbers...</p> <pre><code>Original double: 39.99 Converted to NSDecimalNumber: 39.99000000000001024 </code></pre>
0
How to strip out header from base 64 image in C#?
<p>I have following base 64 image:</p> <pre><code>var image='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0gA...'; </code></pre> <p>I am using <code>Convert.FromBase64String()</code>to convert this to bytes:</p> <pre><code> byte[] bytes = Convert.FromBase64String(convert); </code></pre> <p>But before this, I need to strip out the header of Base 64 string (i.e <code>data:image/png;base64</code>). I am doing this using:</p> <pre><code>string convert = image.Replace("data:image/png;base64,", string.Empty); </code></pre> <p>I can write the same statement for all image extensions separately, but these images are very large and scanning through each one seems inefficient.</p> <p>I searched <a href="https://stackoverflow.com/questions/38633061/how-can-i-strip-the-dataimage-part-from-a-base64-string-of-any-image-type-in-ja?rq=1">this</a> solution which uses regular expression in PHP to cut off the header part, while <a href="https://stackoverflow.com/a/21302482/2828434">other</a> answer in PHP uses an inbuilt method <code>get_contents</code>.</p> <p>My Question is: Is there any inbuilt method to get only contents of base 64 url in C#? If not, then is there any generalized way to strip out header for all extensions?</p>
0
Debug Azure WebJob locally
<p>I've been creating an Azure WebJob, it works aparently fine but I need to create a new function and I need test locally before upload to production site, I run on Debug the console program and this recognize all functions but I can't trigger any function.</p> <p>Documentation say next trigger is every minute.... (<a href="https://github.com/Azure/azure-webjobs-sdk-extensions#timertrigger" rel="nofollow noreferrer">https://github.com/Azure/azure-webjobs-sdk-extensions#timertrigger</a>)</p> <p>My code:</p> <pre><code>public static async void ProcessAugustEndowments([TimerTrigger("0 */1 * * * *", RunOnStartup = true)] TimerInfo timerInfo) { Console.WriteLine("Endowments process tried"); await endowmentNotification(); } </code></pre> <p>Output: <a href="https://i.stack.imgur.com/tv32f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tv32f.png" alt="Output example"></a></p>
0
How does Golang share variables between goroutines?
<p>I'm learning Go and trying to understand its concurrency features. </p> <p>I have the following program.</p> <pre class="lang-golang prettyprint-override"><code>package main import ( "fmt" "sync" ) func main() { var wg sync.WaitGroup for i := 0; i &lt; 5; i++ { wg.Add(1) x := i go func() { defer wg.Done() fmt.Println(x) }() } wg.Wait() fmt.Println("Done") } </code></pre> <p>When executed I got:</p> <pre><code>4 0 1 3 2 </code></pre> <p>It's just what I want. However, if I make slight modification to it:</p> <pre class="lang-golang prettyprint-override"><code>package main import ( "fmt" "sync" ) func main() { var wg sync.WaitGroup for i := 0; i &lt; 5; i++ { wg.Add(1) go func() { defer wg.Done() fmt.Println(i) }() } wg.Wait() fmt.Println("Done") } </code></pre> <p>What I got will be:</p> <pre><code>5 5 5 5 5 </code></pre> <p>I don't quite understand the difference. Can anyone help to explain what happened here and how Go runtime execute this code?</p>
0
python error AttributeError: 'str' object has no attribute 'setdefault'
<p>I'm trying to run the django project using this command.</p> <pre><code>python manage.py runserver 8080 </code></pre> <p>But everytime I'm trying to run I faced the such a error.</p> <pre><code>Traceback (most recent call last): File "manage.py", line 10, in &lt;module&gt; execute_from_command_line(sys.argv) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute django.setup() File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in &lt;module&gt; from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 49, in &lt;module&gt; class AbstractBaseUser(models.Model): File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/db/models/base.py", line 108, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/db/models/base.py", line 307, in add_to_class value.contribute_to_class(cls, name) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/db/utils.py", line 209, in __getitem__ self.ensure_defaults(alias) File "/Users/admin/.virtualenvs/myprojectname/lib/python2.7/site-packages/django/db/utils.py", line 181, in ensure_defaults conn.setdefault('ATOMIC_REQUESTS', False) AttributeError: 'str' object has no attribute 'setdefault' </code></pre> <p>I tried python2(python2.7.11) and python3(python3.5.1) with virtualenvwrapper. I think it's not the bug of the project source. but something missed in environment configuration. But I can't figure out what the problem is. Please help me fix it. </p> <p>Thanks in advance.</p>
0
Selenium - Visual Studios- C# - All (chrome, firefox, and internet explorer) webdrivers unable to start driver service
<p>I'm trying to set up Selenium for testing and none of my webdrivers seem to work. I have tried moving them around in the project folder and the only way I can get Visual Studios to locate them is with a @"path" statement.</p> <p>The real problem is... Once Visual Studio locates the webdriver, the operation times out and I get the following exception:</p> <p><em>An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll Additional information: Cannot start the driver service on <a href="http://localhost:(random" rel="noreferrer">http://localhost:(random</a> port number that changes every time)</em></p> <p>I have tried restarting my computer and having the system administrator check the firewall and malware blocker logs, but neither seems to have helped (or they don't know the correct thing to look for).</p> <p>I figure this is something super simple and I'm just missing it... Any help would be greatly appreciated.</p> <p>Here is a copy of my code:</p> <pre><code>using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.IE; namespace SeleniumWork { class Program { static void Main(string[] args) { IWebDriver driver = new InternetExplorerDriver(@"C:\blahblahpathstring"); driver.Navigate().GoToUrl("http://www.google.com/"); IWebElement query = driver.FindElement(By.Name("q")); query.SendKeys("Cheese"); query.Submit(); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(d =&gt; d.Title.StartsWith("cheese", StringComparison.OrdinalIgnoreCase)); Console.WriteLine("Page title is: " + driver.Title); } } } </code></pre> <p>Here is a copy of the debug output I receive:</p> <pre><code>A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'System.Net.WebException' occurred in System.dll A first chance exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll </code></pre>
0
running two process simultaneously
<p>I'm trying to run 2 processes simultaneously, but only the first one runs </p> <pre><code>def add(): while True: print (1) time.sleep(3) def sud(): while True: print(0) time.sleep(3) p1 = multiprocessing.Process(target=add) p1.run() p = multiprocessing.Process(target=sud) p.run() </code></pre>
0
How to put FloatingActionButton to Fragment?
<p>How can I put my <code>fab</code> on my fragment? help please I'm getting errors such as.</p> <blockquote> <p>android.view.InflateException: Binary XML file line #13: Error inflating class fragment</p> </blockquote> <p>in my fragment acticity. Well here are my codes.</p> <p>well the problem is in the <code>getActivity().setContentView(R.layout.activity_ownerhome);</code></p> <pre><code>#ownerhome.java public class ownerhome extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ownerhome); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } } </code></pre> <h1>ownerhomeFragment.java</h1> <pre><code> @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_owner, container, false); ImageLoader.getInstance().init(UILConfig.config(getActivity())); lvCars = (ListView) v.findViewById(R.id.lvOnwer); pref = getActivity().getSharedPreferences("Login.conf", Context.MODE_PRIVATE); Log.d(TAG, pref.getString("username", "")); Log.d(TAG, pref.getString("password", "")); PostResponseAsyncTask taskRead = new PostResponseAsyncTask(getActivity(), this); tvUser = (TextView) v.findViewById(R.id.tvUser); tvUser.setText("Hello! "+pref.getString("username", "")); taskRead.execute("http://carkila.esy.es/user.php?owner="+pref.getString("username", "")); FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent in = new Intent(getActivity(), InsertActivity.class); startActivity(in); } }); registerForContextMenu(lvCars); return v; } </code></pre> <h1>content_ownerhome.xml</h1> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.kun.carkila.ownerhome" tools:showIn="@layout/activity_ownerhome"&gt; &lt;fragment android:layout_width="wrap_content" android:layout_height="wrap_content" android:name="com.example.kun.carkila.ownerFragment" android:id="@+id/ownerhomeFragment"/&gt; &lt;/RelativeLayout&gt; </code></pre> <h1>activity_ownerhome.xml</h1> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.example.kun.carkila.ownerhome"&gt; &lt;android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /&gt; &lt;/android.support.design.widget.AppBarLayout&gt; &lt;include layout="@layout/content_ownerhome" /&gt; &lt;android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@drawable/plus" /&gt; &lt;/android.support.design.widget.CoordinatorLayout&gt; </code></pre> <h1>fragmentOwnerHome.xml</h1> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.kun.carkila.ownerhome" tools:showIn="@layout/activity_ownerhome"&gt; &lt;ListView android:layout_width="match_parent" android:layout_height="450sp" android:id="@+id/lvOnwer" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentBottom="true" /&gt; &lt;TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="24dp" android:textSize="30sp" android:textColor="@color/colorPrimaryDark" android:id="@+id/tvUser" /&gt; &lt;/RelativeLayout&gt; </code></pre> <blockquote> <p>STACK TRACE</p> </blockquote> <pre><code>FATAL EXCEPTION: main Process: com.example.kun.carkila, PID: 9267 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kun.carkila/com.example.kun.carkila.ownerhome}: android.view.InflateException: Binary XML file line #12: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5021) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.kun.carkila.ownerFragment.onCreateView(ownerFragment.java:127) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1036) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1230) at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1332) at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2288) at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120) at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356) at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:31) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:79) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.kun.carkila.ownerhome.onCreate(ownerhome.java:12) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)  at android.app.ActivityThread.access$800(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5021)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.IllegalArgumentException: Binary XML file line #12: Duplicate id 0x7f0e00aa, tag null, or parent id 0xffffffff with another fragment for com.example.kun.carkila.ownerFragment at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2293) at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120) at android.support.v4.app.FragmentActivity </code></pre>
0
Protocol extension on an ObjC protocol
<p>I have an Objective-C protocol which is used by mostly objective-C objects and one or two Swift objects.</p> <p>I would like to extend the protocol in Swift and add 2 functions. One to register for a notification and another to handle the notification.</p> <p>If I add these</p> <pre><code>func registerForPresetLoadedNotification() { NSNotificationCenter.defaultCenter().addObserver(self as AnyObject, selector: #selector(presetLoaded(_:)), name: kPresetLoadedNotificationName, object: nil) } func presetLoaded(notification: NSNotification) { } </code></pre> <p>I get an error on the #selector which says:</p> <blockquote> <p>Argument of '#selector' refers to a method that is not exposed to Objective-C</p> </blockquote> <p>If I then mark presetLoaded as <code>@objc</code> I get an error which says:</p> <blockquote> <p>@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes</p> </blockquote> <p>I also cannot mark the protocol extension as @objc</p> <p>When I create the Objective-C protocol as a Swift protocol I get the same error.</p> <p>Is there a way to achieve this that will work for Objective-C and Swift classes that use the protocol?</p>
0
android.os.TransactionTooLargeException on Nougat
<p>I updated Nexus 5X to Android N, and now when I install the app (debug or release) on it I am getting TransactionTooLargeException on every screen transition that has Bundle in extras. The app is working on all other devices. The old app that is on PlayStore and has mostly same code is working on Nexus 5X. Is anyone having the same issue?</p> <pre><code>java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 592196 bytes at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3752) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: android.os.TransactionTooLargeException: data parcel size 592196 bytes at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:615) at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3606) at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3744) at android.os.Handler.handleCallback(Handler.java:751)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)  </code></pre>
0
Install Openalpr in Windows python
<p>I am using <strong>Windows 10</strong> and I want to install <strong>openalpr</strong> and import the library to <strong>python</strong>. </p> <p>However, after downloaded the <strong>Pre-compiled Windows binaries</strong>, I dont know how ti import alpr in python</p> <p>I follow the instruction in <a href="https://github.com/openalpr/openalpr" rel="noreferrer">OpenAlpr</a></p> <p>I downloaded the <strong>openalpr-2.3.0-win-64bit.zip</strong> <a href="https://github.com/openalpr/openalpr/releases" rel="noreferrer">here</a> and unzipped it.</p> <p>Afterwards, I can run <code>alpr</code> in command line but I cannot import it.</p> <p>Can anyone teach me how I can import Openalpr in python. Thank you.</p>
0
Rails server start/stop
<p>To run the <strong>Rails server</strong>, I use <code>$rails server</code>. It says 'To stop, click <code>Ctrl+c</code>'. I use <code>Putty</code>.</p> <p>The questions are:</p> <ol> <li><p>Should I keep the terminal open always? Because if the server stops, my web page wouldn't work. With Apache I just used commands apachectl start/stop.</p></li> <li><p>What if I want to use a command? Should I stop the server, use command, and run again? Because in the same terminal I can't do enything if the server run.</p></li> </ol>
0
How to prevent the keyboard from popping up on mobile devices?
<p><a href="http://api.jqueryui.com/spinner/" rel="noreferrer">http://api.jqueryui.com/spinner/</a></p> <p>I am trying to use the jQuery spinner above in my website (a demo of it is available at the bottom of API). </p> <p>It works really work on computers, but on mobile devices, the keyboard very annoyingly pops up every time one clicks the up/down buttons. Is it possible to prevent this from happening? The spinner does not really respond well to native functions like .on('click'), instead it has its own functions. </p> <p>How do I modify the code so that the keybooard only shows up when the textbox is clicked, not the up-down buttons?</p> <p>This was my attempt, it does not work:</p> <pre><code>$( function() { $('.ui-spinner a').on('click', function() { $(':focus').blur(); }); }) // Updated code, I can now see the focus being lost on desktops, but still not mobile devices </code></pre> <p>Note: I got the class name by inspecting the code generated when the spinner is created.Also, I am super new to web development so I am not sure whether I am missing an easy approach.</p>
0
UglifyJS throws error Unexpected token: operator (>)
<p>I currently have this </p> <pre><code>ready : function(){ bus.$on('a-data', (param) =&gt; { this.name = param.name; this.age = param.age; }) }, </code></pre> <p>While this particular code run when <code>uglifyjs</code> is disabled, when enabled it throws the following error</p> <pre><code>SyntaxError: Unexpected token: operator (&gt;) </code></pre> <p>Here's my uglify config</p> <pre><code>new webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: false, compress: { warnings: false, sequences: true, dead_code: true, conditionals: true, booleans: true, unused: true, if_return: true, join_vars: true, drop_console: true } })) </code></pre> <p>I can't seem to understand why it's not working. Any ideas?</p>
0
write dataframe to .xlsx too slow
<p>I have a 40MB dataframe 'dfScore' I am writing to .xlsx。 <a href="https://i.stack.imgur.com/KQFhF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KQFhF.png" alt="enter image description here"></a> the code is as follow,</p> <pre><code>writer = pandas.ExcelWriter('test.xlsx', engine='xlsxwriter') dfScore.to_excel(writer,sheet_name='Sheet1') writer.save() </code></pre> <p>the code <code>dfScore.to_excel</code> take almost an hour ,<code>the code writer.save()</code> takes another hour. Is this normal? Is there a good way to take less than 10 min?</p> <p>i already searched in stackoverflow ,but it seems some suggestions not working on my problem.</p>
0
iOS 10 developer option missing from settings
<p>The topic says it all. I've just upgraded to <code>iOS 10.0.1 /iPhone 6s/</code> &amp; now the Developer option is missing from the Settings.</p> <p>I've tried some tricks for older versions such as sync the device in iTunes and add it in Xcode /it's already added/ but nothing worked.</p> <p>Anybody has clues on this ?</p> <p>I'm running <code>Xcode 7.3.1</code> with DeviceSupport added from the beta and the apps run fine on the iOS 10.</p>
0
Insert RichTextBox in Excel userform
<p>I created a userform in Excel VBA. There is plain text box called "Text box1" which contains few text formatting codes (ex. <code>&lt;Font Color=Black&gt;&lt;/Font&gt;</code>).</p> <p>I need to insert a RichTextBox to show the formatted text in "Text box1".</p>
0
Wrap dynamic array with shared_ptr by make_shared
<p>I want to write some bytes to an array. To make use of modern C++ I have decided to use a smart pointer.</p> <pre><code>#include &lt;memory&gt; #include &lt;cstdint&gt; using namespace std; void writeUint32_t(uint32_t value, unsigned char* p){ *p = static_cast&lt;unsigned char&gt;((value &gt;&gt; 24) &amp; 0xFF); *(++p) = static_cast&lt;unsigned char&gt;((value &gt;&gt; 16) &amp; 0xFF); *(++p) = static_cast&lt;unsigned char&gt;((value &gt;&gt; 8) &amp; 0xFF); *(++p) = static_cast&lt;unsigned char&gt;((value ) &amp; 0xFF); } int main(){ auto buf = make_shared&lt;unsigned char[]&gt;(512); uint32_t data = 1234; writeUint32_t(data, buf.get() + 8); } </code></pre> <p>However, I am receiving the following compilation error:</p> <pre><code>u.cpp:15:37: error: invalid use of array with unspecified bounds writeUint32_t(data, buf.get() + 8); ^ u.cpp:15:38: error: cannot convert ‘unsigned char (*)[]’ to ‘unsigned char*’ for argument ‘2’ to ‘void writeUint32_t(uint32_t, unsigned char*)’ writeUint32_t(data, buf.get() + 8); </code></pre> <p>I am using <code>g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609</code> Is there a way to use smart pointers in such a situation?</p>
0
Tableau parameter filter with multiple values?
<p>In Tableau 9.2, I currently have a parameter set up which contains multiple string values and an additional "All" value. I also have a calculated field which only contains the <code>Str([some_field])</code> function. I have then dragged this calculated field into the "filters" pane and from there enabled "use all" and put the following formula under the "condition" tab:</p> <pre><code>// If All is selected, then do not filter [my_filter_parameter] = 'All' OR // Otherwise, filter on the current parameter [my_filter_parameter] = [my_calculated_Field] </code></pre> <p>After creating the calculated field for multiple sheets in my dashboard (which use different data sources all contain the common some_field), then I can change the parameter's value and it will filter all of the sheets at once. </p> <p>My issue is that I need this to take on multiple values at once via a check-box. I understand that a parameter can only take on one value at a time, so I am wondering how I can do this without making the same filter for each individual sheet in the dashboard. Perhaps this can be done with a calculated field?</p> <p>EDIT: I have tried the technique <a href="http://kb.tableau.com/articles/knowledgebase/creating-filter-actions-dashboards" rel="nofollow">here</a> to make a global filter via a control view. This allows me to use Ctrl+Clicking to select multiple values in some_field at once, however I still do not have a dropdown box. Alternatively, if anyone knows how to use this method with a dropdown box, then that would be another solution.</p>
0
Entity Framework "The wait operation timed out" on simple DeleteAll
<p>We have an MVC web application that I inherited that loads, let's call it MyCategory and all of its children into a webform, takes edit, then saves on save clicked. The way the application works is to first delete all data for the parent level entity in the model, then add everything back. We have pretty low concurrent user base on this, no more than twenty people saving at most every dew minutes each. We are unable to reproduce this error locally, but when the offshore team starts work we have started seeing the</p> <blockquote> <p>[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.]</p> </blockquote> <p>error show up. This is happening when calling a delete from LINQ on the parent table (it has no data at this point, nor do child tables). It is intermittent, but has happened quite a few times in the past week, in which there was a ramp up in work on this portion of the project.</p> <p>From the Stack Trace, it looks to be failing on System.Data.SqlClient.SqlCommand.FinishExecuteReader which appears to be going for 109+ minutes. This should be deleting at most tqo records from the table, and anyone loading data from this table should be retrieving at most two in a very short time span.</p> <p>Any ideas on where to start would be appreciated. Unfortunately, I do not have permissions to run SQL Query Analyzer or Activity Monitor on the production database.</p> <p>Call Stack is:</p> <pre><code>[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +388 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +717 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp;amp; dataReady) +4515 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6557561 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp;amp; task, Boolean asyncWrite, SqlDataReader ds) +6560327 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp;amp; task, Boolean asyncWrite) +586 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +742 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +287 System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +789 System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +188 System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +500 System.Data.Linq.StandardChangeDirector.DynamicDelete(TrackedObject item) +71 System.Data.Linq.StandardChangeDirector.Delete(TrackedObject item) +258 System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +622 System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +932 WebAppData.MyCategory.MyCategoryData.DeleteAll(Int32 id, Guid gid) +1053 WebAppServices.MyCategory.MyCategoryService.DeleteMyCategoryParentItems(Int32 id, Guid gId) +1632 WebAppServices.MyCategory.MyCategoryService.UpdateMyCategory(Int32 id, Guid gId, MyCategoryEntity mce) +51 WebAppUI.Areas.Documents.Categories.Sections.MyCategory.MyCategoryController.Save(Int32 Id, Guid gId, MyCategoryModel model) +93 </code></pre> <p>EDIT:</p> <p>Connection String:</p> <pre><code>&lt;add name="Data" connectionString="Data Source=myserver;Initial Catalog=mydatabase;User ID=myuser;Password=mypassword /&gt; </code></pre>
0
jQuery appear() and show() methods difference?
<p>I'm studying for a HTML, CSS, JS exam and found various resources to help me study. In doing a practice quiz, I found this question.</p> <p>You are creating a page that contains detailed employee information for a company portal. The page uses a jQuery library. The page contains a hidden button named btnEdit that is defined by the following code.</p> <pre><code>&lt;button id="btnEdit" style="display: none;"&gt;Edit&lt;/button&gt; </code></pre> <p>The button is not displayed by default. The button must be displayed only if the user is logged on. You need to add code to the document.ready() function to meet the requirements for the button. Which line of code should you use?</p> <pre><code>A. $ ('#btnEdit').appear(); B. $ ('#btnEdit').visible = true; C. $ ('#btnEdit').show(); D. $ ('#btnEdit').Visible(); </code></pre> <p>The quiz telling me that option A is correct. I haven't use appear() method before.</p> <p>My question is:</p> <ol> <li><p>.appear(), Is this function really as a part of jQuery library? I could not find .appear() function in jQuery doc. <a href="http://i.stack.imgur.com/tXmzR.png" rel="noreferrer">No results in jQuery API</a></p></li> <li><p>Is that option A is correct? If it is correct can anyone tell me why? As of my conscience option C is correct(If I'm wrong correct me).</p></li> <li><p>Can anyone please tell me difference between appear() and show()? And when to use appear(), when to use show()?</p></li> </ol>
0
Android - How to pass data from activity to fragment?
<p>I need to pass data from activity to fragment. I know I can use bundle , but once I passed data,I can't send data without calling and creating fragment again. </p> <p>In my activity, some thing may be changed and I need to notify my fragment for these changes without recreating fragment. </p>
0
Express call GET method within route from another route
<p>I have multiple routes. How can I get the data from the user's route (GET method), by calling it within the GET method of the group's route? What is the best way of doing this?</p> <p>My app.js looks like this:</p> <pre class="lang-js prettyprint-override"><code>var express = require('express'); var routes = require('./routes/index'); var users = require('./routes/users'); var groups = require('./routes/groups'); var app = express(); app.use('/', routes); app.use('/users', users); app.use('/groups', groups); module.exports = app; app.listen(3000); </code></pre> <p>Then I have another file routes/users.js:</p> <pre class="lang-js prettyprint-override"><code>var express = require('express'); var router = express.Router(); /* GET users listing. */ router.get('/', function(req, res, next) { res.send('GET ON THE users!'); }); module.exports = router; </code></pre> <p>And another route routes/groups.js:</p> <pre class="lang-js prettyprint-override"><code>var express = require('express'); var router = express.Router(); var otherRouter = require('./users') /* GET groups listing. */ router.get('/', function(req, res, next) { // call the get on users and retrieve all data from that request res.send('GET for the groups'); }); module.exports = router; </code></pre>
0
How to fix "The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."
<p>This is what I have so far:</p> <pre><code>SELECT account, ' ', message_type, MAX(message_no) as max_message_no, message_text FROM (SELECT account, message_type, message_no, message_text FROM messages m INNER JOIN receivables r ON m.account = r.aracct WHERE m.account IN (SELECT r.aracct AS account FROM receivables r WHERE r.balance &lt;&gt; 0) AND m.message_type = 'N') t1 GROUP BY t1.account, t1.message_type, t1.message_text </code></pre> <p>I keep getting the error message: </p> <blockquote> <p>The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.</p> </blockquote> <p>I essentially want the max <code>message_no</code> from each account and I want it to show the <code>message_text</code>, but it won't allow it because it is a <code>text</code> data type.</p>
0
What is the difference between #import and #include in C?
<p>I've read up a bit on preprocessor directives and I've seen #import being used a few times in C programs. I'm not sure what the difference is between them, some sites have said that #include is only used for header files and #import is used more in Java and is deprecated in C.</p> <p>If that's the case, why do some programs still use #import and how exactly is it different from #include? Also, I've used #import in a few of my C programs and it seems to work fine and do the same thing as #include.</p>
0
How to convert character into date format in R
<p>I have a csv file which has date in following format.</p> <pre><code>8/13/2016 8/13/2016 8/13/2016 2016-08-13T08:26:04Z 2016-08-13T14:30:23Z 8/13/2016 8/13/2016 </code></pre> <p>When I import this into R it takes it as a character. I want to convert it into Date format,but when I convert it into date format it takes all NA values</p> <pre><code>as.Date(df$create_date,format="%m%d%y") </code></pre> <p>Date field in CSV has different formats in which date is recorded. How can I convert it into date format in R </p>
0
How to specify a BIGINT literal in T-SQL?
<p>Aside from wrapping my literal in a CONVERT function, is there a way to specify that I want e.g. 12345 represented as a BIGINT and not an INT? In C#, I could specify 12345L, but I'm unaware of equivalent functionality in T-SQL.</p>
0
Heroku push gets rejected
<p>I am having problem in pushing my master branch to heroku. I am using the following command:</p> <pre><code>git push heroku master </code></pre> <p>Error that I am encountering-</p> <pre><code>Counting objects: 114, done. Delta compression using up to 4 threads. Compressing objects: 100% (112/112), done. Writing objects: 100% (114/114), 335.40 KiB | 0 bytes/s, done. Total 114 (delta 0), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----&gt; Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/php.tgz remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to skyconfapp. remote: To https://git.heroku.com/skyconfapp.git ! [remote rejected] master -&gt; master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/skyconfapp.git' </code></pre> <p>I even visited Heroku's link <a href="https://devcenter.heroku.com/articles/buildpacks#detection-failure" rel="noreferrer">https://devcenter.heroku.com/articles/buildpacks#detection-failure</a> and tried to implement every method that they have mentioned but nothing seems to be working for me.</p> <p>Can someone please assist?</p>
0