pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
29,481,926 | 0 | Query that joins 3 tables <pre><code>CREATE TABLE User(uid INTEGER AUTO_INCREMENT,address VARCHAR(40),city VARCHAR(20),state VARCHAR(20), </code></pre> <p>What Ive tried so far...</p> <pre><code>SELECT User.uid, Job.jobid, Protein.pid FROM User JOIN Job ON (Job.uid = User.uid) JOIN Protein ON (Job.pid = Protein.pid) </code></pre> <p>I cant figure out how to find a job that utilizes all proteins.</p> |
5,137,422 | 0 | <p>I just found a way to do this.</p> <p>Move everything under TRY, and that way, the CATCH is the last thing, so there's nothing else to be executed.</p> |
33,517,311 | 0 | Magento Patch 6788 Installation error <p>I am trying to install magento patch 6788 form ssh. but when i run command </p> <pre><code>sh PATCH_SUPEE-6788_CE_1.8.1.0_v1-2015-10-26-11-59-27.sh </code></pre> <p>i am getting this error </p> <pre><code> Checking if patch can be applied/reverted successfully... ERROR: Patch can't be applied/reverted successfully. can't find file to patch at input line 5 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |diff --git .htaccess .htaccess |index 60e1795..aca7f55 100644 |--- .htaccess |+++ .htaccess -------------------------- File to patch: Skip this patch? [y] Skipping patch. 1 out of 1 hunk ignored patching file .htaccess.sample patching file app/code/core/Mage/Admin/Model/Block.php patching file app/code/core/Mage/Admin/Model/Resource/Block.php patching file app/code/core/Mage/Admin/Model/Resource/Block/Collection.php patching file app/code/core/Mage/Admin/Model/Resource/Variable.php patching file app/code/core/Mage/Admin/Model/Resource/Variable/Collection.php patching file app/code/core/Mage/Admin/Model/Variable.php patching file app/code/core/Mage/Admin/etc/config.xml patching file app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.1-1.6.1.2.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Block.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Block/Edit.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Block/Edit/Form.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Block/Grid.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Variable.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Variable/Edit.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Variable/Edit/Form.php patching file app/code/core/Mage/Adminhtml/Block/Permissions/Variable/Grid.php patching file app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php patching file app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php patching file app/code/core/Mage/Adminhtml/etc/adminhtml.xml patching file app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php patching file app/code/core/Mage/Core/Controller/Request/Http.php Hunk #1 succeeded at 287 (offset -7 lines). patching file app/code/core/Mage/Core/Controller/Varien/Router/Admin.php Hunk #1 FAILED at 131. 1 out of 1 hunk FAILED -- saving rejects to file app/code/core/Mage/Core/Controller/Varien/Router/Admin.php.rej </code></pre> <p>and please give me some tips to upgrade magento current version from ssh Please Help to fix that</p> |
32,045,695 | 0 | How to pass parameters / arguments from one javascript snippet to another, when evaluated <p>My goal is to execute a javascript snippet using another javascript snippet using </p> <p><code>new Function(x1, x2, x3, functionBody)</code> call.</p> <p>My problem appears when i need to pass parameters to the function, this is because functionBody may appear as a new Js script with global declarations and calls. </p> <pre><code>function main() { var a = x1; var b = x2; var c = x3; .... .... } main(); // this is the function that starts the flow of the secondary Js snippets </code></pre> <p><strong>Edit:</strong> I have a script responsible for downloading and executing another Js script. each downloaded script is executed by a global call to main(), which is unknown to the caller script.</p> |
25,948,930 | 0 | <p>$datas = array(); $empcount = 10; $emp = $dIndex = 0;</p> <p>for($i=0;$i if( $emp >= $empcount) { $dIndex++; $emp = 0; } $datas[$dIndex][] = $finaldata[$i]; }</p> |
25,159,412 | 0 | <p>what you probably want is a "provided"*-scope dependency on <code>org.wildfly:wildfly-spec-api:8.1.0</code> (which is a pom artifact containing all the apis/specifications provided to you by wildfly).</p> <p>assumming you intend to deploy your app inside wildfly (as opposed to embedding wildfly in your own main() somehow...) you dont need a dependency on the wildfly container.</p> <p><strong>*</strong> - note that since wildfly-apec-api is a pom artifact (and not a jar) you need to use the import scope and not provided. see <a href="http://www.mastertheboss.com/wildfly-8/maven-configuration-for-java-ee-7-projects-on-wildfly" rel="nofollow">this article</a> for a complete guide. the gist is you put an import scope dependency on the pom in dependency management, and then you can put a provided-scope dependency on any specific member api/spec that you use (say ejb3, jsf, bean validation or jpa) and the versions will be taken from the spec-api pom.</p> |
40,673,098 | 0 | <p>Probably there is. Probably you can also use another callback on the application model which happens before, there are plenty of them. See <a href="http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html" rel="nofollow noreferrer">Active Record Callbacks</a></p> <p>However this is exactly the case, which other people call <code>rails callback hell</code></p> <p>The best practice here would be just creating a form object, which creates the data in the order you need and remove the callbacks</p> <pre><code>class ApplicationCommitmentForm include ActiveModel::Model attr_accessor ... def submit a = Application.create .. a.update_case_code a.commitments.create ... end end </code></pre> <p>See <a href="https://robots.thoughtbot.com/activemodel-form-objects" rel="nofollow noreferrer">ActiveModel Form Objects</a></p> <p>Btw you could also wrap the submit code into a transactions ensuring that either all records are created or in case of any errors nothing at all.</p> |
12,100,843 | 0 | <p>If at all possible you should store your additional values as <code>hidden</code> input fields (one per value) rather than as meta-data on other input fields. They'll then get serialized automatically as part of the form.</p> <p>I won't write a serializer for you, as I think it's a bad idea. If you <em>insist</em> on sending the values to the browser as <code>data-</code> fields you could do this, though, to convert those <code>data-</code> fields into <code>hidden</code> inputs.</p> <pre><code>$('#myform:input').each(function() { var input = this; $.each($(input).data(), function(key, value) { $('<input>', {type: hidden, name: key, value: value}).insertAfter(input); }); }); </code></pre> <p>Hey presto, hidden input fields that'll be automatically serialized!</p> <p>Be aware that jQuery also uses <code>.data()</code> to store things like events. To avoid iterating over those objects you'd have to use the native DOM functions to retrieve the <code>data-</code> <em>attributes</em>, and not any data-related <em>properties</em> that have been stored on the elements.</p> |
38,717,284 | 0 | <p>According to php manual </p> <p><strong>random_bytes</strong> : Generates <strong>cryptographically secure</strong> pseudo-random bytes <strong>openssl_random_pseudo_bytes</strong> : Generate a pseudo-random string of bytes</p> <p>so main difference is the <strong>cryptographically secure</strong></p> <blockquote> <p>The openssl_random_pseudo_bytes() PHP function calls the RAND_psuedo_bytes() OpenSSL function, which the OpenSSL docs say should only be used for non-cryptographic purposes:</p> </blockquote> <p><a href="https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php" rel="nofollow">https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php</a></p> |
23,363,406 | 0 | How to Sort products based on Product Variant Attribute Value in nopcommerce3.10 <p>Please help me to filter products based on Product Variant Attribute Value in nopcommerce3.10</p> <p>Thanks</p> |
17,246,440 | 0 | <p>This will capture the two square brackets <code>\K\[\[(?>[^]]++|](?!]))]]*</code> </p> <p><strong>Input Text</strong></p> <pre><code>like [[ yes|ja ]] with </code></pre> <p><strong>Matches</strong></p> <pre><code>[0] => [[ yes|ja ]] [1] => yes|ja </code></pre> <p>I"m not a python programmer, but I think you'll want to modify your script to be like this:</p> <pre><code>$that = $this; $view = preg_replace_callback('~\K\[\[(?>[^]]++|](?!]))]]*~', function ($m) use ($that) { return $that->__($m[1]); }, $view); </code></pre> |
30,188,231 | 0 | <p>Just loop over the selections:</p> <pre><code>Sub Maja() Dim K As Long K = 1 vals = Array("3", "6", "9") For Each a In vals For Each b In vals For Each c In vals For Each d In vals For Each e In vals Cells(K, 1) = a & b & c & d & e K = K + 1 Next e Next d Next c Next b Next a MsgBox K End Sub </code></pre> <p>A snap of the top of the list:</p> <p><img src="https://i.stack.imgur.com/1DUhg.png" alt="enter image description here"></p> <p><strong>NOTE:</strong></p> <p>Technically, you would call these <strong>permutations</strong> rather than <strong>combinations</strong> because values like <em>33363</em> and <em>33336</em> both appear in the list as they represent different numerical values.</p> |
26,155,338 | 0 | <p>I am using the following</p> <pre><code><fo:block font-weight="normal" text-align="left"> <fo:external-graphic src="url(file:images/CompanyLogo.png)" content-height="8mm" /> </fo:block> </code></pre> |
14,649,880 | 0 | Make a web browser as modal popup window in my web site <p>Hi guys I just found out that it's possible to implement a draggable modal popup using web browser itself.that how tinymce and joomla and other popular frameworks use it. And my questions is how can we apply that css stylize on browser itself, by hiding the address bar and the browser icon on the left up corner, and make it graggable only within the page. i wonder that maybe there is a simple solution for that in html5. Any links will be helpfull</p> <p>Thank you</p> |
24,130,164 | 0 | <p><strong>To display text instead of ID from dropdown list</strong>:</p> <p>You can create a function in the directive that loops through the options, and returns the <code>name</code> when the <code>id</code> matches the value you're binding on. For example:</p> <pre><code>scope.statusText = function(){ var text = ''; angular.forEach(scope.statusOptions, function(item){ if(item.id == scope.task.status) text = item.name; }); return text; } </code></pre> <p><strong>To auto-focus the element</strong></p> <p>Create a function in the directive that is called on the <code>ng-click</code> of the "display" span. This will set <code>scope.editStatusMode = true</code>, then call <code>.focus</code> on the element.</p> <pre><code>scope.setStatusFocus = function(){ scope.editStatusMode = true; var el = element.find('select'); $timeout(function(){ el.focus(); }); }; </code></pre> <p>Wrapping the <code>el.focus()</code> in <code>$timeout</code> will delay the call to focus until the DOM is done rendering. The HTML looks like this:</p> <pre><code><span ng-hide="editStatusMode" ng-click="setStatusFocus()" ng-bind="statusText()"></span> </code></pre> <p><strong>How do you know which object you're updating</strong></p> <p>Create an <code>update()</code> function in the directive that is bound to 'ng-blur<code>. In that function, you can access</code>scope.task`, which you can send off to your server to save. </p> <pre><code>scope.update = function(){ scope.editPriorityMode = false; //Save scope.task here. console.log(scope.task); } </code></pre> <p>This works for <code>description</code> and <code>priority</code>. It doesn't work for <code>status</code> because when you change the status, it immediately disappears from whichever list it is in and is added to a different list, and the <code>blur</code> event is never fired. To deal with <code>status</code>, you can create a <code>$watch</code> on <code>task.status</code>, and call the <code>update()</code> function from there.</p> <pre><code>scope.$watch('task.status', function(oldValue, newValue){ scope.update(); }) </code></pre> <p><a href="http://plnkr.co/edit/MBwAUkPZvYUhDAVW7KZN?p=preview" rel="nofollow">Plunker</a></p> |
22,209,054 | 0 | <p>Instead of checking the empty value it's better to check the length of the content</p> <pre><code>$("td").hover(function(){ var cell = $(this).html(); if(cell.length===0) $(this).css( "background-color", "orange"); else $(this).css( "background-color", "black"); }); </code></pre> |
25,892,005 | 0 | <p>Under normal circumstances. Java properties of the variable names are lowercase letter, such as: userName, ShowMessage, but there are special circumstances, taking into account certain interesting English acronym (USA, XML, etc.), JavaBean also allows capital letters beginning the attributes variable name, but must meet the first two letters of the variable is either all uppercase or all lowercase "requirements, such as: the IDCODE ICcard IDCODE property variable name is legal, but the iC, iCcard, iDCode attribute variables The name is illegal.</p> |
12,333,125 | 0 | <p>By using <a href="http://plugins.jquery.com/project/jCaret" rel="nofollow">JQuery Caret Plugin</a>, you could use some code like:</p> <pre><code><textarea id="codeInput" cols="80" rows="50">content</textarea> <script type="text/javascript"> var tagDict = { "[b]" : "[/b]", "[c]" : "[/c]", "[d]" : "[/d]" }; $(document).ready(function () { $('#codeInput').keyup(function () { var test = $(this).val(); var tagStart = test.substr(test.length - 3, 3); if (tagDict[tagStart]) { $(this).val(test + tagDict[tagStart]); $(this).caret(test.length, test.length); } }); }); </script> </code></pre> <p>It's not perfect, but it could be a start for a complete code completion function.</p> |
29,208,020 | 0 | Set maximum of upload size in a asp.net application <p>in asp.net I cant set my upload limit with the value:"maxAllowedContentLength". This value has the type uint32, that means it has a maximum size of: "4294967295". The problem is, that 4gb for me, are not enough. Is there a way, to increase this value?</p> |
4,671,159 | 0 | <p>If you are having problem with validation messages you can always check the codes for the validation errors using the <code>errors</code> collection on an instance.</p> <pre><code>Customer c = ... c.validate() c.errors.each { println it } c.errors.getFieldError("address").codes.each { println it } c.errors.getFieldError("address").defaultMessage </code></pre> <p>Write a unit test to check the codes to localise the messages.</p> |
22,221,371 | 0 | <p>Yes, this is entirely correct. You can easily check it by setting the grid search procedure in verbose mode:</p> <pre><code>>>> estimator = GridSearchCV(pipe, dict(pca__n_components=n_components, ... logistic__C=Cs), ... verbose=1) >>> estimator.fit(X_digits, y_digits) Fitting 3 folds for each of 9 candidates, totalling 27 fits [...snip...] </code></pre> <p>More generally, the number of <code>fit</code> calls is the product of the number of value per parameter, times <em>k</em>, +1 if you refit the best parameters on the full training set (which happens by default).</p> |
12,421,783 | 0 | <p>iPhone5's cpu is A6(armv7s). The existing Admob sdk does not support it. We have to wait for admob to update the sdk.</p> |
13,379,911 | 0 | Drupal Commerce - Paypal Payment <p>I'm looking for a explanation about how the Paypal Sandbox works. Let's say I have a real Paypal account through which I receive payments and I want to configure it on Drupal Commerce's Paypal module, but also I want to test the payment workflow first before making it live and let my customers use it, I see the Paypal configuration on Drupal has the following options under the "PayPal server" section:</p> <ul> <li>Sandbox - use for testing, requires a PayPal Sandbox account</li> <li>Live - use for processing real transactions</li> </ul> <p>I assume that if I want to do "dummy" transactions I must enable the "Sandbox" option on the Drupal side so my question is </p> <p><em>Is enabling the 'Sandbox' option the only thing I need to do in order to avoid real transactions being charged to my Paypal account? or do I have to create another Paypal account (the Sandbox account) and configure it on the Drupal side instead of my real account?</em></p> <p>I was just wondering if the Paypal Payment plugin on Drupal needs a "Sandbox account" (different from my real Paypal account) or if by just enabling the Sandbox option it somehow signals Paypal about it and any transactions are just ignored while that option is enabled.</p> <p>I'll apreciate if someone clarifies this a bit for me, I'm just starting to develop Paypal related stuff.</p> <p>Thanks!</p> |
3,506,988 | 0 | Output UTF-16? A little stuck <p>I have some UTF-16 encoded characters in their surrogate pair form. I want to output those surrogate pairs as characters on the screen.</p> <p>Does anyone know how this is possible?</p> |
20,399,715 | 0 | <p>Simple wrapping of C# Console behaviour in F# printfn style. </p> <p>NB. the printfn "no format" overload is not working for this work-around.</p> <p>I'll award the question to the best answer if another answer shows up.</p> <pre><code> // .fs code // -------- namespace Play open PlayCS open System open NUnit.Framework module printHelper = let printfn (fmt: Format<_,_,_,_>) x = ConsoleHack.WriteLine <| sprintf fmt x open printHelper [<TestFixture>] type printPatterns2() = [<Test>] member __.testHelper() = printfn "%s" "our overloaded printfn" printfn "%s" "now does" printfn "%s" "what" printfn "%s" "it is supposed to" printfn "%s" "in the F#/Resharper/nunit context" [<Test>] member __.testHackWriteLine() = ConsoleHack.WriteLine(sprintf "%s" "abc") ConsoleHack.WriteLine(sprintf "%s" "abc") // .cs code // -------- using System; namespace PlayCS { public class ConsoleHack { public static void WriteLine(string s) { Console.WriteLine(s); } } } </code></pre> <p>Improvement requests: </p> <ul> <li>is it possible to load this into the top-level-domain?</li> </ul> |
29,608,255 | 0 | <p>View</p> <pre><code>@using (Html.BeginForm("Save", "Doctor", FormMethod.Post)) { <p> @Html.LabelFor(model => model.Foo): @Html.EditorFor(model => model.Foo) @Html.ValidationMessageFor(model => model.Foo) </p> <p> @Html.LabelFor(model => model.barImage) <input type="file" name="Image" /> </p> <p> <input type="submit" value="Save" /> </p> } </code></pre> <p>Controller </p> <pre><code>[HttpPost] public ActionResult Create(Doctor doc) { your_dbcontext db = new your_dbcontext(); db.Add<Doctor>(doc); db.SaveChanges(); return RedirectToAction("Index"); } </code></pre> |
14,801,332 | 0 | <p>A very simple (but rather memory expensive) way would be:</p> <pre><code>bool use_map(const std::string& sentence) { std::set<char> chars(sentence.begin(), sentence.end()); return chars.size() == sentence.size(); } </code></pre> <p>If there's no duplicate chars, the sizes of both string and set will be equal.</p> <p>@Jonathan Leffler raises a good point in the comments: sentences usualy contain several whitespaces, so this will return <code>false</code>. You'll want to filter spaces out. Still, <code>std::set</code> should be your container of choice.</p> <p><strong>Edit:</strong></p> <p>Here's an idea for O(n) solution with no additional memory. Just use a look-up table where you mark if the char was seen before:</p> <pre><code>bool no_duplicates(const std::string& sentence) { static bool table[256]; std::fill(table, table+256, 0); for (char c : sentence) { // don't test spaces if (c == ' ') continue; // add more tests if needed const unsigned char& uc = static_cast<unsigned char>(c); if (table[uc]) return false; table[uc] = true; } return true; } </code></pre> |
14,041,137 | 0 | <p>for anyone having the same problem, I've managed to fix it starting from scratch on the code and using this: <a href="http://jsfiddle.net/tuando/CA8KV/1/" rel="nofollow">http://jsfiddle.net/tuando/CA8KV/1/</a></p> <pre><code>$("#accordion").accordion(); $(".section-link").click(function (e) { e.preventDefault(); $("#accordion").accordion("activate", $(this).parent().index()); }); </code></pre> <p></p> <p>Excellent and lightweight solution.</p> <p>Thanks to anyone who looked into it.</p> |
9,431,116 | 0 | <p>Please try following, </p> <ul> <li>Install Microsoft Access Database Engine.exe.</li> <li>On IIS goto Application pools, choose the application pool of the website. </li> <li>Click on Advanced settings, set Enable 32-bit Applications to true.everything should work.</li> </ul> |
21,770,712 | 0 | <p><code>p</code> elements are paragraphs - so they have a default property of display:block. Either use another element, for example a <code>span</code>. Alternatively you can change the display property of the p dom element, for example to <code>display:inline</code>.</p> <p>Update - the property of vertical align 'vertical-align:middle' should be applied to the images.</p> <p>Also - your nesting of styles seems wrong, see a working example below.</p> <p>Example (updated): <a href="http://jsfiddle.net/YwV54/2/" rel="nofollow">http://jsfiddle.net/YwV54/2/</a></p> |
21,373,683 | 0 | <p>On the basis that the <code>else</code> is there, no, it won't work.</p> <p>For it to work how you wish it to, you'd need to remove the else and just use 2 <code>if</code> statements, such as;</p> <pre><code>// Set default values; $a = 2; $b = 0; // Check $a if( $a == 2 ) { // Change values $a = 0; $ b = 2; } // Check $b, which is now 2 due to the condition matching above if( $b == 2 ) { echo "Cool?"; } </code></pre> <p>I believe you're slightly missing the point with the else.</p> <p>It is used for condition matching, to confirm multiple possibilies.</p> <p>For example, let's imagine a lottery, where the prize money is split into ranges;</p> <p>Numbers 01 - 10 = $5. Numbers 11 - 20 = $10. Numbers 21 - 30 = $20.</p> <p>You're code could look something like</p> <pre><code><?php $random_result = mt_rand(0, 30); if ($random_number > 20) { $amount = 20; } else if ($random_number > 10) { $amount = 10; } else { $amount = 5; } echo 'The jackpot for today was $' . $amount . '!'; </code></pre> |
37,058,855 | 0 | <p>For the addition, it could be like this</p> <pre><code>bool addBigInt( const BigInt n1, const BigInt n2, BigInt res ) { int i, sum, carry = 0; for(i=0; i<MaxDigits; i++) { sum = n1[i] + n2[i] + carry; res[i] = sum % 10; carry = sum / 10; } return carry == 0; } </code></pre> |
37,627,989 | 0 | <p>Use the JavaScript <code>JSON.Stringify()</code> function. Example:</p> <pre><code>$.ajax({ method: "POST", url: "/yourController/yourAction", data: { name: "John", location: "Boston" } }).done(function( data ) { alert(JSON.Stringify(data)); }); </code></pre> |
10,235,421 | 0 | Check the existence of an object in Core Data <p>I found this code in response to another question:</p> <pre><code>NSError *error = nil; NSUInteger count = [managedObjectContext countForFetchRequest:request error:&error]; [request release]; if (!error){ return count; } else return 0; </code></pre> <p>The problem is, I don't know what to make my fetch request be, in order to have it only potentially return my object, and no others.</p> |
11,484,405 | 0 | Incorrect forms authentication timeout <p>I want to make "remember time" on a site something aroun one week. In default mvc 3 application I set this changes:</p> <pre><code><forms loginUrl="~/Account/LogOn" timeout="10880" slidingExpiration="true" /> </code></pre> <p>But, it is not enought. After half an hour site forget me. What could be wrong?</p> |
22,077,214 | 0 | <p>Turn on the Debug Graphics Device (D3D11_CREATE_DEVICE_DEBUG) and you should see that your constant buffer is not 64 bytes in HLSL as you expect.</p> <pre><code>// cbuffer LightBuffer // { // // float4 lightRange; // Offset: 0 Size: 16 // float3 lightPos; // Offset: 16 Size: 12 // float3 lightColor; // Offset: 32 Size: 12 // float3 lightDirection; // Offset: 48 Size: 12 // float2 spotLightAngles; // Offset: 64 Size: 8 // float padding; // Offset: 72 Size: 4 // // } </code></pre> <p>All told, your constant buffer is 80 bytes in size. Meanwhile your struct on the C++ side is made up of structures of floats which don't adhere to the HLSL packing rules (float4 registers) so your two types don't align.</p> |
2,595,096 | 0 | <p>Since traversing a <a href="http://en.wikipedia.org/wiki/Binary_tree" rel="nofollow noreferrer">binary tree</a> requires some kind of state (nodes to return after visiting successors) which could be provided by stack implied by recursion (or explicit by an array).</p> <p>The answer is no, you can't. (according to the classic definition)</p> <p>The closest thing to a binary tree traversal in an iterative way is probably using a <a href="http://en.wikipedia.org/wiki/Heap_%28data_structure%29" rel="nofollow noreferrer">heap</a></p> <p>EDIT: Or as already shown a <a href="http://en.wikipedia.org/wiki/Threaded_binary_tree" rel="nofollow noreferrer">threaded binary tree</a> ,</p> |
39,880,011 | 0 | strange issue when using drawer in android lolipop <p>i have mainlayout.xml as coded below :</p> <pre><code><?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout 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:id="@+id/drawer" android:layout_width="match_parent" android:layout_height="match_parent" android:layoutDirection="rtl" tools:context="com.sanwix.mh.meeting.MainActivity"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <include android:id="@+id/toolbar" layout="@layout/layout_appbar"/> <android.support.v7.widget.RecyclerView android:id="@+id/MyMainReycler" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar" android:padding="16dp"> </android.support.v7.widget.RecyclerView> <android.support.design.widget.FloatingActionButton android:id="@+id/Fabb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_gravity="left|bottom" android:layout_margin="16dp" android:src="@android:drawable/ic_menu_edit" android:transitionName="sharedFab" app:backgroundTint="@color/colorAccent" app:elevation="8dp" app:fabSize="normal" /> </RelativeLayout> <android.support.v7.widget.RecyclerView android:id="@+id/myRecycleDrawer" android:layout_width="280dp" android:fitsSystemWindows="true" android:layout_gravity="start" android:layout_height="match_parent"/> </android.support.v4.widget.DrawerLayout> </code></pre> <p>every things work prefectly on pre-lolipop devices. but on lolipop or above , it doesnt run prefectly. my issue is that : i have no main content for myactivity and each one of my elements take a seperate drawer . i mean the RelativeLayout will be shown as left-side drawer and the RecyclerView will be shown as right-side drawe on lolipop or above. but what i want is just one drawer on rightside(my recycle)</p> <p>any idea will be appreciated</p> |
4,420,170 | 0 | <p>Honestly, no or at least not that I've run across. Whether you use your data (EF) models for the MVC model or not in either case you're going to have to decorate a bunch of classes (properties) with the attributes. </p> <p>Personally I generally insert a business layer between my DAL (EF/NHibernate/etc.) and my UI layer (MVC) so my models in the UI are different from persistence. But I still end up with just as many (if not more) model classes with attributes as I have for the DAL.</p> <p>This may not help in your situation but you may want to take a look at the new validation features coming with the next version of <a href="http://weblogs.asp.net/scottgu/archive/2010/12/10/class-level-model-validation-with-ef-code-first-and-asp-net-mvc-3.aspx" rel="nofollow">EF</a> and see if the will help you any.</p> |
11,094,002 | 0 | <p>You can manually fire the change event after you dynamically populate the field, eg:</p> <pre><code>jQuery("#input_4_64").val(selectedValue).change(); </code></pre> |
23,027,463 | 0 | SQL : search from two tables <p>I'm using SQL Server and I have two tables</p> <p><code>player</code>:</p> <pre><code> player guildId -------------------- a 1 b 2 c 2 d 2 e 1 f 1 g 1 </code></pre> <p><code>game</code>: </p> <pre><code> player gameId -------------------- a 4 b 1 c 2 d 1 e 3 f 2 g 2 </code></pre> <p>I want to create a view called view_test,</p> <p>The view's result :</p> <pre><code>select * from view_test where guildId = 2 and gameId = 2 </code></pre> <p>it shows</p> <pre><code> player joined ---------------- b false c true d false select * from view_test where guildId = 2 and gameId = 1 player joined ----------------- b true c false d true select * from view_test where guildId = 2 and gameId = 3 player joined ---------------- b false c false d false select * from view_test where guildId = 1 and gameId = 4 player joined ---------------- a true e false f false g false </code></pre> <p>How can I do this SQL ?</p> <p>Thanks</p> |
17,477,454 | 0 | <p>You can use <code>CopyTo</code> method of the <em>stream</em>.</p> <pre><code>MemoryStream m = new MemoryStream(); dataStream.CopyTo(m); byte[] byteArray = m.ToArray(); </code></pre> <p>You can also write directly to file</p> <pre><code>var fs = File.Create("...."); dataStream.CopyTo(fs); </code></pre> |
5,097,088 | 0 | How to copy MySQL table structure to table in memory? <p>How to create a table in memory which is identical to "regular" table? I want a copy without indexes and constraints. Pure SQL (no external tools).</p> <p>This works (however indexes are created):</p> <pre><code>create table t_copy (like t_original) </code></pre> <p>This doesn't:</p> <pre><code>create table t_copy (like t_original) engine=memory </code></pre> |
22,898,036 | 0 | <p><em>You can use <code>angular.bootstrap()</code> directly...</em> the problem is you lose the benefits of directives.</p> <p>First you need to get a reference to the HTML element in order to bootstrap it, which means your code is now coupled to your HTML.</p> <p>Secondly the association between the two is not as apparent. With <code>ngApp</code> you can clearly see what HTML is associated with what module and you know where to look for that information. But <code>angular.bootstrap()</code> could be invoked from anywhere in your code.</p> <p>If you are going to do it at all the best way would be by using a directive. Which is what I did. It's called <code>ngModule</code>. Here is what your code would look like using it:</p> <pre><code><!DOCTYPE html> <html> <head> <script src="angular.js"></script> <script src="angular.ng-modules.js"></script> <script> var moduleA = angular.module("MyModuleA", []); moduleA.controller("MyControllerA", function($scope) { $scope.name = "Bob A"; }); var moduleB = angular.module("MyModuleB", []); moduleB.controller("MyControllerB", function($scope) { $scope.name = "Steve B"; }); </script> </head> <body> <div ng-modules="MyModuleA, MyModuleB"> <h1>Module A, B</h1> <div ng-controller="MyControllerA"> {{name}} </div> <div ng-controller="MyControllerB"> {{name}} </div> </div> <div ng-module="MyModuleB"> <h1>Just Module B</h1> <div ng-controller="MyControllerB"> {{name}} </div> </div> </body> </html> </code></pre> <p>You can get the source code for it at:</p> <p><a href="http://www.simplygoodcode.com/2014/04/angularjs-getting-around-ngapp-limitations-with-ngmodule/">http://www.simplygoodcode.com/2014/04/angularjs-getting-around-ngapp-limitations-with-ngmodule/</a></p> <p>It's implemented in the same way as <code>ngApp</code>. It simply calls <code>angular.bootstrap()</code> behind the scenes.</p> |
29,003,856 | 0 | Why I get Forbidden error <p>I have created a custom bitnami app at:</p> <pre><code>/opt/redmine-2.6.0-3/apps/widgets </code></pre> <p>but, when I try to access the app from web browser:</p> <pre><code>http://192.168.10.18:8080/widgets/ </code></pre> <p>I get error:</p> <pre><code>Forbidden You don't have permission to access /widgets/ on this server. </code></pre> <p><code>httpd-app.conf</code> is</p> <pre><code><Directory /opt/redmine-2.6.0-3/apps/widgets/htdocs> Options +FollowSymLinks AllowOverride All Allow from all Require all granted </Directory> </code></pre> <p><code>httpd-prefix.conf</code> is:</p> <pre><code>Alias /widgets/ "/opt/redmine-2.6.0-3/apps/widgets/htdocs/" Alias /widgets "/opt/redmine-2.6.0-3/apps/widgets/htdocs" Include "/opt/redmine-2.6.0-3/apps/widgets/conf/httpd-app.conf" </code></pre> <p>Any one can help?</p> <p><strong>Edit</strong></p> <p>I've checked the widgets folder permission settings:</p> <pre><code>$ ls -l directory drwxr-xr-x 6 root daemon 4096 Jan 5 11:23 redmine drwxr-xr-x 6 root daemon 4096 Mar 11 17:20 widgets /apps/widgets$ ls -l drwxr-xr-x 2 root root 4096 Mar 12 09:09 conf drwxr-xr-x 5 root daemon 4096 Mar 11 17:20 htdocs /apps/redmine$ ls -l drwxr-xr-x 3 root daemon 4096 Jan 5 11:21 conf drwxrwxr-x 19 root daemon 4096 Jan 20 12:15 htdocs </code></pre> <p>Can some one explain please? why redmine works while widgets is forbidden?</p> |
10,542,734 | 0 | NSBundle Not Working <p>NSBundle outputs the old name of my app: "/var/mobile/Applications/0E1638D2-5B9C-4A1F-8ED2-5F8ADF55D3F6/distributedLCA.app" but I renamed the project but it still prints out that old .app name. Is there a way to fix this?</p> <p>My code:</p> <pre><code>[[NSBundle mainBundle] resourcePath] </code></pre> |
13,192,074 | 0 | ehcache - any solution to access expired element content? <p>I am using ehcache to cache data, usually 24h expiration time. I want to take element individual actions at the time an element expires. Therefore i neee the element content. I registered a CacheEventListener in order to get a notification (notifyElementExpired) in case of element expiration. Unfortunately at notification time only the key is known - content is already discarded, which is kind of painful!</p> <p>Any solution to access element content at expiration time? </p> |
35,331,518 | 0 | <p>This is a non-standard GCC extension. Many other compilers like Visual C++ don't support <a href="https://en.wikipedia.org/wiki/Variable-length_array" rel="nofollow">VLA</a>.</p> <p><a href="http://rextester.com/WPX55597" rel="nofollow">LIVE DEMO</a></p> |
20,859,233 | 0 | How to draw ImageView on ImageView? <p>I have an ImageView and I would like to draw dinamically another images on my base ImageView.</p> <p>In this image for example I have a tree and I would like to draw image of people</p> <p>Any suggestions to start?</p> <p><img src="https://i.stack.imgur.com/XTbpy.jpg" alt="enter image description here"></p> <p>yes my problem is like @Tsunaze say:</p> <p>I have a tree, and I want to put heads on it,</p> |
8,016,549 | 0 | ORDER BY timestamp with NULLs between future and past <p>I would like to order SQL results by a timestamp field in descending order with newest entries first. However, I have certain rows that are blank or contain zeros. How can I sandwich these result in between future and past rows? Can this be done with CASEs?</p> <pre><code>SELECT * FROM table ORDER BY when DESC </code></pre> <p>EDIT: Thanks to all the responses. Just so everyone knows, I went with MySQL's IFNULL, i.e.</p> <pre><code>SELECT * FROM table ORDER BY IFNULL(when,UNIX_TIMESTAMP()) DESC </code></pre> <p>This was the simplest approach, where if when contained NULL the select query replaced it with the current unix time. Note that I updated my DB and replaced all 0s with NULL values.</p> |
22,453,289 | 0 | Java public class with public constructor with non-public parameter. Why? <p>Java allows to define the following pair of classes.</p> <pre><code>class Class1 { ... } public Class2 { public Class2(Class1 c1) { ... } } </code></pre> <p>Why Class2 has public constructor if I cannot instantiate it because Class1 is not accessible?</p> <p>For the record, there are no public classes that inherit from Class1.</p> |
28,351,572 | 0 | <p>Call <code>onchange()</code> method on the first element <code>onblur</code></p> <pre><code><input type="text" id="field_1" onblur="onchange()"/> </code></pre> |
21,033,349 | 0 | <p>This is a bit old but I'm trying to find the same myself. The best I can find are:</p> <p><a href="http://www.mapquestapi.com/search/">http://www.mapquestapi.com/search/</a></p> <p>Mapquest search has a data set which allows querying for tourist attractions. However I cannot find a way to sort the results by importance. Radius search returns results in order of proximity and I have no idea what order a rectangle search is in.</p> <p><a href="https://developers.google.com/places/documentation/search">https://developers.google.com/places/documentation/search</a></p> <p>Google places allows sorting by "prominence". This actually returns a list that is reasonably representative of the main places a tourist might want to see. You can filter out certain types to refine this.</p> <p><a href="http://en.wikipedia.org/wiki/Category:Visitor_attractions_in_Manhattan">http://en.wikipedia.org/wiki/Category:Visitor_attractions_in_Manhattan</a></p> <p>Wikipedia has categories of "visitor attractions in_<strong>_</strong>" for many cities. Being crowdsourced, there are lots of issues. For example, the Empire State Building which is one of the main attractions in Manhattan is not on this list, but some random little coffee shop Everyman Espresso is.</p> <p><a href="http://wikitravel.org/en/New_York_City#See">http://wikitravel.org/en/New_York_City#See</a></p> <p>Wikitravel has a "see" section for most cities. There's no structure to it, but most of the attractions are bold, although this example shows a lot of other things that are bold like various passes.</p> <p><a href="http://www.geonames.org/export/wikipedia-webservice.html">http://www.geonames.org/export/wikipedia-webservice.html</a></p> <p>Geonames has indexed all the geotagged Wikipedia articles and has a service to search it. It has a "rank" parameter, which could somewhat indicate the relative interestingness for tourists.</p> |
31,460,945 | 0 | <p>So, after some chat, here is my solution, hope this help: I made 2 <code>.html</code> files, <code>a.html</code> and <code>b.html</code>.</p> <p>Content of <code>a.html</code>:</p> <pre><code><div></div> <script> $.getScript("main.js", function() { $("div").load("b.html #items"); }); </script> </code></pre> <p>And <code>b.html</code>:</p> <pre><code><body> <script src="main.js"></script> </body> </code></pre> <p>Also content of <code>main.js</code> file:</p> <pre><code>$('<div></div>', { text: 'I am alive !!!', id: '#items' }).appendTo('body'); </code></pre> <p>and when I open the <code>a.html</code>, I can see <code>I am alive !!!</code>.</p> <p><strong>Edit</strong>:</p> <p>Please note, I didn't add link of <code>main.js</code> to <code>a.html</code>.</p> <p><strong>UPDATE</strong>, same result with this code:</p> <pre><code>$.getScript("main.js").done(function() { load(); }).fail(function(jqxhr, settings, exception) { alert("Triggered ajaxError handler."); }); function load() { $("#Result").load("b.html #items", function(response, status, xhr) { if (status == "error") { var msg = "error: "; $("#error").html(msg + xhr.status + " " + xhr.statusText); } }); }; </code></pre> |
19,068,113 | 0 | The same jquery version doesn't work if there is on Google Apis <p>I'm very confused, so if I put this in functions.php, on Wordpress, it works</p> <pre><code>function modify_jquery() { if (!is_admin()) { // comment out the next two lines to load the local copy of jQuery wp_deregister_script('jquery'); wp_register_script('jquery', 'http://sitgesgroup.com/wp-content/themes/toolbox/assets/js/jquery-1.9.0.min.js', false, '1.9.0'); wp_enqueue_script('jquery'); } } add_action('init', 'modify_jquery'); </code></pre> <p>BUT,</p> <p>if I put this it breaks</p> <pre><code>http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.jsfunction modify_jquery() { if (!is_admin()) { // comment out the next two lines to load the local copy of jQuery wp_deregister_script('jquery'); wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js', false, '1.9.0'); wp_enqueue_script('jquery'); } } add_action('init', 'modify_jquery'); </code></pre> <p>Why if these are the same file?</p> <p>Thanks!</p> |
1,058,760 | 0 | Adding multiple UIButtons to an UIView <p>I've added some buttons to an UIView (via addSubview) programmatically. However, they appear as overlays (so that I always see the last button only). How do I add new buttons below existing buttons?</p> <p>Regards</p> |
18,729,964 | 0 | <p>First verify it holds for n = 1.</p> <p>Then assume it is true for n = x ( the sum of the first x squares ) and then try to compute the sum of the the first x + 1 squares. You know the result for the first x, you just add the last square to that sum. From there it should be easy.</p> <p>And you posted on the wrong site.</p> |
15,886,536 | 0 | intercept j_security_check <p>when doing login in my login form which is based on j_security_check all ok. in that case I see that the path in JSESSIONID cookie has a value from the URL. but when a nother login page construct dynamic form (it is doing submit to the first login page with /j_security_check at the end of the url) to do the login it fails and I see JSESSIONID cookie has an empty value in the path.</p> <p>when doing login/logout to the first page so the JSESSIONID still exist the login using the second login page works fine.</p> <p>so I thought maybe possible to modify something in the j_security_check process to ok the empty path.</p> <p>thanks.</p> |
19,733,056 | 0 | <p>Use <code>sizeWithFont:constrainedToSize:</code> to get size of string</p> <p>If you're on iOS7 use <code>boundingRectWithSize:options:attributes:context:</code> instead (<code>sizeWithFont:constrainedToSize:</code> is deprecated on iOS7)</p> |
34,916,790 | 0 | Detecting shake gesture by multiple view controllers <p>I need to detect shake gesture in iOS. I have done the usual stuff and it works perfectly fine. The thing is I have multiple view controllers in <code>UITabBarController</code> and I wish each of them to detect the shake gesture. </p> <p>When shaking in any of the view controller , I get switched to a particular tab. The problem is if I shake in one view controller and try to shake in other controller the gesture is not detected unless some action is performed in that controller.</p> <p>I know I need to set <code>becomeFirstResponder</code> but I need to know how can this property be set to the current tab of the <code>UITabBarController</code> so that the shake gesture is recognised by all tabs.</p> |
3,370,831 | 0 | <p>You can do this with <a href="http://drupal.org/project/content_taxonomy" rel="nofollow noreferrer">Content Taxonomy</a>'s Content Taxonomy Options module. Add a new Content Taxonomy field, and use the Select widget. In the field settings, under the <em>Advanced settings for hierarchical vocabularies</em> field group, select the Parent Term you want to use for that field.</p> |
36,285,404 | 0 | <p>I was using gedit and had the setting wrong so it was adding tabs and not spaces so although it looked right it didn't work. Just changed it to adding spaces and it worked, not sure if this is supposed to happen and not even sure it is what went on but never the less I got it working.</p> <p>Thanks</p> |
26,644,525 | 0 | <p>It's going to depend on a lot of things, here's how you can find out. GNU Binutils comes with a utility <code>objdump</code> that gives all sorts of details on what's in a binary.</p> <p>On my system (an ARM Chromebook), compiling test.c:</p> <pre><code>#include <stdio.h> int main(void) { printf("Hello, world!\n"); } </code></pre> <p>with <code>gcc test.c -o test</code> and then running <code>objdump -R test</code> gives</p> <pre><code>test: file format elf32-littlearm DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE 000105e4 R_ARM_GLOB_DAT __gmon_start__ 000105d4 R_ARM_JUMP_SLOT puts 000105d8 R_ARM_JUMP_SLOT __libc_start_main 000105dc R_ARM_JUMP_SLOT __gmon_start__ 000105e0 R_ARM_JUMP_SLOT abort </code></pre> <p>These are the dynamic relocation entries that are in the file, all the stuff that will be linked in from libraries external to the binary. Here it seems that the <code>printf</code> has been entirely optimized out, since it is only giving a constant string, and thus <code>puts</code> is sufficient. If we modify this to</p> <pre><code>printf("Hello world #%d\n", 1); </code></pre> <p>then we get the expected</p> <pre><code>000105e0 R_ARM_JUMP_SLOT printf </code></pre> <p>To get <code>memcpy</code> to be explicitly linked to, we have to prevent <code>gcc</code> from using its own builtin version with <code>-fno-buildin-memcpy</code>.</p> |
16,615,945 | 0 | <p>The <a href="http://docs.python.org/2/reference/expressions.html#is" rel="nofollow">Python <code>is</code> operator</a> checks for <em>object identity</em>, not object value. The two integers must refer to the same actual object internally for is to return true.</p> <p>This will return true for "small" integers due to an internal cache maintained by Python, but two numbers with the same value will not return true if compared with <code>is</code> in general.</p> |
35,969,510 | 0 | Mongo query is slow using C# driver but fast using mongo shell <p>I got very weird problem with MongoDB C# driver. I have a very simple query and I have a correct index for that query. When I run the query using MongoChef (and using the shell) I get the results in 22ms But when my app runs the same query it takes about 2.5mins to return answer (this is not due to network problems).</p> <p>I have checked in db.currentOp() and I saw that the op is indeed taking about 2.5 mins to finish and the query is the same as the one I ran manually and the execution plan do use the index. Any idea? Thanks</p> <p>P.S The problem is not with the size of the result set! I have tested with results set that have 0 results, 21 results and 600,000 results and in all of them the results was horrible! (above 2m for only 21 results which in the shell takes no time!)</p> <pre><code>{ "inprog": [ { "opid" : 53214, "active" : true, "secs_running" : 174, "microsecs_running" : 174085497, "op" : query, "ns" : db.collection, "query" : {{$query : {ParentId: 55, IsDeleted : false}}, {$orderby : {_id : -1}}}, "planSummary": IXSCAN {_id : 1}, "client" : ip:port, "desc" : conn121254, "threadId" : 0x1234567, "connectionId" : 1254651, "locks" : { "Global" : r, "MMAPV1Journal" : r, "Database" : r, "Collection" : R }, "waitingForLock" : false, "numYields" : 46963, "lockStats" : { "Global" : {acquireCount : { r : 93928}}, "MMAPV1Journal" : {acquireCount : { r : 46964} , acquireWaitCount : { r : 2 }, timeAcquiringMicros: { r : 2 } }, "Database" : {acquireCount : { r : 46964}}, "Collection" : {acquireCount : { r : 46964}} } } ] } </code></pre> <p>And the query that is running great on the shell (22ms)</p> <pre><code>db.collection.find({ParentId : 55, IsDeleted : false}).sort({_id : 1}) </code></pre> <p>C# code example :</p> <pre><code>MongoClient client = new MongoClient("mongodb://MongosServer01:27017,MongosServer02:27017,MongosServer03:27017,MongosServer04:27017"); var collection = client.GetServer().GetDatabase("db").GetCollection<BsonDocument>("collection"); var cursor = collection.Find(Query.And(Query.EQ("ParentId" , 55),Query.EQ("IsDeleted" , false))).SetSortOrder("_id").SetLimit(20); </code></pre> |
9,376,434 | 0 | <p>I assume that <code>settings.widgetSelector</code> selects the top element of a widget, that is, the table or a Telerik wrapper around it. I leave your other code intact:</p> <pre><code> ... if(confirm('This widget will be removed, ok?')) { // reference to current widget wrapper var widget = $(this).parents(settings.widgetSelector); // disable and select (all) contained checkboxes widget.find('input[type=checkbox]').prop({disabled: true, checked: true}); // animate and remove widget... widget.animate({ opacity: 0 ... </code></pre> <p>Note that this solution will disable and select <em>all</em> contained checkboxes in a widget. If you have multiple checkboxes and only need to select a single one, give it a class (e.g. <code>myCheckbox</code>) and change the selector to</p> <pre><code> widget.find('input[type=checkbox].myCheckbox').attr({disabled: true, checked: true}); </code></pre> <p>You should not use the existing checkbox ID if you have more than one widget, as element IDs should be unique for the whole document.</p> <p>UPDATE:</p> <p>Turned out that I misunderstood the problem: the checkboxes to be disabled are not inside the mentioned widgets and the actual task is to </p> <blockquote> <p>…disable the input type="checkbox" if the value of the input type ="hidden" that exist in the same is equal to the id of the li (widget).</p> </blockquote> <p>(See discussion in comments.)</p> <p>This could be a solution:</p> <pre><code>... $(settings.widgetSelector, $(settings.columns)).each(function () { var widgetId = this.id; var thisWidgetSettings = iNettuts.getWidgetSettings(widgetId); if (thisWidgetSettings.removable) { $('<a href="#" class="remove">CLOSE</a>').mousedown(function (e) { e.stopPropagation(); }).click(function () { if(confirm('This widget will be removed, ok?')) { // Disable checkboxes which have a sibling hidden input field with value equal to widgetId $('table tr input[type=hidden]').filter(function() { return $(this).val() == widgetId; }).siblings('input[type=checkbox]').prop({disabled:true, checked: true}); // animate and remove widget... $(this).parents(settings.widgetSelector).animate({ opacity: 0 ... </code></pre> |
19,893,087 | 0 | Create Random User algorithm in c# <p>i want to create users based on the number of photos in a folder.</p> <p>for example:</p> <pre><code>user.1 random(4)[photos1-4] dosomething(user.1) user.2 random(6)[photos5-10] dosomething(user.2) user.3 random(3)[photos11-13] dosomething(user.3) user.last [photos.leftover] dosomething(user.last) </code></pre> <p>ideas on how to do this?</p> |
33,551,881 | 1 | Pandas, check if timestamp value exists in resampled 30 min time bin of datetimeindex <p>I have created a resampled data frame (DF1) in pandas with a <code>datetimeindex</code>. I have a separate dataframe (DF2) with a <code>datetimeindex</code> and <code>time</code> column. If an instance of <code>time</code> from DF2 falls within the 30 min bins of <code>datetimeindex</code> in DF1. I want to mark each instance of <code>time</code> in DF2 with the appropriate <code>speed</code> from the 30 min bin in DF1. </p> <p>DF1</p> <pre><code> boat_id speed time 2015-01-13 09:00:00 28.000000 0.000000 2015-01-13 09:30:00 28.000000 0.723503 2015-01-13 10:00:00 28.000000 2.239399 </code></pre> <p>DF2</p> <pre><code> id boat_id time state time 2015-01-18 16:09:03 319437 28 2015-01-18 16:09:03 2 2015-01-18 16:18:43 319451 28 2015-01-18 16:18:43 0 2015-03-01 09:39:51 507108 31 2015-03-01 09:39:51 1 2015-03-01 09:40:58 507109 31 2015-03-01 09:40:58 0 </code></pre> <p>Desired Result</p> <pre><code> id boat_id time state speed time 2015-01-18 16:09:03 319437 28 2015-01-18 16:09:03 2 nan 2015-01-18 16:18:43 319451 28 2015-01-18 16:18:43 0 nan 2015-03-01 09:39:51 507108 31 2015-03-01 09:39:51 1 2.239399 2015-03-01 09:40:58 507109 31 2015-03-01 09:40:58 0 2.239399 </code></pre> <p>I created this script to try and do this but I think it's failing because <code>datetimeindex</code> of DF1 is immutable and so my <code>timedelta</code> request doesn't create a start point for the chunk. One thought I had was if it would be possible to copy the <code>datetimeindex</code> of DF1 into a new column where the objects are mutable but I haven't managed it yet so am not 100% sure of the logic. I'm happy to tinker but at the moment i've been stalled for a while so was hoping someone else might have a few ideas. Thanks in advance.</p> <pre><code>for row in DF1.iterrows(): for dfrow in DF2.iterrows(): if dfrow[0] > row[0] - dt.timedelta(minutes=30) and dfrow[0] < row[0]: df['test'] = row[1] </code></pre> |
29,376,047 | 0 | <p>Spring Session does not currently support HttpSessionListener. See <a href="https://github.com/spring-projects/spring-session/issues/4" rel="nofollow">spring-session/gh-4</a></p> <p>You can listen to <a href="http://docs.spring.io/spring-session/docs/current/reference/html5/#api-redisoperationssessionrepository-sessiondestroyedevent" rel="nofollow">SessionDestroyedEvent's</a></p> <p>They differ from the HttpSessionDestroyedEvent in that Spring Security will fire the HttpSessionDestroyedEvent based on the HttpSessionEventPublisher (an implementation of HttpSessonListener). Thus HttpSessionDestroyedEvent will not get fired when using Spring Session since there is no support for HttpSessionListener.</p> |
25,536,715 | 0 | <p><strong><code>http://your-jenkins-server/configure</code></strong></p> <p><img src="https://i.stack.imgur.com/QO967.png" alt="enter image description here"></p> <p>A picture is worth a thousand words</p> |
35,967,181 | 0 | Equivalent to DirectInput for Windows Store Apps? <p>I am building a game for Windows 10 that utilizes input to draw on the screen, but the fidelity is lacking. It is not accurate enough to draw a straight line if you draw fast. That's when I thought of DirectInput, which I've used in C++ games for Windows 7, but that API is not available for Store Apps... is there an equivalent, which will increase my accuracy for the drawing?</p> |
39,872,581 | 0 | Form is not sending email? <p>I have created a form that appears when a button is pressed. However, when the final submit button is pressed the final email is not sent. Where are the errors in my code?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>// JavaScript Document // Validating Empty Field function check_empty() { if (document.getElementById('name').value == "" || document.getElementById('email').value == "") { alert("Please fill out all fields."); } else { alert("Order Successful!"); } } //Function To Display Popup function div_show1() { document.getElementById("ordertype").innerHTML = "$400 Website Order"; document.getElementById('abc').style.display = "block"; } function div_show2() { document.getElementById("ordertype").innerHTML = "$500 Website Order"; document.getElementById('abc').style.display = "block"; } function div_show3() { document.getElementById("ordertype").innerHTML = "$700 Website Order"; document.getElementById('abc').style.display = "block"; } //Function to Hide Popup function div_hide() { document.getElementById('abc').style.display = "none"; }</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>@charset "utf-8"; /* CSS Document */ #abc { width: 100%; height: 100%; opacity: 0.97; top: 0; left: 0; display: none; position: fixed; background-color: #313131; overflow: auto; z-index: 9999999; } img#close { position: absolute; right: -14px; top: -14px; cursor: pointer; } div#popupContact { position: absolute; left: 50%; top: 17%; margin-left: -202px; font-family: coolfont; } form { max-width: 300px; min-width: 250px; padding: 10px 50px; border: 2px solid gray; border-radius: 10px; font-family: coolfont; background-color: #fff; } p { margin-top: 30px; } h2 { background-color: #FEFFED; padding: 20px 35px; margin: -10px -50px; text-align: center; border-radius: 10px 10px 0 0; font-family: info; } hr { margin: 10px -50px; border: 0; border-top: 1px solid #ccc; } input[type=text] { width: 82%; padding: 10px; margin-top: 30px; border: 1px solid #ccc; padding-right: 40px; font-size: 16px; font-family: coolfont; } textarea { width: 82%; height: 95px; padding: 10px; resize: none; margin-top: 30px; border: 1px solid #ccc; padding-right: 40px; font-size: 16px; font-family: coolfont; margin-bottom: 30px; } #submit { text-decoration: none; width: 100%; text-align: center; display: block; background-color: #FFBC00; color: #fff; border: 1px solid #FFCB00; padding: 10px 0; font-size: 20px; cursor: pointer; border-radius: 5px; } @media only screen and (max-width: 457px) { form { max-width: 200px; min-width: 150px; padding: 10px 50px; margin-left: 50px; } input[type=text] { padding-right: 30px; } textarea { padding-right: 30px; } } @media only screen and (max-width: 365px) { form { max-width: 140px; min-width: 90px; padding: 10px 50px; margin-left: 80px; } input[type=text] { padding-right: 10px; } textarea { padding-right: 10px; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><head> <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <link href="elements.css" rel="stylesheet"> <script src="my_js.js"></script> </head> <body> <a class="button" id="popup" onclick="div_show1()">ORDER NOW</a> <a class="button" id="popup" onclick="div_show2()">ORDER NOW</a> <a class="button" id="popup" onclick="div_show3()">ORDER NOW</a> <div id="abc"> <!-- Popup Div Starts Here --> <div id="popupContact"> <!-- Contact Us Form --> <form action="form.php" id="form" method="post" name="form" enctype="multipart/form-data"> <img id="close" src="images/redcross.png" width="50" onclick="div_hide()"> <h2 id="ordertype" name="ordertype">$400 Website Order</h2> <hr> <input id="name" name="name" placeholder="Name" type="text"> <input id="email" name="email" placeholder="Email" type="text"> <textarea id="msg" name="message" placeholder="Comments/Questions"></textarea> <a href="javascript:%20check_empty()" id="submit">Order</a> </form> </div> <!-- Popup Div Ends Here --> </div> </body></code></pre> </div> </div> </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code><? php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = '#'; $to = '[email protected]'; $subject = $ordertype; $body = "From: ".$name. "\r\n E-Mail: ".$email. "\r\n Message: \r\n".$message; if (isset($_POST['submit'])) { if (mail($to, $subject, $body, $from)) { echo '<script> alert("Message successfully sent."); </script>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } ?></code></pre> </div> </div> </p> <p>The last code snippet attached is the form.php file, which I have tried to link to within the html.</p> |
37,287,933 | 0 | How to bring in string from left of numbers in Excel <p>I'm trying to format a column based off of another (let's say column B2). The column contains a value like "ABC011" and I need to bring in just the letters "ABC".</p> <p>For another column I also need to bring in just the numbers "011" but without the trailing zeroes (although I imagine that if I can get the solution for the first question I'll be able to figure out the second).</p> <p>Thanks in advance.</p> <p>EDIT: The length of the characters can change but the numbers are USUALLY 2 or more digits as well as the letters.</p> |
28,720,601 | 0 | Error in Integrated Weblogic 12C in SOA Suite - Derby server start and stop immediately <p>I need help to solve this problem:</p> <p>I've already installed Oracle SOA Suite 12c using the developer pack (from oracle official downloads). When I try to start integrated weblogic server (in Jdeveloper menu Run) it starts and shows listening on the port but immediately stops with following error:</p> <pre><code>Could: Not find or load main class Stopping Derby Server Derby Server Stopped </code></pre> <p>My config:</p> <ul> <li>Windows 2003 server Enterprise edition x64</li> <li>Jre 7</li> <li>Jdk 1.7 x64</li> <li>Oracle soa suite 12c</li> </ul> |
20,613,977 | 0 | <p>First you don't need a controller, spring security handles all this for you. So drop the controller. </p> <p>The current problem is due to your JSON based post. This is handled by the normal filter which handles login, but it doesn't see a <code>j_username</code> and <code>j_password</code> field and as such will redirect (the 302) to the login page (in your case <code>/shop/home.html</code>) asking for those fields. </p> <p>Basically you are posting the data as JSON whereas it simply should be just an ajaxified form post. This allows you to write a simple <code>AuthenticationSuccessHandler</code> which simply returns a 401 or a 200 status-code (and maybe a body) when things are ok. </p> <p>Changing your ajax submit to something like this should make things work.</p> <pre><code>var data = $(this).serializeObject(); $.ajax({ 'type': $(this).action, 'url': $(this).target, 'data': data }): </code></pre> <p>This should create a ajax form post. Might be that you need a call to <code>preventDefault()</code> in the surrounding method to stop the form from actual posting. </p> |
17,738,649 | 0 | <p>Are you looking for this?</p> <pre><code>SELECT A, B, D, E, COALESCE(C, F) M FROM relation1 r1 FULL JOIN relation2 r2 ON r1.C = r2.F </code></pre> <p>Assuming relation1:</p> <pre> | A | B | C | --------------- | a1 | b1 | 1 | | a2 | b2 | 2 | </pre> <p>and relation2:</p> <pre> | D | E | F | --------------- | d1 | e1 | 1 | | d3 | e3 | 3 | </pre> <p>Output will be</p> <pre> | A | B | D | E | M | ----------------------------------------- | a1 | b1 | d1 | e1 | 1 | | a2 | b2 | (null) | (null) | 2 | | (null) | (null) | d3 | e3 | 3 | </pre> <p>Here is <strong><a href="http://sqlfiddle.com/#!1/93434/2" rel="nofollow">SQLFiddle</a></strong> demo</p> |
22,237,593 | 0 | <p>Your database should have a method for updating the database</p> <pre><code>@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // do something to upgrade } </code></pre> <p>But that isn't called by default, but when your app first tries to open the database. At that point, you should be to architect a dialog that instructs your user and either do the upgrade or not.</p> <p>It's also possible to alter the user's database within that onUpgrade method. For example, a string like this:</p> <pre><code>private static final String ALTER_TABLE3 = "ALTER TABLE exercises ADD COLUMN exscore REAL DEFAULT 0.0"; </code></pre> <p>could be used in onUpgrade like so:</p> <pre><code>if (oldVersion == 5) { db.execSQL(ALTER_TABLE3); // now copy all of the values from integer to real setUpMoveRoutine = true; } </code></pre> <p>I did an upgrade from v4 to v5 that needed new elements within a table. And then called a method to move data as needed. </p> <p>You should be able to manage just about any changes in your database</p> |
4,763,653 | 0 | <p>you can use this</p> <pre><code>@Override public void paintComponents(Graphics g) { super.paintComponents(g); g.drawString("Hello", 0, 0); } </code></pre> <p>or use jTextField</p> <pre><code> jTextField1.setText("Hello"); </code></pre> |
20,840,437 | 0 | <p>Use the below query:</p> <pre><code>var query = from e in context.Table orderby SqlFunctions.Rand(1) select e).Take(10); </code></pre> <p>And hope your MySql Data Providor cannot be recognized by VS.</p> <p>I know that Vs doesn't support MySQL to LINQ directly.. So maybe you can use something like.</p> <p>And perhpas you need to download this kind of data providor and have a try </p> <p>download them and have a try:</p> <ol> <li><a href="http://www.alinq.org/download/ALinq_V2.5.8.msi" rel="nofollow">ALinq</a>.</li> <li><a href="http://www.alinq.org/download/ORDesigner_V2.4.1_VS2008.msi" rel="nofollow">ORDesigner_VS2008</a> or <a href="http://www.alinq.org/download/ORDesigner_V2.4.1_VS2010.msi" rel="nofollow">ORDesigner_VS2010</a>.</li> <li><a href="http://www.alinq.org/download/mysql-connector-net-6.3.0.zip" rel="nofollow"> MySQL ADO.NET Data Provider</a> (If installed, no need to reinstall).</li> </ol> <hr> <hr> <p>And If you still fail, this can be right Suppose <strong>Students</strong> is a model from Student table</p> <pre><code>using (ConsoleApplications.DataClasses1DataContext dd = new ConsoleApplications.DataClasses1DataContext()) { var result = (from stu in dd.Students.AsEnumerable() select new { stu.StudentName, RandomId = new Random(DateTime.Now.Millisecond).Next(dd.Students.Count()) }).OrderBy(s => s.RandomId); foreach (var item in result) { Console.WriteLine(item.StudentName); } } </code></pre> |
39,085,751 | 0 | Inserting a value into a sequential series and then continuing the series <p>Example data series has the sequence seeded with 1 as the initial value, and a step of 1. There is a calculated value that needs to be inserted in the series, in this case it is 3.5</p> <p>Desired output:</p> <pre><code>1 2 3 3.5 4 5 </code></pre> <p>I am avoiding VBA, and I am avoiding sorts. I am trying to do this with an IF formula. </p> <p>So far I have tried the following A2 copied down:</p> <pre><code>=IF(A1+1<3.5,A1+1,IF(A1<>3.5,3.5,A1+1)) </code></pre> <p>Seed value may be any real number. Step value may be any real number.</p> |
310,246 | 0 | Installer for .NET 2.0 application for Windows 98 <p>How can an automatic installer for .NET 2.0 application be created for Windows 98? </p> <p>I mean for application and also for .NET 2.0 if missing.</p> <p>I tried to do it by creating a setup project for Visual Studio 2008, but I didn't succeed. I installed IE6 SP1 manually, but Installer still crashed. Windows Installer 2.0 is installed. It's impossible to install Installer 3.0 there. I unchecked Installer at Setup Project prerequisites, but still it's not possible to install the application - the error message says that it requires a newer version of Windows.</p> <p>How can this be resolved?</p> |
39,898,076 | 0 | Configuration Symfony3 with netbeans <p>I would like to know if netbeans support Symfony 3.1.0? If any one have an idea which version of netbeans should'i use. Thanks </p> |
28,925,917 | 0 | <p>In python <strong>2.X</strong> <code>print</code> is a <em>statement</em> not a function. Accordingly, this is not supported by <code>lambda</code> functions. In python 3, however, <code>lambda x: print(x)</code> works since <code>print</code> is a function. You could also try to import the new <code>print</code> functionality in python 2.X:</p> <pre><code>from __future__ import print_function f = lambda x: print(x) f(4) </code></pre> <p>which prints <code>4</code>.</p> |
16,922,776 | 0 | Encoding wildcarding, stemming, etc in simple search <p>We have a simple search interface which calls the search:search($query-text) function. Is there a syntax to include control for wildcarding, stemming and case sensitivity within the single text string that the function accepts? I haven't been able to find anything in the MarkLogic docs.</p> |
15,331,724 | 0 | stream context for custom stream wrappers <p>In the code snippet that follows this paragraph I'm creating a stream wrapper called test using the Test_Stream object. I'm trying to use stream context's with it and have a few questions. First here's the code:</p> <pre><code><?php class Test_Stream { public $context; public function __construct() { print_r(stream_context_get_options($this->context)); exit; } } $context = array( 'test' => array('key' => 'value'), 'otherwrapper' => array('key' =>'value') ); $context = stream_context_create($context); stream_wrapper_register('test', 'Test_Stream'); $fp = fopen('test://www.domain.tld/whatever', 'r', false, $context); </code></pre> <p>So right now, in that code snippet, Test_Stream is being registered to the 'test' stream wrapper but... what if I didn't know in advance what the wrapper name would be or what if I wanted to leave it up to the developer to decide. How would you know what the wrapper name was in the class? Seems like you'd have to know it in advance to get the appropriate context options (unless you just assume that the first context option array is the correct one) but what if you weren't going to know it in advance?</p> |
25,004,221 | 0 | <p>Your question and code does not help.</p> <p>In your code it seems you are trying to use Speech to Text(Audio recorder), and you are calling it using TTS (Text to Speech) which does exactly the opposite of what you are trying to accomplish i.e. speech to text.</p> <p>Can you make it a bit more clear what you are trying to do??</p> |
39,261,950 | 0 | <p>you may check here:<a href="https://i.stack.imgur.com/Odx2F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Odx2F.png" alt="enter image description here"></a> and make sure that all files in Plugins/Android are set to Android here</p> |
23,586,584 | 0 | <p>make it like this:</p> <pre><code> @Override public void run() { for (int i = 0; i < 10000; i++) { if(i % 100) { mController.runOnUiThread(new Runnable() { public void run() { mController.triggered(i); } }); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } </code></pre> <p><strong>Explanation:</strong> you were previously changing an UI element from a Non-UI thread and this is not good. This code should work, BUT it is still not the recommended way to approach the problem. You should use something like a <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">AsyncTask</a> where you have a template method for 'background' operation (non-ui thread operation) and the 'onPostExecute' which <strong>already</strong> executes on the UI thread.</p> <p>another additional note: NEVER call <strong>Thread.sleep()</strong>; on the UI Thread (a.k.a. Main thread)</p> |
39,610,346 | 0 | Create a new session as a copy of another on Livy <p>I use livy to use Spark as a service. My application send some commands to livy as code, however, spark needs to initialize some variables(read some files, make some map&reduce operations etc.) and this take time. This initializing part is common for all sessions. After the construction, different statements may be sent to these sessions.</p> <p>What i wonder is when livy creates a session, is it possible to copy an old session line an image or should it start everything from scratch?</p> <p>Thank you in advance.</p> |
4,044,674 | 0 | <p>Use:</p> <pre><code> SELECT a.id FROM ORDERHISTORYTABLE AS a LEFT JOIN (SELECT e.EmailAddress, e.product, MAX(OrderDate) AS max_date FROM OrderHistoryTable AS e WHERE e.Product IN ('ProductA','ProductB','ProductC','ProductD') GROUP BY e.EmailAddress) b ON b.emailaddress = a.emailaddress AND b.max_date = a.orderdate AND b.product = a.product WHERE x.emailaddress IS NULL AND a.Product IN ('ProductA','ProductB','ProductC','ProductD') </code></pre> |
16,503,853 | 0 | <p>declare a function and declare <code>config_map</code> as a static inside it</p> <pre><code>class MyClass { ... static std::map<std::string,std::string> & config_map() { static std::map<std::string,std::string> map; return map; } }; void MyClass::SomeMethod() { ... config_map().insert(std::pair<std::string,std::string>("dssd","Sdd")); } std::string OtherClass::mystring = MyClass::config_map()["something"]; </code></pre> <p>now map is guarantee to be initialized.</p> |
12,993,250 | 0 | <p>Assuming you understand class inheritance, I think of an Interface like a skeleton class, where the structure of a class is described but not actually written/implemented.</p> <p>Another class can then work with any class that implements a particular Interface even if it hasn't been implemented yet.</p> <p>For example, someone may create an Interface called <code>Animal</code>. Its methods maybe: <code>Talk()</code>, <code>Walk()</code> and <code>Eat()</code>. You could write a <code>Dog</code> class that implements <code>Animal</code> that prints "woof" when the <code>Talk()</code> method is called. Therefore another class will know how to work with all classes that implements the Animal interface.</p> <p><strong>UPD</strong></p> <p>A good real world example is the JDBC Database Statement Interface. This sets out a number of required properties that a database manufacturer will have to implement, such as <code>execute(String sql)</code>. Oracle will implement this differently from Postgresql. This allow the database to be swapped for another one but the user code remains the same.</p> |
2,257,214 | 0 | <p>The code you mention works fine with Qt 4.6.1 and GCC 4.4.1 on Intel/Mac OS X.</p> <pre><code>$ cat a.cpp #include <QtCore> void foo (QMap<int, QMap<QString, QVector<QPointF> > > &map) { map.clear(); } $ g++-4.4-fsf -c -DQT_CORE_LIB -DQT_SHARED -I/Library/Frameworks/QtCore.framework/Versions/4/Headers a.cpp -W -Wall -Werror -g -O3 -fPIC $ </code></pre> <p>So your issue is probably fixed by upgrading to Qt 4.6.1. (Unless it's a compiler target-specific bug, which seems unlikely; plus, you haven't told us what platform you're compiling on.)</p> |
30,613,065 | 0 | <p>Looking at your code I think you want to show all <code>marcas</code> related to some <code>articulo</code> it via <code>product.type</code>. For this scenario I think you don't need to make any grouping, you can just find all the <code>marcas</code> you are interested in. Here is what i mean:</p> <pre><code>#in the view #add .distinct() if you get duplicates marcas = MarcasOpciones.object.filter(Productos_marca__tipo=articulo.Tipos) #in the template {% for sthelse in marcas %} <li><a href="#">{{ sthelse }}</a></li> {% endfor %} </code></pre> <p>There is one possible drawback with this approach - we are not using the <code>|slugify</code> tag to create the match. A possible solution to this is to create <code>slug</code> fields for the both models.</p> <p>However, if that approach doesn't suit you. I advice you to move all the matching logic in the view and again send only the needed <code>marcas</code> in the template. </p> <pre><code>#in the view from django.template.defaultfilters import slugify marcas = [] for sth in productos.all(): if slugify(articulo.Tipos) == slugify(sth.tipo): for sthelse in sth.marca.all(): if sthelse not in marcas: marcas.append(sthelse) #if you need the product that match that marca #you can add it here #sthelse.product = sth </code></pre> |
28,480,298 | 0 | <p>JavaScript Pure:</p> <pre><code><script type="text/javascript"> document.getElementById("modal").click(); </script> </code></pre> <hr> <p>JQuery:</p> <pre><code><script type="text/javascript"> $(document).ready(function(){ $("#modal").trigger('click'); }); </script> </code></pre> <p>or</p> <pre><code><script type="text/javascript"> $(document).ready(function(){ $("#modal").click(); }); </script> </code></pre> |
25,236,837 | 0 | <p>if you use this code:</p> <pre><code>java.sql.Blob blob=null; blob.setBytes(1, myByte ); </code></pre> <p><code>blob</code> is null. You have to create a new Blob Object like:</p> <pre><code>Blob blob = new SerialBlob(myByte ); </code></pre> <p>and then you can store it.</p> |
39,404,570 | 0 | Understanding lexical scoping of "use open ..." of Perl <pre><code>use open qw( :encoding(UTF-8) :std ); </code></pre> <p>Above statement seems to be effective in its lexical scope only and should not affect outside of it's scope. But I have observed the following.</p> <pre><code>$ cat data € </code></pre> #1 <pre><code>$ perl -e ' open (my $fh, "<encoding(UTF-8)", "data"); print($_) while <$fh>;' Wide character in print at -e line 1, <$fh> line 1. € </code></pre> <p>The <code>Wide character ...</code> warning is perfect here. But</p> #2 <pre><code>$ perl my ($fh, $row); { use open qw( :encoding(UTF-8) :std ); open ($fh, "<", "data"); } $row = <$fh>; chomp($row); printf("%s (0x%X)", $row, ord($row)); € (0x20AC) </code></pre> <p>Does not show the wide character warning!! Here is whats going on here imo</p> <ul> <li>We are using open pragma to set the IO streams to UTF-8, including STDOUT.</li> <li>Opening the file inside the same scope. It reads the character as multibyte char.</li> <li>But printing outside the scope. The print statement should show "Wide character" warning, but it is not. Why?</li> </ul> <p>Now look at the following, a little variation</p> #3 <pre><code>my ($fh, $row); { use open qw( :encoding(UTF-8) :std ); } open ($fh, "<", "data"); $row = <$fh>; chomp($row); printf("%s (0x%X)", $row, ord($row)); ⬠(0xE2) </code></pre> <p>Now this time since the open statement is out of the lexical scope, the <code>open</code> opened the file in non utf-8 mode.</p> <p>Does this mean <code>use open qw( :encoding(UTF-8) :std );</code> statement changes the STDOUT globally but STDIN within lexical scope?</p> |
12,726,613 | 0 | <p>Windows Azure has <em>input endpoints</em> on a hosted service, which are public-facing ports. If you have one or more instances of a VM (Web or Worker role), the traffic will be distributed amongst the instances; you cannot choose which instance to route to (e.g. you must support a stateless app model).</p> <p>If you wanted to enforce a sticky-session model, you'd need to run your own front-end load-balancer (in a Web / Worker role). For instance: You could use IIS + ARR (application request routing), or maybe nginx or other servers supporting this.</p> <p>What I said above also applies to Windows Azure IaaS (Virtual Machines). In this case, you create load-balanced endpoints. But you also have the option of non-load-balanced endpoints: Maybe 3 servers, each with a unique port number. This bypasses any type of load balancing, but gives direct access to each Virtual Machine. You could also just run a single Virtual Machine running a server (again, nginx, IIS+ARR, etc.) which then routes traffic to one of several app-server Virtual Machines (accessed via direct communication between load-balancer Virtual Machine and app server Virtual Machine).</p> <p>Note: The public-to-private-port mapping does not let you do any load-balancing. This is more of a convenience to you: Sometimes you'll run software that absolutely has to listen on a specific port, regardless of the port you want your clients to visit.</p> |
8,801,214 | 0 | <p>the benifit of making string as immutable was for the security feature. Read below</p> <p>Why String has been made immutable in Java?</p> <p>Though, performance is also a reason (assuming you are already aware of the internal String pool maintained for making sure that the same String object is used more than once without having to create/re-claim it those many times), but the main reason why String has been made immutable in Java is 'Security'. Surprised? Let's understand why.</p> <p>Suppose you need to open a secure file which requires the users to authenticate themselves. Let's say there are two users named 'user1' and 'user2' and they have their own password files 'password1' and 'password2', respectively. Obviously 'user2' should not have access to 'password1' file.</p> <p>As we know the filenames in Java are specified by using Strings. Even if you create a 'File' object, you pass the name of the file as a String only and that String is maintained inside the File object as one of its members.</p> <p>Had String been mutable, 'user1' could have logged into using his credentials and then somehow could have managed to change the name of his password filename (a String object) from 'password1' to 'password2' before JVM actually places the native OS system call to open the file. This would have allowed 'user1' to open user2's password file. Understandably it would have resulted into a big security flaw in Java. I understand there are so many 'could have's here, but you would certainly agree that it would have opened a door to allow developers messing up the security of many resources either intentionally or un-intentionally.</p> <p>With Strings being immutable, JVM can be sure that the filename instance member of the corresponding File object would keep pointing to same unchanged "filename" String object. The 'filename' instance member being a 'final' in the File class can anyway not be modified to point to any other String object specifying any other file than the intended one (i.e., the one which was used to create the File object).</p> |
23,428,390 | 0 | How to send file from AJAX to remote FTP directly? <p>I would like to send file(s) with xhr from the user browser to remote FTP server without saving file to my server. </p> <p>Is it possible? How can I do it? I am using PHP backend.</p> |
Subsets and Splits