INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Power set of $\{\{\varnothing\}\}$ $$\mathcal{P}(x)=\\{y\mid y\subseteq x\\}$$ $$\mathcal{P}(\varnothing)=\\{\varnothing\\}$$ $$\mathcal{P}(\\{\varnothing\\})=\\{\varnothing,\\{\varnothing\\}\\}$$ $$\mathcal{P}(\\{a,b\\})=\\{\varnothing,\\{a\\},\\{b\\},\\{a,b\\}\\}$$ For $\mathcal{P}(\\{\\{\varnothing\\}\\})$ we have: $$\varnothing\subseteq\\{\\{\varnothing\\}\\}$$ $$\\{\varnothing\\}\subseteq\\{\\{\varnothing\\}\\}\text{ and}$$ $$\\{\\{\varnothing\\}\\}\subseteq\\{\\{\varnothing\\}\\}$$ Therefore $\mathcal{P}(\\{\\{\varnothing\\}\\})=\\{\varnothing,\\{\varnothing\\},\\{\\{\varnothing\\}\\}\\}$ Is this answer correct? Unsure with this topic, just need some verification, thanks.
This one $$\\{\varnothing\\}\subseteq\\{\\{\varnothing\\}\\}$$ is incorrect. $A\subseteq B$ means that for every $x\in A$ it is true that $x\in B$. $\\{\varnothing\\}$ contains one element: $\varnothing$, but $\\{\\{\varnothing\\}\\}$ doen not contain $\varnothing$ so $$\\{\varnothing\\}\not\subseteq\\{\\{\varnothing\\}\\}$$ The other two are correct. $$\mathcal{P}(\\{\\{\varnothing\\}\\})=\\{\varnothing,\\{\\{\varnothing\\}\\}\\}$$ And as always: power set of set which contains one element contains two elements.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "elementary set theory, definition" }
Point in polygon algortim using location class in android? I've a a set of location that forms a closed path (similar to polygon). Is there any possible way to check if a certain latitude and longitude is inside the closed path?
You need a ray-casting algorithm. Good for you that someone already did this: ;-) Point in Polygon Algorithm And for a little background knowledge: <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "android, point in polygon" }
jquery dynamic form elements for spring form binding I am facing issues with dynamically binding spring form elements in JSP using jquery. I am trying to add dynamic rows to a table which has different form elements. Demo: < Issue here is newly added form elements are havng id's & name attribute as "userName[0]1" instead of "userName[1]" hence they are not getting binded to spring form. I am using a AbstractWizardController and trying to binding Dynamic list of User's on Step1 and then using them in Step2. Is their a way to systematically clone the form elements like dropdown, checkbox and text. Can someone guide me on using this correctly.
pass true while cloning the element will copy all event with the cloned element. from < > .clone( [withDataAndEvents] ) withDataAndEventsA Boolean indicating whether event handlers should be copied along with the elements. As of jQuery 1.4, element data will be copied as well. Replacing integer value of id: id.replace(/\[\d*\]$/, "["+ i +"]")// will replace 'userName[0]' with userName[{i}]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jquery, spring, spring mvc, spring2.x" }
Understanding a proof conceptually Let's assume that $V$ and $W$ are vector spaces over a field $\mathbb{K}$, $\lambda\in\mathbb{K}$, $\lambda\neq0$. $S: V\rightarrow W$ and $T: W\rightarrow V$ are linear maps. Prove, that $\lambda$ is an eigenvalue of $TS\iff\lambda$ is an eigenvalue of $ST$ What can be stated about the eigenvalues of the maps $TS$ and $ST$? Would it also be correct if $\lambda=0$? Proof: 1. $\lambda$ is an eigenvalue of $TS\Rightarrow\lambda$ is an eigenvalue of $ST$ $TSv=\lambda v$ that is $S(TSv)=S(\lambda v)$ that is $ST(Sv)=\lambda (Sv)$ 2. $\lambda$ is an eigenvalue of $ST\Rightarrow\lambda$ is an eigenvalue of $TS$ $STw=\lambda w$ that is $T(STw)=T(\lambda w)$ that is $TS(Tw)=\lambda (Tw)$ I do not understand why the statement is proven by finding two eigenvectors. What would happen if we couldn't construct $Sv$ out of $v$ and $Tw$ out of $w$? I also don't understand how to answer the latter two questions.
That $\lambda$ is an eigenvalue for $T$ means that there is some vector $v$ such that $Tv = \lambda v$. So you have that if $\lambda$ is an eigenvalue for $ST$, then there is some vector (it doesn't matter what it is) $v$ such that $(ST)v = \lambda v$. You then show that there is some other vector (it doesn't matter what it is) $w$ such that $(TS)w = \lambda w$. Hence $\lambda$ is, by definition, and eigenvalue for $TS$. So, you have that if all eigenvalues for $ST$ are also eigenvalues for $TS$. Likewise you have the other way around by the same argument. Hence it is impossible to have an eigenvalue for one that isn't also an eigenvalue for the other. That means they have the same eigenvalues. Note the proof works even if $\lambda =0$.
stackexchange-math
{ "answer_score": 2, "question_score": 3, "tags": "linear algebra, proof writing, eigenvalues eigenvectors" }
Entity Framework: how to annotate two one-to-one relationships to same table In a punch clock application, a given day has two foreign keys into the Punches table: PunchId_In and PunchId_Out. How can you annotate this relationship so Entity Framework creates it as intended? Note: One or both of these foreign keys may be undefined (null). public class Day { public int DayID { get; set; } public int? PunchId_In { get; set; } public int? PunchId_Out { get; set; } public virtual Punch PunchIn { get; set; } public virtual Punch PunchOut { get; set; } } public class Punch { public int PunchID { get; set; } public DateTime PunchDT { get; set; } } TIA
You need to indicate which foreign key matches each navigation property. public class Day { public int DayID { get; set; } public int? PunchId_In { get; set; } public int? PunchId_Out { get; set; } [ForeignKey("PunchId_In")] public virtual Punch PunchIn { get; set; } [ForeignKey("PunchId_Out ")] public virtual Punch PunchOut { get; set; } } <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "entity framework" }
Directory directive for directory outside doc root - best practice I have a virtual host which has access to a directory outside of its document root. In the config for this host I specify the directory directive to allow access to this directory. <Directory /path/to/shared/> Options -Indexes AllowOverride All Order allow,deny allow from all </Directory> The kind of files in this directory are things like images, ssi, facebook apps and some php scripts. My question is, is this directive secure enough or do i need to add anything else? Also, what is the ideal permissions for /shared Thanks in anticipation
From the webserver's perspective it is fine. Next step would be to check the directory permissions and set them accordingly (restrict access to it for the webserver process owner). **Update** : Not sure if you really need `AllowOverride All` as this can hit you in the face with a .htaccess-file inside the directory. I'd suggest you read up here to figure out what you really need. If you don't need .htaccess at all, just set it to `AllowOverride None`
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "apache 2.2, security, permissions, virtualhost, httpd.conf" }
Google news sitemap syntax I have submitted Google news sitemap for my website using Xmap component of Joomla, i got the notification today as follow **Your Sitemap is on a site that is not in the Google News database. Google News can only accept Sitemaps from sites that we crawl. If your site is crawled by Google News, please check that the URL of your Sitemap agrees with the URLs of your articles as they appear on Google News, including any leading "www". If you would like to request inclusion of your site in Google News, please contact the Google News support team.** Here is my sitemap: Any Joomla expert can tell me, how they submit their google news sitemap or whats wrong in my sitemap.
A News Sitemap will only be accepted from sites that were reviewed by the Google News team and included in the Google News database. Since you got that warning, I believe your site is simply not in that database. If you're publishing news content, being that breaking news or editorials, you can suggest your site for inclusion at
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "joomla, sitemap, google news" }
Does the person get notification if I edit my comment and add @hisname in it? > **Possible Duplicate:** > Will edited comments reach addressees? > How do comment @replies work? I sometimes forget to add the _@hisname_ in a comment, so I edit and put it there. Will he be notified after my edits?
Yes, the user will be notified.
stackexchange-meta
{ "answer_score": 12, "question_score": 11, "tags": "discussion, comments, edits" }
What to do with Tag Wiki excerpts that love their subject a bit much? I have seen several tag Wiki edits in the edit queue that are _very_ enthusiastic in tone bordering advertising, and usually don't add real value to the Wiki. A random example that I just saw in the queue (relatively harmless compared to others I've seen, but I didn't write those down, and I'm too lazy to do the research right now): WordPress Now this is well-intentioned, and not really _harmful_ as such. Maybe I'm being too harsh altogether, but I'm not thrilled about project-and product-related tag wikis becoming a billboard for fans. I would like to see some Wikipedia-Style neutrality here. Are there any guidelines for this? All I can see on Meta is more general stuff like this list of tips.
Simple. If it feels to you like it is "selling" something and not concisely describing the tag with critical information. ### Edit It An edit that improves an excerpt will most likely be approved, additionally the widening of the group of people with full tag wiki rights means that we can get a better objective view.
stackexchange-meta
{ "answer_score": 6, "question_score": 7, "tags": "discussion, tag wiki" }
Accessibility of data using different APIs Can I access the same data using different APIs? Example: Can I insert the data using YCQL and read it using YEDIS?
Short answer is No. Even though the APIs share a common distributed document store, the data modeling and query constructs offered are significantly different. This means that the data inserted or managed by one API cannot be queried by the other API. More on this in the Note here: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "database, distributed database, yugabytedb" }
dynamic content - where do i start? I have a rather simple question. I want to dynamically change the content of a based on the selection of a drop down menu. The drop down menu is populated by a php loop that gets data from a mysql database. So far, I'm only familiar with php and html/css. I don't really know where to start, or more specifically, what technologies I should be researching. So far, I've heard AJAX, JQuery, JavaScript, NOLOH, HTML iframes, pure CSS, etc. I really just want to know where to look!
Start off with the basics: HTML (if you're feeling adventurous, you could try HTML5) and CSS. After your comfortable with that, you can start getting a little more complex and pick up JavaScript. This is how the majority of the 'dynamic' bits of web pages are accomplished so learn it well. Once you've got the JavaScript basics down, you can learn how to use JavaScript to manipulate the DOM (Document Object Model) and make AJAX requests back to the server to get new content to insert.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "dynamic, html" }
Strange loop on Java for 0.1 to 2 I tried to loop from 0.1 to 2.0 and then print the output to the console.. But I got strange output like these: 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.7999999999999999 0.8999999999999999 0.9999999999999999 1.0999999999999999 1.2 1.3 1.4000000000000001 1.5000000000000002 1.6000000000000003 1.7000000000000004 1.8000000000000005 1.9000000000000006 2.0000000000000004 Source code: public class test { public static void main(String[] a) { double i = 0.1; while (i < 2.1) System.out.println(i); i+=0.1; } } } Why it doesn't this print the exact numbers instead of having point like `0.79999999999`? Also is ther any difference using `for` instead of `while`, since I dont know how to make 0.1 increment?
This is normal. It's inherent in floating point; numbers like 0.3 can't be stored as exact values in binary, so you get slowly accumulating errors. References: Python manual, Wikipedia, Technical explanation from Princeton CS.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "java, loops, while loop" }
Cannot find method createNotificationChannel(NotificationChannel) I'm trying to handle notification with Android Oreo (SDK 27). Here is my code creating the NotificationChannel: NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // .. building mChannel, the NotificationChannel instance notificationManager.createNotificationChannel(mChannel); Android Studio tells this Error:(67, 32) error: cannot find symbol method createNotificationChannel(NotificationChannel) I've a dependency on support-compat:27.0.0 set into my core/build.gradle file: compile 'com.android.support:support-compat:27.0.0'
There is no `createNotificationChannel()` method on `NotificationManagerCompat`. You have to use the native `NotificationManager` for that. **UPDATE 2019-07-29** : As Onkar Nene points out, they finally added `createNotificationChannel()` on `NotificationManagerCompat`. Use `androidx.appcompat:appcompat:1.1.0-rc01` or newer.
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 9, "tags": "android" }
Assert an Exception is Thrown in I have this Junit test in my project public class CalculatorBookingTest { private CalculatorBooking calculatorBooking; @Rule public ExpectedException expectedException = ExpectedException.none(); @Before public void setUp() { calculatorBooking = new CalculatorBooking(); } @Test public void shouldThrowAnException_When_InputIsNull() { calculatorBooking.calculate(null, null, 0, null); expectedException.expect(CalculationEngineException.class); expectedException.expectMessage("Error"); } } but when I run the test, the Exception is Thrown but nevertheless the test fail
You need to first tell JUnit that the method is expected to throw the exception. Then when it's thrown - it knows that the test passes. In your code you put `expect()` after the exception is thrown - so the execution doesn't even go that far. The right way: @Test public void shouldThrowAnException_When_InputIsNull() { expectedException.expect(CalculationEngineException.class); expectedException.expectMessage("Error"); calculatorBooking.calculate(null, null, 0, null); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, unit testing, testing, junit, junit4" }
How to fill a pandas df with rows for values that do not exist in a column and then fill na backwards? I have the following pandas dataframe: import pandas as pd foo = pd.DataFrame({'week': [1,2,4,5,7], 'items':[1,2,3,4,5]} I would like to fill `foo` with rows for the "missing" weeks from `1` to `7` and then for these rows the `items` column should have as value the previous non-na value The output dataframe should look like this: foo = pd.DataFrame({'week': [1,2,3,4,5,6,7], 'items':[1,2,2,3,4,4,5]} How could I do that ?
You can try with `set_index()` method,`reindex()` method,`ffill()` method and `reset_index()` method: resultdf=foo.set_index('week').reindex(range(1,8)).ffill().reset_index() Now If you print `resultdf` you will get: week items 0 1 1.0 1 2 2.0 2 3 2.0 3 4 3.0 4 5 4.0 5 6 4.0 6 7 5.0 Now If you want items values in `int` then you can make use of `astype()` method: resultdf['items']=resultdf['items'].astype(int)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, pandas" }
Remainder of dividing $3^n$ by $2^n$. I'd like to find the remainder of dividing $3^n$ by $2^n$, that is, I'd like to find value of $r$ in the expression $$3^n=q2^n+r,$$ where $q\in\mathbb{Z}$ and $0<r<2^n$. I know that it can be $$r=3^n-2^n\left\lfloor\frac{3^n}{2^n}\right\rfloor$$ But it isn't nice. Can I do that without floor? I thought I could find it by solving this $$\sum_{i=0}^{k}{n\choose i}2^i<2^n$$ where $k\le n$. It will work because $$3^n=(1+2)^n=\sum_{i=0}^n{n\choose i}2^i,$$ but I can't find the $k$ value.
This sequence is given in the Online Encyclopedia of Integer Sequences: < There doesn't seem to be an explicit formula for it, and it appears to grow exponentially, but unevenly. Sometimes, it decreases, but in the long run, it roughly doubles each time $n$ increments by $1$, which is to say, when $n$ increases to $n+k$, we have $f(n)$ increasing by a ratio of roughly $2^k$, more apparent for larger $k$.
stackexchange-math
{ "answer_score": 0, "question_score": 9, "tags": "number theory, divisibility" }
Confused about the angle to calculate when finding the direction of the vector I was trying some questions and was confused about calculating the angles in some questions. The question is: > A man has to go 50m due North, 40m due East and 20m due South to reach a field. What is his displacement from his house to the field? Here is my diagram for the question- ![enter image description here]( But the answer given for the question is- arctan(3/4) towards the north to east So i figured the diagram made by them is- ![enter image description here]( My question is why is my diagram and why can't we calculate the angle of vector with Y-axis not X-axis Edit: This question was never meant to be an Homework Question, sorry if it looked like one. I was struggling with an concept i.e. find the angle of the resultant vector in similar questions and this is an example of one. It just happens to be a coincident that I understood the answer wrong.
The answer that they gave must have been $\arctan\frac 34$ North $\mathbf {of}$ East. Which means that they are taking angle with respect to $X$-axis, rather than $Y$-axis. Your answer is correct too, you can do either of those things.
stackexchange-physics
{ "answer_score": 0, "question_score": 0, "tags": "newtonian mechanics, vectors, displacement" }
"No such file" error when using `gets.chomp` in seeds.rb I wanted my seeds.rb file to have two paths based on some user input. For the sake of simplicity in this question I've stripped it down to just these two lines: print "> " res = gets.chomp When I run rake db:seed, the following exception is raised: rake db:seed > rake aborted! Errno::ENOENT: No such file or directory @ rb_sysopen - db:seed /home/me/work/my_app/db/seeds.rb:5:in `gets' /home/me/work/my_app/db/seeds.rb:5:in `gets' /home/me/work/my_app/db/seeds.rb:5:in `<top (required)>' Anyone know why this is happening, i.e. why gets.chomp in this context is causing the program to try to open a file named db:seed?
Try using `STDIN.gets.chomp` instead of `gets.chomp`. See What's the difference between gets.chomp() vs. STDIN.gets.chomp()? for the explanation.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "ruby on rails, ruby" }
Select alphabetic only strings of three characters length I have a field in my table that is a varchar and contains alphabetic, numeric, and mixed alphanumeric values. I would like to select only the values from that field which are 3 characters in length and alphabetic only. I am using oracle. Sample Data: AAA BBB 12345 CCC25 DDDDD The select statement should only return: AAA BBB I tried the following and it didn't work. This did not return anything. select name from MyTable where name like '[a-Z][a-Z][a-Z]'; Then I tried the following thinking it would return all 3-characters long results and it just returned everything: select name from MyTable where name like '%%%';
You can use the `regexp_like` function SQL> with x as ( 2 select 'aaa' str from dual union all 3 select 'bbb' from dual union all 4 select '12345' from dual union all 5 select 'CCC25' from dual union all 6 select 'DDDDD' from dual 7 ) 8 select * 9 from x 10 where regexp_like( str, '^[[:alpha:]]{3}$' ); STR ----- aaa bbb
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "sql, regex, database, oracle" }
I Cannot run my code due to this error in vscode. I cannot understand the error I Cannot run my code due to this error in vs code. I cannot understand the error. I have attached the image link below. <
The thing happening here due to _WinMain_ error is The compiler is not getting any instruction from where to start executing the code (This happens when we don't have a main() function in the program) As Your program already has the int main() function but it is clearly seen that you have not saved your file before Compiling so, 1. **You Should Save your file before running/compiling it** by`Ctrl-S` 2. **also, You can change the settings of the Code runner to Save on Run so you won't have to save your code again and again**
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "c, visual studio code" }
Azure Logic App - Manual trigger with user entered parameters I've got a logic app that I want to be able to run ad hoc and specify the parameters when run. The closest manual trigger i could find was the HTTP request. As a workaround, I'm calling it from postman where the JSON body can be defined. While postman works, I'm looking for a way to trigger the app from within azure and provide the JSON body. Thank you
Actually there are many way to trigger the logic app and process the json data. You could try with service bus trigger or blob trigger, the below is my test with servicebus. I send a json message with Service bus Explorer. Note: in the logic app the json data is encoded with base64. ![enter image description here]( The below is the result. ![enter image description here]( However from the action you could find it has a Interval property to set, it means it may be not triggered immediately. And mostly other triggers need to set the Interval, so if you want to trigger immediately, suppose the HTTP request is the best.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "azure logic apps" }
How to compute delta and delta-hedge in practice? I keep hearing things like \begin{align*} ``\text{Traders make their book delta-neutral at the end of each trading day''} \end{align*} I am wondering what this means, and why this is supposed to give the traders some peace of mind. More specifically: How do the traders compute delta and decide how to hedge an option position? Do they assume the Black-Scholes model (or some other model) and then compute delta? In that case, what about model error (delta is the partial derivative w.r.t. price and is model-specific)? Thus, the delta they compute may be completely wrong! Similarly, I have some market data from a financial data vendor, containing S&500 call and put option prices, as well as the delta, gamma, etc. of the options. In general situations like that, how are those quantities computed? Is it simply under Black-Scholes assumptions?
Yes, you are right. There might be model errors. It depends on experience, personal choice and the mandate of the desk which model they use. Using the model you use, you calculate your delta and hedge. You of hedge your delta but you are exposed to higher order greeks which would give you a delta exposure when the market moves. As far market data goes, you should check the documentation. But most likely it would be black-scholes.
stackexchange-quant
{ "answer_score": 3, "question_score": 2, "tags": "options, black scholes, delta hedging, delta" }
Determine Font Size After Autoshrink I have 2 UILabels for a scorekeeping app (Home and Away). The user can tap on Home or Away and change the label to be whatever they like. This is all working fine. When a user enters a name larger than the label size it will shrink the font to fit. This makes the 2 labels no longer match in font size, and doesn't look right. My question: How can you set the font size of one label to the size of another label that has been "autoshrunk"? I also realize I will need to write code to determine which font size is smaller between the two labels and set them both to that number. I don't think I will have a problem with that, as long as I get an answer to the above question. It seems like it should be simple, but it has so far eluded me.
So I hope you know the frame size of both the labels. Use – sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode: to find the minimum font size that it would use. If you have any doubt, please let me know.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "ios, xcode, uilabel, font size" }
Twilio : Dial with two Audio, each for From and To numbers : PHP I have to use twilio to use two audio file, one for the person who is calling, and second audio is for the person who is being called. Its like terms and condition, `terms_conditions_v1.mp3` for `person1` `terms_conditions_v2.mp3` for `person2` person1 will call on twilio number which will be forwarded to person2. both audio files should end in same time, say 20 seconds.
I solved it by creating two TwiML conference file. Keep the friendly name of conferences same and so they will connect. Make both calls simultaneously. Here is what I did in each xml file, <Response> <Play>mp3</Play> <Dial> <Conference>Frindly_name</Conference> </Dial> </Response> as both my audio files have same length, there is very little waiting time.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, twilio, twilio php" }
Long arrows in a commutative diagram with transform canvas I need to represent a commutative diagram. The following code works. Is there a way to modify it in order to have longer arrows? \begin{tikzcd} A \arrow[transform canvas={yshift=.5ex}]{r}{f} \arrow[transform canvas={xshift=.5ex}]{d}{g} & B \arrow[transform canvas={yshift=-.5ex}]{l}{h} \arrow[transform canvas={xshift=-.75ex}]{dl}{} \\ C \arrow[transform canvas={xshift=-.5ex}]{u}{r} \arrow[transform canvas={yshift=-.75ex}]{ur}{} \end{tikzcd}
Use the `sep` key. The input can also be simplified. \documentclass{article} \usepackage{tikz-cd} \begin{document} \begin{tikzcd}[sep=huge] A \arrow[r,shift left,"f"] \arrow[d,shift left,"g"] & B \arrow[l,shift left,"h"] \arrow[dl,shift left] \\ C \arrow[u,shift left,"r"] \arrow[ur,shift left] \end{tikzcd} \end{document} ![enter image description here](
stackexchange-tex
{ "answer_score": 3, "question_score": 0, "tags": "tikz arrows, commutative diagrams" }
Is there a way to remove this unresponsive window of Action Center program in windows 7 without a restart? The following window is not disappearing at all. I don't want to do a restart or shutdown. Also, It persists even after a sleep. My issue is a persistent Aero window that wouldn't close. nothing related to backup. How to remove it ? is there some process or service I can kill ? A small window of action center program is stuck: ![enter image description here](
This window/tile will be 'hosted' by the `explorer.exe` process. I would suggest the following actions: 1. Open up Task Manager 2. Find `explorer.exe` 3. End Task on `explorer.exe` 4. From the File menu in Task Manager, select `Run new task` 5. Enter `explorer.exe` and click OK These steps will restart the explorer process, and the windows it's hosting.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "windows, windows 7" }
Is there a way to keep this character? At the end of chapter 9, > Lao leaves the party due to events taking place in the story. It's been suggested that you can max affinity to keep this character from leaving the party permanently (ie, he would rejoin after the finale), but is that true?
You cannot get this character back. However, if you complete Doug's 5th heart-to-heart, you can at least get the equipment back.
stackexchange-gaming
{ "answer_score": 0, "question_score": 1, "tags": "xenoblade chronicles x" }
Does the symbol in an rspec example definition have special meaning? I am watching a video series on Rspec. And inside his example group, he has several examples, each of which has a symbol: ![enter image description here]( Now that is just a ruby string literal. In normal flow, that `:make` should just be a string not a symbol. Does this have special purpose in Rspec? Why does he do this pattern?
It doesn't have any special meaning in RSpec. Usually, rubyists use `ClassName#method_name` notation (or just `#method_name` when class name could be omitted). Maybe author of that video is just used to refer any names in Ruby as symbols. More than that, anything written in a string between `it` and `do` is just a human readable name for the test and has nothing to do with RSpec internals.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ruby on rails, rspec" }
Is is possible to configure settings in Bitbucket globally? It is possible to configure settings per repository in Bitbucket. Would it be possible to configure settings globally? There are more than 30 repositories at the moment and I would like to avoid that I have to configure the same settings per repository.
At the moment this seems not to be possible in bitbcuket at the moment. Therefore I have created an enhancement in the Bitbucket issue tracker.
stackexchange-devops
{ "answer_score": 1, "question_score": 1, "tags": "bitbucket" }
Why "click_no_wait" is slower than "click"? After I click a button with "click_no_wait" method, there is a delay of almost one second before anything happens... Why is this so? Here is one example (obvious delay between button's yellow-flash and popup window): require 'watir' b = Watir::Browser.start "www.w3schools.com/js/tryit.asp?filename=tryjs_alert" b.frame(:name, "view").button(:text, "Show alert box").click_no_wait If I replace "click_no_wait" with just "click", then there is not any delay after clicking a button (popup window shows up instantly). But "click" can't be used here because then the script hangs... Is there any solution for this delay? (Not a big problem really, just asking...)
It launches a separate process. The plus side is that it prevents hanging because the main process can get on with things immediately. The down side is that setting up a process takes time in itself. It's a balancing found in anything in any language that uses separate processes or separate threads - increased responsiveness and increased performance in certain cases, but with an overhead in and of itself. You might find < of interest.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "watir" }
How to highlight entire line on matching a word within the line in egrep? Currently, I use egrep --color 'error|$' to highlight every word in a line containing the word error: !enter image description here I would like to highlight the entire line though so that the entire string appears in red. How can I achieve that?
To highlight the complete line, you should expand the regex so that it includes all (if any) characters before and after the desired term. Do this by prepending and appending `.*` to the term being searched for: echo "foo bar error baz" | egrep --color '.*error.*|$'
stackexchange-unix
{ "answer_score": 7, "question_score": 5, "tags": "grep, colors, highlighting" }
Is the scanner Canon Pixma MG2450 working in Ubuntu? The Canon Pixma MG2450 printer has an integrated scanner that should work with a tool like Simple Scan (or `xsane` or Skanlite). ![enter image description here]( There are two sets of drivers (provided by Canon as deb files): two drivers for the printer (`cnijfilter-common`and `cnijfilter-mg2400series`) and two for the scanner (`scangearmp-common` and `scangearmp-mg2400series`). All drivers can be installed just fine, the printer works, but the scanner is not detected. As seen here, the Canon Pixma 2400 series is supported. How can I use this 2 in 1 scanner / printer? * * * I have tried to use Xubuntu, Kubuntu and Lubuntu, eOS and Mint, and got the same negative results. Note that **the scanner works in Windows**. How can I get it working?
The drivers already mentioned in the question are just fine, only they cannot be used with the Simple San or Xsane tools, but they install a tool called **ScanGear** that can be launched with the command `scangearmp`. ![enter image description here]( ![enter image description here]( Outputs: **png, pdf, pnm**. To add a `.desktop` launcher for that: sudo gedit /usr/share/applications/scan.desktop and paste this: [Desktop Entry] Categories=Graphics;Scanning; Exec=scangearmp Icon=scanner Name=Scan Type=Application The same can be used within Gimp: **File/Create/ScanGear MP** , but S **canGear does not need Gimp in order to work**. Sources are linked in my other answer.
stackexchange-askubuntu
{ "answer_score": 4, "question_score": 5, "tags": "14.04, drivers, 15.04, scanner, pixma" }
How to strip non-digit characters from an id attribute with JavaScript I am reading the id from a list tag an add it to a `pre` tag like this: $('pre').each(function() { $(this).attr('id', $(this).closest('li').attr('id')); }); for example, the list tag has this id: <li id="Comment_123"> For the pre tag, I want to remove the first 8 characters from the id; so the pre tag should become this id: <pre id="123"> How can I achieve this with the code I already have?
If you want to strip everything except digits, you could use `.replace(/\D/g, '')`: $('pre').each(function () { this.id = $(this).closest('li').attr('id').replace(/\D/g, ''); }); * `\D` \- Matches any non-digit character. * `g` is a global flag to match all occurrences. In other words, all occurrences of any non-digit character(s) are replaced with an empty string, `''`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript" }
How to obtain AWS EC2 key-pair creation date? To access ec2 instances, we need to create a ssh key-pair . I need to extract the date on which the key-pair was created ? Is it possible using aws sdk apis ?
The AWS SDK does not provide a way to get the dates from a key pair generated. There is no API to retrieve the Private Key. The Public key can be retrieved via some languages SDK's. However it is only accessable if running inside of an ec2 instance because they run a command such as `curl to obtain the key and the metadata is only available from within EC2. That being said I've never heard of being able to get a date from an ssh key pair. If you can show me how this is accomplished I can maybe whip something up that works for you. The EC2 ssh key pair is no different than any other key pair. The answer to your question remains the same, the SDK does not provide this function.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "amazon web services, amazon ec2" }
Pass multiple arguments to $.delegate the arguments come from jQuery as `$(this)` and contain multiple elements :) tried $('#el').delegate($(this), 'click' ... $('#el').delegate($(this).each(), 'click' ... none work.. * * * (function($){ $.fn.myfunction= function(){ // here i need to somehow find .a, .b., .c etc... $('#el').delegate($(this), 'click', function(event){ }); }); }); later I'm calling it like: jQuery(document).ready(function($){ $('.a, .b, .c').myfunction(); }); so I want my event on all new .a, .b, .c ...
Depending on your code, you will need `$("xxxx").bind('click',function(e) {...});` OR `$("xxx").live('click', function(e) {...});`. If you are on jquery v1.7, $.on() is the function to use and $.off() reverses it.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jquery, jquery selectors, delegates" }
TFS Database Deployment in Sandbox environment I have a Team Solution which includes the database and dataserver projects – these are currently set to compile and create deployment scripts. This can take an age so would probably be worth setting them to build & deploy only when needed. Does anyone have any views on this either way; is there a best practice approach or is it simply solution specific?? Thanks
In my experience I would go for the latter 'build and deploy when required'...
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "database, visual studio 2010, tfs" }
Representation of $*$-automorphism on finite dimensional matrix algebras Let $\phi$ define a $*$-automorphism from the matrix algebras $M_n(\mathbb{C})$ to $M_n(\mathbb{C})$ such that $\phi(I) = I$. Is it true that any such map $\phi$ can be represented as $\phi(x) = U x U^{\dagger}$ (where $U$ is a suitable unitary matrix)? If not, what is the most general expression?
Here is one generalization: > Every $*$-automorphism of the algebra of compact operators on a Hilbert space is conjugation by a unitary operator on that space. Using the fact that the algebra of compact operators is irreducible, this can be seen as a special case of: > Every irreducible $*$-representation of the algebra of compact operators on a Hilbert space is unitarily equivalent to the identity representation. A proof can be found for instance in Section 1.4 of Arveson's _An invitation to C`*` algebras_. Another proof of the first assertion that gives more information can be found in Proposition 1.6 of Raeburn and Williams's _Morita equivalence and continuous trace C`*`-algebras_. The first part is still true if you take all bounded operators instead of only the compact ones. (And these are the same thing in the finite dimensional case.)
stackexchange-mathoverflow_net_7z
{ "answer_score": 6, "question_score": 9, "tags": "oa.operator algebras" }
C# :How can i set Memory stream as the asp.net image control's source property? I have an asp.net image control in one ASP.NET page and have a Memory Stream which has an image.How can i convert this memory stream to set it as the image source without storing the image in the hard disk ?
The image control takes an `ImageUrl` \- a path to where the image is located. There is no property that takes an actual image (or image data). What you can do is write a `HttpHandler` that will stream your images from whatever source - set the `ImageUrl` to use this handler. Here is an example for a general file handler using a memory stream - it's a good starting point for what I suggest.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "c#, asp.net, image, memorystream" }
window.open is throwing invalid argument error in IE I have IE version 11.0.9600.17358 window.open('editProperties.php?fileid=661BEAB9735A615D65B3FCF676A2F83F', 'editProperties', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=570,height=580,left=490,top=362'); throws invalid argument error. I tried creating a test.html and calling it just by name: window.open('test.html') it does not work, throws the same error. Only time I was able to use it was as: window.open('', 'editProperties','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=570,height=580,left=490,top=362') or window.open('about:blank') As soon as I pass a url as the first argument, it throws the error. Anyone has any ideas?
Oh wow, I've opened another tab, which asked me my credentials again, after entering it, the same exact link just worked. It seems like the session timeout or something but still showed me the page between loads. If anyone encounters this error and none of the comments above work, try opening a new tab!! Thank you all for trying to resolve my issue.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, internet explorer, window.open" }
If $a$,$b$ and $y$ are the roots of $3x^3+8x^2-1=0$ find $(b+1/y)(y+1/a)(a+1/b)$ If a b and y are the roots of $3x^3+8x^2-1=0$ find $(b+1/y)(y+1/a)(a+1/b)$ This is what I have done so far, but apparently it is incorrect. I want to know why. $(b+1/y)(y+1/a)(a+1/b)$ $(by+1/y)(ay+1/a)(ab+1/b)$ $(aby^2+1/ay)(ab+1/b)$ which is equal to $a^2b^2y^2 + 1/aby$ Using Vieta's formula I get: $aby = -d/a$ $aby = 1/3$ Subbing in original: $(1/9 + 1)/1/3$ which is... 10/27 The answer is supposedly 2/3, want to know what I did wrong.
You have a few mistakes: 1. $(b+\frac1y)(y+\frac1a)(a+\frac1b)\neq a^2b^2y^2+\frac1{aby}$, as you write above 2. $(b+\frac1y)(y+\frac1a)(a+\frac1b)\neq \frac{a^2b^2y^2+1}{aby}$, as you apply the formula you wrote The actual solution is: $$(b+\frac1y)(y+\frac1a)(a+\frac1b)=\frac1{aby}(yb+1)(ay+1)(ab+1)=\frac1{aby}(aby^2+ay+yb+1)(ab+1)=\frac1{aby}(a^2b^2y^2+a^2by+ab^2y+aby^2+ab+ay+yb+1)=aby+a+b+y+\frac{ab+ay+yb}{aby}+\frac1{aby}$$ Now, using Vieta's Formulas, we have that $aby=\frac{1}{3},ab+ay+yb=0,a+b+y=-\frac{8}{3}$. This gives $(b+\frac1y)(y+\frac1a)(a+\frac1b)=\frac{1}{3}-\frac{8}{3}+0+3=\frac23$
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "algebra precalculus, polynomials" }
Relationship between optimality and feasibility Say I have two optimization problems A and B. If an optimal solution of A is feasible for b and vice versa: Q 1) Is every optimal solution for A an optimal solution of B (and vice versa)? Q 2) If the answer to Q1 is false, then is there at least one optimal solution of A that is also an optimal solution of B (and vice-versa)?
No to both questions, consider these problems: A: $\min_x \\{ x : 0 \leq x \leq 1\\}$ B: $\min_x \\{ -x : 0 \leq x \leq 1\\}$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "optimization" }
How to flip a Three.js texture horizontally I'm making a 360 viewer, so textures are inside a cylinder. Problem is that they appear inverted horizontally. I know about `texture.flipY` but I haven't found a `texture.flipX` on the source. So how can I flip a texture horizontally, or along the x axis, directly in the code? (not using an image editor)
The answer was easier than I thought. cylinder.scale.x = -1; And don't forget to add material.side = THREE.DoubleSide;
stackexchange-stackoverflow
{ "answer_score": 16, "question_score": 14, "tags": "javascript, three.js" }
Calculating new averages I'm studying for a midterm in my basic stats course and came across a question that I'm confused with how it's solved. * * * A manager at a local gas bar has 13 staff members. The average hourly wage for the employees is `$10.55` per hour. One experienced employee, who was making `$12.50` per hour, quit because they were offered a better job. They were replaced with two employees, each getting a starting wage of `$9.00` per hour. What is the new average hourly wage for the employees at the gas bar? * * * The way I attempted to solve this was: $\frac{(12*10.55) - 12.5 + (9*2)}{13} = \$10.16$ However it's not one of the possible choices: (A) $10.97 (B) $10.19 (C) $10.28 (D) $10.82 (E) $10.68 Can anyone point out what I did incorrectly? * * * As pointed out in the answers section I miss calculated N. The formula should be: $\frac{(13*10.55)-12.5+(9*2)}{14} = \$10.19$
It may be a matter of interpretation but as I read it the intent is that the situation in the question starts with 13 staff members, rather than 12, and presumably ends up with 14 rather than 13. Reassuringly, that would then give a result that matches one of the answers.
stackexchange-stats
{ "answer_score": 1, "question_score": 1, "tags": "self study, mean" }
Can you use SQL to SELECT values from a JSON array? I have a database in SQL Server 2008 and one particular table has information stored in fields as JSON-encoded arrays. I'm wondering there's a SQL-based approach to select out specific values within that JSON field? I can, of course, just select the field and parse the information out myself, but I'm trying to avoid that if at all possible. Thanks in advance!
There's nothing natively, but the first answer on the follow question references an article about parsing JSON objects in tSQL Parse JSON in TSQL For reference, the article of interest is here: <
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 12, "tags": "sql, sql server, arrays, json" }
Using fontawesome (icons) in game, in theory The font-awesome icons are vector based, and from my understanding vector iamges are bad in apps since they are very big (in bytes), is this true for fontawesome icons? In theory, could I use these icons in my game, not only for menu buttons and such, but also for actual game graphics? I'm planning on doing a very simple game, and I'd hate to get stuck on the design part, not only the drawing of them, but I've had trouble with scaling of images (according to screen size) in the past, vector images would solve this. I realize icons are not optimal for game graphics, but would it be usable?
Vector based images are usually smaller than bitmap based images, because they just contain an abstract description of the image content, that can be scaled to virtually any size. Your graphics card does not understand these kind of image formats though. You would have to convert them to a bitmap based format first, which means you have to set a specific size for the resulting image. LibGDX offers the FreeType extension, to convert TrueType font files (.ttf) _at runtime_ to a `BitmapFont` with a specific size, which can then be rendered. That way you will be able to generate icons on the fly for the correct display size, without having to ship many different versions of them, for different resolutions.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "android, libgdx, font awesome" }
structure when storing books in elasticsearch I want to use elasticsearch as a web search engine for books. A book has several editions with different titles in different languages, ISBN's as well as author names in different languages. I want that a book is found by any combination of title language and author name language i.e. the Latin name of Aristotle and the english title of one of his works. How do I store all possible names of the author, all ISBN's, all titles with respective edition-id's of one book and information about the language in order to get the matching title, it's edition-id and its language as a result to a query? I believe I need to use 'Nested Type', but I am not sure. Like that I only find the _id of the book, but not more: { _id: 1 _source: { title: [ Odyssey Odyssee Odisea ] isbn10: [ 2080674722 5941453868 2670361734 ] fullname: [ Homer Omero ] } }
I found out how to do this with the help of this guide: The nested type is right and in my case the only option. curl -XPUT localhost:9200/readgeek/book/1 -d' { "names": [ { "english": "Omero", "german": "Homer" } ], "authorid": "1", "ratings": "2589", "editions": [ { "title": "Odyssey", "languageid": "123", "isbn10": "1234567890", "isbn13": "1234567890123", "ratings": "158" }, { "title": "Odisea", "languageid": "150", "isbn10": "1234568890", "isbn13": "1234569890123", "ratings": "15" }, { ... } ] }'
stackexchange-dba
{ "answer_score": 0, "question_score": 1, "tags": "best practices, elasticsearch" }
How to store NSDate plus 7 calendar days? I need to be able to store the current NS Date plus 7 days. I already store the current NSDate. I then want to compare the two dates, to get the number of days difference between the two and display within a label. The idea is to count down from 7 days, to 6 days, to 5 days, etc until it shows 0 and i will remove it from my tableview. I have been having hard time finding the write code for this, so any help would be greatly appreciated!!!
This code will compute date after 7 days from today. NSDateComponents *comps = [NSDateComponents new]; comps.day = 7; NSDate *today = [NSDate date]; NSCalendar *c = [NSCalendar currentCalendar]; NSDate *dateAfter7days = [c dateByAddingComponents:comps toDate:today options:0]; For Your date diffrence the code is:- // c is calendar object NSDateComponents *comps = [c components:NSDayCalendarUnit fromDate:startDate toDate:currentDate options:0]; int diffrence = [comps day];
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "nsdate, nsdateformatter, nsdatecomponents" }
Substituting number into file name in bash I'm trying to download multiple files such as: www.example.com/v1/file.txt www.example.com/v2/file.txt www.example.com/v3/file.txt ... The following command doesn't work, as it actually looks for a file "r{1..99}/file.txt": for i in {10..99} do wget "www.example.com/v"$i"/file.txt" -O "file_"$i".txt" done It also makes no difference if I put additional quotes " " around $i. What am I doing wrong?
Try putting your variable name inside curly braces like this: for i in {10..99} ; do echo wget "www.example.com/v${i}/file.txt" ; done Misread question. seq or set -B is the way to go...
stackexchange-unix
{ "answer_score": 1, "question_score": 1, "tags": "bash" }
What fields need to be included when configuring IIS web logging according to PCI compliance regulations? From what little I know about PCI compliance I need to be logging all web site activity and keeping said logs online for at least 3 months. What I have not been able to get a straight answer on, however, is what fields or properties must be included from the Advanced tab in IIS Logging properties. Some seem obvious and need to be included (e.g. date,time,client IP) but others are not so obvious. Here is this list of available fields (defaults in bold): * **Date** * **Time** * **Client IP Address** * **User Name** * Service Name * Server Name * **Server IP Address** * **Server Port** * **Method** * **URI Stem** * **URI Query** * **Protocol Status** * **Protocol Substatus** * **Win32 Status** * Bytes Sent * Bytes Received * Time Taken * Protocol Version * Host * **User Agent** * Cookie * Referer
The ones in bold above are all that are needed for PCI compliance. Basically time/date/what they visited/details about them/respond information. However, I would enabled all of them except for Cookie and Protocol. Cookie can have cardholder data, so don't add it. Time taken, bytes, host, referer are all useful columns that you will likely find useful. Log files can be compressed well so it doesn't hurt to have extra data for when you need it.
stackexchange-serverfault
{ "answer_score": 3, "question_score": 3, "tags": "security, iis, log files, pci dss" }
Is it possible to send data through I2C with TIM without CPU interrupt and just DMA Interrupt Because I've seen HAL_TIM_Base_DMA_START() in the STM32F7 HAL timer library, I though maybe it is possible to, for example, call HAL_TIM_Base_DMA_START() and timer continually requesting DMA to transmit data to I2C preiodically without CPU activity?
It seems it's possible using DMA request generator.
stackexchange-electronics
{ "answer_score": 0, "question_score": 2, "tags": "stm32, i2c, timer, dma, direct" }
XOR and II (concatenation) summation symbols In Latex, in math mode, if I want to express summation over a range I can use the following expression `\sum_{from}^{to}`. I can do the same for the product. What is the name of the symbol that does this for XOR or concatenation? If I do: \oplus_{i=0}^7 I don't get the `i=0` and `7` parts below and above the symbol, respectively, but to the right instead, like this: !bulkxor With summation (`\sum_{i=0}^7`), that is not the case - they appear below and below in the output: !bulksum How can I make XOR, or concatenation (II) larger and with indices below and above the symbol?
You want to use `\bigoplus` instead of `\oplus`. I've never seen concatenation done that way. Addition and XOR are commutative operations so it makes sense to sum over a set (or take the exclusive OR of a set). Concatenation is not like that. I think I would explicitly write out the concatenation. That said, you can use `\bigparallel` from the `stmaryrd` package. \documentclass{article} \usepackage{amsmath} \usepackage{stmaryrd} \newcommand*\concat{\mathbin{\|}} \begin{document} \[x_1\concat x_2\concat\dotsb\concat x_n\] \[\bigparallel_{i=1}^n x_i\] \end{document} !enter image description here
stackexchange-tex
{ "answer_score": 18, "question_score": 11, "tags": "math mode, symbols, math operators" }
Performance tuning on filter data from large data set in sql server I want to fix some performance issue with the following query. * Tbl_A has 65 million rows * Tbl_B has 2 rows I need to filter Tbl_A with the values of Tbl_b SELECT COUNT(*) FROM Tbl_A R1 WITH (NOLOCK) INNER JOIN Tbl_B PBD ON PBD.Indicators = CASE R1.Indicator WHEN 'Y' THEN 'B' WHEN 'N' THEN 'D' WHEN '1' THEN 'B' WHEN '0' THEN 'D' ELSE R1.Indicator END I have tried using in & exists instead of join, but I cant find any performance benefits. Please assist.
There is not much you can do here. You should have indexes on `Tbl_A.Indicator` and `Tbl_B.Indicators` of course. The only option for a performance increase I see would be a persisted computed column: ALTER TABLE tbl_a ADD pbd_indicator AS (CASE indicator WHEN 'Y' THEN 'B' WHEN 'N' THEN 'D' WHEN '1' THEN 'B' WHEN '0' THEN 'D' ELSE Indicator END) PERSISTED; Add the related index: CREATE INDEX idx_tbl_a_pbd ON tbl_a(pbd_indicator); And change the query accordingly: SELECT COUNT(*) FROM tbl_a r1 INNER JOIN tbl_b pbd ON pbd.indicators = r1.pbd_indicator;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "sql, performance, sql server 2014, sqlperformance, sql tuning" }
ng-pattern regular expression for real number This is more a question for my own curiosity. I have a working solution, but I'm curious if anybody has any insight as to why one solution works and the other does not. I needed a regular expression to validate a user has entered a valid number. Some examples: 87 887.65 -87 -87.65 My first attempt looked like this: ^(\-?[0-9]+(\.[0-9]*)?)$ It worked great except strings like '7x', '1a', '89p' were accepted. My new solution is below, and it seems to work just fine: ^(\-?[0-9]+(\.[0-9]+)?)$ The second one (note the '+') is slightly more concise, but I fail to see why the first one accepted letters and the second one doesn't. Does anybody see what I'm missing?
The "." in your regex is for the character "." literally, so it should be escaped "\\.", otherwise it will match any character. In the second regex the "+" operator demands at least one decimal so it wont match "7x", but it will match "7x1", see this Regex demo
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "javascript, angularjs, regex, ng pattern" }
Does something happen different in the compiler between these two ways of including the same headers? Does: #include <vector> #include <string> #include <winsock2.h> #include <iphlpapi.h> #include "FileX.h" <--------------which #include <windows.h> Compile the same as in one header file: #include <vector> #include <string> #include <winsock2.h> #include <iphlpapi.h> #include <windows.h> In the first case, the windows.h is another file (still included last). Does something happen different in the compiler between these two ways of including the same headers?
In my world, "FileX.h" is defined as follows #error "This is different from windows.h, as it contains an #error!" #include <windows.h> So yes, there "Does something happen different in the compiler" in this case. Even if it is simply defined as follows, things may be different #include <windows.h> If you include too many headers, you may hit the compiler's resource limit earlier than if you included `<windows.h>` directly, and it may hit different paths that may hit different errors in your compiler etc... So it really depends on what you mean by "Does something different in the compiler" at all.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c++, c, windows, visual studio, winapi" }
How to use a text file to log users in I have tried and tried to get this to work. Essentially I want to read a line of a text file and compare it to the user input. If they are the same then it will continue the log in process. For now I am just using an echo to see if it actually finds something. it seems that the if statement doesn't see the two inputs as a match even when they are. $myFile = fopen("users.txt", "r"); $username = $_POST['username']; while(!feof($myFile)) { $userN = fgets($myFile); //compares entered user to text file users if (($username === $userN)){ echo 'found'; } } The only time that it ever finds a match is if the input is left blank as it will be matched with the final line of the file.
Try this code. <?php $myFile = fopen("users.txt", "r"); $username = $_POST['username']; while(!feof($myFile)) { $userN = fgets($myFile); //$userN = rtrim(fgets($myFile, "\r\n")); //More cleaner way suggested in comment //compares entered user to text file users if ($username == trim($userN)){ echo 'found'; } else { echo "non found"; } } I guess `$userN` is taking some white spaces or other predefined characters before or after string, so use `trim()` to remove it.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "php, authentication, text files" }
How to route requests through router based on domain names? Assuming a setup as seen below, is it possible to route requests for e.g. subdomain1.domain.com to Server 1, subdomain2.domain.com to Server 2, another seconddomain.com to Server 2 etc. without reverse proxies? The goal is to host several servers which should each be accessible and administered by different persons autonomously. As most of them are test environments the goal is to be able to access each of the servers, on all ports, via a different domain/subdomain name. Managing reverse proxies each time a new service is tested on one of the machines would be quite cumbersome, especially as these are not limited to HTTP/HTTPS web servers and can offer a number of protocols across a number of different ports. Is such a setup feasible? How would one go about setting it up? ![Schematic illustration of proposed setup](
What you're asking for is pretty much impossible, because the vast, vast majority of L7 protocols have no concept of a hostname, and thus can't be proxied based on a hostname The correct way to achieve what you want is to assign different public IP addresses, because even though you have a router in your diagram, it's actually NATting, which isn't routing at all. So you need more IP addresses, and you can either route properly and put the public IPs on your three servers, OR, you can put the IP addresses on your router and do a 1:1 NAT (eww, especially if the NAT uses Proxy ARP to "get" the IPs)
stackexchange-serverfault
{ "answer_score": 3, "question_score": 0, "tags": "linux, routing, reverse proxy, nat, subdomain" }
Defining the lines in a vertical histogram I'm trying to create a function that returns a vertical histogram where the height of each column corresponds to an integer from a list. I have written some code that I think would work if I could find a way to define each line. If the goal is not clear I'm trying to write a program with a function that takes a list (ex. [1, 5, 2, 4]) and returns a vertical histogram consisting of asterisks like this: * * * * * *** **** Below is the code that I think could work if I manage to define row in a nice way. def render_histogram(values): histogram = [] for y in range(max(values), 0, -1): row = () histogram.append(row) return '\n'.join(histogram) My first idea would be to check for every column if the number in question is equal or greater than y, but I don't know how I would write this as code.
> My first idea would be to check for every column if the number in question is equal or greater than y, but I don't know how I would write this as code. Yes, that is the right approach. You can do that as follows: row = ''.join(' ' if x < y else '*' for x in values) The rest of your code is fine, but you could also turn that `for` loop into list comprehension, so that you get this function: def render_histogram(values): return '\n'.join( ''.join(' ' if x < y else '*' for x in values) for y in range(max(values), 0, -1) )
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python" }
How can I select tables with more than or less than a certain number of rows? I want to identify all tables with more than 6 rows, as well as all tables with 6 or fewer rows. About the best I can come up with is to loop over the rows for each table and count them, but there must be a more elegant solution. What can I do other than looping and counting to find these tables?
I would use the `.filter()` method to filter out only the tables that match your criteria. In your case you could select all rows within the table and check the length. Something like this: // Get tables with more than six rows $("table").filter(function (){ return $("tr", this).length > 6; }); **Working demo**
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jquery, jquery selectors" }
How to properly send map from angular client to spring boot controller in request body? Received map is always empty **Angular client** \- httpClient sending request const map: Map<string, string> = new Map<string, string>(); map.set('foo', 'bar'); this.http.post(address, map, httpOptions).subscribe( next => console.log('next: ' + next), error => console.log('error: ' + error), () => console.log('complete') ); **Springboot server** \- controller receiving request @RequestMapping(value = "/foobar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public void fooBar(@RequestBody Map<String, String> foo){ System.out.println(foo.entrySet()); //<-- always empty }
You have to convert the Map to an array of key-value pairs, as it turns out, Typescript maps cannot be used directly inside a http post body. You can convert the map as follows: const convMap = {}; map.forEach((val: string, key: string) => { convMap[key] = val; }); this.http.post(apiBaseUrl + '/foobar', convMap, httpOptions).subscribe( next => console.log('next: ' + next), error => console.log('error: ' + error), () => console.log('complete') ); In the back-end, your `System.out.println(foo.entrySet());` will output the following: [foo=bar]
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 7, "tags": "java, angular, spring, dictionary, controller" }
How to open 2 windows in visual studio code? How to open a code window and display window as below: !enter image description here
I believe you need to use Sandbox. This link should explain in more detail. <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "visual studio code" }
What is the appropriate glm to estimate data from a numerical rating scale? I'd like to predict a variable that is bound between 0 and 1, these are patients' responses on a visual analog scale. When I use a simple linear model, some predictions are out of the bounds of the allowed range of values; I'd like to avoid that. It occurred to me to fit a Gaussian glm with a logit link. however, I ran into trouble since logit(0) = -Inf and logit(1) = Inf. I can simply set 0 = 0.001 and 1 = 0.999, model runs fine. My questions are: 1. Is the `glm(..., family = gaussian(link = "logit"))` appropriate for that kind of data? 2. Is there another, more appropriate way to circumvent the Inf/-Inf problems? 3. How could I calculate prediction intervals from that model?
Look into fractional logistic regression, which I suspect is what you're trying to get at intuitively. You already realize that linear regression can give you predictions that are out of bounds. You might or might not have realized that linear regression is also inefficient, because you can't possibly have constant variance of the error term. For example, How to do logistic regression in R when outcome is fractional (a ratio of two counts)? Beta regression is another possibility. It's always possible that neither is appropriate, because you haven't given much information about the nature of the dependent variable (maybe ordered logit is more appropriate?), so you will have to judge for yourself.
stackexchange-stats
{ "answer_score": 1, "question_score": 2, "tags": "normal distribution, generalized linear model, logit" }
JSFiddle and other Live Code Services in New Tab Quite often, a user will use a service such as JSFiddle to demonstrate their point, and some answerers use it in return for a live demonstration of their code. I'm not just talking about JSFiddle either, there are a number of services that allow links as part of a support to the OP's question or an answer. Can these links open in a new window/tab? I often find myself trying things in these services and testing code through a number of revisions and when I've finally solved the OP's issue, I have to use my back button to navigate through everything I've just done, just to post it back to them. Yes, I could open in a new tab through browser functionality, but it's my own fault that I forget to do this all the time, I'm only human. Is this possible?
Yes, yes, a thousand times yes! Do it yourself, though. // ==UserScript== // @name JSFiddle yourself in a new tab // @namespace // @version 0.1 // @description Changes jsfiddle links so they open in a new tab // @match // @copyright None! Suckmahbutt! // ==/UserScript== function exec(fn) { var script = document.createElement('script'); script.setAttribute("type", "application/javascript"); script.textContent = '(' + fn + ')();'; document.body.appendChild(script); document.body.removeChild(script); } window.addEventListener("load", function () { exec(function () { $("a[href^=' }); });
stackexchange-meta
{ "answer_score": 5, "question_score": -1, "tags": "feature request, hyperlinks, tabs" }
What is Corgi mode on Google colab notebook? What does the _Corgi Mode_ do in Google Colaboratory? Accessible from `Tools > Preferences`. ![Corgi mode on Google colab](
The Corgi mode setting adds animated Corgis in the header. ![enter image description here]( <
stackexchange-stackoverflow
{ "answer_score": 53, "question_score": 39, "tags": "google colaboratory" }
invalid form on conditiona angularjs How in angularjs to do what, if myInput==3 , myForm became invalid ? < <!DOCTYPE html> <html> <script src=" <body ng-app=""> <form name="myForm"> <input type="text" name="myInput" ng-model="myInput" ng-required='!myInput==3'> </form> <h1>{{myForm.myInput.$valid}}</h1> </body> </html>
!myInput==3 This expression will return `false` everytime, since `!myInput` returns a boolean value which will never be equals to `3`. Change it to this: myInput != 3 This will compare `myInput` to `3` actually. **Edit** : For validating against a specific value, the easiest way is to use `ng-pattern` directive. If you want to make the input as valid if it contains 3, replace `ng-required` with this: required ng-pattern="/^3$/" This will make the input as required, and will become valid only if it contains the value `3`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "angularjs" }
Equation for subsection of Bezier curve Say I have a cubic Bezier curve, with a starting point `s`, an ending point `e` and control points `c1` and `c2`. Given `t` between 0-1, I want to find the equation of the subsection of the curve between `0` and `t`. Is this possible without being too computationally expensive?
Yes, it's possible. The deCasteljau algorithm divides a Bezier curve into two. If you search, you'll find lots of references. Let me change your notation: let the points of the curve be $A$, $B$, $C$, $D$. So, $A$ is the start point (where $t=0$), $D$ is the end-point (where $t=1$), and $B$ and $C$ are the control points adjacent to $A$ and $D$ respectively. Suppose you are given a value $t$ at which you want to split the curve. The deCasteljau algorithm tells you to do the following calculations: $$L = (1-t)A + tB \quad ; \quad M = (1-t)B + tC \quad ; \quad N = (1-t)C + tD $$ $$P = (1-t)L + tM \quad ; \quad Q = (1-t)M + tN $$ $$R = (1-t)P + tQ$$ Then the control points of the "left" portion of the Bezier curve (the piece from $0$ to $t$) are $A$, $L$, $P$, $R$. And, if you're interested, the control points of the "right" portion of the Bezier curve (the piece from $t$ to $1$) are $R$, $Q$, $N$, $D$. This picture is not accurate, but it might be helpful: !decasteljau
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "bezier curve" }
not accepting null value in mysql `CREATE TABLE DEPT ( DEPT_NO INT PRIMARY KEY, D_NAME VARCHAR(255) NOT NULL, LOC VARCHAR(255) NOT NULL ); CREATE TABLE EMP ( EMP_NO INT primary key, E_NAME VARCHAR(255) NOT NULL, JOB VARCHAR(255) NOT NULL, MGR INT, HIRE_DATE DATE NOT NULL, SAL INT NOT NULL, COMM INT, DEPT_NO INT NOT NULL, foreign key(dept_no) references dept(dept_no) ); INSERT INTO DEPT (DEPT_NO,D_NAME,LOC) VALUES ('10','ACCOUNTING','NEW YORK'); INSERT INTO DEPT (DEPT_NO,D_NAME,LOC) VALUES ('20','RESEARCH','DALLAS'); INSERT INTO DEPT (DEPT_NO,D_NAME,LOC) VALUES ('30','SALES','CHICAGO'); INSERT INTO DEPT (DEPT_NO,D_NAME,LOC) VALUES ('40','OPERATIONS','BOSTON'); insert into emp values(7369,"SMITH","CLERK",7902,"1980-12-17",800," ",20);' `
You declared in the ' **emp** ' table the column ' **comm** ' as INT and in the insert you are inserting a string, the right thing would be: insert into emp values(7369,"SMITH","CLERK",7902,"1980-12-17",800,0,20); or insert into emp values(7369,"SMITH","CLERK",7902,"1980-12-17",800,null,20);'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "mysql" }
Use of "petri dish" as metaphor in non-scientific context Can the word _petri dish_ be used as a metaphor in a non-scientific context?
Yes, it can! > The city was a petri dish for crime.
stackexchange-english
{ "answer_score": 7, "question_score": -1, "tags": "word usage" }
How to change the header layout? I am typing an article. I have used fancyhdr for the header and footer. Now my problem is that the header, which is set by default to the name of the section appears on the top right of all pages. I want to change it. I want it to appear on the top right for odd pages and on the top left for even pages. please help.
You must use the option `twoside` for the standard class _article_. \documentclass[twoside]{article} _article_ and _report_ classes come with `oneside` as option by default. \documentclass[twoside]{article} \usepackage{mwe} %For blindtext \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} \fancyhead[LE,RO]{\slshape\leftmark} \fancyfoot[C]{\thepage} \begin{document} \section{First section} \blindtext \newpage \blindtext \newpage \section{Second section} \blindtext \newpage \blindtext \end{document} !enter image description here
stackexchange-tex
{ "answer_score": 1, "question_score": 0, "tags": "fancyhdr" }
Cookie is not set automatically by the browser I am trying to login by calling an API via a POST HTTP request. post( postLogin(email), JSON.stringify({password: passwd}), { headers: { "Content-Type":"application/json" }, credentials: 'include' // i also tried with 'same-origin' } ) I am using Redux and React. In the API response, I receive the `Set-Cookie` header (I can see it in browser dev tools), but for some reason I cannot access it in my code and the browser doesn't set the cookie. I'm using Chrome Version 63.0.3239.84. It is a cross-origin request, so I have the following CORS headers set so I think it is not from here. Access-Control-Allow-Credentials:true Access-Control-Allow-Headers:* Access-Control-Allow-Methods:GET, OPTIONS Access-Control-Allow-Origin:* Do you have any suggestions or someone has this issue too? Thank you!
I have finally fixed it. The problem was that my application and the API were not in the same domain. I configure a local NGINX in order to have them under the same domain and it works fine.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, reactjs, http, cookies, redux" }
Angular JS format date I have a datetimepicker in one of my inputs and it returns this: "2016-11-15T19:44:33.984Z" I am trying to format it in my view, I have tried the following: {{user.dob | date:'yyyy-MM-dd'}} but it still returns `"2016-11-15T19:44:33.984Z"`
I dont see any issues with your filter code. You can check this sample <pre>Formatted date with angular filter (date:'yyyy-MM-dd') : <em>{{dt | date:'yyyy-MM-dd'}}</em></pre> **DEMO** If you are thinking something else then plz provide Plunker sample
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "jquery, angularjs" }
windows 8 phone development possible under windows 7? is it possible to develop windows 8 phone applications in windows 7 with vs.net 2010? Or do I need to upgrade to windows 8 altogether?
> Windows Phone 8 development possible under windows 7? No, Windows 8 64-bit and Visual Studio 2012 are required. Windows 8 Pro is also required to run the emulator (along with a processor that supports SLAT). Source: <
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 5, "tags": "windows, windows phone 7, windows phone 8" }
Como saber que objeto input perdió el foco Tengo lo siguiente en html: <input type="text" id ="a"> <input type="text" id ="b"> <input type="text" id ="c"> y en jquery: $('#a, #b, #c').blur(function(){ //acá ejecutar de acuerdo al objeto que perdió el foco }); Como sé que objeto fué el que perdió el foco?
Basta con capturar en una variable el **id** del elemento dentro de la función. Luego puedes usar la variable para lo que necesites, en el ejemplo lo muestro en consola. `$(this)` hace referencia al elemento con el que se está interactuando en el momento de perder el foco. Con `.prop('id')` capturas el valor del atributo **id**. $('#a, #b, #c').blur(function(){ //Capturar el id del elemento que pierde el foco let idElemento = $(this).prop('id'); //Mostrar el id en consola console.log(idElemento); }); <script src=" <input type="text" id ="a"> <input type="text" id ="b"> <input type="text" id ="c">
stackexchange-es_stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "jquery" }
Li-ion Swollen battery dangerous or not? I have a Wifi AP and its Li-ion battery has swollen so much that its cover cannot be put in place over it now. ![Li-ion swollen batter]( Its working but its backup time has reduced to 20%. I cannot put on the battery cover because of its bulge. Normally its mains charger is power-ON 24/7. Is it safe to keep it working in this shape? Is their any recommendation as to when to replace a Li-ion battery? Is it possible that it blows up and catches fire?
Provided it hasn't been over-charged, over-discharged or physically damaged it should be safe. But, _why_ did it puff up? If it _was_ overcharged, over-discharged or physically damaged then it could blow up. Apart from that, puffing indicates that some of the electrolyte has turned into gas, which reduces the capacity and efficiency of the cell. You should discharge this cell to zero volts, discard it and get a replacement.
stackexchange-electronics
{ "answer_score": 3, "question_score": 1, "tags": "batteries, lithium ion, charger" }
¿Cómo puedo hacer que en un ciclo if me permita volver a ingresar datos si es que son erróneos? //Programa que solicita un numero, si es par se multiplica por 1, en caso contrario se solicita otro numero sin cerrar el programa int i; int mult; System.out.print("Ingrese un numero: "); i = entrada.nextInt(); if(i % 2 == 0){ mult = i * 1; System.out.println("1 X "+ i + " = " +mult); } else{ System.out.println("Es un numero impar, por favor ingresa el dato nuevamente"); }// Hacer que regrese a pedir el número }
Necesitas utilizar un ciclo. while(true) { // Se repetira indefinidamente System.out.print("Ingrese un numero: "); i = entrada.nextInt(); if(i % 2 == 0){ mult = i * 1; System.out.println("1 X "+ i + " = " +mult); break; // Rompes el ciclo } else{ System.out.println("Es un numero impar, por favor ingresa el dato nuevamente"); } }
stackexchange-es_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java" }
Clear form data when user clicks back How do I clear the contact form data when the user clicks back on the browser to prevent spammers submitting the form multiple times by clicking back, submit over and over again?
If you are using HTML5 then you can set your FORM's Autocomplete function OFF. <form action="youractionpage" method="post" autocomplete="off"> </form>
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 5, "tags": "php, html" }
iOS 6 simulator doesn't look like iPhone My iOS iPhone simulator quit looking like an iPhone for some reason. Now it looks more like an iPad. Just yesterday it looked like an iPhone4/5 depending on my device selection. Here is an example of the odd look: < !enter image description here Anyone know how to get it to look like an iPhone again? I want this for capturing demo shots. Thanks
I have observed that the simulator will show this view if it is launched on a non-Retina screen. If I run the same app & same simulator on a retina screen, it will show the actual iPhone 4/5 frame. If you do not have a Retina MBP, you might try enabling HiDPI mode on your Mac and then restarting the simulator. But I don't know for sure if this will work. See: How to simulate a retina display (HiDPI mode) on a non-retina display?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ios6" }
How can I round up from number 621 to 700 in PHP? $num=621; echo round(round(621,-2));
I think you are trying to round off a number to the nearest 100. Simply do this by using the ceil function. ceil(621 / 100) * 100; You can use ceil function to round any number to its nearest number. $number = ceil($inputNumber / $nearestNumber) * $nearestNumber;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php" }
Magento 2 : Product URL rewrite issue I have a Magento 2.1.10 store. I have imported all the products and categories. Now the product url is > < But I want the URL as > < For this I have done the following steps 1. Stores->configuration->Catalog 2. Removed .html from both fieldsProduct URL Suffix ,Category URL Suffix . 3. Saved the config ,reindexed and cleared cache. But it didn't removed the html from url Then I have tried this solution < It works for all categories and some products. Now few Products have url like this < How can I make these URL as < ?
I have fixed the issue by using this extension < Reference: <
stackexchange-magento
{ "answer_score": 1, "question_score": 1, "tags": "magento2, magento 2.1, catalog, url rewrite, product urls" }
Character arrays assignment and comparison in C What does this statement mean in C language (assuming s1 and s2 are character arrays)? (s1[i] = s2[i]) != '\0'
Considering `string`s are `\0` terminated by the standard. (s1[i] = s2[i]) != '\0' it will assign `s2[i]` to `s1[i]` then it will compare whether assigned value is `\0` or not. It is usually used to break the loop while copying contents from one string to another.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "c" }
PHP string replace? How can I take a string like: navMenu[]=1&navMenu[]=6&navMenu[]=2&navMenu[]=3&navMenu[]=4&navMenu[]=5 And in php make it so that I can remove a certain value for the navMenu[], but it would still stay in the same order but with the value removed. Or add a value as well. I have been tampering with exploding it at the & sign but am not sure how I can add or remove a value, and making sure the & sign is not at the start or end of the string.
$str = 'navMenu[]=1&navMenu[]=6&navMenu[]=2&navMenu[]=3&navMenu[]=4&navMenu[]=5'; parse_str($str, $values); $values['navMenu'] = array_diff($values['navMenu'], array('3')); echo http_build_query($values); If you're getting this from the request, you don't even need `parse_str`, you can just get the already parsed string from `$_GET` or `$_POST`, remove the value, then use `http_build_query` to reassemble it into a query string.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, string" }
Can you override Date.Now or Date.Today for debugging purposes in an ASP.NET web application? We have a very massive system where reports are run off dates from specific days through to today's date using various definitions of "GenerateSalesReport(DateStart, Date.Now)". For debugging purposes, I want to simulate reports that occurred in the past so I need to change the object "Date.Now" to a specific date from the past on my development environment. Is it possible to override `date.Now`?
That is one of the failings of `DateTime.Now` and related functions. You should be passing in a `DateTime` to any function that relies on it. Any place you use `DateTime.Now` or `DateTime.Today` (and such) is a place where you should be passing in the date. This allows you to test for different `DateTime` values, will make your code more testable and remove the temporal dependency.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "asp.net, vb.net, datetime, date" }
Non-singular matrix, determinants I should find the values x for which the matrix is non-singular. ![Given matrix is ]( I already know that the matrix is singular when _det(A)_ is _0_. So basically the matrix will be non-singular when the determinant is something else than 0. I know how to find a determinant but I guess this should be solved "other way around"? It's a homework so hint would be appreciated.
Hint: Calculate the determinant of this matrix. You get an expression that depends on $x$. When is this expression zero?
stackexchange-math
{ "answer_score": 4, "question_score": 0, "tags": "linear algebra, matrices" }
Convert Array of RGB Integers to Bitmap We know that, we can get rgb of bitmap image with using the code as follow : BufferedImage img = ImageIO.read(new File(bitmapURL)); int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth()); And, after executing this parts of code, we have an array of integers that contains 4 bytes for `Alpha, Red, Green and Blue` colors of any pixel. So, i want to know that how can we convert an array of integers like `int [] myPixels;` to Bitmap ? Could any one please help me to reach this? Thanks in advance :)
You can directly use this : image.setRGB(0, 0, width, height, pixels, 0, width); Source
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "java, bitmap" }
column shading by date range I have a spreadsheet that has various rows filled in colours while the columns are set to months in text form - 'mmm' what I want to do is format the sheet so the column that is the current month is shaded - for example - March - to show it is the current month. This will change as we move into April etc etc I only want Current Month column to be shaded but I need to keep my original 'filled rows' as shown in the below screen example as they highlight other important info. example sheet:-!enter image description here Can anyone point me in the correct direction? All advice very welcomed. I am using Excel 2011 for Mac. my hoped for result is something along the lines of the below: !enter image description here
Here's another Conditional Formatting formula that works with your setup. Add this formatting rule from A2 to L22 in your case: =LOWER(A$1)= LOWER(TEXT(NOW(),"MMM")) Note that the conditional formatting with override your row colors.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "excel, excel formula, excel 2011, vba" }
Displaying graph labels, outcome not expected Consider the following two graphs: graph1 = Graph[{1, 2, 3}, {1 -> 3, 2 -> 3}, VertexLabels -> {3 -> 3, 2 -> 2, 1 -> 1}] graph2 = Graph[{1, 2, 3}, {1 -> 3, 2 -> 3}, VertexLabels -> {3 -> 3, 2 -> 1, 1 -> 2}] and the list containing both graphlist = {graph1, graph2} The code: testgraphs = SetProperty[#, VertexLabels -> {v_ :> Placed[{Style[v, Blue]}, {Above}]}] & /@ graphlist produces two V-shaped graphs, for which the labels (displayed in Blue) are the same for each vertex (across the graphs). I expect these to be different as the VertexLabels for graph1 and graph2 are different. Is there an issue with the code?
Try testgraphs = SetProperty[#, VertexLabels -> {v_ :> Placed[{Style[PropertyValue[{#, v}, VertexLabels], Blue]}, {Above}]}] & /@ graphlist; testgraphs ![enter image description here](
stackexchange-mathematica
{ "answer_score": 5, "question_score": 4, "tags": "graphs and networks" }
FileWriter not writing to text file (java) I am trying to write some variables to a text file once a user has inputted some data. I have had it working before but I was tinkering with it and now it doesn't write to the text file at all. Here is the code: try (PrintWriter out = new PrintWriter(new BufferedWriter( new FileWriter("C:\\Users\\A612646\\workspace\\CarParkProject\\PrePaid.txt", true)))) { if (AmountofHours < 0 || AmountofHours > 24) { out.print(RegNo); out.print("\t" + AmountofHours); out.print("\t" + CreditCardNo); out.print("\t" + expiry); } } catch (IOException e) { e.printStackTrace(); }
Are you sure the line: if (AmountofHours < 0 || AmountofHours > 24) should not be if (AmountofHours > 0 && AmountofHours < 24) You're saying if a car is parked less than 0 hours or more than 24 then write a line. I think you intend to say if a car is parked for longer than 0 hours and less than 24...
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, eclipse" }
Assigning random colour from RGB into a image I am implement a picture using OpenCV with Python, the requirement is to assign random R,G,B colour to every pixel into the image. Here is my current code: red, green, blue = (255, 0, 0), (0, 255, 0), (0, 0, 255) rgb = [red, green, blue] image = img_gen(width, height, rgb_color = random.choice(rgb)) width, height = 640, 480 def img_gen(width, height, rgb_color=(0, 0, 0)): ... for x in range (0, width): for y in range (0, height): # what code should be inserted here? I can now implement a picture with assigning only one random choice to fill in the whole image, but I want to know hot to access to every "pixel".
I'm not exactly sure what your img_gen function returns, but to get a random entry from rgb you can use be sure to `import random` try : img = [] for x in range (0, width): for y in range (0, height): img.append(rgb[random.randint(0,2)]) return img It really depends on the image format openCV expects in the functions you want to use. edit : if you are using numpy you should use img = np.array(width*height) then refer to the content with img[x*width + y] = ....
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "python, opencv, image processing" }
hyperref: How to open a directory view with href{...}? I wrote a small LaTeX file which describes the contents of some directories. Now I try to provide a direct link to the described files and directories. I successfully use `\href{filename.ext}{Link name}` to provide a link for files. Unfortunately if I pass a directory name to `\href` the PDF reader (tried with Adobe Reader and Evince) doesn't recognize the link. Examples of unrecognized links (a directory named _abc_ exists in the same directory as the .pdf is): \href{abc}{Open abc directory} \href{abc/}{Open abc directory} \href{./abc}{Open abc directory} \href{./abc/}{Open abc directory} \href{run:abc}{Open abc directory} \href{run:abc/}{Open abc directory} \href{run:./abc}{Open abc directory} \href{run:./abc/}{Open abc directory} Does anyone know if there is any chance to do this?
The root of the problem is that hyperref tries to be smart. If no file extension is found, hyperref adds `.pdf`, so the link becomes either `abc.pdf` or `abc/.pdf` depending on whether there is trailing `/` in the call. You can define your own command, say, `\HREF`, which simply constructs the link and does not do anything else. This works for me: \documentclass{article} \usepackage{hyperref} \makeatletter \newcommand\HREF[2]{\hyper@linkurl{#2}{#1}} \makeatother \begin{document} \HREF{tmp}{open directory \texttt{tmp}} \end{document} Note that this works in `xpdf`. Acrobat disables such links by security reasons. `evince` works with absolute paths (`file:///home/boris/scratch`) but balks at relative ones: somehow `../tmp/` works, but `./tmp` does not. I guess this is some bug in `evince`.
stackexchange-tex
{ "answer_score": 13, "question_score": 10, "tags": "hyperref, links" }
Delphi - Firemonkey Write Out Text to TRectangle still pretty new to Firemonkey. Got a component I'm adding to a form which descends from TRectangle. Once i've drawn it out, I want to add text into it but I'm really struggling to find anywhere which documents how to do this. Can anyone suggest anything or point me in the right direction? Thanks
To build on DSM's comment, this is an example of how to add a TLabel to a TRectangle (or a TRectangle descendent) in code: var MyLabel: TLabel; begin // Create a TLabel and add it to an existing TRectangle MyLabel := TLabel.Create(MyRectangle); // Set the Parent to MyRectangle MyLabel.Parent := MyRectangle; // Align the TLabel in the center of the TRectangle MyLabel.Align := TAlignLayout.Center; // Center align the text in the TLabel MyLabel.TextAlign := TTextAlign.Center; // Set the text for the label MyLabel.Text := 'Test Label'; end;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "delphi, firemonkey, delphi 10 seattle" }
Equation of the line passing through the intersection of two lines and is parallel to another line. The Question is : Find the equation of the line through the intersection of the lines $3x+2y−8=0,5x−11y+1=0$ and parallel to the line $6x+13y=25$ Here is how I did it.. $L_1 = 3x + 2y -8 = 0$ $L_2 = 5x -11y +1 = 0$ $L_3= ?$ $L_4 = 6x + 13y -25= 0$ I found the point of intersection : $(-2, -1)$ Using formula: $L_1 + kL_2$ = 0 $(3x + 2y -8) + k(5x -11y +1)=0$ $(3(2) + 2(1) -88) + k(5(2) -11(1) +1) = 0$ $(6 +2 -8) + k(10 -11 +1) =0$ $8-8 + k(11-11) =0$ $0 +k(0) = 0$ What's wrong ?
L1=3x+2y−8=0 L2=5x−11y+1=0 L3=? L4=6x+13y−25=0 (3x+2y-8) + k(5x-11y+1)= 0 ------(i) 3x+2y-8+5kx-11ky+k =0 Arrange and take common: (3+5k)x + (2 +11k) y - 8 +k =0 The slope from this equation is : -(3+5k)/(2-11k) Since L3 is parallel to L4 therefore: Slope of L3 = Slope Of L4 -(3+5k)/(2-11k) = -6/13 39+65k = 12 -66k 65k+66k = 12-39 131k = -27 k= -27/131 Put the value of k in equation (i) (3x+2y-8) + (-27/131)(5x-11y+1)= 0 393x+262y-1048 -135x+297y-27= 0 258x+559y-1075 =0 Divide by 43: 6x +13y-25 =0 ------(ANSWER) ThankYOU :)
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "linear algebra" }
Badge on TabBarItem I use **UITabBarController** for iOS app. it has 3 tabs. For example tab1 (current tab), tab2 and tab3. I want put **a small red badge** on tab3 icon when click a button on tab1. Is there any way to add it?
UITabBarItems have a badgeValue property. You can set this when your delegate method gets fired. - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item; You can get the TabBarItem #3 from the tabBarController with [tabBarController.tabBar.items objectAtIndex:2];
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, uitabbarcontroller, badge" }
Short Date into English Long Date Convert short date format into English long date in as few bytes as possible. # Input Input will be in the form of a string with format, `yyyy-mm-dd`, with zero padding optional for all values. You can assume that this is syntactically correct, but not necessarily a valid date. Negative year values do not need to be supported. # Output You must convert the date into the English long date format (e.g. `14th February 2017`). Zero padding here is not allowed. If the date is invalid (e.g. `2011-02-29`), then this must be recognised in some way. Throwing an exception is allowed. More examples can be seen below. # Test Cases "1980-05-12" -> 12th May 1980 "2005-12-3" -> 3rd December 2005 "150-4-21" -> 21st April 150 "2011-2-29" -> (error/invalid) "1999-10-35" -> (error/invalid)
# PostgreSQL, 61 characters prepare f(date)as select to_char($1,'fmDDth fmMonth fmYYYY'); Prepared statement, takes input as parameter. Sample run: Tuples only is on. Output format is unaligned. psql (9.6.3, server 9.4.8) Type "help" for help. psql=# prepare f(date)as select to_char($1,'fmDDth fmMonth fmYYYY'); PREPARE psql=# execute f('1980-05-12'); 12th May 1980 psql=# execute f('2005-12-3'); 3rd December 2005 psql=# execute f('150-4-21'); 21st April 150 psql=# execute f('2011-2-29'); ERROR: date/time field value out of range: "2011-2-29" LINE 1: execute f('2011-2-29'); ^ psql=# execute f('1999-10-35'); ERROR: date/time field value out of range: "1999-10-35" LINE 1: execute f('1999-10-35'); ^ HINT: Perhaps you need a different "datestyle" setting.
stackexchange-codegolf
{ "answer_score": 5, "question_score": 14, "tags": "code golf, date, conversion" }
Which declaration is causing a unit to be implicitly imported? I'm installing some custom components for a project. I wrote these many years ago so it's a bit fuzzy how things got linked. I'm getting many warnings like: > [dcc32 Warning] Life32v2.dpk(53): W1033 Unit 'DDUtils' implicitly imported into package 'Life32v2' However when I do a Find in files `ctrl``shift``F` for `DDUtils` it is nowhere to be found in the project(group). Obviously `DDUtils` is used by a unit that **is** explicitly imported by one of my components or the link is even more indirect than that. Doubleclicking on the error simply takes me to the dpk file which is useless. Is there a way to see by which route a unit gets imported?
You can easily find the unit that uses it. Simply find `DDUnit` (`.pas` and/or `.dcu`) on your harddisk and rename it to say, `old_DDUnit.pas` and/or `old_DDUnit.dcu`. Then recompile and the compiler will tell you which unit can't compile because it can't find `DDUnit`. I usually use the free, excellent and terribly fast everything.exe search tool to find any file name or folder on my system. Of course an IDE tool would be nice, but the above works fine.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 3, "tags": "delphi, package" }
Help - endless dealloc loop I am trying to harden my code to avoid low-memory crashes. I'm stuck on one in particular, which occurs according to these steps: 1. Start app. 2. Tap button that presents modal viewcontroller. 3. Simulate memory warning. Via NSLog statements everywhere, I see that the initial (presenting) viewcontroller receives a memory warning, then its dealloc method is called over and over until a crash. For purposes of debugging, I have nothing in my didReceiveMemoryWarning, viewDidUnload, or dealloc methods except the NSLog statements. What does this sound like? Maybe I have some retained instance variable which has a pointer back to the view controller? I just need a general guess of what could be causing this. Can't post my entire view controller code which runs into the 1000's of lines. Thanks.
You indicated in your latest comment that you think you fixed a case of over-releasing the view controller, but I'm not so sure about that. Over-releasing the view controller will still cause `dealloc` only to be called once. A much more likely cause of " _dealloc method called over and over until a crash_ " is calling `[self dealloc];` in your `dealloc` method, rather than the appropriate `[super dealloc];`. Check that your code is correct in this respect, there may be infinite recursion causing you issues. :)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "objective c, ios, memory management, uiviewcontroller, dealloc" }
How can I change the color of the JFXHamburger I use the JFoenix Libary to develop a program with JavaFX. The default color of the JFXHamburger is black but I need white. I use the SceneBuilder to design the program but I can not find any property where I can change the color. Does anyone know how I can do this? TIA.
This might help: How to change the color of the hamburger icon Or this, to change the background: Change Pane Background
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "java, javafx, scenebuilder, jfoenix" }
Image 100% of a div How can I make an image 100% of a div ? I have a 300x300 image and I want to make it the full size of a bigger div. (the size of this div can change, so I have to specify somewhere 100% of it) Is there a solution in CSS or Javascript ?
try this: <img src="test.jpg" alt="test" id="bg" /> img#bg { position:fixed; top:0; left:0; width:100%; height:100%; } css3 also supports this: #testbg{ background: url(bgimage.jpg) no-repeat; background-size: 100%; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "javascript, css, image, resize" }
Zend response application/json utf-8 usually in a xhr action I use this code $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $response = $this->getResponse(); $response->setHeader('Content-type', 'application/json', true); return $response->setBody(Zend_Json::encode($data)); I'm wondering if it need utf-8 encoding like this $response->setHeader('Content-type', 'application/json;charset=UTF-8', true);
It would be good practice to do so. You may not see any problems if you don't. It depends what kind of data you are sending. there is a much shorter way to do what you are doing (Disables layouts and sets the right headers): $this->_helper->json->sendJson($data);
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 5, "tags": "php, json, zend framework" }
Why do I get a "volume with software packages has been detected" dialog every time I log in? !screenshot This comes up every time I login, how do I remove this or fix it. Thanks.
This happens because you have: * An Ubuntu install CD (or Live-CD) in your CD drive * or, an Ubuntu LiveUSB plugged into your computer Please eject and remove all CDs and any USB drives, and then try starting your computer. The message should no longer appear.
stackexchange-askubuntu
{ "answer_score": 8, "question_score": 4, "tags": "package management, login" }
Refresh Recycler View By Clicking A Button In Another Recycler View I am having two Fragments FragmentA and FragmentB inside and activity , both Fragments contains recyclerview with custom layout, now how can i refresh FragmentB's recycler view by clicking on a button which is placed in FragmentA's recyclerview???
Fragment A will communicate to hosting Activity on button click. The Activity will notify the Fragment B to refresh its recyclerview. You communicate with hosting activity with the help of interface.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "java, android, android fragments, android recyclerview" }
Where does WebLogic 12.2.1 keep the users/passwords? In WebLogic 12.2.1 console, under Security Realms -> myrealm -> Users and Groups, we can add users and also change the passwords of existing users. Where does WebLogic keep these user names and their passwords? I looked at config.xml and I don't find them.
Weblogics brings an embedded ldap server by default, which is where it stores the users and passwords. The files are usually in the following folder `$DOMAIN_HOME/servers/AdminServer/data/ldap` You can find more information about the embedded ldap server for here: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "security, credentials, weblogic12c" }