INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Can Boris Johnson prorogue parliament again, after it reconvenes? Assuming Parliament won't grant on Monday the early general elections that Johnson wants, could he send the Parliament on a much longer vacation using prorogation again? E.g. could he prorogue Parliament until, say, February?
The Supreme Court has ruled that a prorogation designed to frustrate the function of Parliament is unlawful without justification. Your scenario fits that description.
stackexchange-politics
{ "answer_score": 10, "question_score": 7, "tags": "united kingdom, parliament, prorogation" }
Subtract value from other table using Inner Join I'm trying to subtract a value by another value from another table (Sorry for the mouthful) But the SQL which i've developed keeps throwing the same error: `#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM products INNER JOIN order_details ON products.ItemID = order_details.Item' at line 2` This is my code: UPDATE products SET Quantity = (products.Quantity - order_details.Quantity) FROM products INNER JOIN order_details ON products.ItemID = order_details.ItemID WHERE order_details.OrderID = 95 AND products.ItemID = order_details.ItemID; Its just code for when someone buys an item, it's supposed to reduce the quantity in the products table by the number of whatever they've bought. Any help is appreciated.
The `join` is part of the `update` not of the `SET`clause: UPDATE products INNER JOIN order_details ON products.ItemID = order_details.ItemID SET Quantity = (products.Quantity - order_details.Quantity) WHERE order_details.OrderID = 95;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "mysql, sql" }
Execute specified function every X seconds I have a Windows Forms application written in C#. The following function checks whenever printer is online or not: public void isonline() { PrinterSettings settings = new PrinterSettings(); if (CheckPrinter(settings.PrinterName) == "offline") { pictureBox1.Image = pictureBox1.ErrorImage; } } and updates the image if the printer is offline. Now, how can I execute this function `isonline()` every 2 seconds so when I unplug the printer, the image displayed on the form (`pictureBox1`) turns into another one without relaunching the application or doing a manual check? (eg. by pressing "Refresh" button which runs the `isonline()` function)
Use System.Windows.Forms.Timer. private Timer timer1; public void InitTimer() { timer1 = new Timer(); timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = 2000; // in miliseconds timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { isonline(); } You can call `InitTimer()` in `Form1_Load()`.
stackexchange-stackoverflow
{ "answer_score": 133, "question_score": 82, "tags": "c#, .net, winforms" }
FindBugs: How can I run it in Java 5 mode? When I run FindBugs on my project via Maven, I get lots of these: Can't use annotations when running in JDK 1.4 mode! How do I fix that? Couldn't find anything in the manual.
I believe you are missing the targetJdk element in the plugin configuration, like in below snippet. <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>2.0.1</version> <configuration> <targetJdk>1.5</targetJdk> </configuration> </plugin> </plugins> </reporting>
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "java, findbugs, java 5" }
How to fix: " invalid literal for int() with base 10:' ' " Довольно долго пытаюсь решить проблему: ![]( Тем, что переписывал тот же код, но разными способами. Без результата. s1=int(input()) s2=1 while s1!=0: s1=s1+int(input()) s2=s2+1 if s1==10: print(s2) else: continue Помогите решить проблему и если не сложно, объясните в чём суть ошибки (Начинающий). Буду очень благодарен за помощь! PS: ввод 2 9 -2 1 6 6 6 0
s1=int(input()) s2=1 s3=1 while true: s3=int(input()) s1=s1+s3 s2=s2+1 if s3 == 0: break if s1 == 10: print(s2)
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, python 3.x" }
pandas: count the number of unique occurrences of each element of list in a column of lists I have a dataframe containing a column of lists lie the following: df pos_tag 0 ['Noun','verb','adjective'] 1 ['Noun','verb'] 2 ['verb','adjective'] 3 ['Noun','adverb'] ... what I would like to get is the number of time each unique element occurred in the overall column as a dictionary: desired output: my_dict = {'Noun':3, 'verb':3, 'adjective':2, 'adverb':1}
Use, `Series.explode` along with `Series.value_counts` and `Series.to_dict`: freq = df['pos_tag'].explode().value_counts().to_dict() Result: # print(freq) {'Noun':3, 'verb':3, 'adjective':2, 'adverb':1}
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, pandas, list, count" }
templates calling function error - No matching function for call to 'bubbleSort' No matching function for call to 'bubbleSort'. I have this two function in the same .hpp file. template<typename T> void bubbleSort(std::vector<T> &vec){ T zacasen; for (int i=0; i<vec.size(); i++) { for (int j=0; j<vec.size()-1; j++) { if(vec[j]>vec[j+1]){ zacasen=vec[j]; vec[j]=vec[j+1]; vec[j+1]=zacasen; } } } } template < int N, typename T > void sort(const std::vector<T> &vec){ if(N==1){ bubbleSort(vec); }else if(N==2){ //quicksort(vec, 0, vec.size()); } }
You have void bubbleSort(std::vector<T> &vec) but void sort(const std::vector<T> &vec) You can't call `bubbleSort(vec)` from within your `sort` because a `const std::vector<T>` is not an `std::vector<T>` (note the `const`) and there's no implicit conversion sequence that could turn it into one. Consequently, there's no viable function which overload resolution could pick here… Why would your `sort` ask for a `const` vector to begin with? Since it doesn't return a new vector, the only way it could possibly do what its name suggests it would be doing is by reordering (i.e., modifying) the contents of the vector its given!?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c++" }
WCF: Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata I created a simple WCF application. The platform is set to Any CPU. I can build and run the application successfully. But when I change the platform to x64 I get the following error: > _Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata_ My system has 64 bit OS. Actually i have to set the platform to x64 to laod a dll in my app. What would be the possible reasons for this error. Please help me. I am using IIS Express.
When using IIS Express and VS2013, you need to check the following option in VS Options when debugging x64 web project: `Tools -> Options -> Projects and Solutions -> Web Projects -> Use the 64 bit version of IIS Express for web sites and projects`
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 5, "tags": "c#, .net, wcf, 64 bit" }
to compute $\int_{2}^{3}\sqrt{1+\frac{1}{x^{2}}} \: \: dx$ Help me please to compute: $\int_{2}^{3}\sqrt{1+\frac{1}{x^{2}}} \: \: dx$ Thanks a lot!
Hint: let $x=\tan{\theta}$, $dx=\sec^2{\theta} d \theta$: $$\begin{align} \int_{2}^{3} dx \: \sqrt{1+\frac{1}{x^{2}}} &= \int_{\arctan{2}}^{\arctan{3}} \frac{d \theta}{\sin{\theta} \cos^2{\theta}} \\\ &= \int_{\arctan{2}}^{\arctan{3}} \frac{d \theta \, \sin{\theta}}{\sin^2{\theta} \cos^2{\theta}} \end{align} $$ Now let $y=\cos{\theta}$, $dy=-\sin{\theta} d \theta$: $$\begin{align} \int_{2}^{3} dx \: \sqrt{1+\frac{1}{x^{2}}} &= \int_{\frac{1}{\sqrt{10}}}^{\frac{1}{\sqrt{5}}} \frac{dy}{y^2 (1-y^2)} \\\ &= \int_{\frac{1}{\sqrt{10}}}^{\frac{1}{\sqrt{5}}} dy \: \left ( \frac{1}{y^2} + \frac{1}{1-y^2} \right )\\\ &= \int_{\frac{1}{\sqrt{10}}}^{\frac{1}{\sqrt{5}}} dy \: \left [ \frac{1}{y^2} + \frac{1}{2} \left ( \frac{1}{1-y} + \frac{1}{1+y} \right ) \right ] \\\ \end{align} $$ I think you can take it from here.
stackexchange-math
{ "answer_score": 4, "question_score": 3, "tags": "integration, definite integrals" }
how my browser know to put in placeholder attribute the value of the Client country? If I have an international website and I have two clients: 1. client from Spain. 2. client from Israel. I want the placeholder will be match for the client user. The pseudo-code is: if (client_from_israel) HTML CODE: <input type="text" placeholder="israel"> else HTML CODE: <input type="text" placeholder="spain"> How can I write it to work and display at the web browser? I think I will need to use php to do it. I know its a LONG answer but if you don't have the power to write the code just tell me what to do in general.
You could get the user's IP address through $_SERVER['REMOTE_ADDR'] and then use some geotargeting class to translate it to a country. I found a good tutorial on this subject. You can of course use a free PHP geotargeting class for your project
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, html" }
How to Build Hydrogen Atoms in MOE using SVL I'm working on automating a process in MOE using SVL commands. I've got pretty much everything worked out, except I can't seem to find anything for building hydrogen atoms using an SVL command (equivalent to Edit->Build->Hydrogens->Add Hydrogens). Is there a method to do this, and if so what is it? Edit: MOE (Molecular Operating Environment), SVL (Scientific Vector Language)
Short Answer: `_EditH 'addH'` As I continued researching how to finish up my project, I came across a tutorial describing the behavior of Menus in MOE. (Tutorial download available from < All menus in MOE have their behavior defined by a file within the MOE installation directory. ("\$MOE/menu/moe-menus" where "\$MOE" is the MOE installation directory.) By following the configuration file you can determine the exact SVL command used upon the selection of any menu item. You then can use that command in the SVL Commands window.
stackexchange-chemistry
{ "answer_score": 0, "question_score": 0, "tags": "computational chemistry, software, hydrogen" }
nested loop in list comprehension I have a list of words in `l` that if any of it exists in the first index of each tuple in l2, remove the entire tuple. my code: l = ['hi', 'thanks', 'thank', 'bye', 'ok', 'yes', 'okay'] l2 = [('hi how are u', 'doing great'), ('looking for me', 'please hold')] l3 = [k for k in l2 if not any(i in k[0] for i in l) ] somehow the code does not work and i get back an empty list for l3. I want l3 = [('looking for me', 'please hold')]
Split `k[0]` to get a list of words: [k for k in l2 if not any(i in k[0].split() for i in l)] This way it checks if `i` matches a word exactly. It could also be interpreted as if `k[0]` does not starts with any of `l`, then you can do this: [k for k in l2 if not k[0].startswith(tuple(l))]
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "python, list, loops" }
WCF customizing metadata publishing I have a universal service hosted on IIS7 that accepts a Message and returns Message ( with Action="*"). This service still publishes meta for the clients. This metadata is explicitly specified using LocationUrl property in ServiceMetadataBehavior. We have a requirement that the metadata can change during lifetime of the service, so in essence metadata has a lifetime. I tried adding IWsdlExportExtension to the service endpoint behavior, but the ExportEndpoint method only gets called once (when the service is loaded first time). Is there a way for me to invalidate the loaded metadata so that anytime there is a call for wsdl using HttpGet, the behavior gets called ?
What you are asking for (changing the published service definition at runtime) is not possible - you need to remove the requirement which specifies that the metadata can change over time. Once you've published a service, the only reason the service specification should change is because the service has been upgraded. You should look closer at the business requirement which is making this technical requirement necessary, and try to find another way to satisfy it (perhaps post in programmers.stackexchange). Perhaps you can have multiple services available, and switch between the services over time - but this is a bit of a stab in the dark without knowing the business requirement.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wcf" }
colorbox with height same as image height What I expect is to get a color box or a bar in the footer section with an image ![enter image description here]( What I am getting is a color bar with some extra space around the image ![enter image description here]( How can I get a color box to have the same height as the included image without any space added at the top or bottom of the image? This is the code that I am currently using. `\fancyfoot[RE,RO]{\hspace*{-0.2\headwidth}\setlength{\fboxsep}{0pt}\colorbox{gray}{% \setlength{\fboxsep}{0pt}\makebox[\dimexpr0.2\headwidth-2\fboxsep][c]{% \strut \includegraphics[width=0.05\textwidth,keepaspectratio]{./LogoShort}}}% \colorbox{gray}{\makebox[\dimexpr0.98\headwidth-2\fboxsep][l]{\strut ORGGroup}}% \colorbox{gray}{\makebox[\dimexpr0.22\headwidth-2\fboxsep][l]{\strut \thepage}}}`
You have \strut \includegraphics A `\strut` has the maximum height _and depth_ of text at the current font size, so you are boxing something that descends below the image which sits on the baseline. Just remove the `\strut`.
stackexchange-tex
{ "answer_score": 1, "question_score": 1, "tags": "pdftex, header footer" }
Cannot include a header in MinGW I'm using SublimeText with MinGW on Windows 7 an wanted to include #include <boost/multiprecision/cpp_int.hpp> but I get fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory #include <boost/multiprecision/cpp_int.hpp> Couldn't figure out what to do from what I've found here and in Google. This is the path to the include folder: C:\MinGW\include\ Should I add something like? (from what I could "understand") > -I C:/MinGW/include/boost But it doesn't work...
> **UPDATE:** > > "-IC:/MinGW/include" Oh okay, I figured it out. So... I have all the necessary libraries here C:\MinGW\include\ But in order to be able to include boost files (C:\MinGW\include\boost) I needed to copy this folder here C:\MinGW\include\c++\4.9.1 which is where MinGW was looking for my files... So in the end I get C:\MinGW\include\c++\4.9.1\boost with all the necessary libraries inside. Now it works.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "c++, windows, include, mingw" }
How do you put your design time view model in a separate assembly? I'm using MVVM Light and Prism with the view model locator pattern. I really like having a design time view model for use in Blend, but I don't necessarily want to ship it with my production code. Is there any way to put the design time view model in another assembly and then tell the view model locator to find it there? It seems like the design time assemblies (*.Design.dll) would help solve this problem, but I can't quite work out how.
Mike, Add the following to your XAML.. xmlns:designTime="clr-namespace:MyDesignTimeNS;assembly=MyBinaryName" d:DataContext="{d:DesignInstance designTime:DesignTimeObjectNameViewModel, IsDesignTimeCreatable=True} With this, I'm able to keep my design time data in a separate binary and not distribute it.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "c#, silverlight, expression blend, mvvm light, viewmodellocator" }
Loading webpage after some time ASP.net using Javascript It seems a duplicate but Its taken a lot of time still causing some problem. Kindly someone point out what I am doing wrong. I have a **button** , when I click it **JS function** **show()** is called <input type="button" onclick="show()" value="Add to Cart"> The javascript code is below function show() { document.getElementById("loadingDiv").style.display = "block"; setTimeout('Redirect()', 2000); function Redirect() { location.href = 'Index.aspx'; } } The div is set to **block** properly but the **page never redirects**. Not sure whats the issue.
You need to remove the brackets and the single quotes when you call the `redirect` function. setTimeout(Redirect, 2000); Here is the documentation for the setTimeout function.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, html, asp.net" }
Skinned Panel content offset in Flex 3 Here is the problem. I've created custom RectangularBorder and set it as border skin for TitleWindow. After this manipulation inner content of window is starting at 0,0 point of it. How could I set offset of it? **Just setting top padding does not work because scroll bar still begins from the top of the window after this manipulation.**
For programmatic skin it went out pretty simple. One should override function get borderMetrics to do so: public override function get borderMetrics():EdgeMetrics { var borderThickness:Number = getStyle("borderThickness"); var cornerRadius:Number = getStyle("cornerRadius"); var headerHeight:Number = getStyle("headerHeight"); return new EdgeMetrics( borderThickness, borderThickness + headerHeight, borderThickness, borderThickness); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "apache flex, flex3" }
Importing and Using NLTK corpus Please, please, please help. I have a folder filled with text files that I want to use NLTK to analyze. How do I import that as a corpus and then run NLTK commands on it? I've put together the code below but it's giving me this error: raise error, v # invalid expression sre_constants.error: nothing to repeat Code: import nltk import re from nltk.corpus.reader.plaintext import PlaintextCorpusReader corpus_root = '/Users/jt/Documents/Python/CRspeeches' speeches = PlaintextCorpusReader(corpus_root, '*.txt') print "Finished importing corpus" words = FreqDist() for sentence in speeches.sents(): for word in sentence: words.inc(word.lower()) print words["he"] print words.freq("he")
I understand this problem has to do with a known bug (maybe it's a feature?), which is partially explained in this answer. In short, certain regexes about empty things blow up. The source of the error is you `speeches =` line. You should change it to the following: speeches = PlaintextCorpusReader(corpus_root, r'.*\.txt') Then everything will load and compile just fine.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "python, nltk" }
How can I restrict Paperclip to only accept images? How can I restrict Paperclip to only accept images? I'm using Amazon S3 for storage if that's relevant. Thanks for reading.
Paperclip has validation methods like `validates_attachment_presence`, `validates_attachment_content_type`, and `validates_attachment_size`. So all you need to do is pass mime types of images you'd like to have as attachments: validates_attachment_content_type 'image/png', 'image/jpg'
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 13, "tags": "ruby on rails, paperclip" }
PHP PDO Fetching Results I'm trying to simply echo results out on the screen from my database. I'm quite new with PDO, and I've been searching on this site for an answer that works, but have found none so far. $results = $MyConnection->prepare("SELECT Antwoord1, Antwoord2, Antwoord3 FROM CCOpendag "); $results->execute(); $foundResults = $results->fetchAll(PDO::FETCH_ASSOC); echo $foundResults; This piece of code simply echoes out 'Array'. What I want to achieve is that I get the results from these 3 columns and display them on the screen. If somebody could help me out, that would be amazing.
print_r($foundResults) or var_dump($foundResults)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, pdo, fetch" }
Intellij idea choose implementation of class/trait action shows two times more results If I have both binary files and sources downloaded and press icon to see who implements some trait or class, idea shows me a list with each child mentioned 2 times - one it takes from sources and another from binary. This isn't a big problem but sometimes irritates me) _Here you can see implemetation in binary files (blue) and sources (red)._ ![enter image description here]( Is there a way to make this implementation list _distinct_ and still have both binary and sources?
I created an issue: < However I just fixed it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "java, scala, intellij idea" }
Why are punitive damages not awarded to the government in a civil litigation In a civil litigation generally a person versus a company, when a person wins against a big company we often see a huge sum of punitive damages being imposed on the company and that sum goes to the person. In my understanding the total figure of the punitive damages is based loosely on the revenue of the company, and not the loss of the person so as to punish the company for its unethical practices. That sum may grossly exceed the losses incurred by that party. This might cause people to file frivolous lawsuits against companies. If instead the government collected the punitive damages, it would serve as a deterrent for the company to pursue unethical practices, the litigator would be compensated as per his loss incurred, and it would also prevent frivolous cases from being filed just for greedy motives. Why can't punitive damages be awarded to the government instead?
**Punitive damages are not awarded to the government, because they would be unconstitutional under the 8th Amendment.** The Supreme Court decided that punitive damages were not unconstitutional under the 8th Amendment when the USA government is not a party. > The first major case in which the Supreme Court ruled on the constitutionality of punitive damages was in 1989, in Browning-Ferris v. Kelco. In that case, the Court held that the Eighth Amendment of the Constitution (which is most commonly known for its Cruel and Unusual Punishment Clause, but which also contains a clause prohibiting “excessive fines”) does not apply to punitive damages awards in civil lawsuits to which the United States is not a party. Clearly, if you allow the government to collect the punitive damages instead of the private party, the 8th Amendment protection against "excessive fines" would apply and would no longer act as a deterrent for companies performing unethical practices.
stackexchange-politics
{ "answer_score": 3, "question_score": 6, "tags": "law" }
Searching for element in an array -- *Not* original object specific < Something like this var test = {a: 'a', b: 'b'}; var test2 = {a: 'a', b: 'b'}; var a = []; a.push(test); alert($.inArray(test2, a)); > Test2 = -1 > > Test = 0 Why is this? The objects should be identical right? What kind of comparison is it doing? EDIT: Clarifying some things. All the answers below are extremely informative. I am using an array to store a runtime pair of values a "page" and a "directory". These are normally separated unrelated values. I wanted to setup a array of certain pair values and be able to get those two unrelated, form that key pair relationship by creating an object, then searching an array of "allowed" pairs using this method. I'll use the custom search function for this. Thanks SO!
You can compare each element: function compareObjects(a, b) { var areEqual = true; for (var key in a) { if (b[key] !== a[key]) { areEqual = false; break; } } for (var key in b) { if (b[key] !== a[key]) { areEqual = false; break; } } return areEqual; } Or maybe serialize the records and string compare: JSON.stringify({a: 1, b: 2}) === JSON.stringify({"a": 1, "b": 2}); // true
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, arrays" }
How to vertically centred an image inside a floating div .container{ float:right; border: 1px solid blue; height: 100px; } .container img{ width:80px; height:20px; vertical-align:middle; border: 1px solid red; } <div class="container"> <img src=" /> </div> My question, is how can you centred the image vertically inside a floating div?
Use Flexbox: .container{ align-items: center; display: flex; float:right; border: 1px solid blue; height: 100px; } .container img{ width:80px; height:20px; border: 1px solid red; } <div class="container"> <img src=" /> </div>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "html, css" }
Testing angular services with controllers I have my custom angular service, which has one method that handles with `$scope.$watch`, is it possible to unit test it? angular.module('moduleName', []).factory('$name', function () { return { bind: function ($scope, key) { $scope.$watch(key, function (val) { anotherMethod(key, val); }, true); }, ... }; });
Solution that I've found seems to be very easy and nice: beforeEach(function () { inject(function ($rootScope) { scope = $rootScope.$new(); scope.$apply(function () { scope.value = true; }); $name.bind(scope, 'value'); scope.$apply(function () { scope.value = false; }); }); }); beforeEach(function () { value = $name.get('value'); }); it('should have $scope value', function () { expect(value).toBeFalsy(); });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, unit testing, angularjs, angularjs scope" }
Why can't I move my weapons individually? I feel like I can barely move my weapons. Is there a way to move them individually from the body?
Yes, you can. Simply hold shift while moving your mouse. If you don't want to have to press shift all the time, disable Arm Lock.
stackexchange-gaming
{ "answer_score": 1, "question_score": 1, "tags": "mechwarrior online" }
How to write basic macro to compare two columns for a difference within .50? I'm trying to write a macro that compares the differences between values in columns B and C. I'd like the macro to compare the two columns (B & C) and find depths that are within +/- .50 of each other, and I'd like to keep track of the sample # (column A) that corresponds to the sample depth that is within +/- .50 of the test depth, and then to find the difference between the sample depth and test depth. For example, the following images are before and after what I'd like the macro to look like: Before: ![img1]( After: ![img2](
here you go. nested loop for the read, iterator to count the output row. May need some customization, but this is the core of it. Sub foo() Dim itr As Integer itr = 2 For Each sd In Range("B:B") If sd.Value = "" Then Exit For If IsNumeric(sd.Value) Then For Each td In Range("C:C") If td.Value = "" Then Exit For If IsNumeric(td.Value) Then If Abs(sd.Value - td.Value) < 0.5 Then Cells(itr, 5) = sd.Value Cells(itr, 6) = td.Value Cells(itr, 8) = sd.Value - td.Value itr = itr + 1 End If End If Next td End If Next sd End Sub
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "excel, vba" }
Understanding smaller parts without understanding what they mean when put together I am looking for an which adjective/adverb/phrase which refers to understanding all of the smaller components of something without understanding what they mean when put together. "We understand every letter, but don't understand the words." For example, say we understand what it means when P -> Q and we understand what it means when Q -> R, but we don't necessarily understand what it means when P -> Q -> R (i.e. P -> Q and Q -> R at the same time). The purpose, for those of you who know mathematics, is that I am writing a graph theory paper. Each edge corresponds to certain, well-understood behavior in an algebraic structure, but what happens when these behaviors happen at the same time has not been studied (until this paper, of course).
The common idiom for this is _can't see the forest for the trees,_ especially to express the sentiment that somebody can't see the whole because of information overload from the details. While that might not fit well into the context, there is some potential for allusion to the term _leaf node_ from tree and graph theory. The loan word _gestalt,_ meaning a whole that is greater than the sum of its parts, might better fit the tone of a mathematical paper.
stackexchange-english
{ "answer_score": 6, "question_score": 3, "tags": "single word requests, mathematics" }
Derivative of Bernstein polynomial I'm trying to obtain the first derivative of Bernstein polynomial $$B_k^n={{n}\choose{k}}x^k(1-x)^{n-k}$$ My goal is to obtain the derivative as in equation below (Hollig and Horner (2014), p. 12) Approximation and modeling with B-splines): $$\frac{d}{d x} b_{k}^{n}(x)=\left(\begin{array}{l}n \\\ k\end{array}\right)(1-x)^{n-k-1} x^{k-1}[-(n-k) x+k(1-x)]$$ My effort: $$\frac{d}{d x} b_{k}^{n}(x)= {{n}\choose{k}}x^kn-k-1^{n-k-1} + (1-x)^{n-k}k{{n}\choose{k}}x^{k-1}$$ $$={{n}\choose{k}}[[n-k-1]x^k(1-x)^{n-k-1}+k(x^{k-1})(1-x)^{n-k}$$ I appreciate your help.
You should have a $[n-k]$ and not $[n-k-1]$. Explicitly, \begin{align*}\frac{d}{dx}B_k^n(x) &= \binom{n}{k} kx^{k-1}(1-x)^{n-k} - (n-k)x^k(1-x)^{n-k-1}\\\&=\binom{n}{k}x^{k-1}(1-x)^{n-k-1}[k(1-x) - (n-k)x]\\\&=\binom{n}{k}x^{k-1}(1-x)^{n-k-1}[-(n-k)x + k(1-x)]\end{align*}
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "derivatives, polynomials" }
How to validate data from new return data value feature stored in block header How would one go about validating the data from the block header of a return data value action? It seems like a cool feature, but you'd need a full history node to validate wouldn't you? <
In block header, you can find `action_mroot`. `action_mroot` is the root hash of merkle tree of `action_receipt`s. `action_receipt` contains `act_digest`, and `act_digest` is constructed by hashing `action` itself and `action_return_value`. You can validate `action_return_value` by comparing the hash value (of action and its return value) and `act_digest` in action receipt. // eos/libraries/chain/apply_context.cpp act_digest = generate_action_digest( this { return trx_context.hash_with_checktime<digest_type>(data, datalen); }, *act, action_return_value // here );
stackexchange-eosio
{ "answer_score": 1, "question_score": 1, "tags": "eosjs" }
How can I print a views exposed form into a custom block? I have a page view with exposed filters and would like to print said filters into a custom block in order to add extra html markup above the actual form. This block will be used on other pages using Context. I know I can create a block by setting 'exposed filters in block' to yes, however that's not the solution I am looking for.
Hours and hours of searching and nothing was working. Several minutes after posting this question, I figured it out. The following code can be used in template files or blocks. <?php $block = module_invoke('views', 'block_view', '-exp-VIEW_NAME-DISPLAY_NAME'); print render($block['content']); ?>
stackexchange-drupal
{ "answer_score": 8, "question_score": 3, "tags": "views, blocks" }
How to loop over multiple elements in an array at a time I am trying to loop over 10 elements within a big array and see if there are any mismatches with another array (let's call it array2). Dim j As Long, i As Long, arr As Variant mismatch = Compare_array(array1, array2) 'Compare_array is a function and returns an array of mismatches For i =LBound(mismatch) to UBound(mismatch) j=0 For arr = mismatch(j + 1, 1) To mismatch(j + 10, 1) 'other code' Next Next Basically what I want to do is get 10 elements of the mismatch array and perform other procedures with it. After the other procedures are done, I want to take the next 10 elements of the mismatch array, and so on. I'm just not sure if I have done the second for statement correctly. Any advice would be appreciated.
If I understand the question correctly, all you should need to do is step through the array by 10s, then have the inner loop offset the main index: For i = LBound(mismatch) To UBound(mismatch) - 10 Step 10 For j = 0 To 9 arr = mismatch(i + j) 'other code' Next Next If you don't have the requirement that the sub-groups have exactly 10 elements, you can add a separate bound calculation to the inner loop by looping through the maximum of elements or however many are left: For i = LBound(mismatch) To UBound(mismatch) Step 10 Dim innerBound As Long If i + 10 > UBound(mismatch) Then innerBound = UBound(mismatch) - i Else innerBound = 9 End If For j = 0 To innerBound arr = mismatch(i + j) 'other code Next Next
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "vba, excel" }
Does overfitting depend only on validation loss or both training and validation loss? There are several scenarios that can occur while training and validating: 1. Both training loss and validation loss are decreasing, with the training loss **lower** than the validation loss. 2. Both training loss and validation loss are decreasing, with the training loss **higher** than the validation loss. 3. Training loss decreasing, but validation loss is increasing. I am aware that overfitting occurs in scenario 3, but does overfitting occur in scenario 1? If so, does this mean that overfitting only occurs when either scenario 1 or scenario 3 occur? Otherwise, if overfitting only occurs in scenario 3, does this mean that overfitting only occurs when validation loss is increasing?
In my opinion, only case 3 should be considered overfitting. As @stans has mentioned, there is not a very rigorous definition of overfitting so other people might think differently. I wouldn't say the point where the validation loss stops decreasing is where bias and variance are minimized since there is a trade-off between bias and variance: * A constant model will have very low variance, but very high bias. * An overfitting model will have very low bias, but very high variance. The point where the validation loss starts increasing can be considered optimal in terms of the sum of squared bias and variance, that is, an optimum of the generalization error.
stackexchange-datascience
{ "answer_score": 1, "question_score": 1, "tags": "training, overfitting, validation" }
Creating an element by using .append() and assigning onclick handler directly afterwards Is it ok to directly assign an onclick-handler to an element that was inserted into the html code just before by using .append()/.after() or can it be that this element is not "ready" yet?
It is totally OK to _assign_ event listener to an element (or an element's child-element), and then insert that element into DOM. As the question is about jquery. Here is an jquery example: var buttonWrapper = $('<div>mmmmmmmm<button class="btn">click</button></div>'); var button = buttonWrapper.find('button.btn'); button.on('click', clickListener); var container = $('#container'); function clickListener() { alert('clicked!'); } container.append(buttonWrapper); <script src=" <div id="container"> content </div>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, html" }
Stopwatch Java API Is there something out there that would allow me to create static object in my class or extend my class and give me functions to start, stop time configure statistics collection with properties file and bunch of other goodies I don't even know about. I'm working on app that has crazy amount of threads running at any given moment and making sense out of the log files is becoming increasingly difficult. That's why I'm looking for some kind of a solution to help me with that. Ideally I would like to have bean in my spring application context that would pretty much automate all the tracking of running treads based on annotation which would allow to configure the names of threads and accuracy of the stopwatch. Also ability to hooking it up with database instead of just log file would be great as well.
Maybe you want the apache commons StopWatch class?
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "java, api, stopwatch" }
Vim: How to exclude already typed result from CTRL+N autocomplete I've searched the manual, but really have no idea what I'm looking for. Here's a screenshot of what happens when I'm typing a word and press `CTRL`+`N` to autocomplete it: ![]( I obviously do not want to autocomplete the word I just typed as it's already typed, therefore don't need it to show in the results dropdown. It doesn't show up every time I use `CTRL`+`N`, which is odd.
The `control``N` autocompletes with words starting with the keyword at your curson position, starting the search _forward_ (think of `N` as "next). And in your case, you do have a word right on the same line that is `requiredF`, which was found by the auto complete. If your desired keyword is before your cursor, you can use the similar command `control``P` which does the search _backwards_ , thus searching for the previous possible completion. This is the most common command you will use when you're writing new text, for example.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "vim" }
What is use of azure functions AzureWebJobsStorage and AzureWebJobsSecretStorageType settings Can you please help me to understand what is use of azure functions **AzureWebJobsStorage** and **AzureWebJobsSecretStorageType** settings. I am new to Azure , So please say answer through an example .
From the `official documentation`: > **AzureWebJobsSecretStorageType** > > Specifies the repository or provider to use for key storage. Currently, the supported repositories are blob storage ("Blob") and the local file system ("Files"). The default is blob in version 2 and file system in version 1. > > **AzureWebJobsStorage** > > The Azure Functions runtime uses this storage account connection string for all functions except for HTTP triggered functions. The storage account must be a general-purpose one that supports blobs, queues, and tables.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 12, "tags": "azure, azure storage, azure functions" }
Dynamics CRM 2016 - Creating History Log I have new small Dynamics CRM 2016 system without server side infrastructure and I would like to keep it that way. I'm trying to create history log for some entity that should include previous and new value. The history log should be created on any CRUD action, and I'm trying to implement it on the client side. Is there any way to triggered it that way (via Webapi)? I'm not sure how to implement the Delete record log. I will be happy to get alternatives also.
So you don’t want to use server side things like Plugin/WF/action and OOB Audit. But everything in JavaScript? You can do it.. its broad. Start writing js event handlers, customizing with ribbon workbench & button command to include all your custom event handlers to capture before & after values of fields (equivalent of plugin images), insert into custom history entity using webapi, take care of native handlers like save, deactivate, delete,etc. Apart from plugin which is tailored by product to extend logic of platform execution like this, there’s no alternate from me.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "logging, dynamics crm, crm, microsoft dynamics" }
MySQL: Count entries without grouping? I want to pull results and count how many of each name is pulled but without grouping... for example I want this: John Doe 3 John Doe 3 John Doe 3 Mary Jane 2 Mary Jane 2 instead of this: John Doe 3 Mary Jane 2 Does that make sense? Thanks.
SELECT b.name, a.the_count FROM some_table b, (SELECT name, COUNT(*) AS the_count FROM some_table GROUP BY name) AS a WHERE b.name = a.name
stackexchange-stackoverflow
{ "answer_score": 21, "question_score": 21, "tags": "sql, mysql" }
Multiplying a query value with multiple select from another table I have two tables A and B Table A Name Time Price a 12/01/2011 12:01 1.2 a 12/01/2011 12:02 1.3 a 12/01/2011 12:03 1.7 Table B Name Date Factor_P Factor_Q Factor_R a 12/01/2011 0.234 1.456 1.445 a 12/02/2011 0.345 1.222 1.765 I need to do a Select Price * (Factor_P * Factor_Q / Factor_R) from Table A where Name = 'a' and Time > '12/01/2011 09:30' and Time < '12/01/2011 16:00' I need to fetch the three factors from Table B and do the multiplication. How do I do the multiplication with multiple values from another table after matching the date?
Try this: SELECT (a.Price * b.Factor_P * b.Factor_Q / b.Factor_R) AS num FROM tableA a INNER JOIN tableB b ON a.Name = b.Name AND TO_CHAR(a.Time, 'DD-MON-YYYY') = TO_CHAR(b.Date, 'DD-MON-YYYY') WHERE a.Name = 'a' AND Time BETWEEN '2011/01/12 09.30.00' AND '2011/01/12 16.00.00'
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, oracle" }
ASP.NET DetailsView Update exception handling - truncated data I'm using a DetailsView for updating a record. If the edit input of some fields is too long, the system produces a "data will be truncated" exception. I can see where I can detect the error in DetailsViewItemUpdating or DetailsViewItemUpdated, and provide a user message. However, I believe the visual feedback should be sufficient for this release, i.e. "hey, it didn't take my 30 characters, even though the header label said it would only allow 20". Is there a way to force the DetailsView to do the truncation and accept the update? Or some other approach to this data handling exception, which must be pretty common.
ANSWER: from Ammar Gaffar at EE: Convert to template field In EditItemTemplate Set DataBindings > MaxLength property to desired max length of field Works fine.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "asp.net, detailsview" }
How to split the polynomial . How do I split $x^2-5 $ in $\mathbb{Z}/5\mathbb{Z}$ ? Since $0$ is a root I have $x $ as linear factor . How can I find the other linear factor ?
Note that $x^2-5 = x^2$, which is already factorised.
stackexchange-math
{ "answer_score": 11, "question_score": 2, "tags": "abstract algebra, number theory" }
Eclipse: create two projects sharing files I need to create an application that will be deployed on Desktop and Android. I'll use the MVC pattern; the Desktop and Android versions will share the Controller and the Model. I thus want to create my two projects in a way that allows me to share the code related to the controller and the model, each project having its own version of the view. What is the best way to do that in Eclipse? I don't want to use the code as a library because it must be possible to modify it directly from any of the two projects, with the modifications visible immediately in both. Moreover, when the applications will be done, I must be able to generate an "ant build file", so I want a file structure that allows to build the two versions separately with no redundancy. Thanks in advance!
You can share class files and jar files between projects as a library, so what you would need would be three projects: two with the interface code and one with the common files. The common files would be your library.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, android, eclipse, ant, sharing" }
How to make a variable accessible from a subclass but not an instance java? I have 3 classes. In 1 class I create an instance of a subclass inheriting from a superclass. How do I make my variables accessible to my subclass without it being available to the instance of the subclass? (Like static but only over multiple classes. I am new to java so at least that is how I think.) public class Super { protected int myInt; //Struggling here } public class Sub { // Like to use the myInt in the super in a method here } public class MainPage { Sub obj = new Sub(); int x = obj.myInt; //This should not happen }
Protected scope is accessible from all classes in the same package, as well as subclasses in any package. Put `Super` and `Sub` in a separate one, and you have what you want (well, if `class Sub extends Super`). From your example actually it is not clear, if package private (default) scope may also suit your needs.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "java" }
A little php/html help So I got some php code, but I want to separate the 'echo' from the 'echo this' so I can put them into 2 DIVs so that I can give them individual css (I have posted the exact code from my site). This code is to give a frontend message so that people can see that items are for backorder BEFORE the checkout phase. <div class="extra-info"> <?php $inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product); $inv_qty = (int)$inventory->getQty(); if ($inventory->getBackorders() >= 0 && $inv_qty == 0) { echo "TO ORDER - LEAD TIME APROX. 3 WEEKS"; } else { echo $this->getChildHtml('product_type_availability'); } ?> </div> Thx,
<?php $inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product); $inv_qty = (int)$inventory->getQty(); if ($inventory->getBackorders() >= 0 && $inv_qty == 0) { ?> <div class="extra-info-a">TO ORDER - LEAD TIME APROX. 3 WEEKS</div> <?php } else { ?> <div class="extra-info-b"><?php echo $this->getChildHtml('product_type_availability');?></div> <?php } ?>
stackexchange-magento
{ "answer_score": 1, "question_score": 0, "tags": "magento 1.9, backorder" }
unchecked conversion on multidimensional arraylist Does anyone know how to fix this warning? MyMain.java:12: warning: [unchecked] unchecked conversion found : java.util.ArrayList[][] required: java.util.ArrayList<java.lang.String>[][] obj[count].someArrayList = new ArrayList[4][4]; I tried to change this to: obj[count].someArrayList = new ArrayList<String>[4][4]; But the amendment changes the warning into the following error: MyMain.java:12: generic array creation obj[count].someArrayList = new ArrayList<String>[4][4]; The declaration of someArrayList is: public ArrayList<String>[][] someArrayList;
You cannot create arrays with generics (hence the error). The warning indicates the heavily discouraged use of raw types with an `ArrayList`. Instead, the following creates a multidimensional `ArrayList`: `public ArrayList<ArrayList<String>> someArrayList;` You can then perform normal operations on your multidimensional `ArrayList`. obj[count].someArrayList = new ArrayList<ArrayList<String>>(); ArrayList<String> toAdd = new ArrayList<String>(); toAdd.add("test"); toAdd.add("test2"); obj[count].someArrayList.add(toAdd);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java" }
Routes handling in go In express you can handle any routes by doing this app.get('/*', dosomething..) I've tried doing the same in go but it doesn't seem to be working http.Handle("/*", http.FileServer(http.Dir("../client/dist")))
If you read closely the documentation of http.ServeMux, the slash `/` matches all routes. Simply writes: http.Handle(“/“, MyHandler)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "http, express, go, routes" }
Divided Differences expanded form definition. From definition of divided differences we have that $$f[x_0,\cdots,x_n]=\sum_{j=0}^n\frac{f(x_j)}{\Pi_{{k\in\\{0,\cdots,n\\}-\\{j\\}}}(x_j-x_k)} $$ It makes completely sense to have $k\neq j$ otherwise the denominator becomes zero. In many articles I've seen the following notation, let $q(\xi)=(\xi -x_0)\cdots(\xi-x_n)$, then we can re-express the expanded form of the divided difference as $$f[x_0,\cdots,x_n]=\sum_{j=0}^n\frac{f(x_j)}{q'(x_j)}$$ In this link there's a brief explanation but I don't really get the point. why is it that $$q'(x_j)=(x_j - x_0)\cdots(x_j -x_{j-1})(x_j-x_{j+1})\cdots(x_j - x_n)$$ ? Maybe I am messing up things, but if I apply the product rule for derivatives I don't obtain that result. Thanks in advance
First, look at the following equivalent expression of $q$: $$q(\xi)=(\xi-x_j)\cdot \prod_{i\neq j}{(\xi - x_i)}$$ Take the derivative of $q(\xi)$ with respect to $\xi$, using the product rule (no need to expand the rightmost expression): $$q'(\xi)=1\cdot \prod_{i\neq j}{(\xi - x_i)} + (\xi-x_j)\cdot \left( \prod_{i\neq j}{(\xi - x_i)}\right )'$$ Now substitute $\xi=x_j$, to get $$q'(x_j)=\prod_{i\neq j}{(x_j - x_i)} + (x_j-x_j)\cdot \left( \prod_{i\neq j}{(x_j - x_i)}\right )' = \prod_{i\neq j}{(x_j - x_i)}$$ I don't think you should view it as anything more meaningful than a shorthand for the longer expression on the right hand side.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "derivatives, interpolation, recursive algorithms" }
Session is destroyed after return from paypal I have integrated the paypal recurring subscription with my site.I have set return url after the successful transaction..But once I redirected from paypal I got my session values are destroyed and it returns nothing on that page as well..I could not get the response(transaction id,status, etc)..Any one can instruct me to get this resolved.
Check that your response is coming back to the correct URL. On some servers, www.site.com is considered different (session-wise) from site.com
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, session, paypal" }
C# Creating buttons for WPF app that can connect and save the connection to a Serial Port Hi there I'm a newbie in programming, hope it's the right place to start! Currently I designed a program which is suposed be UI for a control program of an old 80s robot. The problem is that I need to open a COM port (COM2) assign that function to a button and save that, so I can use it all around the menus. Any help would be appreciated! :)
XAML code: <Window x:Class="WpfApplication1.MainWindow" xmlns=" xmlns:x=" Title="MainWindow" Height="350" Width="525"> <Grid> <Button Click="Button_Click">Open Serial Port</Button> </Grid> Code behind: private System.IO.Ports.SerialPort _serialPort; private void Button_Click(object sender, RoutedEventArgs e) { if (_serialPort == null) _serialPort = new System.IO.Ports.SerialPort("COM2"); try { _serialPort.Open(); } catch (Exception) { // Do something throw; } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wpf, button, serial port" }
CsvHelper rounding a double to two places in maps For mapping classes I have this. public sealed class MyMap : ClassMap<MyBase> { public MyMap() { Map(m => m.EventDate).Index(1); Map(m => Math.Round(m.Price,2)).Index(2); } } Is there a way that will work as this errors out when rounding. I know you can use custom converters but that seems like over kill just to truncate input to two decimal places.
Something like this? public sealed class MyMap : ClassMap<MyBase> { public MyMap() { Map(m => m.EventDate).Index(1); Map(m => m.Price).Index(2).Convert(row => Math.Round(row.Row.GetField<decimal>("Price"),2)); } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, csv, csvhelper" }
unable to run LibGDX game on android device due to not being able to find the android launcher class i have an error on the logcat which reads FATAL EXCEPTION: main RunTime exception unable to instatiate activity componentInfo(android launcher) java.lang.classNotFoundException: Didn't find class " androidLauncher " on path : DexPathList[[zip file "/android-3.apk"],nativeLibraryDirectories=[android-3, /vendor/lib, /system/lib]] i shortened it down as i couldnt copy and paste it but the basic error is there If you need any more details just ask but hopefully this should be enough My game compiles but doesnt run and a message pops up on my android device "game has stopped" Hopefully someone can help as i have been messing around with this for a few days and still no luck :( thankyou
java.lang.classNotFoundException: Didn't find class " androidLauncher " on path : DexPathList[[zip file "/android-3.apk"],nativeLibraryDirectories=[android-3, /vendor/lib, /system/lib]] You seem to have changed the AndroidLauncher.java name. (notice the caps A). * You can make a file search (Ctrl + H), with "case sensitive" checked, and change any references to this non-existing "androidApplication" class. * Also cleaning your projects may pop these wrong references. * Also remaking your project with the Gdx Setup, and importing your code is a 100% error proof way of fixing your problem, but may take you more time.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "java, android, gradle, libgdx, dex" }
Кто такой Ешкин Кот? Мы говорим "ешкин кот", когда хотим выразить досаду на что-то. А кто он такой, этот ешкин кот, откуда пошло выражение?
Ёшка, правильнее - Ёжка, "народное" уменьшительное от "Яга" - в нарицательном значении нечто, насылающее порчу (сам вид порчи варьируется, подробнее - у Фасмера). В том числе и та Яга, которая "баба". Эвфемистическое толкование - позднейшее. Более того, прежде чем стать эвфемизмом слово, видимо, испытало сильное влияние созвучных слов - имен собственных и нарицательных, вполне благопристойного значения. Многочисленные версии того, каких именно, легко находятся в сети; не привожу, ибо крайне недостоверно. Тут, имхо, гораздо интереснее сам кот. То ли он в прямом значении (и у какой же ведьмы нет кота?), то ли сам по себе замена чего-то утраченного... Подобно тому, как это произошло в "сукин кот".
stackexchange-rus
{ "answer_score": 3, "question_score": 2, "tags": "фразеология" }
asp.net - build linkedin style photo cropper On linkedin.com, the photo that you can manage for your profile has the ability to select a "region" from the photo to crop and use as your profile picture. I assume that it uploads the original picture to a server, and then stores the x,y of the top left corner, and the width and height. Does anyone know of a web example of something like this? The platform is asp.net 3.5, ideally.
check this out - this might be of help < has a demo at <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net, photo management" }
How to install/deploy a sources jar with maven ant tasks I had a hard time understanding how to install or deploy a jar file with its accompanying sources (or any additional classifier for that matter). The documentation wasn't clear to me and left me to do some trial and error.
Here is an example of how to use a classifier with maven ant run tasks: <target name="install-jar"> ... <artifact:pom id="sharedPom" file="shared/pom.xml" /> <artifact:install file="${classesdir}/shared.jar" > <pom refid="sharedPom" /> <attach file="${builddir}/shared-sources.jar" classifier="sources" /> </artifact:install> </target> The attach referenced to in the documentation is meant to be a sub-element. Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "maven, ant, maven ant tasks" }
How to deal with the challenges Allah gives us? After each prayer i'm asking Allah for Janah/heaven. However, my life has gotten very difficult since then. I've gone through many problems and am wondering how to stay positive. My question is how do you stay positive while going through the challenges? It's incredibly challenging. I'm really tired.
Just try to think of it as a challenge/trial. I have gone through some problems too. Remember that you are on Allah's Earth and that Allah knows everything and that Allah knows best. "Fighting has been enjoined upon you while it is hateful to you. But perhaps you hate a thing and it is good for you; and perhaps you love a thing and it is bad for you. And Allah Knows, while you know not." Surah 2:216 Just remember that Allah knows best and that this world is nothing compared to what Allah can give you. The wealth, women/men and luxuries are nothing.
stackexchange-islam
{ "answer_score": 0, "question_score": 0, "tags": "jannah" }
Visual Studio Web Deploy not publishing all Files When I publish my ASP.net MVC 3.0 Application to IIS 7 using Visual Studio Web Deploy settings one Partial View File is not updated. Is it possible to debug why it failed for one particular file?
Select the view that is not publishing to server, go to properties (click F4) of the view under properties check the properties set for it: 1. **Build Action** : this should be **Content** 2. **Copy to Output Directory** : this should be like the other file are configured (I believe it should be **Do not copy** ) Then publish it.
stackexchange-stackoverflow
{ "answer_score": 48, "question_score": 29, "tags": "iis 7" }
React-router remove url with History api I am using [email protected] and I cant get rid of the #/?_k=jg0dw5 on the end of my url. I have looked at other examples and they tell me to do it this way: var createBrowserHistory = require('history/lib/createBrowserHistory'); var routes = ( <Router createElement={createElement} history={createBrowserHistory()}> <Route path='/' component={App} /> <Route path='/login' component={Login} /> <Route path='*' component={NotFound}/> </Router> ); ReactDOM.render(routes, document.getElementById("app")); Doing it this way removes the url but I cant access any of my pages since I have added it. Have I missed something out?
Take a look here: Caveats of Using Hash History You should pass a `{ queryKey: false }` parameter to the createHashHistory function.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "reactjs, react router" }
How do I respond to a tap on a UNUserNotification? I'm using the new `UNUserNotification` framework in iOS 10. I can see how to add action buttons, but how do I respond when the user taps the notification itself? In my case, it will be an image with some text. The default behavior is that the application opens. 1. Can I have custom code that detects if my application is being opened because of a `UNUserNotification` tap, and ideally with identifier information about the notification tapped? 2. Will these work if my app is running in the background or closed? `UNUserNotification` documentation suggests setting the delegate of `UNUserNotificationCenter`, but I think this only works if the app is running.
Set `AppDelegate` to be `UNUserNotificationCenterDelegate` if you haven't already and add the following to the `didReceive` method: func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { let userInfo = ["identifier":response.notification.request.identifier] NotificationCenter.default.post(name: Notification.Name(rawValue: "userNotificationCenterDidReceiveResponse"), object: self, userInfo: userInfo) completionHandler() } You can then register for that "userNotificationCenterDidReceiveResponse" notification and do whatever you like with the identifier. This works no matter what state your app is in, including not running. If this isn't clear enough I can upload a sample project.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "ios, notifications, unusernotificationcenter" }
update row if count(*) > n my DB has this structure: ID | text | time | valid This is my current code. I'm trying to find a way to do this as one query. rows = select * from table where ID=x order by time desc; n=0; foreach rows{ if(n > 3){ update table set valid = -1 where rows[n]; } n++ } I'm checking how many rows exist for a given ID. Then I need to set valid=-1 for all rows where n >3; Is there a way to do this with one query?
Assuming that `(id,time)` has a `UNIQUE` constraint, i.e. no two rows have the same `id` and same `time`: UPDATE tableX AS tu JOIN ( SELECT time FROM tableX WHERE id = @X -- the given ID ORDER BY time DESC LIMIT 1 OFFSET 2 ) AS t3 ON tu.id = @X -- given ID again AND tu.time < t3.time SET tu.valid = -1 ;
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "mysql, sql, insert, sql update" }
How can you target multiple platform's inside Android NDK Application.mk I need a version of my application that supports PIE (Position Independent Executable) for Android L and one that does not for older devices. Can this be done with a single Application.mk? The Application.mk for older devices looks like: > > APP_PLATFORM := android-10 > APP_ABI := armeabi x86 > APP_STL := stlport_static > But for newer devices it's: > > APP_PLATFORM := android-L > APP_ABI := armeabi-v7a > APP_STL := stlport_static > * * * ## Answer It can't be done inside a single Application.mk, but you can specify an Application.mk like: ~/ndk/ndk-build ~/ndk/ndk-build NDK_APPLICATION_MK=Application-L.mk Note the docs falsely call this NDK_APP_APPLICATION_MK
I do not believe this is possible with the NDK make system. All I can suggest is have the two files and two separate build trees.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "android, build, android ndk" }
SQL resulting table satisfies two conditions I hope I can explain this well enough. Say I have this table: Owner +--------+--------+ | Name | Type | +--------+--------+ | Bob | Cat | | Bob | Dog | | Bob | Cow | | Tim | Dog | | Tim | Cat | | Ted | Cat | | Joe | Dog | | Joe | Cat | | Joe | Sheep | +--------+--------+ I am trying to find everyone who has all the animals tim has (so a cat and a dog). This means Joe and Bob would satisfy this, but not Ted as he only has one type of animal Tim has How would I go about getting this result? So I have a table with all the types tim owns: SELECT Type FROM Owner WHERE Name= 'Tim'; How do I get it so that only those who have both Types tim has get selected from the list of owners? Any guidance would be appreciated, thanks in advance.
select name from owner where type in (select distinct type from owner where name = 'tim') group by name having count(distinct type) = (select count(distinct type) from owner where name = 'tim')
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql" }
Regular expression for only numbers I want a regular expression for only numbers not less and more than 4 digit and also it should not accept characters. I tried this but it is accepting characters also var reg = /^\d{4,4}$/; I want in JavaScript.
You could simply use this, ^\d{4}$ It allows exactly 4 digits only. You don't need to specify the range. Use the below regex if you want to allow 4 or more digits. ^\d{4,}$
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "javascript, regex" }
Is a conversion constructor called for this overloaded operator? (C++) Given that this is the only == function in the class, bool myClass::operator == ( const myClass & rhs ) { if ( var1 == rhs.var1 ) return true; else return false; } What does the following comparison assume? myClass mc1; anotherClass ac1; if ( mc1 == ac1 ) My instinct was to say that it assumes that ac1 will be converted to type myClass, but how can that happen? operator== has a parameter of type myClass & rhs, so how could myClass's conversion constructor be called when ac1 is passed to the function? Thanks!
Since there's no perfect overload for that operator the converting constructor is called (it counts as an implicit conversion), and the temporary created in this way is passed to your `operator==`. After the call the temporary is destroyed. Notice that this wouldn't happen if `operator==` accepted a non-`const` reference, because temporaries can be bound only to `const` references.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c++, overloading, operator keyword" }
if statement updates variable var text = 'abc'; if(text = '' || text != '') console.log(text); else console.log('in else'); It is just a useless code snippet, but it gives the strange result which I was not expecting at all. So my curiosity brought me here. It prints `true` only. Why does it updates the `text` value to `true` rather than setting it as empty?
The expression text = '' || text != '' is parsed as text = ('' || text != '') The value of ('' || text != '') is the boolean value `true` because `text != ''` is `true`.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "javascript, if statement" }
Is there something similar to Java applet which can be used as script on web page in Python? Does python provide scripts to be embedded into web page (and can use python language structures) something similar to .asp?
Check out Pyjamas, which is a Python framework that targets the Web Browser (basically, a Python to Javascript compiler): <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "python" }
Operator overloading confusion in Java Though we all know that Java doesn't support operator overloading, then why is the `+` operator an arithmetic operator as well as `String` concatenation operator. Can anybody explain this?
Java doesn't allow _custom_ operator overloading. Several operators, not just `+`, are overloaded _by specification_ , and that's the way they stay. The main issue with custom operator overloading is the opaqueness and unpredictability of their semantics, contributing to the probability of massive WTF moments while reading (and even writing) code.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 0, "tags": "java, operator overloading" }
Regex pattern does not support # symbol I use regex in Nginx configs to capture file urls but if the file URL contains the # symbol, regex pattern will not capture it. Here is the part of nginx config. location ~ ^/p/(?<secure>[\w\-=]+,\d+),(?<user>[^/]+)(?<file>/.*)$ { } An example file URL causing the error because it has # symbol in it. (DVD-ISO)/Ubuntu-12-04.iso
You need to change `#` to `%23` in url: (DVD-ISO)/Ubuntu-12-04.iso Here is complete list of URL Escape Characters
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "regex, nginx" }
Test to see if a listbox item is selected I have a form that loads 3 pre-defined scores in a list box. I want to convert a selected score into a string, and then output that string in a textbox. So far i think i've converted the item to a string, and tried setting it to the textbox but it doesn't seem to be working. private void frmStudentScores_Load(object sender, EventArgs e) { lstStudents.Items.Clear(); lstStudents.Items.Add("Joe Smith|93|92|98"); lstStudents.Items.Add("Mike Jones|56|61|33"); lstStudents.Items.Add("Rita Jackson|100|89|96"); lstStudents.SelectedIndex = 0; if (this.lstStudents.SelectedIndex >= 0) { string a = lstStudents.Items.Cast<string>().ToString(); txtDisplay.Text = a; } btnUpdate.Enabled = false;
Assuming your question is about Windows Forms, One way to get the selected item is to use code like this: txtDisplay.Text =lstStudents.SelectedItem.ToString(); It is common to want to get the selected item that the user has selected, to do this, you need to place the above code in an event to look like this for example: private void lstStudents_SelectedIndexChanged(object sender, EventArgs e) { txtDisplay.Text = this.lstStudents.SelectedItem.ToString(); } An event can be wired to the control either by code or via the VS IDE, you can't just copy and paste the above code. Ask me if you don't know how to do that. If you want to grab the first item only, then Plutonix comment above applies. You don't need the IF statement.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#" }
Need help trying to EagerLoad some data in EntityFramework I'm trying to do some eager loading on an EF Entity. so, if the entity is called `Orders` .. then I guess i would do the following... `_someContext.Orders.Include("Whatever") ....` But the problem is, I have a method like the following ... public IQueryable<Order> Find(Expression<Func<Order, bool>> predicate) { return CurrentContext.Orders.Where(predicate); } which works great .. but can i leverage the `Expression` predicate to include the `Include("whatever")` in there, instead of having to add another method parameter?
I don't think so. Since the predicate and **ObjectQuery.Where Method** in genral has nothing to do with eager loading by Include. You can create a extension method though, but that does not save you from having yet another parameter for specifying the include: public IQueryable<Order> Find(Expression<Func> predicate, string include) { return CurrentContext.Orders.Where(predicate, include); } public static ObjectQuery<T> Where<T>(this ObjectQuery<T> entity, Expression<Func<T, bool>> predicate, string include) { return (ObjectQuery<T>)entity.Include(include).Where<T>(predicate); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "linq, entity framework, lambda, expression, predicate" }
How to debug protractor in Intellij? In OSX, I have configured an Intellij 15 run/debug task as in this question: How to debug angular protractor tests in WebStorm It runs ok but debug doesn't work. It throws: /usr/local/bin/node --debug-brk=60144 --nolazy /usr/local/lib/node_modules/protractor/lib/cli.js /Users/XXXX/Workspace/frontend-test/config.js Debugger listening on port 60144 Using the selenium server at [launcher] Running 1 instances of WebDriver Process finished with exit code 139 Any idea? Thanks in advance.
Got it! Just add `--harmony` parameter to "Node parameters" in the Run/Debug Configuration window.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "angularjs, intellij idea, protractor" }
DataSources folder in MVC? Is it possible to access to the "DataSources" window in Visual studio in an MVC project? We are trying to use Report Viewer in our MVC project. Tutorials for setting it up use the DataSources window, but I think this is just a WebForms project feature. Can anyone confirm that that is the case?
DataSources are not supported (and do not work) in MVC.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "asp.net mvc, reporting services, reportviewer" }
create data.table column based on content of strings in other columns in r I'm working/wrangling/cursing with data similar to these: names <- data.table(namesID = 1:3, fullName = c("bob so", "larry po", "sam ho")) trips <- data.table(tripsID = 1:3, tripNames= c("Mexico", "Alaska", "New Jersey"), tripMembers = c("bob so|larry po|sam ho","bob so|sam ho", "bob so|larry po") ) I want to create a new table like this, taking the tripMembers, and connecting the correct nameID to the correct tripID and tripName. I guess this is a join (tried many joins)? namesTrips tripsID tripNames namesID 1 "Mexico" 1 1 "Mexico" 2 1 "Mexico" 3 2 "Alaska" 1 2 "Alaska" 3 3 "New Jersey" 1 3 "New Jersey" 2
You can do something like this: # split the tripMembers column and unnest it; then join with names on the tripMembers namesTrips <- trips[, .(tripMembers = unlist(strsplit(tripMembers, "\\|"))), by = .(tripsID, tripNames)][names, on = .(tripMembers = fullName)] namesTrips[, tripMembers := NULL][order(tripsID)] # tripsID tripNames namesID #1: 1 Mexico 1 #2: 1 Mexico 2 #3: 1 Mexico 3 #4: 2 Alaska 1 #5: 2 Alaska 3 #6: 3 New Jersey 1 #7: 3 New Jersey 2
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "r, data.table" }
Bash: Merge foldername from variable with filename First I write a configfile with all my parameters like this path="/home/test/" I name it `test.conf`. Then I write a shell script with this content, name it `test`, and make it executable with `chmod +x`. #!/bin/bash #read the config file . /home/test/test.conf #cat the file /home/test/test cat `$path`test #This line is the problem I get this output ./test/test: line 3: /home/test/: Is a directory cat: test: No such file or directory What I would like is that it shows me the content of the file `/home/test/test`. How do I write this script correctly, so that it doesn't make a new line after the file path?
```` and `$()` is used for command execution, not for substituting it for variable content. So bash tries to execute varaible meaning in ```` and returns the error that it is a directory. Just write `cat ${path}test` and it will work in the way you want. For more information read about bash variables and command substitution.
stackexchange-unix
{ "answer_score": 13, "question_score": 5, "tags": "bash, shell script, quoting, command substitution" }
Do AppIndicators work on Xubuntu? I don't have access to an Xubuntu install right now so I thought I'd just ask this here. Does Xubuntu (or more specifically, the XFCE panel) support AppIndicators? I'm porting an application to use them and I am curious to know if my app will work there.
It should definitely be possible because the indicators are made to be cross-platform. It appears that someone has developed an xfce panel applet to do provide this functionality: < It doesn't seem very mature though - its at version 0.0.1, which is the first stable release. It is not packaged but is available as source code.
stackexchange-askubuntu
{ "answer_score": 4, "question_score": 8, "tags": "indicator, xubuntu" }
Ruby scopes: Diference between MyClass.new and ::MyClass.new I know that the double colon (::) is basically a namespace resolution operator. But in this particular case, I'm not sure in which scope I'm working. Does it mean that I want MyClass class from the ruby core? Sort of like ~ means home directory in bash..
Imagine the following code: class A def a puts 'TOPMOST' end end module B class A def a puts 'NESTED' end end def self.topmost ::A.new.a end def self.nested A.new.a end end `B.topmost` will print `"TOPMOST"`, and `B.nested` will print `"NESTED"`. So, `::A` means not “from ruby core”, but rather “from no module.”
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "ruby, scope" }
How Do I Hide wpf datagrid row selector I'm using the WPF DataGrid control to show some details and a select button, and I don't need the gray selector column down the left-hand side. It's also ruining the beauty of my design. Is there a way to remove it, or how can I style it to match if not?
Use the `RowHeaderWidth` property: <my:DataGrid RowHeaderWidth="0" AutoGenerateColumns="False" Name="dataGrid1" /> Note that you can also specify a style or template for it also, should you decide you really do like it and want to keep it because you can do something cool with it.
stackexchange-stackoverflow
{ "answer_score": 162, "question_score": 117, "tags": "wpf, wpfdatagrid" }
Micro-graphics in caption environment I am using my own icons in a document using `\newcommand{\icon}{\includegraphics[scale=0.2]{myicon.pdf}}` as described in this post. Now I am trying to use this newcommand in a caption environment, but I get errors ! Argument of \@caption has an extra }. ! Paragraph ended before \@caption was complete. Is there any way to add figures to the caption environment? or any suggested workaround to this? * * * Minimal example \documentclass{article} \usepackage{graphicx} \newcommand{\icon}{\includegraphics[scale=0.2]{myicon.pdf}} \begin{document} This is an inline \icon % this part compiles good \begin{figure} \includegraphics[width=\linewidth]{myfigure} \caption{This is an \icon in a caption environment.} % this part gives errors \end{figure} \end{document}
In recent releases `\includegraphics` is robust so should not prematurely expand when writing the `.toc` file, but in any release you could define your command via \DeclareRobustCommand{\myicon}{\includegraphics[scale=0.2]{myicon.pdf}} then it will not expand in moving environments. Unrelated you may prefer to use something like `height=1.1ex` rather than `scale=0.2` then the icon will adjust to font size commands such as `\large`.
stackexchange-tex
{ "answer_score": 2, "question_score": 0, "tags": "captions" }
Average Number Of Factors What is the average number of factors of 2 for all numbers up to some arbitrarily large $k$ as $k$ goes to infinity? What about factors of 3 up to $k$ ? 5? My intuition tells me that it should be 1 factor of 2 as $k$ goes to infinity, because half of the numbers have no factor of 2, $\frac{1}{4}$ have two factors of 2, $\frac{1}{8}$ have three factors of 2, et cetera, and I think this deficit goes to zero in the limit, but I don't know how to prove it. For the others, I don't really know what the analogue to the thought process I describe above is.
You seem to be looking for this limit: $$\lim_{k \to \infty} \dfrac{\displaystyle \sum_{n=1}^\infty \left\lfloor \dfrac{k}{p^n} \right\rfloor }{k}$$ To calculate this, it suffices to look at values of $k=p^m$ for some arbitrarily large $m$. This gives $$\lim_{m \to \infty} \dfrac{\displaystyle \sum_{n=0}^{m-1}p^n}{p^m} = \lim_{m \to \infty} \dfrac{\left( \dfrac{p^m-1}{p-1} \right)}{p^m} = \dfrac{1}{p-1}$$
stackexchange-math
{ "answer_score": 4, "question_score": 2, "tags": "elementary number theory, prime numbers, prime factorization" }
javascript-how to open window (from hyperlink) and then close it with delay of 5 sec? I am trying to open new window from hyperlink using java script and then auto close it in five seconds. It either closes right away or doesn't close at all. Here are some samples of code I was using: "function closeOnLoad(myLink){var newWindow=window.open(myLink);newWindow.onload=SetTimeout(newWindow.close(),5000);}" + LinkText + ""
You're better off closing the window from the parent instead of defining an onload handler within the child. Due to security restrictions, you simply may not have access to modify child window events. function closeOnLoad(myLink) { var newWindow = window.open(myLink); setTimeout( function() { newWindow.close(); }, 5000 ); }; }
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 2, "tags": "javascript" }
Index documentation url with ELK stack I want to load below documentation using logstash to do indexing it with elastic search: < Currently,I am able to index all the logs with elasticsearch,but I am not sure how to index documentation with a url. Is this scenario is valid with logstash,if yes,please help me on this.
You could give it a go by using the http poller plugin which was released recently, within your _logstash_ config itself. The `input` could look something like this: input { http_poller { urls => { myurl=> " } } request_timeout => 60 interval => 60 codec => "json" <--- to decode the results to json } } The above is just a sample so that you could reproduce. Hope this helps!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "elasticsearch, logstash, kibana, logstash grok, logstash configuration" }
Finding the hypotenuse I have the question "The force vectors in the following diagrams are all coplanar but not drawn to scale. Use appropriate trigonometry to answer the following questions. Calculate the resultant force on the following objects and the acceleration it produces." !enter image description here For this I have made a triangle and have used Pythagoras to find the length of the hypotenuse R. The answer is get for this is: !enter image description here However, the solutions say that the answer for the length R should be 4.2 N. I do not understand how This is achieved.
First combine two horizontal forces. As they are in opposite direction. So you got 3 N as resultant force. Now, $\sqrt{(3)^2 + (3)^2} = \sqrt{18}$ = 4.24 N
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "algebra precalculus, trigonometry, euclidean geometry, classical mechanics" }
Inserting table from one table to another, and adding values are specified I need to insert value in a table, extracted from another table, but some values are specified by me, and therefore not from another table. INSERT INTO Person (age) SELECT age FROM AnotherPerson; Now let's pretend that I want to add another data in another column in the person table, and this data is not extracted from the other table. So what I'm thinking, is something like this: INSERT INTO Person (age, name) VALUES (SELECT age FROM AnotherPerson, 'Peter'); The above code is just an example I came up with, so I'm can stay with the relevant aspect. I was thinking that I could insert the data separately, which would work, since this syntax: INSERT INTO Person (age, name) VALUES (SELECT age FROM AnotherPerson, 'Peter'); doesn't work. But what if all the ecolumns of the Person table must be not null? How can I do this?
INSERT INTO Person (age, name) SELECT age, 'Peter' FROM AnotherPerson
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "sql, oracle" }
How do URL's work for files I'm using Parse to download my PFFiles for my videos and images on my backend. However after i get the file url from the PFFile, it takes forever to load. Why is this? Does using a file url mean you are essentially downloading the data? Like the PFFile was just a network pointer to the actual image/videos? NSURL *fileUrl = [NSURL URLWithString:scene.file.url]; AVAsset *asset1 = [AVAsset assetWithURL:fileUrl]; AVPlayerItem *item = [[AVPlayerItem alloc] initWithAsset:asset1]; [QPlayer insertItem:item afterItem:nil]; If this is true, Would a NSURLCache allow me to save THAT DATA locally without having to say go to this server via this url to get THAT DATA? Essentially I'm asking am I downloading this twice - the PFFILE then the data its contents point to? And if so would an NSCache allow me to only do the second download once? Thanks! I'm trying to really get the conceptual understanding of networking.
The OP code as presented does just one synchronous download. But if it got the `scene` object from parse just before, then there are two network operations, both necessary, as you point out. You can cache whatever you wish in an NSCache. The file download is probably slow because the file is large. And it must feel very slow because the synchronous operation -- if done on the main -- blocks the UI.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "objective c, url, networking, parse platform, pffile" }
Why are manufacturers allowed to make false claims about memory capacity of thumbdrives? I have a number of thumb drives and hard drives. One hard drive I bought was said to be 2TB but its actual capacity is about 1.8 TB. A couple of thumb drives I got say they are 16 GB but on the back say: > 1MB = 1,000,000 bytes / > 1GB = 1,000,000,000 bytes This definition is the reason why I've accepted the false advertising on hard drive space, even though conventionally: 1KB = 1024 bytes 1MB = 1024x1024 bytes 1GB = 1024x1024x1024 bytes and not 1KB = 1000 bytes 1MB = 1000x1000 bytes 1GB = 1000x1000x1000 bytes As we get to higher levels the amount of space that is lost by this rounding down increases. But isn't this still false advertising? E.g., in Australia could I get a refund as I was misled in the believe that a thumb/hard drive had the higher capacity?
It's not the manufacturers who are wrong. _Your_ definitions of KB, MB, and GB are incorrect. See, for example, NIST. The numbers they are using are not "rounded down," they are the proper standardized definitions of those terms. 1024 bytes is properly termed a _kibibyte_ (or KiB), not a kilobyte. 1024 kibibytes is a _mebibyte_ , MiB. 1024 mebibytes is a _gibibyte_ , GiB. These are defined in an international standard, IEC 80000-13 (part of the ISO series of standards defining units); "kilobyte" refers to 1000 bytes, "megabyte" to 1000000, and "gigabyte" to 1000000000. It's not lying to use units correctly, and that's what the manufacturers are doing.
stackexchange-law
{ "answer_score": 13, "question_score": 0, "tags": "advertisements" }
Avoid printing attributes of the nil object in Rails Currently, when I'm wanting to print a value for my class I do the following... <%= @person.team.name if @person.team.present? %> This seems really redundant to me. I've also have done... <%= @person.team.name_display %> where I've created a function for each attribute to kind of hide the first case. It seems a little much though. Is there a more preferred way to do it such as... <%= @person.team.name || "" %>
You are right, you code is too verbose. This is a pretty common pattern and you have some alternatives. For example, _active_support_ has the abstraction `Object#try`: <%= @person.team.try(:name) %> Another alternative is the `Object#maybe` proxy: < <%= @person.team.maybe.name %>
stackexchange-codereview
{ "answer_score": 7, "question_score": 7, "tags": "ruby, ruby on rails, null, erb" }
Declare table as not replicable How can I make sure that a certain table is not selected as an article in a publication? So that this table is never replicated (even by error). The replication for the database is setup by different people and one particular table should never be included in the replication. Can we make that table non selectable in the publication wizard (the step where the articles are added to the publication) or is there any way we can use the database schema to define that this table is not available as article in a publication? Type of replication used: merge replication Thanks!
The only way I know to do that is to leverage this limitation: > Tables published for transactional replication must have a primary key. Publish Data and Database Objects So replace the table's primary key with a unique clustered index called `pk_MyTable_PreventReplication` or somesuch. Merge replication requires a special ROWGUIDCOL column on the table, which you can prevent with security or a DDL trigger.
stackexchange-dba
{ "answer_score": 0, "question_score": 2, "tags": "sql server, replication, merge replication" }
Can you map the open unit disk conformally onto $\{ z: 0 < |z| < 1 \}$? I only find that is not possible from the punctured disk to the unit disk, but in the other direction is possible or not ? If not, counter example, if yes please provide the mapping. This is problem 15 from section 3 chapter 3, functions of complex variables Conway book.
$\textbf{Solution:}$ Let $D = \\{z \in \mathbb{C}: |z| < 1 \\}$ and $D^{*} = \\{z \in \mathbb{C}: 0 < |z| < 1 \\}$. Consider the Mobius transformation that takes $D$ to the right half plane $ z_1 = \displaystyle\frac{1 + z}{1 - z} $ then by a rotation, we can obtain the left half plane $ z_2 = -z_1 $ Finally, the left half plane can be mapped conformally to $D^{*}$ by the exponential transformation $ z_3 = e^{z_2} $ Hence, the desired conformal map is $f: D \to D^{*}$ $ \boxed{ f(z) = \exp\\{-\displaystyle\frac{1+z}{1 - z}\\} } $
stackexchange-math
{ "answer_score": 4, "question_score": 4, "tags": "complex analysis, conformal geometry, analytic functions" }
Is it ok to use the original-source meta tag for pages that are not news I am building an online shop for selling products manufactured by others. Should I use the `original-source` meta tag to give credit for the product (or product info) to the original manufacturer or is this tag intended to be used only for news ?
I don't think it's ok. It seems to be really related to Google News. And I don't think your content to be listed in Google News since it's an online shop. In the presentation article, Google describe `original-source` meta tag as _a metatag for Google News_. Also, regarding the help center article, it clearly identify these tags to _highlight standout journalism on the web_.
stackexchange-webmasters
{ "answer_score": 1, "question_score": 1, "tags": "seo, meta tags" }
Android Studio drawable folders In Android Studio, I can't figure out where to put images to be used inside the app. The drawable folder isn't broken down into drawable-hdpi, drawable-ldpi, etc. I saw another question asking this and the answer was to switch to Project view instead of Android view but drawable is only one folder there too. There is mipmap-hdpi, mipmap-ldpi, etc, but people are saying that's only for app icons. I'm confused.
If you don't see a drawable folder for the DPI that you need, you can create it yourself. There's nothing magical about it; it's just a folder which needs to have the correct name.
stackexchange-stackoverflow
{ "answer_score": 47, "question_score": 73, "tags": "android, android studio, android drawable" }
SP 2016 with March CU stating Application with Search is not compliant The minrole feature is supposedly supported, but is not reflecting such.
[SOLVED] - Thanks to Trevor Seward I had intentionally installed the Foundation Web Application on the WFE and not the APP, thinking it was correct since the APP should not serve pages, but apparently there are situations and reasons that it is needed on the APP server. I followed < to provision the service and then the missing web applications. The Provision() method can be invoked to only provision on the server that invoked it, instead of needing to use ProvisionGlobally().
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 0, "tags": "minrole" }
PHP imagick gif to jpg - background I've this gif: (transparent background) And with this code: $im = new Imagick(); $im->readimage("example.gif"); $im->setImageAlphaChannel(11); $im->setImageBackgroundColor('white'); $im->setImageFormat("jpg"); $im->stripImage(); $im->writeImage("example.jpg"); $im->clear(); $im->destroy(); Results: https*://dl.dropboxusercontent.com/u/76885657/stackoverflow/3.jpg(without *) (gold background) But want this: (white background)
I've found it. Was the order!: $im = new Imagick(); $im->readimage("example.gif"); // Wrong $im->setImageBackgroundColor('white'); $im->setImageAlphaChannel(11); // Write!!! $im->setImageAlphaChannel(11); $im->setImageBackgroundColor('white'); // Rest of code... $im->setImageFormat("jpg"); $im->stripImage(); $im->writeImage("example.jpg"); $im->clear(); $im->destroy();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, jpeg, gif, imagick, alpha transparency" }
How can I find the new match position converting an Unicode String to a Byte String? I know I can convert an UnicodeString to a ByteString and vice versa using these commands: UnicodeStr = ByteStr.decode(encoding='UTF-8') ByteStr = UnicodeStr.encode(encoding='UTF-8') UTF-8 is multibyte character encoding. Characters can have 1 to 4 bytes, the position of a match changes converting from UnicodeStr to ByteStr. This is not a big problem using english text characters but it is using characters in the French, German, Spanish or Dutch language. p.e.: UnicodeStr = "Ça te changera les idées John!" (=That’ll take your mind off things John!) The match position of the word "idées" is: p=re.compile("idées") for m in p.finditer(UnicodeStr): print(m.span()) \--> (19, 24) How can I find the new match position converting a UnicodeStr to ByteStr?
Maybe by converting the pattern: p=re.compile("idées".encode(encoding='UTF-8')) for m in p.finditer(ByteStr): print(m.span()) (20, 25)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, regex, python 3.x, pattern matching" }
Pick which browser window to open a new tab in Typically when creating the markup for `anchor` tags in HTML, you can set a `target` attribute on the DOM node to specify how this link should open when clicked—in a new tab, in the current tab, etc. Let's say, for example, I have two Chrome windows open. `Window A` is on my left on its own monitor, and `window B` is to my right, also on its own monitor. I have a custom `new tab` page that allows me quick access to links I visit the most frequently. It also has a big clock so I always know what time it is while I'm writing code. These links currently only open in a new tab in the same window. Is it possible then to click a link in `window A`, and have it open as a new tab in `window B` so that I still have unobstructed access to my custom new tab page?
No. ("Browser context" refers to a viewport with associated gubbins, typically a tab or window depending on the browser and OS). You can: * Open in an existing, named, browser context * Open in a new, named or unnamed, browser content The most control over where and what that context is, is to use JavaScript's `open()` method to specify the height and width, which will trigger a new window instead of a new tab in most desktop browsers. There is no way to override the user preference to trigger a new tab instead of a new window. There is no way to determine where a new tab will appear.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, html" }
How do I turn on the Steam Link without a Steam Controller? I have a PS4 controller connected to my Steam Link. If I choose "turn off" from the Steam Link menu options, how do I, uh, turn it back on? Is unplugging it and plugging it back in seriously the only option? With a Steam Controller you can hit the big button in the center of the controller, but that doesn't seem to work with a PS4 controller.
As of several updates ago, turning on the Steam Link now works correctly with a wireless PS4 controller.
stackexchange-gaming
{ "answer_score": 4, "question_score": 17, "tags": "steam link" }
How to get modification time for a file (in UNIX TIME!) on AIX? $ istat TESTFILE.txt Inode 2317 on device 12/7 File Protection: rw------- Owner: 4847(testuser) Group: 346(testuser) Link count: 1 Length 1480 bytes Last updated: Sun Jun 15 08:20:17 2014 Last modified: Sun Jun 15 08:20:17 2014 Last accessed: Sun Jun 15 13:03:37 2014 $ istat doesn't know any format for UNIX TIME on AIX? **My question:** How can I display the modification time for a file in UNIX TIME format on AIX?
You can use `perl`: $ perl -le 'print((stat shift)[9])' test.txt 1402577190 Or `GNU date`: $ date -r test.txt +%s You can install `GNU date` on `AIX` refer to this link.
stackexchange-unix
{ "answer_score": 11, "question_score": 4, "tags": "date, aix" }
Datatables Tabletools print mode shows all data. In need of only what was previously displayed I made Tabletools to work, although I am struggling with the print mode. Once the button is hit, the print mode is run correctly, only displaying the records shown previously. Within a second, the rest of the data is also shown. Has anyone encountered the same issue? Is it possible that my jQuery code is triggering this action? Thanks in advance.
Nevermind guys, I have just found my answer in the functionality site. $(document).ready( function () { $('#example').dataTable( { "sDom": 'T<"clear">lfrtip', "oTableTools": { "aButtons": [ { "sExtends": "print", "bShowAll": false } ] } } ); } );
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, datatables, tabletools" }
Command to open pdf files in bash scripting could anybody suggest me any simple linux command to open pdf files(text only) on command line. If we are able to pass the password as an argument to the command that would be more appreciated. I am trying to build a script that iterates all the possible 4 character passwords, to crack password of a password protected pdf file. Thanks in Advance Harsha
If your goal is to open the pdf into a terminal, you can use Zathura, but it requires X11 anyway! You can't see a pdf without a properly installed graphical interface. If you want to open a pdf into another window, you can simply call an external program like **evince** ; in this case, you simply use the terminal to choose the pdf to open and nothing more. EDIT: I found this link, I think this could solve your problem!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "linux, bash, unix, pdf, ubuntu" }
gcd(2a+1, 9a+4) = 1 The question is from Burton's Elementary Number Theory. I want to know if my proof is legible. Proof : Let $$d=gcd(2a+1, 9a+4)$$ Then $$d|2a+1$$ and $$d|9a+4$$ $$2a+1=db$$ and $$9a+4=dc$$ $$ a = \frac{db-1}{2}$$and$$a= \frac{dc-4}{9}$$ Equating both equations : $$ 9db-9=2dc-8 $$ $$ d(9b-2c) = 1 $$ $$ 9b-2c = \frac{1}{d}$$ Now, since b and c are integers, therefore $\frac{1}{d}$ is an integer, i.e d divides 1 and therefore $$gcd(a, b)= d = 1$$.
Seems fine. Alternatively, $$9a+4=4(2a+1)+a$$ $$2a+1=2(a)+1$$ Hence, $$1=(2a+1)-2a=(2a+1)-2(9a+4)+8=9(2a+1)-2(9a+4)$$ That is the greatest common divisor of $2a+1$ and $9a+4$ must divide $1$. Hence the greatest common divisor is $1$.
stackexchange-math
{ "answer_score": 0, "question_score": 3, "tags": "proof verification" }