body1
stringlengths 20
4.1k
| body2
stringlengths 23
4.09k
|
---|---|
If a body with an accurate clock is moving away from A which is stationary, then the time in B would be slower than that in A. Since relative to B A would have an equal velocity time in A would be slower than that in B. This results in a contradiction. This is the argument given in this . Can someone say how this argument is wrong from a deeper study of SR.? | It is said that we can verify time dilation by flying a very accurate clock on a fast jet or spaceship and prove that it registers less time than the clocks on earth. However, the clocks on earth would be moving relative to the clock on the spaceship, and since time always dilates and never goes faster regardless of the direction of relative motion, the clocks on earth should register less time than the clock on the spaceship. Is this true? Whenever there is a fast-moving object such as a rocket do all clocks on earth really become slow? If the rocket with the clock landed after moving at relativistic speed, would its clock and the earth's clock again show the same time since during its travel both appeared slow to each other? Or is all this just an illusion, ie. the clocks just appear to be slow to each other but in actually run at normal speed, and neither is behind when the rocket actually lands? |
I would like to create a form with CCK. The user should be able to create unlimited number of "people" : M - Smith - John Mrs - Dave - Lily M - John - Doe ... So I need a Select (with gender) - textfield (last name) - textfield (first name). I can not create each field to unlimited it would not be linked. I have tried field_group, but it does not give me the ability to put multiple value. What would be the best way to do that ? I thought about create my own field with those 3 inputs. but it seems way to complicated for the simple thing I need to do. further more I cannot find any good tutorial. EDIT : I'm using Drupal 7 | I've used in the past to do multiply occurring series of field groups; now, working on a Drupal 7 project, I'm setting up a "Resume" content type and need a way to set up repetitive entries for education/work experience. IE: for "Education", I need the ability to dynamically add new rows comprised of a combination of dates and places for each institution studied at. What is the best way to accomplish CCK3 multigroup/FlexiField-like functionality in Drupal 7? Thanks! |
The small reputation graph on the profile page is broken in Edge and IE: While in Chrome it looks like this: Firefox also shows it correctly. I have not tested Safari. I know the Edge rendering engine is going to go away at some point, so this issue will disappear in the long run, but it'd be nice if Stack Exchange worked on all browsers, not just the main ones. Seeing as you are redesigning the profile page, seems like an ideal time to fix it. π Tested versions: Chrome 71.0.3578.98, Firefox 64.0, Edge 44.17763.1.0, IE 11.195.17763.0, all on Windows 10 1809 (17763). | Which browsers are officially supported by Stack Exchange? Also, what else is needed in order to use every feature of the site? |
I want to know if I can create an animation in a separate Blender file, and put it into another file so I don't have to worry about the scenery in my Animation. Thanks! | I have created several designs for a particular project and they are related, but I don't want to have to keep recreating any similar elements, such as shared materials or textures. How can I use the existing data in a new Blender file? |
I use String.Compare like below sample static void Main(string[] args) { int result = String.Compare("A", "a"); Console.Write(result); Console.ReadKey(); } but , when run the program , result is 1 . but i except result will be -1 . i use vs 2013 . | When comparing two strings in c# for equality, what is the difference between InvariantCulture and Ordinal comparison? |
I want to change my OS from windows to UBUNTU. So what I did is below. I downloaded the Ubuntu 16.04.3 LTS from saved it in a usb and set the boot order of USB to be the first boot in BIOS. But the installation failed. What causes the installation to fail? after saving the changes in BIOS the laptop restarts and goes to windows Additional information Laptop is new and i am installing to change os to practice programming better. | I would like to see a full how-to guide on how to install Ubuntu. |
Is it true you shouldn't rely on placeholder alone for form input fields? ie - Because putting the same text as the title seems reduntant: ie - Is there a reason why a title is necessary for simple/self explanatory form fields? | I am familiar with research on label placement to the left or above. I tend to go with right justified with the label to the left of the field for my form designs. However, inline placeholder text is trending and it does further reduce page clutter. Is there any research out there supporting its use? Has anyone conducted usability studies on their forms that they can share? Research Links: |
Many times in physics when we analyze a physical system mathematicly we get divergences, but when those divergences has no dependence on any actual physical quantity of interest we tend to disregard those "infinity Constants". An example where such a thing happens is in the derivation of the Casimir force for two metal plates we get $\zeta(-3)$ which contains infinities. One can provide many more examples where we make this analytical approach. My question is why those infinities are treated this way, is there a deep mathematical reason why we do it? | For starters, let me say that although the Casimir effect is standard textbook stuff, the only QFT textbook I have in reach is Weinberg and he doesn't discuss it. So the only source I currently have on the subject is . Nevertheless I suspect this question is appropriate since I don't remember it being addressed in other textbooks Naively, computation of the Casimir pressure leads to infinite sums and therefore requires regularization. Several regulators can be used that yield the same answer: zeta-function, heat kernel, Gaussian, probably other too. The question is: What is the mathematical reason all regulators yield the same answer? In physical terms it means the effect is insensitive to the detailed physics of the UV cutoff, which in realistic situation is related to the properties of the conductors used. The Wikipedia mentions that for some more complicated geometries the effect is sensitive to the cutoff, so why for the classic parallel planes example it isn't? EDIT: Aaron provided a wonderful Terry Tao ref relevant to this issue. From this text is clear that the divergent sum for vacuum energy can be decomposed into a finite and an infinite part, and that the finite part doesn't depend on the choice of regulator. However, the infinite part does depend on the choice of regulator (see eq 15 in Tao's text). Now, we have another parameter in the problem: the separation between the conductor planes L. What we need to show is that the infinite part doesn't depend on L. This still seams like a miracle since it should happen for all regulators. Moreover, unless I'm confused it doesn't work for the toy example of a massless scalar in 2D. For this example, all terms in the vacuum energy sum are proportional to 1/L hence the infinite part of the sum asymptotics is also proportional to 1/L. So we have a "miracle" that happens only for specific geometries and dimensions |
My brother downloaded a game on his ps4 console, and I would like to play that game on my console without buying it myself. Is this possible? | So this is the situation: My brother received a PS4 on his birthday. He doesn't have a PS+ account, and I don't have a PS4, so I activated it as my primary PS4. Based on what I've read on the FAQ, any user can play my digital games and do online gaming since I activated the system as my primary PS4. A friend offered his account so we can play his digital games. He has a primary PS4 activated. The question is, can we really play his games without any issues? For example, can we download GTAV from his account and play it using any account on our PS4? |
I have a Plantronics BackBeat Sense SE bluetooth headset. When Connecting it to Windows 10, it installs two profiles in Playback devices list: PLT_BBTSENSE Hands-Free. PLT_BBTSENSE Stereo. The Second one (Stereo) is set to be the "Default Device" and the "Default Communication Device" on the system. At this point the sound works great and normally. The problem happens when I want to use the mic. When I start any program that uses the mic (recorder, chat, VoIP Calls, gaming, etc.) The sound suddenly stops working And I can only use the mic until I stop the recorder or the call. The thing that kind of fixes the problem is setting the (Hands-Free) as the default device. I can hear the sound when I do that and it works with the mic but it becomes Very bad quality. What I became to understand is that bluetooth had different profiles for sound and mic: A2DP and HSP. The first handle the voice(High Quality) but the latter handles the mic and reduces the sound quality. Is this really the case? Is there anyway to make them work simultaneously? Is there any solution to this problem at all? | Is it somehow possible to get better audio quality sound when Bluetooth headphones are on hands-free mode? When it is audio only, sound quality is good (16-bit 44β―kHz) but when I talk through the microphone, audio quality is changed to poor (16-bit 8β―kHz) like an old radio. Or I do not hear something through headphones. I have Creative Sound Blaster Jam. Simple, have set Bluetooth Audio Renderer (Bluetooth stereo audio), for playing, with Bluetooth Audio Input Device (Bluetooth Hands-free audio), for recording? |
What is the title of this movie? I think it's set somewhere in Europe. There were a group of friends in a yacht in the middle of the sea when a strong storm capsized their boat. Some managed to survive and drifted to an island with small village. Apparently, they are killers and skin their preys and wear them. There is also a beautiful lady with lower limbs of an octopus tentacles. She fell in love with the male main character. In the end, that character is one of them - the sea creatures. | There is a movie I watched many years ago. I can hardly remember its title. The movie was set on an island. The story goes like this: A group of friends were on a yacht when a strong storm capsized their boat. They managed to survive and landed on a remote island with small village. Its inhabitants act strangely. They are killers who skin their victims and wear them. There is a beautiful lady with octopus tentacle legs. She fell in love with the main character. |
I wanted to create bash binding so that ctrl+backspace deletes word in terminal. But I somehow ended up screwing up my backspace and now it doesn't work, it outputs character. I know I can list all binding with bind -P but can't delete them or find where file with bindings is located. I have .inputrc but its empty. | I bound some keys by mistake, and they don't work any more, such as HOME, END, UP, DOWN, LEFT, RIGHT. Is there a way to reset all the bound keys to their original state? |
Let $A$ and $B$ be disjoint compact subsets of a Hausdorff space $(X,Ο)$. Prove that there exist disjoint open sets $G$ and $H$ such that $AβG$ and $BβH$. This one was getting a bit messy for me, but my idea is to first fix a point $x$ in $B$ and then apply Hausdorff property on points of $A$ so for all points an in $A$ with $x$ in $B$ we can find disjoint open sets containing them. We can say $U_a$ and $V_a$ be the set of all open sets we just created such that $U_a$ and $V_a$ are disjoint. We note that $U_a$ is an open cover for $A$ and we can pick out a finite subcover. Then we select another point in $B$ and repeat the same process and do this for every single point in $B$. Then we have a family of finite subcovers each corresponding to each point in $B$. We can take the intersection and call it $W$ and let that be the open set that contains $A$. Then the next step would be to repeat everything above by fixing a point in $A$ and cycling through points in $B$ then fixing another point in $A$ and create a family of open subcovers to cover $B$ and intersect them all and call that $G$. Now I believe $A$ is contained in $W$ and $B$ is in $G$ and $W$ and $G$ are disjoint. A concern I have is that while each subcover is finite, the family of subcover may be uncountable and the intersection of uncountable open sets are not always open. | I want to show that any two disjoint compact sets in a Hausdorff space $X$ can be separated by disjoint open sets. Can you please let me know if the following is correct? Not for homework, just studying for a midterm. I'm trying to improve my writing too. My work: Let $C$,$D$ be disjoint compact sets in a Hausdorff space $X$. Now fix $y \in D$ and for each $x \in C$ we can find (using Hausdorffness) disjoint open sets $U_{x}(y)$ and $V_{x}(y)$ such that $x \in U_{x}(y)$ and $y \in V_{x}(y)$. Now the collection $\{U_{x}: x \in C\}$ covers $C$ so by compactness we can find some natural k such that $C \subseteq \bigcup_{i=1}^{k} U_{x_{i}}(y)$ Now for simplicity let $U = \bigcup_{i=1}^{k} U_{x_{i}}(y)$, then $C \subseteq U$ and let $W(y) = \bigcap_{i=1}^{k} V_{x_{i}}(y)$. Then $W(y)$ is a neighborhood of $y$ and disjoint from $U$. Now consider the collection $\{W(y): y \in D\}$, this covers D so by compactness we can find some natural q such that $D \subseteq \bigcup_{j=1}^{q} W_{y_{j}}$. Finally set $V = \bigcup_{j=1}^{q} W_{y_{j}}$, then $U$ and $V$ are disjoint open sets containing $C$ and $D$ respectively. What do you think? |
A friend of mine wanted to convert his MBR boot drive to GPT to use UEFI. He accessed DISKPART over the command prompt within the Windows installation environment using SHIFT + F10 and used clean then convert gpt on his disk. After that he proceeded with the setup partitioning his disk and installing the system. What methods can we try to restore the partition table and files? | When I reinstall Windows XP by mistake I deleted all five partitions. I did not format them yet though. How can I recover the partitions? When I attach the hard disk to another PC it just says that the partition is unformated and asks "Would you like to format it?". |
I'm trying to replace a divs content with jQuery's .html() function and within that new content i want to create a button, containing an ID that i can access from another function. $('#content').html("<div style='padding: 10px;'>" + " <input class='btn btn-primary' value='Button' id='button'> </input>" + "</div>"); After this i got another function that tries to access the button: $('#button').click(function(e){ //... do something }); I inspected the generated button in Chrome and it tells me that it has the right ID but somehow nothing happens when i try to trigger it? Any solutions on that? Thanks in advance. | I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off. This happens on page ready and works just fine. The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound. I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option. |
How can I print the contents of a file minus everything including and below the line above the first occurrence of a pattern? Say the pattern is "^Previous" on line 15; then I would like to print lines 1--13. | grep --before-context 5 shows 5 lines before the match. I want to show everything before the match. Doing grep --before-context 99999999 would work but it is not very... professional. How to show all the file up to the match? |
I have a problem $ mono Source/PashConsole/bin/Debug/Pash.exe [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;mPash - Copyright (C) Pash Contributors. License: GPL/BSD. See https://github.com/Pash-Project/Pash/ [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;m [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;mPASH /home/gbuday/projects/Pash> [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;m that seemed to be a terminal one but it might be a Mono one. Might Mono not set termcap or terminfo properly and that causes that garbage to go on my terminal? | I would like to use , a PowerShell implementation for mono on my CentOS box. After compilation I started it and got $ mono Source/PashConsole/bin/Debug/Pash.exe [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;mPash - Copyright (C) Pash Contributors. License: GPL/BSD. See https://github.com/Pash-Project/Pash/ [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;m [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;mPASH /home/gbuday/projects/Pash> [%?%p1%{8}%<%t37%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;7%;m[%?%p1%{8}%<%t40%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;0%;m I was told that my terminal does not understand ANSI sequences. I use gnome terminal. Is it capable of this with some configuration trick? Or, I need to use some other terminal emulator software? |
I want to go from $(0,0)$ to $(8,8)$ in this $8\times8$ grid. I can only move up or right. However, I have to avoid the points $(3,3), (3,4), (4,3), (4,4)$ ($a,b,c,d$ in the figure). How many distinct paths are possible? | I was asked to find the no. of ways to get from (0,0) to (8,8) with the 4 points of the shaded box unpassable, aka I can't use the 4 points namely (3,3)(4,4)(3,4)(4,3) while on my way to (8,8). Right and up movements. I know it is something like a pascal triangle and worked out the solution of 4050 ways. May I know if there are any faster means using permutation formula? Thank you in advance. |
There have reports of issues with mobile site's ability to "flag" or "close" questions: This seemed to have been fixed, however, when the new categories of close/flag votes were introduced the issue has reoccurred again. As of now I am unable to "close" or "flag" from the mobile interface to the site. | This morning (it's about six AM here) I find that I can no longer submit close votes; the link just jumps to the beginning of the page. I'm on iOS, using a third-party browser called Grazing, but a brief check with Mobile Safari shows the same problem there. Here on Meta, where my score is much lower, I only get a "delete" link on my own question, and that works fine. (Oops :-)) Update: As per comments, this affects the "flag" link, too, which doesn't even scroll to the top of the page. Update 2: Latest comment suggests this affects Android, too. Update 3: This also affects desktop computers when viewing mobile (when you click "mobile" in the footer) Update 4: mentions Windows 8, too; simply deleting platform-specific tags |
is it possible to write/edit the files on the memory card with i tried the command: termux-setup-storage but it only gives the permission to write on my device storage(/emulated/0/) | How do I access $HOME/storage Termux directory on Android Pie with a GUI File Explorer? In Termux I print the working directory with pwd and it shows $HOME/storage as: /data/data/com.termux/files/home My internal storage looks like this: . βββ Alarms βββ Android | βββdata | | βββ ... | | βββ com.termux | | | βββ files | | | βββ 0 items | | βββ ... | βββ ... βββ DCIM βββ Download βββ ... My external storage looks like this: . βββ Android | βββdata | | βββ ... | | βββ com.termux | | | βββ files | | | βββ 0 items | | βββ ... | βββ ... βββ LOST.DIR Neither my internal storage, nor my sd card, contain a /data/ directory at the root level. Where is this /data/ directory? For that matter, where is the root /storage/ directory? Where is the root /emulated/ directory? Where are any of these directories and why cant I access any of them? |
I am trying to prove the following using induction, and kind of stuck. I used a computer to validate this sentence. Using $n = 1$ gave the correct result. I assumed that this is true for some $n = k$, but how do I prove for $n = k+1$. Should logarithms be used? $$2\leq \left(1+\frac{1}{n}\right)^{n}\leq 3$$ I've seen similar solutions, but none with induction, I need a solution using the natural numbers, without limits and calculus. | (a)For $m,n \in \mathbb{N}$, $m<n$ and $k=0, ..., m$: $$\frac{1}{m^k} \binom{m}{k} \leq \frac{1}{n^k} \binom{n}{k}$$ (b)For $n\in \mathbb{N}$ and $k=1, ..., n:$ $$\frac{1}{n^k} \binom{n}{k} \leq \frac{1}{k!} \leq \frac{1}{2^{k-1}}$$ (c)Show that for $n \in \mathbb{N}:$ $$2 \leq (1+ \frac{1}{n})^n < 3$$ Use (a) and the binomial theorem for (b). Use the following for (c): $$\sum_{j=0}^{n}q^j=\frac{1-q^{n+1}}{1-q}$$ I've already proven (a) thanks to @trancelocation. Now I got stuck on (b) and (c). (b) I don't know how to use (a) and the binomial theorem here. $\frac{1}{n^k} \binom{n}{k} \leq \frac{1}{k!} \leq \frac{1}{2^{k-1}} \Leftrightarrow \frac{n!}{n^k*(n-k)!* k!}\leq \frac{1}{k!} \leq \frac{1}{2^{k-1}} \Leftrightarrow \frac{n!}{n^k*(n-k)!}\leq 1 \leq \frac{k!}{2^{k-1}}$ Now I have to show: $\frac{n!}{n^k*(n-k)!}\leq 1$ and $1 \leq \frac{k!}{2^{k-1}}$ $\frac{n!}{n^k*(n-k)!} = \frac{n*(n-1)*...*(n-k+1)*[(n-k)*...*1]}{n^k*[(n-k)*...*1]}=\frac{n*...*(n-k+1)}{n^k}=\frac{n}{n}*\frac{n-1}{n}*...*\frac{n-k+1}{n} \leq 1$. The first factor is $1$. Starting from the second factor their value gets smaller, so the entire term gets smaller then $1$. I tried to do it like this: for $i=0, ..., n$: $\frac{n-i}{n} \leq 1 \Leftrightarrow n-i \leq n \Leftrightarrow 0 \leq i$ For the second part: $\frac{k!}{2^{k-1}} \geq 1 \Leftrightarrow \frac{k!}{2^k*2} \geq 1 \Leftrightarrow \frac{k!}{2^k} \geq 2\Leftrightarrow \frac{k}{2}*\frac{k-1}{2}*\frac{k-2}{2}*...*\frac{1}{2} \geq 2$ So for $\frac{k-j}{2} \geq 2$, with $j=0, ..., k-1$ $\frac{k-j}{2} \geq 2 \Leftrightarrow k-j \geq 4$ This doesn't seem to help at all. (c)$2 \leq (1+ \frac{1}{n})^n < 3$ I didn't know how to start at c) at all. The provided formula doesn't help me. |
I'm pretty new to Linux, but trying to learn. Ive installed Ubuntu 18 as a VM and playing around. I was wondering, is there a plugin/application/scheme (not sure of proper term) that allows you to preview what linux is doing in the shell when you do things in the GUI? For those of you familiar with Windows Server environments, im looking for something like the "Preview powershell command" button that is in the bottom of the gui windows. I feel this would help me a ton on learning commands and seeing what is actually happening in the shell. For example when i install a program using the 'ubuntu software' repository, and click to install 'terminator' is there something that someone has created that will let me see "sudo apt install terminator" ? Thanks in advance! | Is there any application (or sequence of commands) for this function: seeing the result of the actions, while using a GUI interface, being automatically translated into a Terminal (or similar CLI environment) on the same machine. I saw this in action long years ago in VBA for Applications (for example the Macros in Excel). I wonder if there is same function in Linux. |
A piece of spaghetti falls and breaks into three pieces with two break points selected randomly. What is the probability that an ACUTE angled triangle can be formed with the three pieces? My initial attempt was to find cases of ALL triangles which I managed to conclude has a probability of 1/4. I have also seen a similar problem on this site which yields the same answer so I am happy with the steps up to this point! I would please like some help as to how I should now isolate the cases for acute triangles only? Thanks! Edit: Had a look at the link below but I think mine may be slightly different as it deals with the case of a totally random and independent break. Not the case where we break once and choose another of the two to break again. | A stick is broken in three parts of any length , if we join the pieces then what's the probability of getting a acute angled triangle? |
I have a text file containing a an array of objects in the following format: [{ "symbol": "MSFT", "side": "BUY", "price": 120, "quantity": 100 }, { "symbol": "KPMG", "side": "SELL", "price": 88, "quantity": 10 }] However, when I upload the file into my application, and store it as a variable, it gets stored as a string. Does anyone know how I can avoid doing this? I want to be able to read the file in (which I can already do) and store that as an array. So I can go like data[1] and get access to { "symbol": "KPMG", "side": "SELL", "price": 88, "quantity": 10 } I also want to be able to go like: data[1].side and retrieve the field | Given a string of JSON data, how can I safely turn that string into a JavaScript object? Obviously I can do this unsafely with something like: var obj = eval("(" + json + ')'); but that leaves me vulnerable to the JSON string containing other code, which it seems very dangerous to simply eval. |
How small should I be making functions? For example, if I have a cake baking program. bakeCake(){ if(cakeType == "chocolate") fetchIngredients("chocolate") else if(cakeType == "plain") fetchIngredients("plain") else if(cakeType == "Red velvet") fetchIngredients("Red Velvet") //Rest of program My question is, while this stuff is simple enough on its own, when I add much more stuff to the bakeCake function it becomes cluttered. But lets say that this program has to bake thousands of cakes per second. From what I've heard, it takes significantly longer (relative to computer time) to use another function compared to just doing the statements in the current function. So something that's similar like this should be very easy to read, and if efficiency is important wouldn't I want to keep it in there? Basically, at what point do I sacrifice readability for efficiency. And a quick bonus question, at what point does having too many functions decrease readability? Here's an example of Apple's swift tutorial. func isCandyAmountAcceptable(bandMemberCount: Int, candyCount: Int) -> Bool { return candyCount % bandMemberCount == 0 They said that because the function name isCandyAmountAcceptable was easier to read than candyCount % bandMemberCount == 0 that it'd be good to make a function for that. But from my perspective it may take a few seconds to figure out what the second option is saying, but it's also more readable when ti comes to knowing how it works. Sorry about being all over the place and kinda asking 2 questions in one. Just to summarize my questions: Does using functions extraneously make efficiency (speed) suffer? If it does how can I figure out what the cutoff between readability and efficiency is? How small and simple should I make functions for? Obviously I'd make them if I ever have to repeat the function, but what about one time use functions? Thanks guys, sorry if these questions are ignorant or anything but I'd really appreciate an answer. | 35 lines, 55 lines, 100 lines, 300 lines? When you should start to break it apart? I'm asking because I have a function with 60 lines (including comments) and was thinking about breaking it apart. long_function(){ ... } into: small_function_1(){...} small_function_2(){...} small_function_3(){...} The functions are not going to be used outside of the long_function, making smaller functions means more function calls, etc. When would you break apart a function into smaller ones? Why? Methods should do only one logical thing (think about functionality) You should be able to explain the method in a single sentence It should fit into the height of your display Avoid unnecessary overhead (comments that point out the obvious...) Unit testing is easier for small logical functions Check if part of the function can be reused by other classes or methods Avoid excessive inter-class coupling Avoid deeply nested control structures Thanks everyone for the answers, edit the list and vote for the correct answer I'll choose that one ;) I am refactoring now with those ideas in mind :) |
I think the comment-reply (ping) mechanism is way too limited. You can only reply to one person in a comment. And you can't use an @ whatsoever in questions and answers. It just doesn't make sense to me. Sometimes, when responding to a chain of comments, multiple commenters might be making the same point or similar points, and your answer to them might be the same. Therefore, it would be better to be able to comment-reply to all of the users in one comment, instead of posting multiple comments or only responding to one of them. On a question asked before about this, user Manishearth answered that one can just add a comment under with the other user's name. Not only is this less practical, but a few problems can arise. Firstly, what if there is a lot of people you want to ping? If the comment chain gets too long everyone is moved to chat, which might not work too well in every situation. Secondly, in a case of a sea of comments, your extra referral might get lost in all the comments, leaving the user tagged oblivious as to what comment they were actually tagged to. In questions and answers, there are many times were pinging someone would be quite beneficial. Just look at this question, where notifying user Manishearth of his mention would've been great, as I'd be able to get his opinion, and he would be aware if I was using his name in vain (or just misrepresenting his opinions or answers). If your question includes or links to a post of another user, then it would be great to be able to ping them. Or if the question is about something a user said, like this question: And in questions, there are many times you find yourself quoting or pointing to something another user has already said. What if we could instead of just give credit to them, also let them know we referenced something they said first. If there is a reason why this wouldn't work, or would be bad, please enlighten me. | Now this is probably a surprise to many since I always see thousands of comments like : @Sarfraz, @balpha just told you they did in the first comment he wrote. Also, allowing only one Stack Overflow user to be logged in per IP address would be problematic for networks with shared IPs. What's surprising is that apparently the notification will trigger only for Sarfraz and not for balpha. As you can see from the : Only one person can be replied to at a time in a comment. The first one in the string wins. I propose to increase the limit to let's say 3 or 5 people; it won't hurt (never seen that feature being abused) and especially many people believe it already works that way. |
I have the following problem: "Assume $R$ is an ID. For each maximal ideal $M$ let $R_M$ be the localization $(R \ M)^{β1}R$ considered as a subset of $Frac(R)$. Show that $\cap_M R_M = R \ (β Frac(R))$ where the intersection is over all maximal ideals $M$." Was given a hint saying to take $q$ in the intersection and consider the ideal $\{r \in R; rq \in R\}$ but I am not sure how to work with these things. Can someone give me some others hints in order to make my work easier and try to explain me how to see an arbitrary element in the localization ring? Thank you very much, everyone! | This result appears to be ubiquitous as an algebra exercise. How do you prove this result? Let $A$ be an integral domain with field of fractions $K$, and let $A_{\mathfrak{m}}$ denote the localisation of $A$ at a maximal ideal $\mathfrak{m}$ considered as a subring of $K$. Prove that $$A = \bigcap_{\mathfrak{m}} A_{\mathfrak{m}}\,,$$ where the intersection is taken over all maximal ideals $\mathfrak{m}$ of $A$. |
Given that two circles with coordinates (x1, y1) and (x2, y2) and radius r1 and r2 respectively . I need to find an equation , which can be used in code to to find the coordinates and the presence of touching and intersection . Like Ay2 + By + C = 0 . Circle 1 (x - x1)2 + (y - y1)2 = R1 * R1 Circle 2 (x - x2)2 + (y - y2)2 = R2 * R2 | Given the radius and $x,y$ coordinates of the center point of two circles how can I calculate their points of intersection if they have any? |
When making a fabric server and adding mods to it, do you have to download the mods the server has in order to even join your Minecraft server? | I'm wondering if I could play Minecraft with my friend. A modded Minecraft, only myself with mods and him without mods. Is it possible? |
It seems that when someone drops their saber it turns off, but Lukes hand still gripped his when his hand got chopped. Why did it extinguish? | I rewatched the three newer movies and noticed that whenever a Jedi was killed, or let go of their lightsaber, it immediately turned off. What was curious was that the lightsaber turns off right away, when a Jedi is killed, even before it leaves their hand (if it does fall out). I could understand if the button needs to be held for it to stay on, but when a Jedi is shot and is still holding the lightsaber why would it turn off? |
I have a shell script which is used to launch the java application.Shell script has following commands in it to launch the class which contain main method : _MainJava="com.abc.launchers.AgentLauncher" _ConfigFilePath="/home/lego/ConfigProperties" _LogFilePath="/home/lego/Logs/" java -jar "${_MainJava}" "${_ConfigFilePath}" "${_LogFilePath}" I launch this script through command prompt. Java code has a JMS listener which is always in listening mode .So this java code is always up and never terminates. Now I want to terminate this java program.One way is (and which I do every time) is terminate by pressing "Cntrl+c" which is killing the program by force and this way I cannot print logs like, "Terminating agent". If I know in advance that agent will be terminated(like some condition),I can print the logs and do System.exit(0). But I cannot know this in advance as agent will only be terminated during maintenance time. Please help me to understand how can I achieve this. As suuggested in comment section ,shutdown hook is the perfect option. Now I have been trying to implement it in my test code.My code is like following : public static void main(String[] args) throws IOException, InterruptedException { // TODO Auto-generated method stub Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { System.out.println("Shutdown Hook is running !"); } }); System.out.println("Application Terminating ..."); while(true) { System.out.println("Running"); } } In eclipse IDE, I go in debug tab where I see this code running continuously ,I do right click -> terminate and it doesn't print anything. Final output : Running Running Running . . . . | Is it possible to handle POSIX signals within the Java Virtual Machine? At least and should be quite platform independent. |
I am trying to create something like stackoverflow.com tag cloud. I am able to display the tags but stuck on how to capture which tag element cancel button was clicked. The cancel buttons are created dynamically using jquery on click of btnAdd. $("#<%=btnAdd.ClientID%>").on('click',function(){ var tagText = $('#<%=txtTag.ClientID%>').val(); var btnCancel = '<button class="btn btn-default">X</button>'; var tagTextDiv ='<div class="tagElement">' + tagText + btnCancel +'</div>'; $("#divTagCloud").append(' ' + tagTextDiv); }); HTML is <div class="col-xs-12 col-sm-6"> <asp:TextBox runat="server" /> </div> <div class="col-xs-12 col-sm-6"> <asp:Button runat="server" id="btnAdd"/> </div> <div class="col-xs-12 col-sm-12"> <div id="divTagCloud"></div> </div> I want to remove the tag i.e corresponding tagTextDiv on click of corresponding cancel button. How to do this ? | I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off. This happens on page ready and works just fine. The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound. I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option. |
Is it possible to change the path of latex output files (e.g .aux, .log, .etc) to a different directory. The main directory is becoming a mess. Thank you | I am trying to figure out a way to cleanly separate the TEX files from all of the intermediate and output files. Various approaches I've tried, including the one described by don't seem to work. I'm using TexMaker + MikTex (portable). Ideally, I would like my file/directory structure to look something like this: texproject texfiles 1.tex 2.tex intfiles 1.out 1.log 1.aux 2.out 2.log 2.aux pdffiles 1.pdf 2.pdf Instead, what I have, is the jumbled-up mess where all of these files live in the same directory. I've tried setting the ouput-directory, for example, on pdflatex but this doesn't work. The pdf file still gets created in the same place but now it doesn't show up in the previewer. This should be pretty easy to solve but I've so far been unsuccessful. How can I set up my environment to use the above structure when compiling? Update: I believe I have narrowed this down to something specific to TexMaker. If the desired aux and out directories are passed via the command line to pdflatex, everything builds as it should. Yet, I get numerous message boxes popping up saying that files can't be found and the PDF doesn't display in the internal viewer. I can't see any obvious options within TexMaker to change to address this. So, has anyone been able to make the scenario I'm describing work with TexMaker? |
I would like to have a section where I insert a PDF-page and write a few lines of text before. What I got: \section{FOO} %some text is following \includepdf[scale=0.9,pages=1,pagecommand={},offset=0 -3cm]{myPDF.pdf} Sadly the \includepdf-command seems to produce a pagebreak right when it is used. One workaround is to insert the \section{FOO} into the pagecommand-option of \includepdf, but in that case I am not able to write some text between the PDF and the section-heading. How can I have heading, text and PDF on the same page? | I want to include some pages of a pdf file into my document and wrap them into a figure with a caption for example (with pdfpages) \begin{figure}[h] \centering \includepdf[pages={1,3,2},nup=2x2]{test.pdf} \caption{Test} \label{fig:Test} \end{figure} However this doesn't work. So is there another way to do this? |
I'm following this tutorial: But I have different options in Voronoi Texture node. How can i get this result? | I noticed that some nodes changed significantly with Blender 2.81 and 2.82. Now I can't follow older tutorials, because some have different options than me. Voronoi Node is totally different Mapping Node is missing it's maximum / minimum clipping controls Q: How to get these older nodes back into Blender 2.82? |
There doesn't appear to be an option to delete my answer. Can I not do that through the app? | Currently, the only way to vote to delete (and undelete, since you can't see deleted posts) in the Android app is to open the post in a browser, and then vote to delete from there. Can we get delete vote functionality within the app, as well as the ability to delete our own posts? Worth to mention: users , so it's possible in the API. Related: |
What is the largest possible order of a cyclic subgroup of $S_7$? What's an example of this? I really just need a better understanding of cyclic subgroups of symmetric groups. I know that the largest possible subgroup of $S_7$ is of size $7$. And I know all the possible cycle structures. Would it be $6$ because $\left<(1 2 3 4 5 6 )\right>$ is a cyclic subgroup generated by the size of $S_6$ or the element $(1\ 2\ 3\ 4\ 5\ 6)$? | If we let $S_n$ denote the symmetric group on $n$ letters, then any element in $S_n$ can be written as the product of disjoint cycles, and for $k$ disjoint cycles, $\sigma_1,\sigma_2,\ldots,\sigma_k$, we have that $|\sigma_1\sigma_2\ldots\sigma_k|=\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$. So to find the maximum order of an element in $S_n$, we need to maximize $\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$ given that $\sum_{i=1}^k{|\sigma_i|}=n$. So my question: How can we determine $|\sigma_1|,|\sigma_2|,\ldots,|\sigma_k|$ such that $\sum_{i=1}^k{|\sigma_i|}=n$ and $\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$ is at a maximum? Example For $S_{10}$ we have that the maximal order of an element consists of 3 cycles of length 2,3, and 5 (or so I think) resulting in an element order of $\operatorname{lcm}(2,3,5)=30$. I'm certain that the all of the magnitudes will have to be relatively prime to achieve the greatest lcm, but other than this, I don't know how to proceed. Any thoughts or references? Thanks so much. |
If $A \in M_{n}(F)$, I have to show that $A$ is a unit only if $AB = I$ or $BA = I$ for some $B \in M_{n}(F)$. I am not sure how to approach this at all since this fact was pretty intuitive to me. One way I am thinking this is using the fact that this basically means prove that $A$ is invertible if $AB=BA=I$. A hint that was given, however, was that if $V$ and $W$ are finite dimensional vector spaces, $T: V \to W$ is isomorphic only when it is injective (or only when it is surjective). This hint is completely throwing me off on how to do this question. Can somebody help? Thanks. | If $A$ and $B$ are square matrices such that $AB = I$, where $I$ is the identity matrix, show that $BA = I$. I do not understand anything more than the following. Elementary row operations. Linear dependence. Row reduced forms and their relations with the original matrix. If the entries of the matrix are not from a mathematical structure which supports commutativity, what can we say about this problem? P.S.: Please avoid using the transpose and/or inverse of a matrix. |
Is there any way I can get the package size? I.e. if I am doing any installation, how much package (in MB's) size I have to download? How can I know ? I know one way that is with: jai@frank-Jai:~$ sudo apt-get install gedit Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: gedit-common gir1.2-gtksource-3.0 libgtksourceview-3.0-0 libgtksourceview-3.0-common Suggested packages: gedit-plugins The following NEW packages will be installed: gedit gedit-common gir1.2-gtksource-3.0 libgtksourceview-3.0-0 libgtksourceview-3.0-common 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 985 kB of archives. After this operation, 10.0 MB of additional disk space will be used May I know the other ways ? | When using apt-get install <package_name>, and there are dependencies that need to be downloaded, the terminal outputs names of additional packages and total size, and asks for confirmation before downloading. But, when dependencies are satisfied and nothing but the named package needs to be downloaded there is no size output and no confirmation. When using Synaptic, I can see the total size that new packages that will use after installation but no way to see the size that needs to be downloaded, except to go from package to package and use properties to see the compressed size. I would like to know if there is a way to see the size of a package(s) in terminal and Synaptic prior to downloading and installing it/them? |
I would like a command to execute when my PC starts up. My OS is Ubuntu 18.04 LTS. The command is: xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync && xrandr --addmode VGA-1 1920x1080_60.00 && xrandr --output VGA-1 --mode 1920x1080_60.00 It works perfectly when I execute it (from the Terminal) after the pc has booted up. I have tried various options (after internet searches) but can't get any of them to work - have tried both command line and GUI profferings - none has worked. | How can I run the following xrandrcommand on startup? xrandr cvt 1368 768 xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync xrandr --addmode VGA1 1368x768_60.00 xrandr --output VGA1 --mode 1368x768_60.00 |
I have lab and in that ,collection of Linux computer are connected in LAN. i want how to writ e shell script to shut down all PC when we run that shell script. | I used the following bash to shutdown remote computers,but for each computer,I must input the password for it.Is it possible to input the password Automatically? #!/bin/bash ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" ssh -t [email protected] "sudo poweroff" |
I am getting this grub rescue error no filesystem thing. I have read a lot of threads on this issue, but those solutions are not working. I tried live CD, and changed the booting option from hard disk to CD ROM, but still I get the same grub rescue error. I have two operating systems, the other one is Windows 7. I formatted some part of my hard drive during which GRUB might have lost some files. I get that, but now what should I do? Please tell me how to deal with this thing: Error: unknown filesystem. grub rescue> | I get this error: Error: unknown filesystem. grub rescue> I'm not exactly sure what I did. I believe I installed Ubuntu over Windows on my Acer netbook. I then tried to install , but it wouldn't start installing. I turned the netbook off and back on. Now I get the error. I have read a lot of other questions like this, but in my case I cannot boot a CD. If I put a Ubuntu CD or a Linux Mint CD into my external CD/DVD drive and change my BIOS to boot the CD-ROM first, it just gives me the same error screen. Update copied from comment dated 2012-05-26 02:54:29Z Here are some results from my commands: grub rescue>ls (hd0) (hd0,msdos5) (hd0,msdos1) grub rescue>ls (hd0,msdos5) unknown filesystem grub rescue>ls (hd0,msdos1) unknown filesystem grub rescue>ls (hd0) unknown filesystem |
I want to create a directory, for instance testing-data on CentOS 6.5 Linux version, and have read,write,execute to all the sub-folders and sub-sub-folders and files within them to everyone(all users), not to any specific group. In fact, whenever a new file is written into any of these sub-folders without using chmod 777 the new file should be able to be accessed by any user. Is this possible? | I am having a problem with permissions on a Linux server. I am used to BSD. When a directory is owned by a group the user who owns it isn't in such as www-data, files created in it will be owned by that group. This is important because I want files to be readable by the webserver (which I will not run as root) but so a user can still put new files in the directory. I can't put the users in www-data because then they can read every other users websites. I want the webserver to read all websites, I want users to be able to change their own. The permissions are set like this on the folders at the moment.... drwxr-x--- 3 john www-data 4096 Feb 17 21:27 john It is standard behavior on BSD for permissions to work this way. How do I get Linux to do this? |
I have the following integral to solve: $$\int_0^\infty \frac{\sqrt[3]{x+1} - \sqrt[3]{x}}{\sqrt{x}} \, \mathrm dx$$ I tried substitution $u= x+1$ and $u=\sqrt[3]{x+1}$ then partial integration but that didn't really help because it didn't become any simpler. Thank you. | I would like to show that $$ \int_0^{\infty} \frac{ \sqrt [3] {x+1}-\sqrt [3] {x}}{\sqrt{x}} \mathrm dx = \frac{2\sqrt{\pi} \Gamma(\frac{1}{6})}{5 \Gamma(\frac{2}{3})}$$ thanks to the beta function which I am not used to handling... $$\frac{2\sqrt{\pi} \Gamma(\frac{1}{6})}{5 \Gamma(\frac{2}{3})}=\frac{2}{5}B(1/2,1/6)=\frac{2}{5} \int_0^{\infty} \frac{ \mathrm dt}{\sqrt{t}(1+t)^{2/3}}$$ ...? |
Perhaps this is a dumb question. I write a small pdf-book on coding and use there many examples using listings package. But the amount of code expands text too much, for every 5 lines of text there is 10-20 lines of listings. I wish there was a way to show code on demand (like spoiler). May be there is some format supported by latex which would allow to do such thing ? | Is there a way to fold/unfold certain sections in a pdf. Only when the user clicks on the section or plus sign the items show up. Example: user clicks on the plus sign and the items appear as drop down list. |
I am looking into getting the for my Olympus E-PL5, since it has a that works with it. Is this a viable solution? | I have flash brand X and would like to know whether it will work with camera brand Y.βWhat do I need to consider to determine whether the combination will work? Other questions of relevance: |
I am stuck on proving this statement. I know I can use the definition of the geometric sum to prove this, but I wanted to know how to prove this without external definitions. Let $P(n)$ be the statement $\forall n \in \mathbb N, \sum_{i=0}^{n-1} 2^i = 2^n - 1$ Proof. Let $n \in \mathbb N$. Base Case (Let $n = 1$) $\sum_{i=0}^{1-1} 2^i = 2^1 - 1$ $1 = 1$ Therefore $P(1)$ holds Induction Step: Let $k \in \mathbb N$ Assume P(k): $\sum_{i=0}^{k-1} 2^ i = 2^k - 1$ is true (Induction Hypothesis) W.T.P. $P(k + 1): \sum_{i=0}^k 2^i = 2^{k+1} - 1$ Now to prove $P(k+1)$, would I let $2^k$ be equal to $\sum_{i=0}^{k-1} (2^i +1)$, by the induction hypothesis? I'm not sure how to proceed. | I was hoping someone could help me come up with a combinatorial proof, one with an easy to understand 'story' for $\sum_{k=0}^{n-1} 2^{k} = 2^n - 1$. For instance I understand that $2^n$ is the number of possibilities when creating subsets of size $n$. For example, if you're given a choice of any topping on a pizza, and you can only have said topping once (decide to include or exclude) then you have $2^n$ choices. But I'm not sure how the $-1 $ would be incorporated, or why the LHS would be $1+2+4+8+...+2^{n-1}$ |
(I changed the point of question into about more basic symptom.) I created child and grand child in bash script.(in Ubuntu 14.04) #! /bin/bash { sleep 21 & sleep 22 }& sleep 23 But 2 kind of command to kill process group shows different result. ( I've run the kill command in another terminal at this test.) kill -INT -<pgid> # -> grand child(sleep 21) survives. kill -TERM -<pgid> # -> kills all correctly. Could you explain what it is going on internally? | I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution. |
See the top banner in this screenshot, looks like a bug to me. | And if I click on it... Looks like a CSS sprite issue... I'm thinking that the image was recently changed, by looking at the name, Currently on Chrome Version 33.0.1750.154 m. Firefox is fine though, with all zoom levels. Steps to reproduce: Either browse the site on a device with Retina display, or using Chrome follow those steps: Change zoom level to 150% or more. Reload the page. |
I have an website, wich shows information through an SQL Query. This is working just fine, except when one of the parameters is a string with blank spaces. echo $seminar = $_POST['Seminar']; echo $start = $_POST['DatumGruppe']; $prep_stmt = $mysqli->prepare("SELECT `idtermine` FROM `termine`, seminar WHERE termine.seminar = seminar.idseminar AND seminar.name = ? AND termine.start= ? "); $prep_stmt->bind_param('ss', $seminar, $start); if (!$prep_stmt->execute()) { echo 'Error executing!'; } else { $prep_stmt->store_result(); $prep_stmt->bind_result($termin); if ($prep_stmt->num_rows != 1) { echo '<p class="error">Kein passendes Seminar gefunden</p>'; } while ($prep_stmt->fetch()) { echo 'ID: '.$termin.'<br>'; } } Like i said: when $seminar is something like "Entspannung" its perfectly working. But "Metakognitives Training - Umgang mit GrΓΌbeln und Sorgen" isn't working - theres no mistake in the query, it just doesn't find a fitting row. There are no mistakes in the writing, and the same query is working on another website. So I really don't get the problem. I tried using quotes echo $seminar = "'".$_POST['Seminar']."'"; which didn't helped eather. I hope you can help. | I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1. Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to do this β is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur? This is for a new Linux server, running MySQL 5, PHP, 5 and Apache 2. |
While I am always logging into a CentOS server for simulations it got me thinking: why can't I keep running the simulations even if my session is closed? I know that when a session is ended or a user logs out, any process generated from the session is also terminated. Could there be a way to let the processes keep on running by itself even if the session is closed? -- a silly question from a user with not much unix background :) | Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in such a way that I can close the terminal without killing the process? |
Consider we have a roll of paper with the size of 5 cm in diameter and 10 cm in width. If the thickness of the paper sheet is 0.05 cm, and the rolling has been started from the point zero (the internal reel is 0cm), how can we calculate the length or area of the whole paper sheet? | Fun with Math time. My mom gave me a roll of toilet paper to put it in the bathroom, and looking at it I immediately wondered about this: is it possible, through very simple math, to calculate (with small error) the total paper length of a toilet roll? Writing down some math, I came to this study, which I share with you because there are some questions I have in mind, and because as someone rightly said: for every problem there always are at least 3 solutions. I started by outlining the problem in a geometrical way, namely looking only at the essential: the roll from above, identifying the salient parameters: Parameters $r = $ radius of internal circle, namely the paper tube circle; $R = $ radius of the whole paper roll; $b = R - r = $ "partial" radius, namely the difference of two radii as stated. First Point I treated the whole problem in the discrete way. [See the end of this question for more details about what does it mean] Calculation In a discrete way, the problem asks for the total length of the rolled paper, so the easiest way is to treat the problem by thinking about the length as the sum of the whole circumferences starting by radius $r$ and ending with radius $R$. But how many circumferences are there? Here is one of the main points, and then I thought about introducing a new essential parameter, namely the thickness of a single sheet. Notice that it's important to have to do with measurable quantities. Calling $h$ the thickness of a single sheet, and knowing $b$ we can give an estimate of how many sheets $N$ are rolled: $$N = \frac{R - r}{h} = \frac{b}{h}$$ Having to compute a sum, the total length $L$ is then: $$L = 2\pi r + 2\pi (r + h) + 2\pi (r + 2h) + \cdots + 2\pi R$$ or better: $$L = 2\pi (r + 0h) + 2\pi (r + h) + 2\pi (r + 2h) + \cdots + 2\pi (r + Nh)$$ In which obviously $2\pi (r + 0h) = 2\pi r$ and $2\pi(r + Nh) = 2\pi R$. Writing it as a sum (and calculating it) we get: $$ \begin{align} L = \sum_{k = 0}^N\ 2\pi(r + kh) & = 2\pi r + 2\pi R + \sum_{k = 1}^{N-1}\ 2\pi(r + kh) \\\\ & = 2\pi r + 2\pi R + 2\pi \sum_{k = 1}^{N-1} r + 2\pi h \sum_{k = 1}^{N-1} k \\\\ & = 2\pi r + 2\pi R + 2\pi r(N-1) + 2\pi h\left(\frac{1}{2}N(N-1)\right) \\\\ & = 2\pi r N + 2\pi R + \pi hN^2 - \pi h N \end{align} $$ Using now: $N = \frac{b}{h}$; $R = b - a$ and $a = R - b$ (because $R$ is easily measurable), we arrive after little algebra to $$\boxed{L = 4\pi b + 2\pi R\left(\frac{b}{h} - 1\right) - \pi b\left(1 + \frac{b}{h}\right)}$$ Small Example: $h = 0.1$ mm; $R = 75$ mm; $b = 50$ mm thence $L = 157$ meters which might fit. Final Questions: 1) Could it be a good approximation? 2) What about the $\gamma$ factor? Namely the paper compression factor? 3) Could exist a similar calculation via integration over a spiral path? Because actually it's what it is: a spiral. Thank you so much for the time spent for this maybe tedious maybe boring maybe funny question! |
After updating with regular updates of packages of 14.04 .. my system started to boot directly to windows .... how i would be able to get it back | I installed Windows 7, which ate Ubuntu's boot file. When starting up the computer, it now goes straight to Windows, without giving me the option of booting Ubuntu. How can I get Ubuntu back? |
edit - this shouldn't be marked as a duplicate. The question isn't how to prevent SQL injection attacks (I'm already using prepared statements elsewhere), it's related to why MySQL is killing a maliciously-injected query. I'm testing out a web app with a connected MySQL database, specifically looking for potential SQL injection concerns and wondering how to prevent such attacks in this specific case. One page loads a person's information from the database based on a unique ID number, which is visible through the page's URL. Obviously, this is a concern in its own right - I could simply change the ID from "?id=2" to "?id=3" to load a new record from the database - but the issue I'm more concerned with at the moment is a URL-based attack to execute a "bad" query on top of the intended query. The intended query looks something like this: ... where person.ID="10" and person.ID = notes.ID and ... By changing the URL, I'm able to close the parameter that's looking for an ID and execute another, potentially malicious query, like this: ... ?id=10"; drop table person; select * from notes where ID=" ... which would cause the following queries to be executed: ... select * from person, notes where id="10"; drop table person; select * from notes where ID="" and ... I've been able to get this malicious set of queries to print (echo) to my webpage, so I know it's a vulnerability. However, when I try to execute this exact query in MySQL, it hangs for several seconds before exiting MySQL completely with the response "Killed" and no further explanation. My question, then, is what's causing MySQL to kill this malicious query and exit? This seems like a security feature, but I don't know what it'd be - those queries are perfectly fine on their own. I'm also confused by the lack of error message beyond "Killed" if anyone has come across a similar situation. | If user input is inserted without modification into an SQL query, then the application becomes vulnerable to , like in the following example: $unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')"); That's because the user can input something like value'); DROP TABLE table;--, and the query becomes: INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--') What can be done to prevent this from happening? |
Let $X$ be a scheme and $\mathscr{F}$, $\mathscr{G}$ sheaves on $X$. Suppose we know that for every $x\in X$ the stalks are isomorphic: $$ \mathscr{F}_x \cong \mathscr{G}_x $$ Can we conclude immediately from here that $\mathscr{F}\cong \mathscr{G}$, or do we first need to find a morphism of sheaves $f:\mathscr{F}\to \mathscr{G}$ such that $f_x$ induces the above isomorphisms on the stalks for every $x$ ? Remark: Proposition 1.1 (page 63) of Hartshorne says that: A morphism of sheaves $f : \mathscr{F} \to \mathscr{G}$ on a topological space $X$ is an isomorphism iff the induced map on stalks $f_x : \mathscr{F}_x \to \mathscr{G}_x$ is an isomorphism for every $x\in X$. Extra question: What can we say, instead, if we have isomorphisms between every fiber of $\mathscr{F}$ and $\mathscr{G}$ ? | It is well-known (Hartshorne 2.1.1) that if $F$ and $G$ are sheaves on a space $X$, then $\phi:F\rightarrow G$ is an isomorphism if and only if the induced stalk map $\phi_p:F_p\rightarrow G_p$ is an isomorphism for all $p\in X$. However, if we have a collection of isomorphisms $\{\psi_p:F_p\rightarrow G_p\}_{p\in X}$, this does not guarantee that $F$ and $G$ are isomorphic, because the $\psi_p$ might not be related to each other, i.e. there might not be a sheaf map $\psi:F\rightarrow G$ such that $\psi_p$ is the induced stalk map for all $p\in X$. However, I was recently making this point to someone and was unable to think of a good example of non-isomorphic $F$ and $G$ having isomorphisms $\psi_p:F_p\rightarrow G_p$. I'm sure I knew one at some point, but I'm blanking on it now. Can someone provide an illustrative example, e.g. an example that occurs in some natural or basic problem, or one that captures the essential pattern of any example where this issue arises, or one where it is clear that $F$ and $G$ could not be isomorphic? |
I'm running a Ubuntu VM with an 8 GB RAM with docker containers ( 8 GB is just about enough for my requirements) but at some point the VM freezes/crashes due to memory exhaustion leaving me no choice but to power-off/reset the VM. Is there a system configuration that can be done/added so that there is always enough just about enough memory for the OS to run without freezing? | I'm running pdftoppm to convert a user-provided PDF into a 300DPI image. This works great, except if the user provides an PDF with a very large page size. pdftoppm will allocate enough memory to hold a 300DPI image of that size in memory, which for a 100 inch square page is 100*300 * 100*300 * 4 bytes per pixel = 3.5GB. A malicious user could just give me a silly-large PDF and cause all kinds of problems. So what I'd like to do is put some kind of hard limit on memory usage for a child process I'm about to run--just have the process die if it tries to allocate more than, say, 500MB of memory. Is that possible? I don't think ulimit can be used for this, but is there a one-process equivalent? |
For some reason, after I install Ubuntu 16.04 on my desktop and laptop, after a while I'm getting a message and I can't do anything anymore. I searched online about my problem, I asked some other "Ubuntu" guys, but nobody could help me at all. I have dual boot with Windows 10, and openSUSE 42.1 and Fedora 24-1.2 are working just fine. Everything based on Ubuntu 16.04 doesn't work for me. Today, after 2 months of using openSUSE 42.1 without a problem, I tried Ubuntu again. But this time I tried 16.04.1 and I got the same message. I attached here the message I'm getting, maybe someone can help me with my problem. Thank you in advance! @roema Thank you for taking the time to answer me. I tried to find one of those options in Bios, but apparently there's no "secure chip" or "secure boot" anywhere in there. The BIOS version was 2.15 (now is upgraded to 2.29), Aptio Setup Utility version is 2.10.1208 and here is the system that has the above problem. Thank you again for your suggestions. P.S. I upgraded the BIOS, but I still can't find any of those two options. Is there any way I can resolve this problem? | I am trying to boot Ubuntu on my computer. When I boot Ubuntu, it boots to a black screen. How can I fix this? Table of Contents: |
As per 2 months ago (March 2020): after you've written your question, you are taken to a 2nd page which prompts you to "Review your question". There are 2 possibilities when you land on that page: either your question has "obvious" validation failures. or it successfully passes validation. In the former case, the page is clearly beneficial, in that it provides a nice UX for understanding what needs to be fixed (especially if you're new to the site, and aren't familiar with the form). But in the latter case, I offer that it doesn't add anything. As far as I can tell, it has all the same information as the previous page: You could already see a pre-render of your question. You could already see a list of various Similar Questions. As far as I can tell, it just forces me to click the same button twice; adding annoying UX for no benefit. It might be a prompt for new users to encourage them to actually use the above features. It might perhaps be intended as a mental prompt to get people to reflect on their question? But I'd honestly be surprised if it were actually achieving that, rather than everyone ignoring it and auto-clicking "Post". Do we have server-log evidence of how long people spend on the "Review" page? Conversely is there any evidence of questions getting "lost" because people forget to click twice? If there is some new info on that page, then it needs a re-design in order to make that clear! If not, we should gather evidence to assess its efficacy. If it does nothing (as I suspect), then I offer that it's a pointless irritation and should be removed. | This is terrible . I understand that the motivation behind "Review your question" is quality control, but if there is nothing for me to review, why can't the question be submitted in a single click? Instead the page jumps back, to draw my attention to possibly this: But it doesn't stand out in the UI, and if you didn't read that the button said "Review your question", it's hard to see why the page just jarringly jumped back instead of posting the question. Is it really important for me to know that the automated system didn't find any way to improve my question? Does Stack Exchange have metrics to see how often the question passes the quality check in the first go? To add a minor point, as a veteran Stack Exchange user, the system doesn't have any reviews most of the time (in fact, the only time it had one is today while posting this question where it reminded me that one of feature-request, bug, .. tags were required). |
Question: $x^{13}+x+90$ is divisible by $x^2-x+a$ $(a\in\mathbb N)$. Find $a$. What I did was: \begin{align} &x^{13}+x+90 = Q(x)(x^2-x+a)\\ &\text{Let $t$ be one of roots of }x^2-x+a=0\\ &t^2=t-a\\ &t^4=(t-a)^2=t^2-2at+a^2=(1-2a)t+a(a-1)\\ \\ &t^8=((1-2a)t+a(a-1))^2=(1-2a)^2t^2+2(1-2a)a(a-1)t+a^2(1-a)^2\\ &=(1-2a)^2(t-a)+2(1-2a)a(a-1)t+a^2(1-a)^2\\ &=(1-2a)((1-2a)+2a(a-1))t+a^2(1-a)^2-a(1-2a)^2\\ \\ &t^{12}={(1-2a)t+a(a-1)}{(1-2a)((1-2a)+2a(a-1))t+a^2(1-a)^2-a(1-2a)^2}\\ &=(1-2a)^2((1-2a)+2a(a-1))t^2\\ &+ (a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)^2))t\\ &+ a^2(a-1)(a(1-a)^2-(1-2a)^2)\\ &=(1-2a)^2((1-2a)+2a(a-1))(t-a)\\ &+(a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)Β²^2))t\\ &+ a^2(a-1)(a(1-a)^2-(1-2a)^2)\\ &=\left((1-2a)^2((1-2a)+2a(a-1))+a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)^2)\right)t\\ &+ a^2(a-1)(a(1-a)^2-(1-2a)^2)-a(1-2a)^2((1-2a)+2a(a-1))\\\\ &t^{13}=((1-2a)^2((1-2a)+2a(a-1))+a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)^2))t^2\\ &+ (a^2(a-1)(a(1-a)^2-(1-2a)^2)-a(1-2a)^2((1-2a)+2a(a-1)))t\\ &=((1-2a)^2((1-2a)+2a(a-1))+a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)^2))(t-a)\\ &+ (a^2(a-1)(a(1-a)^2-(1-2a)^2)-a(1-2a)^2((1-2a)+2a(a-1)))t\\ &=((1-2a)^2((1-2a)+2a(a-1))+a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)^2)+a^2(a-1)(a(1-a)^2-(1-2a)^2)-a(1-2a)^2((1-2a)+2a(a-1)))t\\ &-a((1-2a)^2((1-2a)+2a(a-1))+a(a-1)(1-2a)((1-2a)+2a(a-1))+(1-2a)(a^2(1-a)^2-a(1-2a)^2))\\ &=-t-90\\\\ &(1-2a)^2((1-2a)+2a(a-1))+a(a-1)(1-2a)((1-2a)+2a(a-1))\\ &+(1-2a)(a^2(1-a)^2-a(1-2a)^2)\\ &+a^2(a-1)(a(1-a)^2-(1-2a)^2)-a(1-2a)^2((1-2a)+2a(a-1))\\&=-1\\ \\&\text{with an aid of Wlofram Alpha,}\\ &(a-2)(a^5-19a^4+32a^3-20a^2+5a-1)=0\\ &\therefore a=2 \end{align} Is there a smarter way to get to the answer? Thanks. (*) Any solution is welcomed, but this question was given to high school students who didn't learn calculus. | Find all integers $a$ for which $x^2-x+a$ divide $x^{13}+x+90$. The answer is $a=2$. |
I have a complex form API managed form that has several fieldsets with nested fieldsets and table elements (defined with webform component editor) with AJAX-controlled 'Add another' and 'Remove Last' buttons. There is also a form submit button at the end of the form, external to all fieldsets. After a certain (of the order of 100) number of element groups (containing 4 or 5 fields each) are added and the form is submitted, the $_POST data generated after submitting the form does not include the value of the input element, so at a later stage the form API cannot determine the correct triggering element in function _form_button_was_clicked of form.inc. The $form_state['input'][$element['#name']] element does not exist. I've doubled the post_max_data and explicitly named the input element (by setting $element['#name']), all to no avail. I'd appreciate any thought on what else to try... | I have googled and binged and yahooed this question but can't seem to find an answer. I was working on a form that included over 800 fields but the form's submit function would never execute. After I pared the form down, the submit function ran. So now I'm curious if there's an actual built in maximum number of elements. |
Given the permutation $$\sigma = \begin{pmatrix} 1&2&3&4&5\\3&1&2&5&4\end{pmatrix}$$ the matrix A is defined to be the one whose i-th column is the $\sigma(i)$-th column of the identity I. Which of the following is correct? $A=A^{-2}$ $A=A^{-4}$ $A=A^{-5}$ $A=A^{-1}$ I didn't understand what $\sigma(i)$-th means here? | Given the permutation $$\sigma=\left(\begin{array}{ccccc} 1&2&3&4&5\\ 3&1&2&5&4 \end{array}\right)$$ the matrix A is defined to be the one whose $i$-th column of the identity matrix $I$. Which of the following is correct? $A=A^{-2}$ $A=A^{-4}$ $A=A^{-5}$ $A=A^{-1}$ |
Please after the Upgrade, I can no longer choose from "which Operating system" to use. Whenever I restart my laptop, Ubuntu now becomes my default Operating system and does not give me de Options to choose the OS to use at that moment. Plz help me. | I installed Windows on my computer, followed by an installation of Ubuntu. However, now I'm unable to boot into my Windows install. What can I do to fix this? |
Hello two weeks ago I uninstalled windows 10 and installed fedora 23 using a USB drive created by win32diskimager. My notebook : HP Envy dv6 current OS : fedora 23 Fedora 23 have some bugs with my computer so I decided to give ubuntu a chance. However I cannot boot from usb or CD/DVD for the installation. I have make some research and changed the boot order I have activated the legacy mode and deactivated the secure boot option but it still does not work. I have not the option to boot from CD/DVD not from an USB drive in the F9-bootmenu I have: HDD EFI BOOT FROM EFI FILES (In this menu my CD or USB is visible) But I have already installed an OS (fedora 23) with a bootable usb drive on this pc but it doesn't work anymore. Could you please help me? :) ps : i'm french, sorry for the mistakes :). | How do I make an Bootable Ubuntu USB containing the the latest version of Ubuntu? For completeness, how would I be able to do this on Ubuntu, Windows, OS X or another Linux distro? |
I'm new in Ubuntu and I have a question to ask: I wanna download a file the his type is: tgz. For example: androidstudio.tgz and in the site that's says: For Linux. Is it gonna work on Ubuntu? | I have downloaded tar.gz files. But I don't know how to install it. How do I install this kind of file? |
In the side bar of the site when looking at the Help Centre there are two areas for Privileges. One is listed with Reputation but has nothing to do with Privileges only Reputation. And the other Privileges that has all the information about it. | On the are two categories: "Reputation & Privileges" and the seemingly redundant "Privileges". Both have a small entry count and were likely intended to be merged. They probably should be merged or the first should be renamed to "Reputation". Showing the word "Privileges" twice looks like a mistake. |
I usually create a object like these: List<Student> students= new List<Student>(); but when I install the resharper in vs2012,it suggest me to create a object like these: var students= new List<Student>(); I wonder whether they have the same effect.I think they have the same effect.Will it be better when I use varοΌ | After discussion with colleagues regarding the use of the 'var' keyword in C# 3 I wondered what people's opinions were on the appropriate uses of type inference via var? For example I rather lazily used var in questionable circumstances, e.g.:- foreach(var item in someList) { // ... } // Type of 'item' not clear. var something = someObject.SomeProperty; // Type of 'something' not clear. var something = someMethod(); // Type of 'something' not clear. More legitimate uses of var are as follows:- var l = new List<string>(); // Obvious what l will be. var s = new SomeClass(); // Obvious what s will be. Interestingly LINQ seems to be a bit of a grey area, e.g.:- var results = from r in dataContext.SomeTable select r; // Not *entirely clear* what results will be here. It's clear what results will be in that it will be a type which implements IEnumerable, however it isn't entirely obvious in the same way a var declaring a new object is. It's even worse when it comes to LINQ to objects, e.g.:- var results = from item in someList where item != 3 select item; This is no better than the equivilent foreach(var item in someList) { // ... } equivilent. There is a real concern about type safety here - for example if we were to place the results of that query into an overloaded method that accepted IEnumerable<int> and IEnumerable<double> the caller might inadvertently pass in the wrong type. var does maintain strong typing but the question is really whether it's dangerous for the type to not be immediately apparent on definition, something which is magnified when overloads mean compiler errors might not be issued when you unintentionally pass the wrong type to a method. |
Can a surjective function $f: \mathbb N\to \mathbb N $ be not injective? Hi; I've been breaking my head over this simple question since last night. It's actually a small sub problem (of a simple Analysis Question) to what I'm trying to solve but essential to me solving it. At first I thought it can not be. For example, say there is an infinite number of $ n \in \mathbb N $ that map to some x and an infinite number that doesn't. But then, wouldn't the first have to be finite? Because, for example if I were to arrange that first infinite subset on a line and say that all other terms that "hit" every other $n \in \mathbb N $ come afterwards then we'd never get to the other ones. Are they there? I apologize if this doesn't make a lot of sense. I'm quite confused by all the scenarios that I can think of. It (the feeling of wonder) makes me excited and kind of happy, but also quite helpless. I appreciate any tip to guide my thinking in the right direction. Cheers | The mapping is supposed to be from $\mathbb{N}$ to $\mathbb{N}$. I'm still trying to understand if this is possible, I mean if it was from $\mathbb{R}$ to $\mathbb{N}$, I guess $x^2$ would work. |
If I control a and I play and choose for Renegade Doppleganger to copy it, would the Renegade Doppleganger get the +1/+1 counter? | I was playing a game last night with a guy who was playing a new Simic Gatecrash deck, and he claimed that if he made a land into a creature, it counted as entering the battlefield, thus triggering evolve (or other "enters the battlefield" abilities). I thought this was incorrect, being that the creature didn't actually enter the battlefield, it was just created. Which of us was right? |
Is there an easy way to have a function return multiple variables that can be easily accessed? | I have a function where I need to do something to a string. I need the function to return a boolean indicating whether or not the operation succeeded, and I also need to return the modified string. In C#, I would use an out parameter for the string, but there is no equivalent in Python. I'm still very new to Python and the only thing I can think of is to return a tuple with the boolean and modified string. Related question: |
Fragmented memories from my childhood: I thought the protagonist was Toby Huss (Artie from Adventures of Pete & Pete), but I cannot find anything that matches on his filmography. Protagonist definitely was 'dorky', he was an actor who played a superhero in our world and then was recruited by those from the other world who thought he was a real superhero. I also thought it was from one of the companies that made Hercules and Xena. It may have just been broadcast on the same channel. The whole thing is really campy but definitly had heart. Probably a "TV-14" rating. There is some type of reactor meltdown scene at the climax. Had a longer golden-age-of-sf title like "The Adventures of..." | So from what I remember it was on cable TV. The main hero was a TV actor zapped to a alien planet. It had a evil overlord with a virgin priestesses. She wants to get laid but he refuses because the next priestesses is only three. Regardless it's a parody things include a man who was maimed by the evil overlord wants revenge the hero eventually screws the virgin priestesses it cuts to scenes of a train going into a tunnel and a volcano erupting. |
As i am new to java i got a task to find duplicate word only and its count. i stuck in a place and i am unable to get the appropriate output. I can not use any collections and built in tool. i tried the below code. Need some help, Please help me out. public class RepeatedWord { public static void main(String[] args) { String sen = "hi hello hi good morning hello"; String word[] = sen.split(" "); int count=0; for( int i=0;i<word.length;i++) { for( int j=0;i<word.length;j++) { if(word[i]==word[j]) { count++; } System.out.println("the word "+word[i]+" occured"+ count+" time"); } } } } | I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug. Is == bad? When should it and should it not be used? What's the difference? |
I know the hypothesis that the light speed is constant is retained by experiments. But is there any theory explaining why the light speed is constant no matter how an observer moves relative to light? My question is, specifically: Suppose an observer $O$ launches a light and $O$ starts to move at the same time with a uniform velocity $v$ in the same direction that light points. Then why $c$ is still the light speed that $O$ will measure rather than $c-v$? | I was told that the Galilean relative velocity rule does not apply to the speed of light. No matter how fast two objects are moving, the speed of light will remain same for both of them. How and why is this possible? Also, why can't anything travel faster than light? |
Why is it that if I multiply a certain number of consecutive primes starting from $2$ and add $1$, I get another prime? This property is used it prove that there are infinitly many primes, but why is it correct? | Proof: The proof is by contradiction. Suppose there are only finitely many primes. Let the complete list be $p_1,p_2,\dots,p_n$. Let $N = p_1p_2 \dots p_n+1$. According to the Fundamental Theorem of Arithmetic, $N$ must be divisible by some prime. This must be one of the primes in our list. Say $p_k \mid N$. But $p_k\mid p_1\dots p_n$, so $p_k\mid(N-p_1 \dots p_n) = 1$ Hence contradiction. I don't see how this proof works. I understand that $N$ isn't necessarily prime, but I don't understand how it apparently must show that some primes weren't in our list. A number could be made of different powers of the given primes right? Someone please explain. |
What is the name of song from Code Geass in episode 5 when the Lancelot is saving Jeremiah? I can't find it or any covers of it anywhere, it starts at 1:16 here: | What's the section of the soundtrack used in the second episode of R2 at 8:00, after Kallen defeats a Knightmare and Lelouch gives new orders, called? |
I'm trying to understand how scopes work in JS. Can you tell me if I correct with understanding of this chunk of code: for(var i = 0; i<5; i++){ setTimeout(function timeoutHandler() { var i = i; console.log(i); //undefined }) } console.log prints undefined 5 times. So as I understand, when timeoutHandler is executed, it has its own local scope with own i variable. So is that correct that during timeoutHandler execution, the interpreter asks for i variable, finds it declared in local scope and uses this declared variable for assignment? This explains why it is undefined, but I'm not sure I'm fully correct. Thanks UPD I don't need this code to work properly, I just want to understand why it behaves like that in this case | What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally? |
One idea from cosmology is that galaxies are all moving away from each other. Naively this could be taken to mean that they are expanding into something. Popularly this could be seen as them moving outwards into an area of completely empty space at the 'edge' of the universe. However, if the universe is infinite and unbounded and uniformly populated, there is no empty volume for the galaxies to move into. Therefore logic dictates that the space between galaxies must be expanding. Let us suppose this is true. Then Is it also the case that the space within the galaxies is expanding. What about the space in our solar system. Where do we stop? Under this theory is the space inside an atom expanding? | I have looked at other questions on this site (e.g. "why does space expansion affect matter") but can't find the answer I am looking for. So here is my question: One often hears talk of space expanding when we talk about the speed of galaxies relative to ours. Why, if space is expanding, does matter not also expand? If a circle is drawn on balloon (2d plane), and the balloon expands, then the circle also expands. If matter is an object with 3 spatial dimensions, then when those 3 dimensions expand, so should the object. If that was the case, we wouldn't see the universe as expanding at all, because we would be expanding (spatially) with it. I have a few potential answers for this, which raise their own problems: Fundamental particles are 'point sized' objects. They cannot expand because they do not have spatial dimension to begin with. The problem with this is that while the particles would not expand, the space between them would, leading to a point where the 3 non-gravity forces would no longer hold matter together due to distance Fundamental particles are curled up in additional dimensions a la string theory. These dimensions are not expanding. Same problems as 1, with the added problem of being a bit unsatisfying. The answer seems to be (from Marek in the previous question) that the gravitational force is so much weaker than the other forces that large (macro) objects move apart, but small (micro) objects stay together. However, this simple explanation seems to imply that expansion of space is a 'force' that can be overcome by a greater one. That doesn't sound right to me. |
If you randomly pick a coin from a box that contains $90\%$ fair coins and $10\%$ loaded coins, (a loaded coin gives heads $90\%$ of the time), toss it $5$ times and get all heads. What is the probability that this is a loaded coin? $$n = 5, x = 5, p = 0.1(0.9)^5$$ Where $n$ is the number of flips, $x$ is number of heads, and $p$ is the probability of getting heads. so $$( 0.1 (0.9)^5 ) + (0.9 (0.5)^5) = 0.087$$ Can anyone see if the answer I provided is correct or not ! | Given a box that contains 90% fair coins and 10% loaded coins, (a loaded coin gives heads 90% of the time), what is the probability for a randomly drawn coin to give 5 heads in a row? P(HHHHH | random coin from box of mixed coins) = ? I used Bayes Theorem to calculate the probability I got .219 or 21.9% probability for the random coin to give 5 heads in a row! But I am still doubting if my answer is correct !!! Any help appreciated :) |
Please excuse me if my question is simple. because when I see the examples about php and MySql in internet, they use from the capital letters for commends MySql. Is it necessary to use the capital letters in MySql? $sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('John', 'Doe', '[email protected]')"; | Is SQL case sensitive. I've used MySQL and SQL Server which both seem to be case in-sensitive. Is this always the case? Does the standard define case-sensitivity? |
I want to know the meanings of these phrases Having said that and That being said, the difference between them, and in which context I can use both of them. According to my first understanding of these expressions, I think they are equivalent to the phrase "Considering what was said before" or in "reference to what has already been said". I am not sure of the meaning, but hope to find its exact meaning. | I often write what "sounds" right (being not a native English speaker/writer), and I believe the expression "that being said" to be fairly common, as opposed to a more complete form like "that's been said" or "Having said that". In doubt, I turn to , which seems to confirm the . (not exactly the right reference, I know.) Yet, I don't think that "that being said" is correct, especially in writing. "That said" is even more common. Is it also acceptable in writing? What expression would you use in formal writing? (Not too formal though: like a ) |
How can I implement something like $ echo "hello" | my_app with usage of Python's subprocess? subprocess.Popen() expects a pipe or a file handle for STDIN. But I want to provide STDIN for the called program via a variable. So something like myinput = "hello" subprocess.Popen("an_external_programm", stdin=myinput) β¦. | If I do the following: import subprocess from cStringIO import StringIO subprocess.Popen(['grep','f'],stdout=subprocess.PIPE,stdin=StringIO('one\ntwo\nthree\nfour\nfive\nsix\n')).communicate()[0] I get: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/build/toolchain/mac32/python-2.4.3/lib/python2.4/subprocess.py", line 533, in __init__ (p2cread, p2cwrite, File "/build/toolchain/mac32/python-2.4.3/lib/python2.4/subprocess.py", line 830, in _get_handles p2cread = stdin.fileno() AttributeError: 'cStringIO.StringI' object has no attribute 'fileno' Apparently a cStringIO.StringIO object doesn't quack close enough to a file duck to suit subprocess.Popen. How do I work around this? |
I have a problem with understanding where my disk space goes. I can check with Total commander most of the folders, but it shows only 50 of 121 occupied GB. With windows explorer I can see also hidden files and folders, but it is not possible to check the size of this folders: I also tried utility, but it also shows nothing Thereby my question - how to check size of all types of folder on a windows computer? | I have a 250 GB SSD installed as my primary disc on which I have Win 10 installed. I just recently realized that the explorer overview & the windows disc property dialog stated, that there are 200 GB used & only 31 GB free on that disk. Since I was curious on where that much used space came from, I started the free application WinDirStat which told me that there were only 62 GB used on C. Also if I select everything under C with hidden files & system folders shown in the explorer, the properties dialog states that those are only 62,5 GB in sum. Where do the 200 GB used space come from which are shown in the disc overview? |
I have runkeeper installed and within the app they direct yoy to there website to create routes. However when I browse to runkeeper.com it redirects me to the playstore app automatically. How can I force to open and browse the website? | There are a load of sites that do this now, and it's really annoying: I visit a content site on my Android device. 10-15 seconds after loading starts the site hangs for a few seconds. Google play store loads with a garbage app (usually some awful FTP or useless battery app) pre-selected. This appears to be because a dodgy ad-script (i.e. Javascript running in the web page) is somehow able to redirect my device to open a link to an application in the store without me selecting it directly. I consider it to be a critical security fail that Android lets this happen, but then Iphones do the exact same thing (but hang for much longer opening the app store). This isn't me accidentally clicking on anything - the site loads, then the play-store redirect fires, every time. Is there any way to stop this? Any option I can set in the store or browser to stop this incredibly annoying behaviour? I'm on a Nexus 7, but I've seen this on lots of other Android devices. |
I just saw this pic So I got curious and logged in on physics.stack first time, is it true? I am a math major and usually wander on mathstack but I would like to understand why Bumble bee cannot fly according to physics laws but still do? I am only familiar with high school physics, no aerodynamics at all. If some one can explain it to me in easy terms, I'll be obliged. | According to some source or other (I forget which now) it is theoretically impossible for bumblebees to fly by virtue of their size/bulk/aerodynamic properties. Is this old adage apocraphyal or true? And if its true, how come they do fly? |
I created the following sign for my computer: "Please do not turn off this computer." My office mate told me that this should be the correct way to do it: "Do not turn this computer off." He said that the preposition should be at the end. Is he correct? | Like many others, I commonly find myself ending a sentence with a preposition. Yes, it makes me cringe. I usually rewrite the sentence, but sometimes (in emails) I just live with it. To, with... you know who you are. Should I keep fighting myself on this one, or is it okay in some circumstances? |
I have a use-case to process following file types: 1 - mylog_1.log 2 - mylog_2.log.gz I have to run two different text processing commands on each of them as follows: cat mylog_1.log | grep text | sort | uniq -c zcat mylog_2.log.gz | grep text | sort | uniq -c (cat, grep, awk and sed are the frequently used commands) Is there a way to process both file types in a single command without unzipping the file? | When handling log files, some end up as gzipped files thanks to logrotate and others not. So when you try something like this: $ zcat * you end up with a command line like zcat xyz.log xyz.log.1 xyz.log.2.gz xyz.log.3.gz and then with: gzip: xyz.log: not in gzip format Is there a tool that will take the magic bytes, similar to how file works, and use zcat or cat depending on the outcome so that I can pipe the output to grep for example? NB: I know I can script it, but I am asking whether there is a tool out there already. |
After having trouble with booting Linux after installing Windows 7 on a separate SSD, I am just wondering, what is the benefit of creating a separate /boot partition during installation? I remember reading about it years ago when I first started trying out Linux. It seemed to be a best practices procedure for installation. But, after having trouble booting just now and wondering what the difference is between the files in the /boot partition vs. the files in the /boot directory in root, I'm just wondering why there seems to be two copies. | I'm reading a relatively old text on Linux partitions and file systems (the LPIC 1 Certification Bible). It says: Some versions of the Linux boot loaders cannot access a kernel that is outside the first 1024 cylinders on a disk. By putting the /boot partition at the beginning of the drive you can be assured of not having a problem when accessing the kernel at boot. This problem shows itself most often in cases of dual booting Linux along with another operating system that is on the first partition. Why would a boot loader have "no access to the kernel outside the first 1024 cylinders on a disk"? Also, what does "putting the /boot partition at the beginning of the drive" mean? |
I am trying to delete some of my production code. I am using VS Code and when I push the following to Prod: <?xml version="1.0" encoding="UTF-8"?> <ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>36.0</apiVersion> <status>Deleted</status> </ApexTrigger> I receive the following error: INVALID_OPERATION: INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations How do I delete Apex code from production? To my knowledge, you go into the metadata of your production code and change the status from "Active" to "Deleted". | I was recently told ( ): You cannot delete a class in production directly. You will need delete the class from your sandbox and then deploy the deletions to your production org. When you deploy from sandbox to production, the missing classes will come up in red and you can choose to deploy these deletions to Production. However, I'd like some clarification because finding information on how to do this is like pulling teeth, unfortunately. Am I supposed to: Delete the Trigger in Sandbox Make a deployment package in Sandbox Add the Trigger which is going to be listed in RED now Deploy (and that deletes it from Production)? I am not seeing deleted Triggers in Red in Sandbox. Are they NOT listed under "Triggers" for deployment, but elsewhere? Frustrated = true. Does this ONLY apply to Classes?? UPDATE: I just tried again, with a CLASS, and it still doesn't show up at all as a Deployable package (red or not) after I delete it in the Sandbox. UPDATE 2: I was just able to delete a class, that I know was written via IDE from a third party, in both Sandbox and Production. So now I'm wondering if it has to do with where it was originally deployed from (if from IDE, IDE can delete it - it from Sandbox, you have to jump through hoops). :-( |
So, I made a bidirectional LSTM model for sentiment classification. Model's job was to predict ratings of movies(1-5 stars) based on the movie review. While training the model I first used categorical cross entropy loss function. I trained the model for 10+ hours on CPU for about 45 epochs. While training every epoch showed model accuracy to be 0.5098(same for every epoch). Then I changed the loss function to binary cross entropy and it seemed to be work fine while training. So, I want to know what exactly is the difference between these two? | First of all, I realized if I need to perform binary predictions, I have to create at least two classes through performing a one-hot-encoding. Is this correct? However, is binary cross-entropy only for predictions with only one class? If I were to use a categorical cross-entropy loss, which is typically found in most libraries (like TensorFlow), would there be a significant difference? In fact, what are the exact differences between a categorical and binary cross-entropy? I have never seen an implementation of binary cross-entropy in TensorFlow, so I thought perhaps the categorical one works just as fine. |
I have a Compaq 620 with 4 partitions on the hard drive. The primary partition has Windows 7 installed on it. I want to dual boot this computer with Windows 7 (Korean version) installed on the other partition. How should I go about doing this? I do not want the Korean version to interact in any way with the English version. I also don't want to mess anything up so I thought I should ask here first. Please let me know how I should go about doing this, where things might go wrong, and how I can avoid them. Thank you | 2 questions. Please answer seperately. I want to dual boot Windows 7 Ultimate with Windows 7 Professional. Is it possible? Can Windows 7 32-bit be dual boot with Windows 7 64-bit? |
I'm a javascript newbie. I have a line of code: data.content_teaser.image_square_attachment_url square can change: I have a variable called contentType that can be 'square', or 'vertical' or 'horizontal'. In ruby I can use send with the string interpolation, how can I obtain the same in js? Something like "data.content_teaser.image_" + contentType + "_attachment_url" | I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later? Depending on the circumstances, I may need to pass various arguments into the method too. Some of the functions may take the form of namespace.namespace.function(args[...]). |
I'm trying to check user input value against two or arrays to see if the value inputed by the user equals a value in one of the arrays. Based on which array the input value equals to, I want to display a specific alert message. So far I have this: var zip = document.getElementById('zip').value; var zone1 = ['11220', '11223', '11224', '11225', '11226','11228']; var zone2 = ['10038', '10001']; So if the user enters ZIP code 11220, I would like to display a message: "Price: $50". If the user enters 10038, I would like the message "Price: $75". What's the easiest and most efficient way to do this? | What is the most concise and efficient way to find out if a JavaScript array contains a value? This is the only way I know to do it: function contains(a, obj) { for (var i = 0; i < a.length; i++) { if (a[i] === obj) { return true; } } return false; } Is there a better and more concise way to accomplish this? |
I want to find out if a point $(x, y)$ is surrounded by a set of points. To understand my problem a short explanation: I am a programmer and I have a function for the user to select objects by drawing around the object with his/her finger. When the user is finished, I get a list of points with the user's touch-points. basically i want to find out if a point is surround by a polygon Hope you can help me. Pic: | Given the coordinates of a point $(x, y)$, what is a procedure for determining if it lies within a polygon whose vertices are $(x_1, y_1), (x_2, y_2), \ldots , (x_n,y_n)$? |
I currently have a git repository with several folders, for example: /folder1 /folder1/subfolder1-1 /folder1/subfolder1-2 /folder2 /folder2/subfolder2-1 /folder2/subfolder2-2 /folder3 /folder3/subfolder3-1 /folder3/subfolder3-2 I want to make /folder2/subfolder2-1 a repository of its own because I want to push and share its code as an independent functionality. However, I want to keep this folder as a part of the main repository because its further development happens in pace with the whole application it makes part of. How can I accomplish that using git? | I have a repository which contains a number of subdirectories. Now I have found that one of the subdirectories is unrelated to the other and should be detached to a separate repository. How can I do this while keeping the history of the files within the subdirectory? I guess I could make a clone and remove the unwanted parts of each clone, but I suppose this would give me the complete tree when checking out an older revision etc. This might be acceptable, but I would prefer to be able to pretend that the two repositories doesn't have a shared history. Just to make it clear, I have the following structure: XYZ/ .git/ XY1/ ABC/ XY2/ But I would like this instead: XYZ/ .git/ XY1/ XY2/ ABC/ .git/ ABC/ |
Does anyone know when it's coming to the U.S.!? The UI looks beautiful and I've been waiting to get it. I feel like we've been waiting forever. Also did they mention how it will work? Do you have to buy a phone with it already installed on it or will we be able to download and install it on any Android phone like we can download the desktop version of Ubuntu on any Windows PC? | Canonical has recently announced , which is Ubuntu with a specific interface for mobile devices. Where can I get phones with this version of Ubuntu pre-installed? If no devices are available yet, where can I pre-order one? |
There is Mac and Windows drivers only. I tried that tar.gz file Nothing happened. Usb cable not connected. Trying to print over wifi. How can I use MX435 from Ubuntu? | I tried to install the MP190 drivers, but appeared a message show me that requires to have libcupsys2. I understand that libcup2 is an update of libcupsys2. How do I solve this? Are there proprietary drivers for my Canon printer or scanner? |
I have to compare the slopes of 2 regression lines with R. The 2 regressions are made with the same parameters in 2 different locations. I did my regressions with the function lm(). Now I have the results but I don't know how to compare them.. I tried with student test or ANOVA but it requires more than the 2 slopes. I looked for an answer during something like 2 hours but didn't find, so I ask the question here : How should I do my test? Thank you in advance, b.raoul | I would like to test the difference in response of two variables to one predictor. Here is a minimal reproducible example. library(nlme) ## gls is used in the application; lm would suffice for this example m.set <- gls(Sepal.Length ~ Petal.Width, data = iris, subset = Species == "setosa") m.vir <- gls(Sepal.Length ~ Petal.Width, data = iris, subset = Species == "virginica") m.ver <- gls(Sepal.Length ~ Petal.Width, data = iris, subset = Species == "versicolor") I can see that the slope coefficients are different: m.set$coefficients (Intercept) Petal.Width 4.7771775 0.9301727 m.vir$coefficients (Intercept) Petal.Width 5.2694172 0.6508306 m.ver$coefficients (Intercept) Petal.Width 4.044640 1.426365 I have three questions: How can I test the difference between slopes? How can I test the difference between residual variances? What is a simple, effective way to present these comparisons? A related question, , suggests re-running the model with a dummy variable to differentiate the slopes, are there options that would allow the use of independent data sets? |
I want to enumerate a list of (left) coset representatives for a quotient group (say, $A/B$) with the following properties: (a) No two members of the list represent the same coset. (b) Every coset is represented by some member of the list. For context, my goal is to construct a set of these representatives so that I ensure that the set's cardinality equals the order of $A/B$. My attempt: Use the bijection $f\colon A/B \to A$ such that $f(xB) = x$. Does this work? Edit: It was pointed out that my function is (clearly) not well-defined. So, my question remains, but I now realize that my attempt won't work. | I'm wondering if anyone knows an algorithm to find a in a group efficiently. The definition is you are given a subgroup $H$ of a group $G$, and you want to find a representative of each coset of $H$ in $G$. Recall the : $x, y \in G$ are in the same coset iff $x^{-1}y \in H$. This yields a trivial $O(|G|)$ algorithm. Simply test each element of $G$ until you find $|H : G|$ unique representatives. I'm wondering if there is a more efficient way to do this, preferably deterministically. Also, if finding a base or strongly generating set is necessary beforehand, the cost of such should be included in the efficiency of the algorithm. I am interested in such an algorithm for any arbitrary group, but if a special algorithm exists when $G = S_n$ and $H$ is a permutation group, possibly $S_k$ for some $k < n$, I'd be happy to learn of this as well. I would also appreciate any references to textbooks or papers that might help solve this problem. Thanks! |
I want to use on Ubuntu 16.04, which requires CUDA 9.0, not the latest 9.1. However, I previously had CUDA 9.1 installed. After running sudo apt-get remove --purge cuda* && sudo apt-get autoremove I confirmed that /usr/local contained no cuda folders. Then, I followed the to install CUDA 9.0 using the .deb. However, when I sudo apt-get install cuda, the confirmation message begins with: The following NEW packages will be installed: cuda cuda-9-1 ... and other references to CUDA 9.1. Question: Why is this 9.1 version being installed? Where is this being linked from? Here is the output from apt-key list, if helpful: /etc/apt/trusted.gpg -------------------- pub 1024D/437D05B5 2004-09-12 uid Ubuntu Archive Automatic Signing Key <[email protected]> sub 2048g/79164387 2004-09-12 pub 4096R/C0B21F32 2012-05-11 uid Ubuntu Archive Automatic Signing Key (2012) <[email protected]> pub 4096R/EFE21092 2012-05-11 uid Ubuntu CD Image Automatic Signing Key (2012) <[email protected]> pub 1024D/FBB75451 2004-12-30 uid Ubuntu CD Image Automatic Signing Key <[email protected]> pub 1024D/7FAC5991 2007-03-08 uid Google, Inc. Linux Package Signing Key <[email protected]> sub 2048g/C07CB649 2007-03-08 pub 4096R/D38B4796 2016-04-12 uid Google Inc. (Linux Packages Signing Authority) <[email protected]> sub 4096R/640DB551 2016-04-12 [expires: 2019-04-12] sub 4096R/997C215E 2017-01-24 [expires: 2020-01-24] pub 4096R/48457EE0 2016-05-24 [expires: 2018-05-24] uid Bazel Developer (Bazel APT repository key) <[email protected]> sub 4096R/43FF45F9 2016-05-24 [expires: 2018-05-24] pub 4096R/7FA2AF80 2016-06-24 uid cudatools <[email protected]> /etc/apt/trusted.gpg.d/graphics-drivers_ubuntu_ppa.gpg ------------------------------------------------------ pub 4096R/1118213C 2015-08-12 uid Launchpad PPA for Graphics Drivers Team /etc/apt/trusted.gpg.d/webupd8team_ubuntu_atom.gpg -------------------------------------------------- pub 1024R/EEA14886 2010-05-04 uid Launchpad VLC | For a specific package, can I find out why it is installed? So, can I see or it's manually installed, or that it is installed as a dependency of another package? Or that it is installed as part of the distro? |
Any one has any idea what this notification icon means? Thanks | After I recently updated my phone about a day ago, this strange sign showed up on the top left that I have never seen before. Does anyone know what it means? Or how to get rid of it? |
I reinstalled mysql-server and I can't access mysql anymore : ERROR 1045(28005) : Access denied for user 'root@localhost' (using password: no ) | In my server, everytime I try to access MySQL I get the error: Access denied for user 'root'@'localhost' (using password: NO) when I try mysqladmin -u root -p password I get Access denied for user 'root'@'localhost' (using password: YES) How can I access MySQL in my Ubuntu server 12.04? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.