qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
12,598,223
I need to get both table and here is the table structure Table A ------- * UserID * Username * Status * IntroCode Table B ------- * IntroCode * UserID I want to get the table a data and join with table b on tblA.IntroCode = tblB.IntroCode, then get the username of tblB.userID. How can i do such join ? I tried half way and stuck in the middle, please help. Thanks for reply
2012/09/26
[ "https://Stackoverflow.com/questions/12598223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235119/" ]
This is just a simple join. ``` SELECT a.*, b.* -- select your desired columns here FROM tableA a INNER JOIN tableB b ON a.IntroCode = b.IntroCode WHERE b.userid = valueHere ``` **UPDATE 1** ``` SELECT a.UserID, a.`Username` OrigUserName, a.`Status`, c.`Username` IntroUserName FROM tableA a INNER JOIN tableB b ON a.IntroCode = b.IntroCode INNER JOIN tableA c ON b.userID = c.userID -- WHERE b.UserID = valueHere -- extra condition here ```
use this query ``` SELECT * FROM tblA INNER JOIN tblB ON tblA.IntroCode = tblB.IntroCode where tblB.userid = value ```
12,598,223
I need to get both table and here is the table structure Table A ------- * UserID * Username * Status * IntroCode Table B ------- * IntroCode * UserID I want to get the table a data and join with table b on tblA.IntroCode = tblB.IntroCode, then get the username of tblB.userID. How can i do such join ? I tried half way and stuck in the middle, please help. Thanks for reply
2012/09/26
[ "https://Stackoverflow.com/questions/12598223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235119/" ]
This is just a simple join. ``` SELECT a.*, b.* -- select your desired columns here FROM tableA a INNER JOIN tableB b ON a.IntroCode = b.IntroCode WHERE b.userid = valueHere ``` **UPDATE 1** ``` SELECT a.UserID, a.`Username` OrigUserName, a.`Status`, c.`Username` IntroUserName FROM tableA a INNER JOIN tableB b ON a.IntroCode = b.IntroCode INNER JOIN tableA c ON b.userID = c.userID -- WHERE b.UserID = valueHere -- extra condition here ```
Use this query. ``` SELECT TableA.Username FROM TableA JOIN TableB ON (TableA.IntroCode = TableB.IntroCode); ```
12,598,223
I need to get both table and here is the table structure Table A ------- * UserID * Username * Status * IntroCode Table B ------- * IntroCode * UserID I want to get the table a data and join with table b on tblA.IntroCode = tblB.IntroCode, then get the username of tblB.userID. How can i do such join ? I tried half way and stuck in the middle, please help. Thanks for reply
2012/09/26
[ "https://Stackoverflow.com/questions/12598223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235119/" ]
you have to give the columns with same name an unique value: ``` SELECT a.UserID as uid_a, b.UserID as uid_b FROM tableA a INNER JOIN tableB b ON a.IntroCode = b.IntroCode WHERE b.UserID = 1 ```
use this query ``` SELECT * FROM tblA INNER JOIN tblB ON tblA.IntroCode = tblB.IntroCode where tblB.userid = value ```
4,507,009
Why does this test fail? ``` private class TestClass { public string Property { get; set; } } [Test] public void Test() { var testClasses = new[] { "a", "b", "c", "d" } .Select(x => new TestClass()); foreach(var testClass in testClasses) { testClass.Property = "test"; } foreach(var testClass in testClasses) { Assert.That(!string.IsNullOrEmpty(testClass.Property)); } } ``` The problem is obviously to do with lazy yielding in the Select statement, because if I add a .ToList() call after the Select() method, the test passes.
2010/12/22
[ "https://Stackoverflow.com/questions/4507009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21966/" ]
Every time you iterate over the `testClasses` variable, you will run the code in the `.Select()` lambda expression. The effect in your case is that the different foreach loops gets different instances of `TestClass` objects. As you noticed yourself, sticking a `.ToList()` at the end of the query will make sure the ot is only executed once.
It's because LINQ extension methods such as Select return `IEnumerable<T>` which are lazy. Try to be more eager: ``` var testClasses = new[] { "a", "b", "c", "d" } .Select(x => new TestClass()) .ToArray(); ```
4,507,009
Why does this test fail? ``` private class TestClass { public string Property { get; set; } } [Test] public void Test() { var testClasses = new[] { "a", "b", "c", "d" } .Select(x => new TestClass()); foreach(var testClass in testClasses) { testClass.Property = "test"; } foreach(var testClass in testClasses) { Assert.That(!string.IsNullOrEmpty(testClass.Property)); } } ``` The problem is obviously to do with lazy yielding in the Select statement, because if I add a .ToList() call after the Select() method, the test passes.
2010/12/22
[ "https://Stackoverflow.com/questions/4507009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21966/" ]
Because of how LINQ works, you are actually creating **8** different versions of `TestClass` - one set of 4 per `foreach`. Essentially the same as if you had: ``` var testClasses = new[] { "a", "b", "c", "d" }; foreach(var testClass in testClasses.Select(x => new TestClass())) { testClass.Property = "test"; } foreach(var testClass in testClasses.Select(x => new TestClass())) { Assert.That(!string.IsNullOrEmpty(testClass.Property)); } ``` The first set (discarded) have the property set. By calling `ToList()` at the end of `testClasses`, you force it to store and re-use the same 4 `TestClass` instances, hence it passes.
Every time you iterate over the `testClasses` variable, you will run the code in the `.Select()` lambda expression. The effect in your case is that the different foreach loops gets different instances of `TestClass` objects. As you noticed yourself, sticking a `.ToList()` at the end of the query will make sure the ot is only executed once.
4,507,009
Why does this test fail? ``` private class TestClass { public string Property { get; set; } } [Test] public void Test() { var testClasses = new[] { "a", "b", "c", "d" } .Select(x => new TestClass()); foreach(var testClass in testClasses) { testClass.Property = "test"; } foreach(var testClass in testClasses) { Assert.That(!string.IsNullOrEmpty(testClass.Property)); } } ``` The problem is obviously to do with lazy yielding in the Select statement, because if I add a .ToList() call after the Select() method, the test passes.
2010/12/22
[ "https://Stackoverflow.com/questions/4507009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21966/" ]
Because of how LINQ works, you are actually creating **8** different versions of `TestClass` - one set of 4 per `foreach`. Essentially the same as if you had: ``` var testClasses = new[] { "a", "b", "c", "d" }; foreach(var testClass in testClasses.Select(x => new TestClass())) { testClass.Property = "test"; } foreach(var testClass in testClasses.Select(x => new TestClass())) { Assert.That(!string.IsNullOrEmpty(testClass.Property)); } ``` The first set (discarded) have the property set. By calling `ToList()` at the end of `testClasses`, you force it to store and re-use the same 4 `TestClass` instances, hence it passes.
It's because LINQ extension methods such as Select return `IEnumerable<T>` which are lazy. Try to be more eager: ``` var testClasses = new[] { "a", "b", "c", "d" } .Select(x => new TestClass()) .ToArray(); ```
8,787
I use discrete Fourier transform for digital image processing purposes , but I don't understand basic concept behind it. For example : 1. What information exists in frequency domain? 2. What is difference between spatial domain and frequency domain?
2013/04/22
[ "https://dsp.stackexchange.com/questions/8787", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/4408/" ]
> > What information exists in frequency domain? > > > As JasonR says in the comment, ***The frequency domain is a different view of the same data.*** No new information is created, it just takes the "spatial" domain data (the image pixel values and their locations) and re-presents it as the coefficients of complex exponentials (sines and cosines). > > What is difference between spatial domain and frequency domain? > > > The spatial domain is the domain of the image: the pixel values are located at particular positions in the image --- they are spatially distributed, usually in a regular grid. The frequency domain takes this same data and finds any underlying periodicities (sine waves and cosine waves) in the spatial data, and their amplitudes and phases (spatial offsets). For example, suppose I have the following image (Scialab, not matlab): ``` N = 100; x = [1:N]; y = [1:N]; phi = 2*%pi*0.0987298374*ones(N,1)*x + 2*%pi*0.033102974*y'*ones(1,N); im1 = sin(phi); ``` Which looks like (appropriately scaled to the grey scale values): ![Periodic image (scaled)](https://i.stack.imgur.com/vNmzL.png) Then the FFT of this is: ![FFT of periodic image (scaled)](https://i.stack.imgur.com/rjd48.png) (again, with appropriate scaling). The frequency domain version shows up the periodicities of the spatial domain as a small number of large coefficients.
Fourier transform approximates a function to a sum of sine and cosine signals of varying frequency. The Fourier transform is an extension of the Fourier series that results when the period of the represented function is lengthened and allowed to approach infinity. Due to the properties of sine and cosine, it is possible to recover the amplitude of each wave in a Fourier series using an integral.
8,787
I use discrete Fourier transform for digital image processing purposes , but I don't understand basic concept behind it. For example : 1. What information exists in frequency domain? 2. What is difference between spatial domain and frequency domain?
2013/04/22
[ "https://dsp.stackexchange.com/questions/8787", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/4408/" ]
Fourier transform approximates a function to a sum of sine and cosine signals of varying frequency. The Fourier transform is an extension of the Fourier series that results when the period of the represented function is lengthened and allowed to approach infinity. Due to the properties of sine and cosine, it is possible to recover the amplitude of each wave in a Fourier series using an integral.
Spatial domain in image looks like time domain in signals. Any signal (image,data...everything) can be composed of sine signals of varying frequencies (cosine signals are sine signals too, with just some lag or lead). So a definite signal can be decomposed to the sum of lots of sine signals with different frequencies. In more easy terms, any signal has a lot of components having multiple frequencies. This is the basic underlying principle of fourier transform. So what it basically tells is what is the strength of the signal at a definite frequency. "What frequency, What strength". So fourier transform mainly converts the signal from spatial domain to frequency domain. So, in spatial domain, you are concerned about finding the value of the pixel at a definite location, right? Like if I go this location, what value of pixel would I find there, what color would I see there. But in frequency domain, you can find the strength of the signal occurring at a definite frequency. Remember, any signal contains of components of multiple frequencies. So any signal can be thought of having a lot of frequencies. So in frequency domain, you get to know how strong the signal would be at this particular frequency.
8,787
I use discrete Fourier transform for digital image processing purposes , but I don't understand basic concept behind it. For example : 1. What information exists in frequency domain? 2. What is difference between spatial domain and frequency domain?
2013/04/22
[ "https://dsp.stackexchange.com/questions/8787", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/4408/" ]
> > What information exists in frequency domain? > > > As JasonR says in the comment, ***The frequency domain is a different view of the same data.*** No new information is created, it just takes the "spatial" domain data (the image pixel values and their locations) and re-presents it as the coefficients of complex exponentials (sines and cosines). > > What is difference between spatial domain and frequency domain? > > > The spatial domain is the domain of the image: the pixel values are located at particular positions in the image --- they are spatially distributed, usually in a regular grid. The frequency domain takes this same data and finds any underlying periodicities (sine waves and cosine waves) in the spatial data, and their amplitudes and phases (spatial offsets). For example, suppose I have the following image (Scialab, not matlab): ``` N = 100; x = [1:N]; y = [1:N]; phi = 2*%pi*0.0987298374*ones(N,1)*x + 2*%pi*0.033102974*y'*ones(1,N); im1 = sin(phi); ``` Which looks like (appropriately scaled to the grey scale values): ![Periodic image (scaled)](https://i.stack.imgur.com/vNmzL.png) Then the FFT of this is: ![FFT of periodic image (scaled)](https://i.stack.imgur.com/rjd48.png) (again, with appropriate scaling). The frequency domain version shows up the periodicities of the spatial domain as a small number of large coefficients.
Spatial domain in image looks like time domain in signals. Any signal (image,data...everything) can be composed of sine signals of varying frequencies (cosine signals are sine signals too, with just some lag or lead). So a definite signal can be decomposed to the sum of lots of sine signals with different frequencies. In more easy terms, any signal has a lot of components having multiple frequencies. This is the basic underlying principle of fourier transform. So what it basically tells is what is the strength of the signal at a definite frequency. "What frequency, What strength". So fourier transform mainly converts the signal from spatial domain to frequency domain. So, in spatial domain, you are concerned about finding the value of the pixel at a definite location, right? Like if I go this location, what value of pixel would I find there, what color would I see there. But in frequency domain, you can find the strength of the signal occurring at a definite frequency. Remember, any signal contains of components of multiple frequencies. So any signal can be thought of having a lot of frequencies. So in frequency domain, you get to know how strong the signal would be at this particular frequency.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
I use C professionally, nearly every day. In fact, C is the *highest* level language in which I regularly program. **Where I use C:** I write low-level library code that has a requirement to be as efficient as possible. My glue code is written in C, inner computational loops are written in assembly. **Why I use C:** It's much simpler to handle complex argument structures and error conditions than it is in assembly, and the performance overhead for that sort of condition checking before starting the real computation is often negligible. Because C is a simple, well-specified language, I have an easy time working with the compiler team at work to improve the code generation whenever I see compiled code with unacceptable performance hazards. Portability is another great virtue of C. My glue code is shared across multiple hardware-specific implementations of the libraries I work on, which really simplifies bringing up support for new platforms. Most platforms don't have a virtual machine or interpreter for the language flavor of the month. Some platforms don't have a good C++ compiler. There are very few platforms that lack a usable C compiler (and, since I have a good working relationship with our compiler team, I usually don't have a hard time getting the support I need).
Yes, I do it all the time. If you don't call any libraries, code generated from C requires no OS support. It also gives you fine control over the generated machine language. So it's great for writing drivers or other code that lives in kernel spaces, and other constrained situations like many kinds of embedded systems work. It's also the primary language for open-source projects I work with like X Windows, GTK+, and Clutter. While you can do everything in C you can in C++, often C++'s mechanisms make it quicker and easier to write code. I love OOP and the way C++ classes encapsulate functionality, and I love RAII. Careful use of automatic destructor invocation when an object goes out of scope eliminates most of the memory and resource leaks that are the bane of C programming. The STL is basically a giant library of highly optimized algorithms and data structures; if you wanted to use them from C, you'd have to write them yourself or buy them someplace. Unfortunately, for reasons I don't understand, the runtime system on Linux requires a special shared object library (equivalent to DLL on Windows, dylib on Mac) to run any C++, and it's not found when you run a C program. So I can't do one of my favorite Mac and Windows tricks, which is to write a C++-based shared object with a C-based API, and call it from a C program. So here's my decision-making process: 1. Am I working in a constrained situation like a device driver? Use C. 2. Am I writing a Linux library anybody else will have to use? Use C. 3. Am I working inside code that's already written in C? Use C. 4. Am I writing a Mac or Windows library, or a Linux library only I will use? Write the internals in C++, but only expose a C interface to avoid the fragile binary interface problem. 5. Use C++. One nice thing is that because C++ can compile C, if you really need fine-grained control over the code generated for a particular situation, you can just write C for that, and C++ for the rest, and compile it all with the C++ compiler.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
Every single language out there has a decent niche of use. I frequently find myself implementing things in higher-level languages, and then gradually bringing them down to C-land if I need them to be higher-performance or even simply just more portable. There are C compilers for nearly everything in existence, and if you write to an API that is universally available (such as POSIX), then it can be very useful. What I often tell people who are interested in learning programming today is to make sure that at *some* point, they learn C and become comfortable with it. You might find yourself in circumstances where you need it. On more than one occasion, I've had to compile a tiny, statically-linked "fast reboot" program, and use scp to put it on a RAM disk on a server where the disk subsystem went away entirely. (Cheap, cheap servers, no online redundancy, and only the ability to load a small program? C is the way to go.) Also, learning how to work in C without shooting yourself in the foot can contribute significantly to one's ability to write efficiently in other languages and environment. At least, that has been my experience. While I certainly don't use it for everything, or even most things, it has its place and it's pretty much universal: so yes, I've used it in the past and will use it in the future (though I don't know when at the moment).
**C++** is portable across platforms and embedded devices like microcontrollers. (C++ can be compiled to C, therefore microcontrollers.) **C** is even portable (as foreign functions) to other languages. Therefore, iff I program low-level libraries, then I want more compatibility than C++. **Haskell** is portable across platforms (ARM is coming soon) but NOT embedded devices like microcontrollers. Its speed is comparable to C and C++; but because it is functional, it uses a garbage-collector instead of an runtime-stack, therefore it can be faster and slower than C at different times (garbage-collecting) and in different situations (continuations instead of sub-routine calls). --- I choose the most abstract language possible, because the program speed does not differ but the development time and bug-rate. C and C++ differ much, but not from the point of view of Haskell. I do not prefer other languages, even though I know one or two hand full. …except in a few cases, well, **bash**.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
I work mostly with the Xen hypervisor, the assorted libraries it features and the Linux kernel. On occasion, I have to write a device driver (or re-write one so that nxx virtual machines can share a single device such as a HRNG). C is my primary language and I am quite happy with that. Would I try to write a spreadsheet program using it? No way. Each tool has its applications, and I'm happy that I have many tools. I love C, but I don't try to pound screws with a hammer. If C is a sensible choice for a new project, sure. If not, I'll use something else.
if it has to be both * fast, and * portable then I use C. Maybe C++.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
Every single language out there has a decent niche of use. I frequently find myself implementing things in higher-level languages, and then gradually bringing them down to C-land if I need them to be higher-performance or even simply just more portable. There are C compilers for nearly everything in existence, and if you write to an API that is universally available (such as POSIX), then it can be very useful. What I often tell people who are interested in learning programming today is to make sure that at *some* point, they learn C and become comfortable with it. You might find yourself in circumstances where you need it. On more than one occasion, I've had to compile a tiny, statically-linked "fast reboot" program, and use scp to put it on a RAM disk on a server where the disk subsystem went away entirely. (Cheap, cheap servers, no online redundancy, and only the ability to load a small program? C is the way to go.) Also, learning how to work in C without shooting yourself in the foot can contribute significantly to one's ability to write efficiently in other languages and environment. At least, that has been my experience. While I certainly don't use it for everything, or even most things, it has its place and it's pretty much universal: so yes, I've used it in the past and will use it in the future (though I don't know when at the moment).
Embedded systems frequently have no more than a few kilobytes of RAM and perhaps a couple dozen kilobytes of flash, with a processor clock rate of a few MHz. C is the only option that makes any sense in such a bare-metal environment.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
if it has to be both * fast, and * portable then I use C. Maybe C++.
I would use C if I was writing an operating system. Since that is not going to happen in the next twenty years, unless I hit lotto and have nothing else to do but make my own awesome Linux distro, I'll probably just stick to C#, Java, Python, etc, etc. I haven't used C in a very long time but I always enjoyed using it; I think though, these days my head is so wrapped around OO if I have to go back to it it'd take me a bit to get rolling again.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
Yes, I do it all the time. If you don't call any libraries, code generated from C requires no OS support. It also gives you fine control over the generated machine language. So it's great for writing drivers or other code that lives in kernel spaces, and other constrained situations like many kinds of embedded systems work. It's also the primary language for open-source projects I work with like X Windows, GTK+, and Clutter. While you can do everything in C you can in C++, often C++'s mechanisms make it quicker and easier to write code. I love OOP and the way C++ classes encapsulate functionality, and I love RAII. Careful use of automatic destructor invocation when an object goes out of scope eliminates most of the memory and resource leaks that are the bane of C programming. The STL is basically a giant library of highly optimized algorithms and data structures; if you wanted to use them from C, you'd have to write them yourself or buy them someplace. Unfortunately, for reasons I don't understand, the runtime system on Linux requires a special shared object library (equivalent to DLL on Windows, dylib on Mac) to run any C++, and it's not found when you run a C program. So I can't do one of my favorite Mac and Windows tricks, which is to write a C++-based shared object with a C-based API, and call it from a C program. So here's my decision-making process: 1. Am I working in a constrained situation like a device driver? Use C. 2. Am I writing a Linux library anybody else will have to use? Use C. 3. Am I working inside code that's already written in C? Use C. 4. Am I writing a Mac or Windows library, or a Linux library only I will use? Write the internals in C++, but only expose a C interface to avoid the fragile binary interface problem. 5. Use C++. One nice thing is that because C++ can compile C, if you really need fine-grained control over the code generated for a particular situation, you can just write C for that, and C++ for the rest, and compile it all with the C++ compiler.
Embedded systems frequently have no more than a few kilobytes of RAM and perhaps a couple dozen kilobytes of flash, with a processor clock rate of a few MHz. C is the only option that makes any sense in such a bare-metal environment.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
C is a great language for System programming -------------------------------------------- I would use C if I implemented some harware drivers. And I would use C if I implement my own Operating System kernel or my own Virtual Machine. It is a very good language to do low-level things if you have to deal with hardware or low-level OS APIs for Windows API, Linux, Mac OS X, Solaris and so on... Embedded systems has usually good support for C with a compiler + development kit.
**Yes, in fact I have recently!** I like programming in C. I do most my programming in python, but there are times when I need fast code and I really enjoy the elegance that come from the simplicity of the language. The project I'm working on now is a database, which, as you can imagine, is performance critical. At the moment I'm using C and some python, but it will eventually be predominantly, if not entirely C.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
I work mostly with the Xen hypervisor, the assorted libraries it features and the Linux kernel. On occasion, I have to write a device driver (or re-write one so that nxx virtual machines can share a single device such as a HRNG). C is my primary language and I am quite happy with that. Would I try to write a spreadsheet program using it? No way. Each tool has its applications, and I'm happy that I have many tools. I love C, but I don't try to pound screws with a hammer. If C is a sensible choice for a new project, sure. If not, I'll use something else.
Every single language out there has a decent niche of use. I frequently find myself implementing things in higher-level languages, and then gradually bringing them down to C-land if I need them to be higher-performance or even simply just more portable. There are C compilers for nearly everything in existence, and if you write to an API that is universally available (such as POSIX), then it can be very useful. What I often tell people who are interested in learning programming today is to make sure that at *some* point, they learn C and become comfortable with it. You might find yourself in circumstances where you need it. On more than one occasion, I've had to compile a tiny, statically-linked "fast reboot" program, and use scp to put it on a RAM disk on a server where the disk subsystem went away entirely. (Cheap, cheap servers, no online redundancy, and only the ability to load a small program? C is the way to go.) Also, learning how to work in C without shooting yourself in the foot can contribute significantly to one's ability to write efficiently in other languages and environment. At least, that has been my experience. While I certainly don't use it for everything, or even most things, it has its place and it's pretty much universal: so yes, I've used it in the past and will use it in the future (though I don't know when at the moment).
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
**Yes, in fact I have recently!** I like programming in C. I do most my programming in python, but there are times when I need fast code and I really enjoy the elegance that come from the simplicity of the language. The project I'm working on now is a database, which, as you can imagine, is performance critical. At the moment I'm using C and some python, but it will eventually be predominantly, if not entirely C.
I would use C if I was writing an operating system. Since that is not going to happen in the next twenty years, unless I hit lotto and have nothing else to do but make my own awesome Linux distro, I'll probably just stick to C#, Java, Python, etc, etc. I haven't used C in a very long time but I always enjoyed using it; I think though, these days my head is so wrapped around OO if I have to go back to it it'd take me a bit to get rolling again.
26,301
If yes, where and why would you use it? If no, please provide an explanation to why C is not acceptable to you.
2010/12/14
[ "https://softwareengineering.stackexchange.com/questions/26301", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/3306/" ]
C is a great language for System programming -------------------------------------------- I would use C if I implemented some harware drivers. And I would use C if I implement my own Operating System kernel or my own Virtual Machine. It is a very good language to do low-level things if you have to deal with hardware or low-level OS APIs for Windows API, Linux, Mac OS X, Solaris and so on... Embedded systems has usually good support for C with a compiler + development kit.
**C++** is portable across platforms and embedded devices like microcontrollers. (C++ can be compiled to C, therefore microcontrollers.) **C** is even portable (as foreign functions) to other languages. Therefore, iff I program low-level libraries, then I want more compatibility than C++. **Haskell** is portable across platforms (ARM is coming soon) but NOT embedded devices like microcontrollers. Its speed is comparable to C and C++; but because it is functional, it uses a garbage-collector instead of an runtime-stack, therefore it can be faster and slower than C at different times (garbage-collecting) and in different situations (continuations instead of sub-routine calls). --- I choose the most abstract language possible, because the program speed does not differ but the development time and bug-rate. C and C++ differ much, but not from the point of view of Haskell. I do not prefer other languages, even though I know one or two hand full. …except in a few cases, well, **bash**.
62,256,834
I keep getting this error while writing a spring boot application using REST API. > > { > "status": 415, > "error": "Unsupported Media Type", > "message": "Content type 'text/plain' not supported" } > > > How do I get rid of the error? My Post Request code is as follows, in my ``` StudentController.java, @RequestMapping(value = "/students/{studentId}/courses", method = RequestMethod.POST, consumes = "application/json", produces = {"application/json"}) public ResponseEntity<Void> registerStudentForCourse(@PathVariable String studentId, @RequestBody course newCourse) { course course1 = studentService.addCourse(studentId, newCourse); if (course1 == null) return ResponseEntity.noContent().build(); URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(course1.getId()).toUri(); return ResponseEntity.created(location).build(); } ``` And my postman input for the requestBody is as follows, to add a new course to student . The code is in json ``` { "name":"Microservices", "description"="10 Steps", "steps": [ "Learn How to Break Things up ", "Automate the hell out of everything ", "Have fun" ] } ``` `My addcourse()` method is as follows : ``` SecureRandom random = new SecureRandom(); public course addCourse(String studentId, course cour) { Student student = retrieveStudent(studentId); if(student==null) { return null; } String randomId = new BigInteger(130,random).toString(32); cour.setId(randomId); student.getCourses().add(cour); return cour; } ```
2020/06/08
[ "https://Stackoverflow.com/questions/62256834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704420/" ]
As each Pod of Statefulset is created, it gets a matching DNS subdomain, taking the form: `$(podname).$(governing service domain)`. For your case, * podname = `report-mysqlha-0` * governing service domain = `report-mysqlha.middleware.svc.cluster.local` Pod's subdomain will be, `report-mysqlha-0.report-mysqlha.middleware.svc.cluster.local` * [Reference](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id)
`report-mysqlha-0` is the name of the pod and not the name of the service. Hence you can't access it via `report-mysqlha-0.middleware.svc.cluster.local`
42,298,694
* History: I'm making a Powershell script in order to create user from a defined table containing list of users and put them in a defined OrganizationalUnit. * Problem: At the end of the script, I'd like to have a report in order to list whether or not there is one or many user account disabled amoung newly created account In my script, I have to input a password for each user, but I may enter a password that won't meet the password policy defined in Active Directory; in this case, the account will be created but disabled. To proceed, I tried : ``` dsquery user "ou=sp,dc=mydomain,dc=local" -disabled ``` and it print me this : ``` "CN=user1,OU=SP,DC=mydomain,DC=local" "CN=user2,OU=SP,DC=mydomain,DC=local" "CN=user3,OU=SP,DC=mydomain,DC=local" ``` * My goal : I'd like to extract in a variable the values in "CN" field in order to compare them to the inital user table in my script. ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.CN -ne $null} ``` or ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.Common-Name -ne $null} ``` But it didn't help (doesn't work). How can I proceed please?
2017/02/17
[ "https://Stackoverflow.com/questions/42298694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7572709/" ]
You need to check if `firstNode` is `null` before you try to access it in the line with the error, since you initialize it with `null`.
In ``` public class LinkedSet<T> implements Set<T> { private Node firstNode; public LinkedSet() { firstNode = null; } // end Constructor ``` `firstNode` is null and you are not initializing the memory to the node and accessing it afterwards.That's the reason you are getting null pointer exception because you are accessing null. Change it to. ``` public class LinkedSet<T> implements Set<T> { private Node firstNode; public LinkedSet() { firstNode = new Node(); } // end Constructor ``` To check if empty ``` public boolean isEmpty() { return firstNode==null; } // end isEmpty() ``` Node Class ``` private class Node { private T data; private Node next; //Get Error here private Node(T data, Node next) { next= new Node(); this.data = data; this.next = next; } // end Node constructor private Node(T data) { this(data, null); }// end Node constructor } // end Node inner Class ``` Main ``` public class SetTester { public static void main(String[] args) { LinkedSet<String> set = new LinkedSet<String>(); System.out.println(set.isEmpty()); } } ```
42,298,694
* History: I'm making a Powershell script in order to create user from a defined table containing list of users and put them in a defined OrganizationalUnit. * Problem: At the end of the script, I'd like to have a report in order to list whether or not there is one or many user account disabled amoung newly created account In my script, I have to input a password for each user, but I may enter a password that won't meet the password policy defined in Active Directory; in this case, the account will be created but disabled. To proceed, I tried : ``` dsquery user "ou=sp,dc=mydomain,dc=local" -disabled ``` and it print me this : ``` "CN=user1,OU=SP,DC=mydomain,DC=local" "CN=user2,OU=SP,DC=mydomain,DC=local" "CN=user3,OU=SP,DC=mydomain,DC=local" ``` * My goal : I'd like to extract in a variable the values in "CN" field in order to compare them to the inital user table in my script. ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.CN -ne $null} ``` or ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.Common-Name -ne $null} ``` But it didn't help (doesn't work). How can I proceed please?
2017/02/17
[ "https://Stackoverflow.com/questions/42298694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7572709/" ]
Your set is empty if it has no nodes. Therefore your `isEmpty()` implementation is your problem, since it assumes you always have a `firstNode` even though you explicitly set it to `null` in the constructor. Try this: ``` public boolean isEmpty() { return firstNode == null; } ``` *Edit after the first problem was edited away:* You still access null (which causes the `NullPointerException`) since you set `current` to `firstNode` which in turn has never been set to anything but null.
In ``` public class LinkedSet<T> implements Set<T> { private Node firstNode; public LinkedSet() { firstNode = null; } // end Constructor ``` `firstNode` is null and you are not initializing the memory to the node and accessing it afterwards.That's the reason you are getting null pointer exception because you are accessing null. Change it to. ``` public class LinkedSet<T> implements Set<T> { private Node firstNode; public LinkedSet() { firstNode = new Node(); } // end Constructor ``` To check if empty ``` public boolean isEmpty() { return firstNode==null; } // end isEmpty() ``` Node Class ``` private class Node { private T data; private Node next; //Get Error here private Node(T data, Node next) { next= new Node(); this.data = data; this.next = next; } // end Node constructor private Node(T data) { this(data, null); }// end Node constructor } // end Node inner Class ``` Main ``` public class SetTester { public static void main(String[] args) { LinkedSet<String> set = new LinkedSet<String>(); System.out.println(set.isEmpty()); } } ```
42,298,694
* History: I'm making a Powershell script in order to create user from a defined table containing list of users and put them in a defined OrganizationalUnit. * Problem: At the end of the script, I'd like to have a report in order to list whether or not there is one or many user account disabled amoung newly created account In my script, I have to input a password for each user, but I may enter a password that won't meet the password policy defined in Active Directory; in this case, the account will be created but disabled. To proceed, I tried : ``` dsquery user "ou=sp,dc=mydomain,dc=local" -disabled ``` and it print me this : ``` "CN=user1,OU=SP,DC=mydomain,DC=local" "CN=user2,OU=SP,DC=mydomain,DC=local" "CN=user3,OU=SP,DC=mydomain,DC=local" ``` * My goal : I'd like to extract in a variable the values in "CN" field in order to compare them to the inital user table in my script. ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.CN -ne $null} ``` or ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.Common-Name -ne $null} ``` But it didn't help (doesn't work). How can I proceed please?
2017/02/17
[ "https://Stackoverflow.com/questions/42298694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7572709/" ]
``` public boolean isEmpty() { Node next = firstNode.next; //Get error here if (next.equals(null)) { return true; } return false; } // end isEmpty() ``` This line gives you NullPointerException, I hope: ``` Node next = firstNode.next; //Get error here ``` Because `firstNode` is probably `null` and not pointing anywhere so far. It's also best practice to handle `NullPointerException`. So, what you should do is: ``` public boolean isEmpty() { if (firstNode == null) { return true;} return false; } // end isEmpty() ``` Also, do not check null as: `next.equals(null)` Always check it as: `null == next` or `next == null`
In ``` public class LinkedSet<T> implements Set<T> { private Node firstNode; public LinkedSet() { firstNode = null; } // end Constructor ``` `firstNode` is null and you are not initializing the memory to the node and accessing it afterwards.That's the reason you are getting null pointer exception because you are accessing null. Change it to. ``` public class LinkedSet<T> implements Set<T> { private Node firstNode; public LinkedSet() { firstNode = new Node(); } // end Constructor ``` To check if empty ``` public boolean isEmpty() { return firstNode==null; } // end isEmpty() ``` Node Class ``` private class Node { private T data; private Node next; //Get Error here private Node(T data, Node next) { next= new Node(); this.data = data; this.next = next; } // end Node constructor private Node(T data) { this(data, null); }// end Node constructor } // end Node inner Class ``` Main ``` public class SetTester { public static void main(String[] args) { LinkedSet<String> set = new LinkedSet<String>(); System.out.println(set.isEmpty()); } } ```
42,298,694
* History: I'm making a Powershell script in order to create user from a defined table containing list of users and put them in a defined OrganizationalUnit. * Problem: At the end of the script, I'd like to have a report in order to list whether or not there is one or many user account disabled amoung newly created account In my script, I have to input a password for each user, but I may enter a password that won't meet the password policy defined in Active Directory; in this case, the account will be created but disabled. To proceed, I tried : ``` dsquery user "ou=sp,dc=mydomain,dc=local" -disabled ``` and it print me this : ``` "CN=user1,OU=SP,DC=mydomain,DC=local" "CN=user2,OU=SP,DC=mydomain,DC=local" "CN=user3,OU=SP,DC=mydomain,DC=local" ``` * My goal : I'd like to extract in a variable the values in "CN" field in order to compare them to the inital user table in my script. ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.CN -ne $null} ``` or ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.Common-Name -ne $null} ``` But it didn't help (doesn't work). How can I proceed please?
2017/02/17
[ "https://Stackoverflow.com/questions/42298694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7572709/" ]
Your set is empty if it has no nodes. Therefore your `isEmpty()` implementation is your problem, since it assumes you always have a `firstNode` even though you explicitly set it to `null` in the constructor. Try this: ``` public boolean isEmpty() { return firstNode == null; } ``` *Edit after the first problem was edited away:* You still access null (which causes the `NullPointerException`) since you set `current` to `firstNode` which in turn has never been set to anything but null.
You need to check if `firstNode` is `null` before you try to access it in the line with the error, since you initialize it with `null`.
42,298,694
* History: I'm making a Powershell script in order to create user from a defined table containing list of users and put them in a defined OrganizationalUnit. * Problem: At the end of the script, I'd like to have a report in order to list whether or not there is one or many user account disabled amoung newly created account In my script, I have to input a password for each user, but I may enter a password that won't meet the password policy defined in Active Directory; in this case, the account will be created but disabled. To proceed, I tried : ``` dsquery user "ou=sp,dc=mydomain,dc=local" -disabled ``` and it print me this : ``` "CN=user1,OU=SP,DC=mydomain,DC=local" "CN=user2,OU=SP,DC=mydomain,DC=local" "CN=user3,OU=SP,DC=mydomain,DC=local" ``` * My goal : I'd like to extract in a variable the values in "CN" field in order to compare them to the inital user table in my script. ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.CN -ne $null} ``` or ``` dsquery user "dc=mydomain,dc=local" -disabled | where-object {$_.Common-Name -ne $null} ``` But it didn't help (doesn't work). How can I proceed please?
2017/02/17
[ "https://Stackoverflow.com/questions/42298694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7572709/" ]
``` public boolean isEmpty() { Node next = firstNode.next; //Get error here if (next.equals(null)) { return true; } return false; } // end isEmpty() ``` This line gives you NullPointerException, I hope: ``` Node next = firstNode.next; //Get error here ``` Because `firstNode` is probably `null` and not pointing anywhere so far. It's also best practice to handle `NullPointerException`. So, what you should do is: ``` public boolean isEmpty() { if (firstNode == null) { return true;} return false; } // end isEmpty() ``` Also, do not check null as: `next.equals(null)` Always check it as: `null == next` or `next == null`
You need to check if `firstNode` is `null` before you try to access it in the line with the error, since you initialize it with `null`.
27,216,349
I want a quick way to burn a ZIP file into an ISO file so I use NeroCmd.exe which is the command-line tool for Nero. When I'm using the following command: ``` NeroCmd --write --drivename "Image Recorder" --real --iso isoName rarFile.rar ``` The problem is that it prompts for the image name and I don't know if it's possible to specify it in the parameters and which parameter should I include, supposing the image name is "Image.iso". **EDIT:** I tried using `--output_image test.iso`, so my final code is: ``` NeroCmd --write --no_error_log --drivename "Image Recorder" --real --iso Drive --enable_abort --underrun_prot --output_image Image.iso --verify rarFile.rar ``` But no file was created, here's the console output: ``` PHASE: Unspecified [i] Generation of disc structures started Creating directories [i] Creating directories PHASE: Unspecified [i] Generation of disc structures completed Checking discs [i] Checking discs Enter file name to save image to (RETURN to abort): GameSetup.iso There is not enough space available to burn the image. Enter file name to save image to (RETURN to abort): Not enough space available in the given location. [!] Canceled by user ERROR: The operation cannot be performed without user interaction! User aborted! ``` The command works perfectly without that parameter, but the problem is it prompts.
2014/11/30
[ "https://Stackoverflow.com/questions/27216349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4133866/" ]
In the first example, some variation of the below may happen: 1. `even()` acquires the lock 2. `even()` prints `count` (which is 0) and signals the condition (though `odd()` can't wake until `even()` releases the lock) 3. `even()` increments `count` to 1 4. `even()` releases the lock, and `odd()` wakes. 5. `odd()` increments `count` to 2 6. `odd()` releases the lock (but hasn't signalled the condition) 7. `odd()` acquires the lock 8. `odd()` waits, because `count` is even (== 2)... now both threads are waiting and neither can signal the condition. Things may happen slightly differently depending on which thread goes first, but both threads still get stuck in a way similar to the above. Both examples are unreliable, though, because they don't account for spurious wakeups when waiting for the condition. Normally a loop should be used to retry the wait if the desired wakeup conditions aren't met, holding the lock the whole time so a signal won't be missed: ``` pthread_mutex_lock(&lock); /* ...stuff... */ /* Use a loop to restart the wait if it was interrupted early */ while(count % 2 != 0) pthread_cond_wait(&cond,&lock); /* ...stuff... */ pthread_mutex_unlock(&lock); ```
In the first example, in `even()`, then if count is odd, you `pthread_cond_signal` `odd()` to run if `count` is even. `count` will be incremented, and the mutex dropped. At this point `odd()` may run and signal `even()` before `even()` ever reaches the `pthread_cond_wait()`. Now `odd()` will never again signal `even()` (because `count` is now even), and the `even()`'s `pthread_cond_wait()` will never exit. But both of your examples are buggy. You are (last full line) reading `count` outside the mutex that protects it.
27,216,349
I want a quick way to burn a ZIP file into an ISO file so I use NeroCmd.exe which is the command-line tool for Nero. When I'm using the following command: ``` NeroCmd --write --drivename "Image Recorder" --real --iso isoName rarFile.rar ``` The problem is that it prompts for the image name and I don't know if it's possible to specify it in the parameters and which parameter should I include, supposing the image name is "Image.iso". **EDIT:** I tried using `--output_image test.iso`, so my final code is: ``` NeroCmd --write --no_error_log --drivename "Image Recorder" --real --iso Drive --enable_abort --underrun_prot --output_image Image.iso --verify rarFile.rar ``` But no file was created, here's the console output: ``` PHASE: Unspecified [i] Generation of disc structures started Creating directories [i] Creating directories PHASE: Unspecified [i] Generation of disc structures completed Checking discs [i] Checking discs Enter file name to save image to (RETURN to abort): GameSetup.iso There is not enough space available to burn the image. Enter file name to save image to (RETURN to abort): Not enough space available in the given location. [!] Canceled by user ERROR: The operation cannot be performed without user interaction! User aborted! ``` The command works perfectly without that parameter, but the problem is it prompts.
2014/11/30
[ "https://Stackoverflow.com/questions/27216349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4133866/" ]
In the first example, in `even()`, then if count is odd, you `pthread_cond_signal` `odd()` to run if `count` is even. `count` will be incremented, and the mutex dropped. At this point `odd()` may run and signal `even()` before `even()` ever reaches the `pthread_cond_wait()`. Now `odd()` will never again signal `even()` (because `count` is now even), and the `even()`'s `pthread_cond_wait()` will never exit. But both of your examples are buggy. You are (last full line) reading `count` outside the mutex that protects it.
``` #include <stdio.h> #include <pthread.h> #include<iostream> void *odd(void* data); void *even(void* data); static int count=0; pthread_mutex_t mutex; pthread_cond_t cond; int main() { pthread_t thread1,thread2; pthread_create(&thread1,NULL,&even,0); pthread_create(&thread2,NULL,&odd,0); pthread_join(thread1,NULL); pthread_join(thread2,NULL); return 0; } void *even(void* data) { pthread_mutex_lock(&mutex); while(count< 10) { while(count%2!=0) { pthread_cond_wait(&cond,&mutex); } std::cout<<count; count++; pthread_mutex_unlock(&mutex); pthread_cond_signal(&cond); } pthread_exit(0); } void *odd(void* data) { pthread_mutex_lock(&mutex); while(count<10) { while(count%2!=1) { pthread_cond_wait(&cond,&mutex); } std::cout<<count; count++; pthread_mutex_unlock(&mutex); pthread_cond_signal(&cond); } pthread_exit(0); } ```
27,216,349
I want a quick way to burn a ZIP file into an ISO file so I use NeroCmd.exe which is the command-line tool for Nero. When I'm using the following command: ``` NeroCmd --write --drivename "Image Recorder" --real --iso isoName rarFile.rar ``` The problem is that it prompts for the image name and I don't know if it's possible to specify it in the parameters and which parameter should I include, supposing the image name is "Image.iso". **EDIT:** I tried using `--output_image test.iso`, so my final code is: ``` NeroCmd --write --no_error_log --drivename "Image Recorder" --real --iso Drive --enable_abort --underrun_prot --output_image Image.iso --verify rarFile.rar ``` But no file was created, here's the console output: ``` PHASE: Unspecified [i] Generation of disc structures started Creating directories [i] Creating directories PHASE: Unspecified [i] Generation of disc structures completed Checking discs [i] Checking discs Enter file name to save image to (RETURN to abort): GameSetup.iso There is not enough space available to burn the image. Enter file name to save image to (RETURN to abort): Not enough space available in the given location. [!] Canceled by user ERROR: The operation cannot be performed without user interaction! User aborted! ``` The command works perfectly without that parameter, but the problem is it prompts.
2014/11/30
[ "https://Stackoverflow.com/questions/27216349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4133866/" ]
In the first example, some variation of the below may happen: 1. `even()` acquires the lock 2. `even()` prints `count` (which is 0) and signals the condition (though `odd()` can't wake until `even()` releases the lock) 3. `even()` increments `count` to 1 4. `even()` releases the lock, and `odd()` wakes. 5. `odd()` increments `count` to 2 6. `odd()` releases the lock (but hasn't signalled the condition) 7. `odd()` acquires the lock 8. `odd()` waits, because `count` is even (== 2)... now both threads are waiting and neither can signal the condition. Things may happen slightly differently depending on which thread goes first, but both threads still get stuck in a way similar to the above. Both examples are unreliable, though, because they don't account for spurious wakeups when waiting for the condition. Normally a loop should be used to retry the wait if the desired wakeup conditions aren't met, holding the lock the whole time so a signal won't be missed: ``` pthread_mutex_lock(&lock); /* ...stuff... */ /* Use a loop to restart the wait if it was interrupted early */ while(count % 2 != 0) pthread_cond_wait(&cond,&lock); /* ...stuff... */ pthread_mutex_unlock(&lock); ```
``` #include <stdio.h> #include <pthread.h> #include<iostream> void *odd(void* data); void *even(void* data); static int count=0; pthread_mutex_t mutex; pthread_cond_t cond; int main() { pthread_t thread1,thread2; pthread_create(&thread1,NULL,&even,0); pthread_create(&thread2,NULL,&odd,0); pthread_join(thread1,NULL); pthread_join(thread2,NULL); return 0; } void *even(void* data) { pthread_mutex_lock(&mutex); while(count< 10) { while(count%2!=0) { pthread_cond_wait(&cond,&mutex); } std::cout<<count; count++; pthread_mutex_unlock(&mutex); pthread_cond_signal(&cond); } pthread_exit(0); } void *odd(void* data) { pthread_mutex_lock(&mutex); while(count<10) { while(count%2!=1) { pthread_cond_wait(&cond,&mutex); } std::cout<<count; count++; pthread_mutex_unlock(&mutex); pthread_cond_signal(&cond); } pthread_exit(0); } ```
16,892,869
I am using JSP and Servlets to first display a Form in a JSP page then inserting all the parameters to a table in the servlet. Here is some of the code which I am using: ``` <form action="ClassServlet" method="post"> <fieldset> <label for="year">Year</label> <input type="text" name="year" id="year" class="text ui-widget-content ui-corner-all" /> <label for="subject">Subject</label> <input type="text" name="subject" id="subject" value="" class="text ui-widget-content ui-corner-all" /> <label for="name">Name of your class</label> <input type="text" name="name1" id="name1" value="" class="text ui-widget-content ui-corner-all" /> <input type="hidden" name="teacher" id="teacher" <% out.println("value=\""+TeacherId+"\""); %> class="text ui-widget-content ui-corner-all" /> <input type="submit" value="Add"> </fieldset> </form> ``` And for servlets: ``` PreparedStatement ps = null; ps = con.prepareStatement("insert into TB_classes( CLASS_ID , CLASS_TEACHER_ID , CLASS_NAME , CLASS_YEAR , CLASS_SUBJECT) values (? , ? , ? , ? ,?) "); ps.setString(1, "3"); ps.setString(2, request.getParameter("teacher")); ps.setString(3, request.getParameter("name1")); ps.setString(4, request.getParameter("year")); ps.setString(5, request.getParameter("subject")); ps.executeUpdate(); ``` The code is working totally fine But being new to this I wanted to know is there any possible way to do same task on one page. If yes then how ? Please help?
2013/06/03
[ "https://Stackoverflow.com/questions/16892869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/994926/" ]
What you're looking for is a process called ajax. Rather than going to a new page, you want to send a message to the server to do the insert but without making the page change. Take a look at using jquery with a servlet, so the flow would be something like the following in javascript. ``` $.post('/servlet'); ``` Then in that servlet, just do the insert SQL statement. Take a look at the short example [here](http://nareshkumarh.wordpress.com/2012/10/11/jquery-ajax-json-servlet-example/) for further clarification.
you can have both input and output on the same page with the use of XmlHttpRequest in java script. The following code snippet should work out for you... ``` var xhReq = new XMLHttpRequest(); xhReq.open("post", "ClassServlet", false); xhReq.send(null); var serverResponse = xhReq.responseText; alert(serverResponse); ``` use this code on the click event of your submit button... then it will send the request to 'ClassServelet' and display the output in an alert box.
16,892,869
I am using JSP and Servlets to first display a Form in a JSP page then inserting all the parameters to a table in the servlet. Here is some of the code which I am using: ``` <form action="ClassServlet" method="post"> <fieldset> <label for="year">Year</label> <input type="text" name="year" id="year" class="text ui-widget-content ui-corner-all" /> <label for="subject">Subject</label> <input type="text" name="subject" id="subject" value="" class="text ui-widget-content ui-corner-all" /> <label for="name">Name of your class</label> <input type="text" name="name1" id="name1" value="" class="text ui-widget-content ui-corner-all" /> <input type="hidden" name="teacher" id="teacher" <% out.println("value=\""+TeacherId+"\""); %> class="text ui-widget-content ui-corner-all" /> <input type="submit" value="Add"> </fieldset> </form> ``` And for servlets: ``` PreparedStatement ps = null; ps = con.prepareStatement("insert into TB_classes( CLASS_ID , CLASS_TEACHER_ID , CLASS_NAME , CLASS_YEAR , CLASS_SUBJECT) values (? , ? , ? , ? ,?) "); ps.setString(1, "3"); ps.setString(2, request.getParameter("teacher")); ps.setString(3, request.getParameter("name1")); ps.setString(4, request.getParameter("year")); ps.setString(5, request.getParameter("subject")); ps.executeUpdate(); ``` The code is working totally fine But being new to this I wanted to know is there any possible way to do same task on one page. If yes then how ? Please help?
2013/06/03
[ "https://Stackoverflow.com/questions/16892869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/994926/" ]
There are several technologies, which I only can recommend. You could do it all in one servlet as follows: * On HTTP GET (normal page call) fill the data *model* = do `request.setAttribute("TeacherId", teacherId);` and forward to the JSP with the form, the *view*. * On HTTP POST (coming back from the form), do the SQL INSERT, and for the new case, call the doGet. In the form use `${TeacherId}`. To derive a new record ID from the database itself. In MySQL that would be an INT AUTO\_INCR field. And the generated primary key could be retrieved as follows: ``` ps = con.prepareStatement("insert into TB_classes" + "( CLASS_TEACHER_ID , CLASS_NAME , CLASS_YEAR , CLASS_SUBJECT) " + "values (? , ? , ? ,?)"); ps.setString(1, request.getParameter("teacher")); ps.setString(2, request.getParameter("name1")); ps.setString(3, request.getParameter("year")); ps.setString(4, request.getParameter("subject")); ps.executeUpdate(); ResultSet primaryKeysRS = ps.getGeneratedKeys(); if (primaryKeyRS.next()) { int classId = primaryKeyRS.getInt(1); ... } primaryKeysRS.close(); ```
you can have both input and output on the same page with the use of XmlHttpRequest in java script. The following code snippet should work out for you... ``` var xhReq = new XMLHttpRequest(); xhReq.open("post", "ClassServlet", false); xhReq.send(null); var serverResponse = xhReq.responseText; alert(serverResponse); ``` use this code on the click event of your submit button... then it will send the request to 'ClassServelet' and display the output in an alert box.
59,514,022
I wanted to ask if there is a way in Java where I can read in, basically any file format (N3, JSON, RDF-XML) etc and then convert it into turtle(.ttl). I have searched on Google to get some idea, but they mainly just explain for specific file types and how a file type can be converted to RDF whereas I want it the other way. EDIT (following the code example given in the answer): ``` if(FilePath.getText().equals("")){ FilePath.setText("Cannot be empty"); }else{ try { // get the inputFile from file chooser and setting a text field with // the path (FilePath is the variable name fo the textField in which the // path to the selected file from file chooser is done earlier) FileInputStream fis = new FileInputStream(FilePath.getText()); // guess the format of the input file (default set to RDF/XML) // when clicking on the error I get take to this line. RDFFormat inputFormat = Rio.getParserFormatForFileName(fis.toString()).orElse(RDFFormat.RDFXML); //create a parser for the input file and a writer for Turtle RDFParser rdfParser = Rio.createParser(inputFormat); RDFWriter rdfWriter = Rio.createWriter(RDFFormat.TURTLE, new FileOutputStream("./" + fileName + ".ttl")); //link parser to the writer rdfParser.setRDFHandler(rdfWriter); //start the conversion InputStream inputStream = fis; rdfParser.parse(inputStream, fis.toString()); //exception handling } catch (FileNotFoundException ex) { Logger.getLogger(FileConverter.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FileConverter.class.getName()).log(Level.SEVERE, null, ex); } } ``` I have added "eclipse-rdf4j-3.0.3-onejar.jar" to the Libraries folder in NetBeans and now when I run the program I keep getting this error: > > Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory > at org.eclipse.rdf4j.common.lang.service.ServiceRegistry.(ServiceRegistry.java:31) > > > Any help or advice would be highly appreciated. Thank you.
2019/12/28
[ "https://Stackoverflow.com/questions/59514022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12615393/" ]
Yes, this is possible. One option is to use [Eclipse RDF4J](https://rdf4j.org/) for this purpose, or more specifically, its [Rio parser/writer toolkit](https://rdf4j.org/documentation/programming/rio/). Here's a code example using RDF4J Rio. It detects the syntax format of the input file based on the file extension, and directly writes the data to a new file, in Turtle syntax: ```java // the input file java.net.URL url = new URL(“http://example.org/example.rdf”); // guess the format of the input file (default to RDF/XML) RDFFormat inputFormat = Rio.getParserFormatForFileName(url.toString()).orElse(RDFFormat.RDFXML); // create a parser for the input file and a writer for Turtle format RDFParser rdfParser = Rio.createParser(inputFormat); RDFWriter rdfWriter = Rio.createWriter(RDFFormat.TURTLE, new FileOutputStream("/path/to/example-output.ttl")); // link the parser to the writer rdfParser.setRDFHandler(rdfWriter); // start the conversion try(InputStream inputStream = url.openStream()) { rdfParser.parse(inputStream, url.toString()); } catch (IOException | RDFParseException | RDFHandlerException e) { ... } ``` For more examples, see the [RDF4J documentation](https://rdf4j.org/documentation/). *edit* Regarding your `NoClassDefFoundError`: you're missing a necessary third party library on your classpath (in this particular case, a logging library). Instead of using the onejar, it's probably better to use Maven (or Gradle) to set up your project. See the [development environment setup](https://rdf4j.org/documentation/programming/setup/) notes, or for a more step by step guide, see [this tutorial](https://rdf4j.org/documentation/maven-eclipse-project/) (the tutorial uses Eclipse rather than Netbeans, but the points about how to set up your maven project will be very similar in Netbeans). If you really don't want to use Maven, what you can also do is just [download the RDF4J SDK](https://rdf4j.org/download/), which is a ZIP file. Unpack it, and just add all jar files in the `lib/` directory to Netbeans.
An other option would be to use [Apache Jena](https://jena.apache.org/tutorials/rdf_api.html).
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can do: ``` new int[][][] myArray = new int[][][] { new int[][] { new int[] { // Your numbers } } } ``` ``` myArray[0].Length myArray[0][0].Length myArray[0][0][0].Length ``` Works fine
First, ``` int[][][] ``` is a jagged array, or an array of arrays of arrays. Where as, ``` int [,,] ``` is a multi-dimensioinal array. A single array with many dimensions. --- While multi-dimensional arrays are easier to instantiate and will have fixed dimensions on every axis, historically, the CLR [has been optimized for the vastly more common case of single dimensional arrays,](https://stackoverflow.com/a/468873) as used in jagged arrays. For large sizes, you may experience unexpected performance issues. You can still get the dimensions of a multi-dimensional array by using the [GetLength](https://learn.microsoft.com/en-us/dotnet/api/system.array.getlength?view=net-6.0) method, and specifying the dimension you are interested in but, its a little clunky. The number of dimensions can be retrieved from the [Rank](https://learn.microsoft.com/en-us/dotnet/api/system.array.rank?view=net-6.0#system-array-rank) property. You may prefer a jagged array and instantiating one axis at a time. To instantiate jagged arrays, see this [Initializing jagged arrays](https://stackoverflow.com/questions/1738990/initializing-jagged-arrays).
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can't declare a jagged array in one line like this: `new int[sizeX][sizeY][sizeZ];` as you really have three levels of nested arrays. You need to initialize them at each level. This is what that would look like: ``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = new int[sizeX][][]; for (var x = 0; x < sizeX; x++) { my3DArray[x] = new int[sizeY][]; for (var y = 0; y < sizeY; y++) { my3DArray[x][y] = new int[sizeZ]; } } } ``` Now, if you do want to initialize a multidimensional array, you can do this: ``` int[,,] z = { { { 1, 2, }, { 1, 2, }, { 1, 2, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, }; ``` And then, to get the dimensions, you can do this: ``` Console.WriteLine(z.GetLength(0)); Console.WriteLine(z.GetLength(1)); Console.WriteLine(z.GetLength(2)); ``` That gives me: ``` 4 3 2 ``` It's important to note that with a jagged array each nested array can be of different length, but with a multidimensional array then each dimension must be uniform. For example, a jagged array could look like this: ``` int[][] y = new int[][] { new [] { 1, 2, }, new [] { 1, 2, 3, }, new [] { 1, }, }; ``` And a multidimensional array like this: ``` int[,] y = { { 1, 2, 3, }, { 4, 5, 3, }, { 1, 6, 3, }, { 1, 7, 8, }, }; ``` I could not do this: ``` //illegal!!! int[,] y = { { 1, 2, 3, }, { 4, 5, 3, 7, }, { 1, 6, }, { 1, 7, 8, }, }; ```
First, ``` int[][][] ``` is a jagged array, or an array of arrays of arrays. Where as, ``` int [,,] ``` is a multi-dimensioinal array. A single array with many dimensions. --- While multi-dimensional arrays are easier to instantiate and will have fixed dimensions on every axis, historically, the CLR [has been optimized for the vastly more common case of single dimensional arrays,](https://stackoverflow.com/a/468873) as used in jagged arrays. For large sizes, you may experience unexpected performance issues. You can still get the dimensions of a multi-dimensional array by using the [GetLength](https://learn.microsoft.com/en-us/dotnet/api/system.array.getlength?view=net-6.0) method, and specifying the dimension you are interested in but, its a little clunky. The number of dimensions can be retrieved from the [Rank](https://learn.microsoft.com/en-us/dotnet/api/system.array.rank?view=net-6.0#system-array-rank) property. You may prefer a jagged array and instantiating one axis at a time. To instantiate jagged arrays, see this [Initializing jagged arrays](https://stackoverflow.com/questions/1738990/initializing-jagged-arrays).
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
int[][] is a jaggad array, which means that every array can be in a different size. This is why you can initialize it that way: ``` int[][] arr2D= new int[3][]; arr2D[0] = new int[0]; arr2D[1] = new int[1]; arr2D[2] = new int[2]; ``` which will create a 2d array that looks like this: ``` _ _ _ _ _ _ ``` The following is an example to create 3d jaggad array (with different sizes for each dimension- 5 rows, 3 columns and 6 depth): ``` int[][][] arr3D = new int[5][][]; for (int col = 0; col < arr3D.Length; col++) { arr3D[col] = new int[3][]; for (int depth = 0; depth < arr3D[col].Length; depth++) { arr3D[col][depth] = new int[6]; } } ``` In order to get the dimension size in jaggad array, you can simply get the lenth of the array, but keep in mind that if the array is actually jagged, you will have different sizes for different arrays. if you initialize all of the arrays in a specific dimension with the same value, than you can check either of them, it will be the same. --- int[,] is a multi dimensional array that every dimension have a fixed size. To create a multi dimensional: `int[,] arr2D = new int[3,4];` which will create a 2d array looking like this: ``` _ _ _ _ _ _ _ _ _ _ _ _ ``` In multi dimensional array you can't change the length of a specific row or column. In most cases you will probably prefer a multi dimensional array. In order to get the size of a specific dimension in a multi dimensional array, you can use the following method: `int rows = arr22.GetLength(0); int cols = arr22.GetLength(1); int depth = arr22.GetLength(2);` The input is the dimension you want the size of.
First, ``` int[][][] ``` is a jagged array, or an array of arrays of arrays. Where as, ``` int [,,] ``` is a multi-dimensioinal array. A single array with many dimensions. --- While multi-dimensional arrays are easier to instantiate and will have fixed dimensions on every axis, historically, the CLR [has been optimized for the vastly more common case of single dimensional arrays,](https://stackoverflow.com/a/468873) as used in jagged arrays. For large sizes, you may experience unexpected performance issues. You can still get the dimensions of a multi-dimensional array by using the [GetLength](https://learn.microsoft.com/en-us/dotnet/api/system.array.getlength?view=net-6.0) method, and specifying the dimension you are interested in but, its a little clunky. The number of dimensions can be retrieved from the [Rank](https://learn.microsoft.com/en-us/dotnet/api/system.array.rank?view=net-6.0#system-array-rank) property. You may prefer a jagged array and instantiating one axis at a time. To instantiate jagged arrays, see this [Initializing jagged arrays](https://stackoverflow.com/questions/1738990/initializing-jagged-arrays).
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can do: ``` new int[][][] myArray = new int[][][] { new int[][] { new int[] { // Your numbers } } } ``` ``` myArray[0].Length myArray[0][0].Length myArray[0][0][0].Length ``` Works fine
``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = Enumerable.Repeat(Enumerable.Repeat(new int[sizeZ], sizeY).ToArray(),sizeX).ToArray(); } ```
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can do: ``` new int[][][] myArray = new int[][][] { new int[][] { new int[] { // Your numbers } } } ``` ``` myArray[0].Length myArray[0][0].Length myArray[0][0][0].Length ``` Works fine
You can't declare a jagged array in one line like this: `new int[sizeX][sizeY][sizeZ];` as you really have three levels of nested arrays. You need to initialize them at each level. This is what that would look like: ``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = new int[sizeX][][]; for (var x = 0; x < sizeX; x++) { my3DArray[x] = new int[sizeY][]; for (var y = 0; y < sizeY; y++) { my3DArray[x][y] = new int[sizeZ]; } } } ``` Now, if you do want to initialize a multidimensional array, you can do this: ``` int[,,] z = { { { 1, 2, }, { 1, 2, }, { 1, 2, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, }; ``` And then, to get the dimensions, you can do this: ``` Console.WriteLine(z.GetLength(0)); Console.WriteLine(z.GetLength(1)); Console.WriteLine(z.GetLength(2)); ``` That gives me: ``` 4 3 2 ``` It's important to note that with a jagged array each nested array can be of different length, but with a multidimensional array then each dimension must be uniform. For example, a jagged array could look like this: ``` int[][] y = new int[][] { new [] { 1, 2, }, new [] { 1, 2, 3, }, new [] { 1, }, }; ``` And a multidimensional array like this: ``` int[,] y = { { 1, 2, 3, }, { 4, 5, 3, }, { 1, 6, 3, }, { 1, 7, 8, }, }; ``` I could not do this: ``` //illegal!!! int[,] y = { { 1, 2, 3, }, { 4, 5, 3, 7, }, { 1, 6, }, { 1, 7, 8, }, }; ```
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can't declare a jagged array in one line like this: `new int[sizeX][sizeY][sizeZ];` as you really have three levels of nested arrays. You need to initialize them at each level. This is what that would look like: ``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = new int[sizeX][][]; for (var x = 0; x < sizeX; x++) { my3DArray[x] = new int[sizeY][]; for (var y = 0; y < sizeY; y++) { my3DArray[x][y] = new int[sizeZ]; } } } ``` Now, if you do want to initialize a multidimensional array, you can do this: ``` int[,,] z = { { { 1, 2, }, { 1, 2, }, { 1, 2, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, }; ``` And then, to get the dimensions, you can do this: ``` Console.WriteLine(z.GetLength(0)); Console.WriteLine(z.GetLength(1)); Console.WriteLine(z.GetLength(2)); ``` That gives me: ``` 4 3 2 ``` It's important to note that with a jagged array each nested array can be of different length, but with a multidimensional array then each dimension must be uniform. For example, a jagged array could look like this: ``` int[][] y = new int[][] { new [] { 1, 2, }, new [] { 1, 2, 3, }, new [] { 1, }, }; ``` And a multidimensional array like this: ``` int[,] y = { { 1, 2, 3, }, { 4, 5, 3, }, { 1, 6, 3, }, { 1, 7, 8, }, }; ``` I could not do this: ``` //illegal!!! int[,] y = { { 1, 2, 3, }, { 4, 5, 3, 7, }, { 1, 6, }, { 1, 7, 8, }, }; ```
``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = Enumerable.Repeat(Enumerable.Repeat(new int[sizeZ], sizeY).ToArray(),sizeX).ToArray(); } ```
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
int[][] is a jaggad array, which means that every array can be in a different size. This is why you can initialize it that way: ``` int[][] arr2D= new int[3][]; arr2D[0] = new int[0]; arr2D[1] = new int[1]; arr2D[2] = new int[2]; ``` which will create a 2d array that looks like this: ``` _ _ _ _ _ _ ``` The following is an example to create 3d jaggad array (with different sizes for each dimension- 5 rows, 3 columns and 6 depth): ``` int[][][] arr3D = new int[5][][]; for (int col = 0; col < arr3D.Length; col++) { arr3D[col] = new int[3][]; for (int depth = 0; depth < arr3D[col].Length; depth++) { arr3D[col][depth] = new int[6]; } } ``` In order to get the dimension size in jaggad array, you can simply get the lenth of the array, but keep in mind that if the array is actually jagged, you will have different sizes for different arrays. if you initialize all of the arrays in a specific dimension with the same value, than you can check either of them, it will be the same. --- int[,] is a multi dimensional array that every dimension have a fixed size. To create a multi dimensional: `int[,] arr2D = new int[3,4];` which will create a 2d array looking like this: ``` _ _ _ _ _ _ _ _ _ _ _ _ ``` In multi dimensional array you can't change the length of a specific row or column. In most cases you will probably prefer a multi dimensional array. In order to get the size of a specific dimension in a multi dimensional array, you can use the following method: `int rows = arr22.GetLength(0); int cols = arr22.GetLength(1); int depth = arr22.GetLength(2);` The input is the dimension you want the size of.
``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = Enumerable.Repeat(Enumerable.Repeat(new int[sizeZ], sizeY).ToArray(),sizeX).ToArray(); } ```
72,980,481
I've tryed running a raw mongo command from C# this is the command that I'm interested to run in C# ``` db.getUser("MyUser") ``` I've tried ``` public static async Task GetUserInfoAsync(this IMongoDatabase database, string username, string databaseName) { try { BsonDocument document = new BsonDocument { {"usersInfo", new BsonDocument { { "user", username}, { "db", databaseName} } } }; BsonDocumentCommand<BsonDocument> command = new BsonDocumentCommand<BsonDocument>(document); var t = await database.RunCommandAsync(command); } catch (Exception ex) { throw; } } ``` What I get is ok=1 , users = [] no matter if the users exists or not
2022/07/14
[ "https://Stackoverflow.com/questions/72980481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
int[][] is a jaggad array, which means that every array can be in a different size. This is why you can initialize it that way: ``` int[][] arr2D= new int[3][]; arr2D[0] = new int[0]; arr2D[1] = new int[1]; arr2D[2] = new int[2]; ``` which will create a 2d array that looks like this: ``` _ _ _ _ _ _ ``` The following is an example to create 3d jaggad array (with different sizes for each dimension- 5 rows, 3 columns and 6 depth): ``` int[][][] arr3D = new int[5][][]; for (int col = 0; col < arr3D.Length; col++) { arr3D[col] = new int[3][]; for (int depth = 0; depth < arr3D[col].Length; depth++) { arr3D[col][depth] = new int[6]; } } ``` In order to get the dimension size in jaggad array, you can simply get the lenth of the array, but keep in mind that if the array is actually jagged, you will have different sizes for different arrays. if you initialize all of the arrays in a specific dimension with the same value, than you can check either of them, it will be the same. --- int[,] is a multi dimensional array that every dimension have a fixed size. To create a multi dimensional: `int[,] arr2D = new int[3,4];` which will create a 2d array looking like this: ``` _ _ _ _ _ _ _ _ _ _ _ _ ``` In multi dimensional array you can't change the length of a specific row or column. In most cases you will probably prefer a multi dimensional array. In order to get the size of a specific dimension in a multi dimensional array, you can use the following method: `int rows = arr22.GetLength(0); int cols = arr22.GetLength(1); int depth = arr22.GetLength(2);` The input is the dimension you want the size of.
You can't declare a jagged array in one line like this: `new int[sizeX][sizeY][sizeZ];` as you really have three levels of nested arrays. You need to initialize them at each level. This is what that would look like: ``` void Set3DArraySize(int sizeX, int sizeY, int sizeZ) { my3DArray = new int[sizeX][][]; for (var x = 0; x < sizeX; x++) { my3DArray[x] = new int[sizeY][]; for (var y = 0; y < sizeY; y++) { my3DArray[x][y] = new int[sizeZ]; } } } ``` Now, if you do want to initialize a multidimensional array, you can do this: ``` int[,,] z = { { { 1, 2, }, { 1, 2, }, { 1, 2, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, { { 1, 5, }, { 1, 5, }, { 2, 8, }, }, }; ``` And then, to get the dimensions, you can do this: ``` Console.WriteLine(z.GetLength(0)); Console.WriteLine(z.GetLength(1)); Console.WriteLine(z.GetLength(2)); ``` That gives me: ``` 4 3 2 ``` It's important to note that with a jagged array each nested array can be of different length, but with a multidimensional array then each dimension must be uniform. For example, a jagged array could look like this: ``` int[][] y = new int[][] { new [] { 1, 2, }, new [] { 1, 2, 3, }, new [] { 1, }, }; ``` And a multidimensional array like this: ``` int[,] y = { { 1, 2, 3, }, { 4, 5, 3, }, { 1, 6, 3, }, { 1, 7, 8, }, }; ``` I could not do this: ``` //illegal!!! int[,] y = { { 1, 2, 3, }, { 4, 5, 3, 7, }, { 1, 6, }, { 1, 7, 8, }, }; ```
35,122,168
I am confused on how to write the map function, which maps over two lists: for example: ``` def map[A,B,C](f: (A, B) => C, lst1: List[A], lst2: List[B]): List[C] ``` The input would be 2 lists and the output could be a list that adds the integers alternatively Test example: ``` assert(map(add, List(1, 2, 3), List(4, 5, 6)) == List(5, 7, 9)) ```
2016/02/01
[ "https://Stackoverflow.com/questions/35122168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4570919/" ]
You could use `f.tupled` to convert `f` from a function that accepts to arguments `(A, B) => C`, to a function that accepts one argument as a tuple `((A, B)) => C`. Then, you can `zip` the lists together (make them one list of tuples) and feed them to `f` using the traditional `map`. ``` def map[A,B,C](f: (A, B) => C, lst1: List[A], lst2: List[B]): List[C] = (lst1 zip lst2) map f.tupled scala> def add(a: Int, b: Int): Int = a + b add: (a: Int, b: Int)Int scala> map(add, List(1, 2, 3), List(4, 5, 6)) res20: List[Int] = List(5, 7, 9) ``` Keep in mind that if the two lists are not the same size, then `zip` will truncate the longer list to match the size of the smaller one.
As stated in m-z's answer you can zip the lists, and then map on the list of tuples. If you want to avoid the use of `tupled`, you can do the destructure explicitly: ``` def map[A,B,C](f: (A, B) => C, lst1: List[A], lst2: List[B]): List[C] = { val zipped = lst1 zip lst2 zipped.map { case (a,b) => f(a,b) } } ```
36,282,550
I am having trouble running my ASP.NET5 from command line under IISExpress. My current command line setup (thanks to [this answer](https://stackoverflow.com/questions/33295622/iis-express-command-line-asp-net-mvc-6-beta-8/33309714#33309714)) looks like so > > iisexpress.exe /config:"[project\_dir].vs\config\applicationhost.config" /site:"WebUI" /apppool:"Clr4IntegratedAppPool" > > > Note that running the project from within VS2015 works fine. When I run the command above, IISExpress starts up, it even finds the correct port it should run under. The main problem is every request returns a 502.3. Looking at the contents of `IISExpress\TraceLogFiles` I see this error > > ModuleName: httpPlatformHandler > > > Notification: EXECUTE\_REQUEST\_HANDLER > > > HttpStatus: 502 > > > HttpReason: Bad Gateway > > > HttpSubStatus: 3 > > > ErrorCode: The server is currently disabled. (0x8007053d) > > > What is causing this? Why can't I get this to run!?
2016/03/29
[ "https://Stackoverflow.com/questions/36282550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/94278/" ]
As the earlier answer points out, Visual Studio sets %LAUNCHER\_PATH% and %LAUNCHER\_ARGS% environment variables when launching iisexpress. If you set these, you don't have to run `dotnet publish`, however the contents of these arguments changes slightly from version to version of Visual Studio. Luckily, you can use Process Explorer to see what's in there. Quoting a good blog post on this: <https://blog.lextudio.com/how-visual-studio-launches-iis-express-to-debug-asp-net-core-apps-d7fd3677e3c3> ``` So in fact Visual Studio silently adds the two environment variables when launching IIS Express, so that ASP.NET Core related bits can be injected. LAUNCHER_ARGS: -debug -p “C:\Program Files\dotnet\dotnet.exe” -a “exec \”C:\Users\lextm\documents\visual studio 2017\Projects\WebApplication2\WebApplication2\bin\Debug\netcoreapp1.0\WebApplication2.dll\”” -pidFile “C:\Users\lextm\AppData\Local\Temp\2\tmpFD6D.tmp” -wd “C:\Users\lextm\documents\visual studio 2017\Projects\WebApplication2\WebApplication2” LAUNCHER_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe``` ``` When I ran into this issue (I had to use iisexpress instead of just `dotnet run` since I was running an application with legacy components), I set LAUNCHER\_ARGS="-p C:\$XXX\$MY\_PROGRAM.exe" and LAUNCHER\_PATH: to the above, and launching the application worked for me. I recommend using Process Explorer to find what Visual Studio is putting in there, and using that to craft a launch command.
The applicationhost.config is likely pointing to your project's root directory, and in that directory, the default web.config file for the project has a line that looks something like the following: ``` <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/> ``` Visual Studio (and the `dotnet publish` command) will replace the launcher variables during F5-startup with the actual path to the ASP.NET Core application; I'm not sure where this new web.config file is stored through. That said, I was able to get a command-line invocation of IIS Express working for my ASP.NET Core application with the following steps. 1. Run `dotnet publish`. 2. Copy the applicationhost.config file from the .vs directory to the publish output directory. 3. Modify the paths in the new applicationhost.config for my application to refer to the publish output directory. 4. Run iisexpress.exe and point to the new applicationhost.config file.
40,941,800
I try to convert my excel data to tree data using vba. ``` Sub MakeTree() Dim r As Integer ' Iterate through the range, looking for the Root For r = 1 To Range("Data").Rows.Count If Range("Data").Cells(r, 1) = "Root" Then DrawNode Range("Data").Cells(r, 2), 0, 0 End If Next End Sub Sub DrawNode(ByRef header As String, ByRef row As Integer, ByRef depth As Integer) 'The DrawNode routine draws the current node, and all child nodes. ' First we draw the header text: Cells(Range("Destination").row + row, Range("Destination").Column + depth) = header Dim r As Integer 'Then loop through, looking for instances of that text For r = 1 To Range("Data").Rows.Count If Range("Data").Cells(r, 1) = header Then 'Bang! We've found one! Then call itself to see if there are any child nodes row = row + 1 DrawNode Range("Data").Cells(r, 2), row, depth + 1 End If Next End Sub ``` My excel data like this, [![Source data](https://i.stack.imgur.com/pMjwL.png)](https://i.stack.imgur.com/pMjwL.png) I try to convert tree data like this by using my vba code. [![Output data format](https://i.stack.imgur.com/NO1zW.png)](https://i.stack.imgur.com/NO1zW.png) But above code didn't work for me. Anyone suggest me ? Thanks
2016/12/02
[ "https://Stackoverflow.com/questions/40941800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1967219/" ]
I guess the downloader script is broken. As a temporal workaround can manually download the punkt tokenizer from [here](http://www.nltk.org/nltk_data/) and then place the unzipped folder in the corresponding location. The default folders for each OS are: * Windows: `C:\nltk_data\tokenizers` * OSX: `/usr/local/share/nltk_data/tokenizers` * Unix: `/usr/share/nltk_data/tokenizers` I am not sure but you may find this [post](https://stackoverflow.com/a/33142108/5352399) helpful.
Though this is an old question, I had the same issue on my mac today. The solution [here](https://github.com/sloria/TextBlob/issues/133#issuecomment-338844284) helped me solve it. Edit: Run the following command on the OSX before running nltk.download(): ``` /Applications/Python\ PYTHON_VERSION_HERE/Install\ Certificates.command ```
52,592,627
I can't quite believe I'm having to ask this, but **how do I obtain the full value of a String variable in the Watch window in VSCode**? From here: [![I want this string](https://i.stack.imgur.com/3pjJo.png)](https://i.stack.imgur.com/3pjJo.png) I'm trying to get the multi-line string that I can see in the tooltip into my clipboard. EDIT: If I expand out the treeview of values here in the Watch window, I can see deeper levels of the variable's object hierarchy. As suggested in ChatterOne's original answer, I could have copied the values from "primitive" types from the rght-clck context menu, however, this value is awkwardly a String type, so isn't working in the same way as primitives would. As shown here: [![can't copy String](https://i.stack.imgur.com/7ZJ0q.png)](https://i.stack.imgur.com/7ZJ0q.png) Note that only the lowest level (fullExceptionString.value[0]) has the copy value context menu item, but it's greyed out here, and I wanted the entire string not individual chars.
2018/10/01
[ "https://Stackoverflow.com/questions/52592627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1073157/" ]
I'm a bit late to this but you can try putting this in the variable watch ``` *(char (*)[3091])variableName ```
That's because you're selecting an expression with nested values. If you right-click on anything "below" that (meaning in the same tree) but with a primitive value (meaning not nested), you'll see a `copy value` menu entry. What you want is probably in the `value` entry. Expand that and right-click on the entry for which you need to copy the value.
52,592,627
I can't quite believe I'm having to ask this, but **how do I obtain the full value of a String variable in the Watch window in VSCode**? From here: [![I want this string](https://i.stack.imgur.com/3pjJo.png)](https://i.stack.imgur.com/3pjJo.png) I'm trying to get the multi-line string that I can see in the tooltip into my clipboard. EDIT: If I expand out the treeview of values here in the Watch window, I can see deeper levels of the variable's object hierarchy. As suggested in ChatterOne's original answer, I could have copied the values from "primitive" types from the rght-clck context menu, however, this value is awkwardly a String type, so isn't working in the same way as primitives would. As shown here: [![can't copy String](https://i.stack.imgur.com/7ZJ0q.png)](https://i.stack.imgur.com/7ZJ0q.png) Note that only the lowest level (fullExceptionString.value[0]) has the copy value context menu item, but it's greyed out here, and I wanted the entire string not individual chars.
2018/10/01
[ "https://Stackoverflow.com/questions/52592627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1073157/" ]
I'm a bit late to this but you can try putting this in the variable watch ``` *(char (*)[3091])variableName ```
A workaround I found is to cast variable in Watch pane: e.g. Type in "(char \*)variableName" instead of "variableName". It is annoying but works.
52,592,627
I can't quite believe I'm having to ask this, but **how do I obtain the full value of a String variable in the Watch window in VSCode**? From here: [![I want this string](https://i.stack.imgur.com/3pjJo.png)](https://i.stack.imgur.com/3pjJo.png) I'm trying to get the multi-line string that I can see in the tooltip into my clipboard. EDIT: If I expand out the treeview of values here in the Watch window, I can see deeper levels of the variable's object hierarchy. As suggested in ChatterOne's original answer, I could have copied the values from "primitive" types from the rght-clck context menu, however, this value is awkwardly a String type, so isn't working in the same way as primitives would. As shown here: [![can't copy String](https://i.stack.imgur.com/7ZJ0q.png)](https://i.stack.imgur.com/7ZJ0q.png) Note that only the lowest level (fullExceptionString.value[0]) has the copy value context menu item, but it's greyed out here, and I wanted the entire string not individual chars.
2018/10/01
[ "https://Stackoverflow.com/questions/52592627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1073157/" ]
I'm a bit late to this but you can try putting this in the variable watch ``` *(char (*)[3091])variableName ```
Perhaps, you may copy/paste the output to any JSON formatter to work with your data. In a debug console: `copy(JSON.stringify(yourVarialbeHere));` I tope it helps.
40,556,945
I have a project build using jdk1.5 which is using ant as a build tool. As you know that in ant scripting we can write our own custom tasks like this and than later on we can use this. ``` <taskdef name="loadxml" classname="SomeClass" classpathref="CLASSPATH"/> ``` And here is the java class looks like. ``` import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; class SomeClass extends Task { ....................... } ``` The code works fine in windows server 2003 , but i am trying to run it on windows 7 64-bit. I currently have my java home variable pointing to jdk 1.5. On my system i have java 8 installed. The ant version (by ant -version) is coming as 1.7.1. The ant script works perfect , but when it comes to that xml line mentioned above at top, it gives the following error. ``` java.lang.UnsupportedClassVersionError: Bad version number in .class file at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:397) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.Delegati ngMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.Main.start(Main.java:179) at org.apache.tools.ant.Main.main(Main.java:268) Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:394) Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at org.apache.tools.ant.AntClassLoader.defineClassFromData(AntClassLoader.java:1146) at org.apache.tools.ant.AntClassLoader.getClassFromStream(AntClassLoader.java:1324) at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1388 ) at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341) at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) ``` I have tried changing the JDK to 64 bit and vice versa, tried installing different jres as well, tried different ant version as well. But some how i cant get to the bottom of it. Can you please shed some light on it. Thanks a lot.
2016/11/11
[ "https://Stackoverflow.com/questions/40556945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1646665/" ]
> > I currently have my java home variable pointing to jdk 1.5. > > > That is probably the problem. It looks like you are trying to use a version of Ant that has been compiled for a newer Java platform. Running it on an ancient copy of Java won't work. You should UNINSTALL the JDK 1.5 installation. It is years out of date. You have a Java 8 (JDK I assume) install, so use that. Then update your JAVA\_HOME to point to the Java 8 install. > > I have tried changing the JDK to 64 bit and vice versa > > > That won't help. It is not a 32 bit versus 64 bit problem. The problem is that you are >>using<< an ancient JRE / JDK via your JAVA\_HOME
I had the same problem (Using Java 1.5 and Ant 1.7.1). I upgraded to ant 1.9.7 and that resolved my problem. Make sure you change the ANT\_HOME, antrc locations.
20,487,912
I am trying to save drawing as an image from `GLPaint` app from Apple sample code. Saving the image is working fine in iPad(non-retina), but it issued when it runs on iPad(retina). Whenever I run my app on iPad retina, then the image size is 1/4 from original. Can anyone help me out from this?
2013/12/10
[ "https://Stackoverflow.com/questions/20487912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2894098/" ]
You're on the right track there, but you forgot to implement one step of the description: ``` remove it from the current playlist and place it at the end of newList ``` The method Shuffle needs to be rewritten to the following: ``` public void shuffle (){ newList = new ArrayList<Mp3> (); while (songs.size()>0){ Mp3 song = songs.get(nextInt(songs.size())); songs.remove(song); // the forgotten step newList.add(song); System.out.println("new list" + newList); } } ```
The program goes crash, it is because, in your `shuffle` method, **`while (songs.size()>0){`** is always be `true`. **The size of list is not changed.** If you want to write a `shuffle` method with your own, then a simple way is to **iterater the songs list** and **swap 2 songs of current index i and the song with a random index**. ``` public void shuffle (List<Mp3> songsList) { for(int i=0;i< songsList.size(); i++) { //Do something here //generate a random number //Swap songs according to the i index and and random index. } } ``` The simpliest way is to use **Collections # shuffle** method to make the list to be random. Corresponding source code of shuffle in Collections is as follows: ``` /** * Randomly permutes the specified list using a default source of * randomness. All permutations occur with approximately equal * likelihood.<p> * * The hedge "approximately" is used in the foregoing description because * default source of randomness is only approximately an unbiased source * of independently chosen bits. If it were a perfect source of randomly * chosen bits, then the algorithm would choose permutations with perfect * uniformity.<p> * * This implementation traverses the list backwards, from the last element * up to the second, repeatedly swapping a randomly selected element into * the "current position". Elements are randomly selected from the * portion of the list that runs from the first element to the current * position, inclusive.<p> * * This method runs in linear time. If the specified list does not * implement the {@link RandomAccess} interface and is large, this * implementation dumps the specified list into an array before shuffling * it, and dumps the shuffled array back into the list. This avoids the * quadratic behavior that would result from shuffling a "sequential * access" list in place. * * @param list the list to be shuffled. * @throws UnsupportedOperationException if the specified list or * its list-iterator does not support the <tt>set</tt> method. */ public static void shuffle(List<?> list) { shuffle(list, r); } ```
20,487,912
I am trying to save drawing as an image from `GLPaint` app from Apple sample code. Saving the image is working fine in iPad(non-retina), but it issued when it runs on iPad(retina). Whenever I run my app on iPad retina, then the image size is 1/4 from original. Can anyone help me out from this?
2013/12/10
[ "https://Stackoverflow.com/questions/20487912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2894098/" ]
``` import java.util.Random; public class SuffleSongs { public static void main(String[] args) { List<String> playList = new ArrayList<String>(); playList.add("Song1"); playList.add("Song2"); playList.add("Song3"); playList.add("Song4"); playList.add("Song5"); playList.add("Song6"); playList.add("Song7"); playList.add("Song8"); playList.add("Song9"); playList.add("Song10"); playList.add("Song11"); playList.add("Song12"); playList.add("Song13"); playList.add("Song14"); playList.add("Song15"); playList.add("Song16"); playList.add("Song17"); playList.add("Song18"); playList.add("Song19"); playList.add("Song20"); playList.add("Song21"); // shuffle the playlist for (int i=0; i<playList.size(); ++i) { Random rand = new Random(); int temp = rand.nextInt(playList.size() -i) + i; Collections.swap(playList, i, temp); } // print the shuffled playlist for(int j = 0; j < playList.size(); ++j) { System.out.println(playList.get(j)); } } } ``` This will shuffle without need of creating new playlist (ArrayList). Basically this code just gets a playlist ArrayList and then shuffle within the same ArrayList.
The program goes crash, it is because, in your `shuffle` method, **`while (songs.size()>0){`** is always be `true`. **The size of list is not changed.** If you want to write a `shuffle` method with your own, then a simple way is to **iterater the songs list** and **swap 2 songs of current index i and the song with a random index**. ``` public void shuffle (List<Mp3> songsList) { for(int i=0;i< songsList.size(); i++) { //Do something here //generate a random number //Swap songs according to the i index and and random index. } } ``` The simpliest way is to use **Collections # shuffle** method to make the list to be random. Corresponding source code of shuffle in Collections is as follows: ``` /** * Randomly permutes the specified list using a default source of * randomness. All permutations occur with approximately equal * likelihood.<p> * * The hedge "approximately" is used in the foregoing description because * default source of randomness is only approximately an unbiased source * of independently chosen bits. If it were a perfect source of randomly * chosen bits, then the algorithm would choose permutations with perfect * uniformity.<p> * * This implementation traverses the list backwards, from the last element * up to the second, repeatedly swapping a randomly selected element into * the "current position". Elements are randomly selected from the * portion of the list that runs from the first element to the current * position, inclusive.<p> * * This method runs in linear time. If the specified list does not * implement the {@link RandomAccess} interface and is large, this * implementation dumps the specified list into an array before shuffling * it, and dumps the shuffled array back into the list. This avoids the * quadratic behavior that would result from shuffling a "sequential * access" list in place. * * @param list the list to be shuffled. * @throws UnsupportedOperationException if the specified list or * its list-iterator does not support the <tt>set</tt> method. */ public static void shuffle(List<?> list) { shuffle(list, r); } ```
51,085,357
I am trying to get a properties file from within a zip file. I need to use a wild card, because I will want to match either "my.properties" or "my\_en.properties". I create a `ResourcePatternResolver` like so: ``` ClassLoader loader = MyClass.class.getClassLoader(); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(loader); ``` I succeed when I try to retrieve the "my.properties" file using no wild card: ``` resolver.getResource("file:C:/somePath/a.zip/META-INF/my.properties").exists() ``` returns `true`. However, if I add a wild card to the file name, it fails, e.g., ``` resolver.getResource("file:C:/somePath/a.zip/META-INF/my*.properties").exists() ``` returns `false`. What can I do to match and retrieve either file? I am trying to do this in a webapp within Tomcat.
2018/06/28
[ "https://Stackoverflow.com/questions/51085357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/352319/" ]
The documentation is unclear about this, but the `getResource` method does not use PathMatcher internally to resolve the resource (that means that no wildcard is allowed), try `getResources(String locationPattern)` instead. For example : ``` Resource[] resources = resolver.getResources("file:C:/somePath/a.zip/META-INF/my*.properties"); for(Resource resource : resources) { // do something for each resource found } ```
The official documentation explains it: > > **No Wildcards:** > > > In the simple case, if the specified location path does not start with > the "classpath\*:" prefix, and does not contain a PathMatcher pattern, > this resolver will simply return a single resource via a getResource() > call on the underlying ResourceLoader. Examples are real URLs such as > "file:C:/context.xml", pseudo-URLs such as "classpath:/context.xml", > and simple unprefixed paths such as "/WEB-INF/context.xml". The latter > will resolve in a fashion specific to the underlying ResourceLoader > (e.g. ServletContextResource for a WebApplicationContext) > > > For trying anti-patterns, have a look at: <https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/io/support/PathMatchingResourcePatternResolver.html>
51,085,357
I am trying to get a properties file from within a zip file. I need to use a wild card, because I will want to match either "my.properties" or "my\_en.properties". I create a `ResourcePatternResolver` like so: ``` ClassLoader loader = MyClass.class.getClassLoader(); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(loader); ``` I succeed when I try to retrieve the "my.properties" file using no wild card: ``` resolver.getResource("file:C:/somePath/a.zip/META-INF/my.properties").exists() ``` returns `true`. However, if I add a wild card to the file name, it fails, e.g., ``` resolver.getResource("file:C:/somePath/a.zip/META-INF/my*.properties").exists() ``` returns `false`. What can I do to match and retrieve either file? I am trying to do this in a webapp within Tomcat.
2018/06/28
[ "https://Stackoverflow.com/questions/51085357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/352319/" ]
The documentation is unclear about this, but the `getResource` method does not use PathMatcher internally to resolve the resource (that means that no wildcard is allowed), try `getResources(String locationPattern)` instead. For example : ``` Resource[] resources = resolver.getResources("file:C:/somePath/a.zip/META-INF/my*.properties"); for(Resource resource : resources) { // do something for each resource found } ```
How suggest Sébastien Helbert getResource and getResources works very different in fact if you see the original Spring Code you can see a this code: ``` public class PathMatchingResourcePatternResolver implements ResourcePatternResolver { .... @Override public Resource getResource(String location) { return getResourceLoader().getResource(location); } @Override public Resource[] getResources(String locationPattern) throws IOException { Assert.notNull(locationPattern, "Location pattern must not be null"); if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX)) { // a class path resource (multiple resources for same name possible) if (getPathMatcher().isPattern(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()))) { // a class path resource pattern return findPathMatchingResources(locationPattern); } else { // all class path resources with the given name return findAllClassPathResources(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length())); } } else { // Generally only look for a pattern after a prefix here, // and on Tomcat only after the "*/" separator for its "war:" protocol. int prefixEnd = (locationPattern.startsWith("war:") ? locationPattern.indexOf("*/") + 1 : locationPattern.indexOf(':') + 1); if (getPathMatcher().isPattern(locationPattern.substring(prefixEnd))) { // a file pattern return findPathMatchingResources(locationPattern); } else { // a single resource with the given name return new Resource[] {getResourceLoader().getResource(locationPattern)}; } } } ... } ``` reading the Spring code is clear that getRersources use the AntPattern and geetResource no. I fell it right because with a Wildcards is implicit that you want a multi result and not only one, get resource do not works because it do not take an the common opinion of if I have more that one I take the first, it just do not works because it is no been think in order to works for take the first in case of multi result, it is just a choice. For this reason the your use case, use the wildcard, can be achieved using the getResources() method I hope that it can help you to take the right method.
5,940,633
I'm a novice programmer so feel free to comment on things that make no sense so that I can learn. I'm working on a coffee shop finder android app that makes calls to the [SimpleGeo](http://simplegeo.com "SimpleGeo") API to get each place of interest. I'm having trouble thinking up a way to store the returned JSON data in a way that I can use for my purposes. I need to do 2 things with the data: first, I need a map overlay class to access it so I can draw markers for each coffee shop (which I'm okay with); second, I need to display the data in a list view. The API call: ``` /** Queries SimpleGeo with current location **/ private void getJSONData() { SimpleGeoPlacesClient client = SimpleGeoPlacesClient.getInstance(); client.getHttpClient().setToken(oauth_key, oauth_secret); double radius = 25; try { client.search(lat, lng, "coffee", null, radius, new FeatureCollectionCallback() { public void onSuccess(FeatureCollection collection) { try { features = collection.toJSON(); } catch (JSONException e) { System.out.println(e.getMessage()); } } public void onError(String errorMessage) { System.out.println(errorMessage); } }); } catch (IOException e) { System.out.println(e.getMessage()); } } ``` Parsing the data: ``` private void parseJSONData() throws JSONException { for (int i = 0; i < features.length(); i++) { JSONObject feature = features.getJSONObject(i).getJSONObject( "feature"); } } ``` I'm currently trying to create java objects out of the data using GSON outlined in [this](http://www.softwarepassion.com/android-series-parsing-json-data-with-gson/ "this") tutorial. Would SQLite be appropriate for this? Any pro-tips would be greatly appreciated. Thanks.
2011/05/09
[ "https://Stackoverflow.com/questions/5940633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338724/" ]
You should **not** use NHibernate.Linq.dll with NHibernate 3.0! NHibernate 3.0 has Linq included (a by far better version than the old extension dll), you just need to add `using NHibernate.Linq;` and use `session.Query<T>()` instead of `session.Linq<T>()`.
as far as I can see you are not comparing, but assigning the Text. Should it not be == in stead of =: ``` using(var session = NHibernateHelper.OpenSession()) { var informations = (from i in session<Information>() where i.Text=="some text" select i).ToList(); } ```
1,700,015
I've the following question for homework. Find the wrong operations between `a` and `d` and explain why. [![enter image description here](https://i.stack.imgur.com/3NHep.png)](https://i.stack.imgur.com/3NHep.png) Currently i think that the following operations are wrong: * `a` is wrong since the number `1` in the denominator is deleted without doing so in the numerator. * `d` is wrong since $\infty - \infty \neq 0$ What's your take?
2016/03/16
[ "https://math.stackexchange.com/questions/1700015", "https://math.stackexchange.com", "https://math.stackexchange.com/users/19059/" ]
Note that $$ \{X\_2 = X\_3\} \supseteq \{X\_1 = X\_3\} \cap \{X\_1 = X\_2\} $$ that is, in points $\omega \in \Omega$ where $X\_1(\omega) = X\_3(\omega)$ and $X\_1(\omega) = X\_2(\omega)$ we must have $X\_2(\omega) = X\_3(\omega)$. Hence, we have \begin{align\*} \def\P{\mathbf P}\P[X\_2 = X\_3] &\ge \P[X\_1 = X\_2, X\_1 = X\_3]\\ &= \P[X\_1 = X\_2] + \P[X\_1 = X\_3] - \P[\{X\_1 = X\_3\} \cup \{X\_2 = X\_3\}]\\ &= 2 - \P[\{X\_1 = X\_2\} \cup \{X\_1 = X\_3\}]\\ &\ge 2-1\\ &= 1. \end{align\*} Hence, $\P[X\_2 = X\_3] = 1$.
If $A$ and $B$ are events with $P(A)=1=P(B)$ then: $$P(A\cap B)=P(A)+P(B)-P(A\cup B)=1+1-1=1$$ Applying that on $A=\{X\_1=X\_2\}$ and $B=\{X\_1=X\_3\}$ we find that $P(X\_1=X\_2=X\_3)=1$ and consequently $P(X\_2=X\_3)=1$
1,700,015
I've the following question for homework. Find the wrong operations between `a` and `d` and explain why. [![enter image description here](https://i.stack.imgur.com/3NHep.png)](https://i.stack.imgur.com/3NHep.png) Currently i think that the following operations are wrong: * `a` is wrong since the number `1` in the denominator is deleted without doing so in the numerator. * `d` is wrong since $\infty - \infty \neq 0$ What's your take?
2016/03/16
[ "https://math.stackexchange.com/questions/1700015", "https://math.stackexchange.com", "https://math.stackexchange.com/users/19059/" ]
Suppose that $X$, $Y$ and $Z$ are random variables defined on the same probablity space $(\Omega,\mathcal F,P)$ such that $P(X=Y)=1$ and $P(X=Z)=1$. Since $P(X=Y)=1$, there exists $\Omega\_1\subset\Omega$ such that $X(\omega)=Y(\omega)$ for each $\omega\in\Omega\_1$ and $P(\Omega\_1)=1$. Similarly, there exists $\Omega\_2\subset\Omega$ such that $X(\omega)=Z(\omega)$ for each $\omega\in\Omega\_2$ and $P(\Omega\_2)=1$. For any $\omega\in\Omega\_1\cap\Omega\_2$, we have that $Y(\omega)=Z(\omega)$. Let us evaluate the probability $P(\Omega\_1\cap\Omega\_2)$. We have that $P(\Omega\_1\cap\Omega\_2)=1-P(\Omega\_1^c\cup\Omega\_2^c)$. But $P(\Omega\_1^c\cup\Omega\_2^c)=0$ since $P(\Omega\_1^c)=0$ and $P(\Omega\_2^c)=0$. Hence, $P(Y=Z)=1$.
If $A$ and $B$ are events with $P(A)=1=P(B)$ then: $$P(A\cap B)=P(A)+P(B)-P(A\cup B)=1+1-1=1$$ Applying that on $A=\{X\_1=X\_2\}$ and $B=\{X\_1=X\_3\}$ we find that $P(X\_1=X\_2=X\_3)=1$ and consequently $P(X\_2=X\_3)=1$
42,949
How do I disable or hide the pink background on missing fonts? I do not care that the fonts are missing. I do not want to install the fonts. I do not want to replace the fonts in the file; I want to keep the fonts the same even though I have opened the file on a computer that does not have these fonts installed.
2014/12/01
[ "https://graphicdesign.stackexchange.com/questions/42949", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/34277/" ]
Understand that you **can not** *"Keep the fonts the same"* unless you install the fonts on your system. The pink background is telling you that the fonts **are not** displaying correctly. In any event, you can turn off the pink background by navigating to `Preferences > Type` and *unchecking* the `Enable Missing Glyph Protection` option or, if using Illustrator CC, the `Highlight Substituted Fonts` option.
Try: Preferences > Type and make sure'Highlight Substituted Fonts' is unchecked
13,733,840
Is it possible to get Google Drive to **automatically** convert uploaded documents to the native format? I know it works with **manual** upload (i.e. Google Drive can auto-convert files you upload via the website), but I want to avoid having to upload every file by hand. I'd prefer to use the API, or better yet, dump the files in my `~/Google Drive` folder.
2012/12/05
[ "https://Stackoverflow.com/questions/13733840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18763/" ]
Using the API, you can pass the `convert=true` parameter to [`files.insert`](https://developers.google.com/drive/v2/reference/files/insert). The uploaded file will attempt to be converted to a native Google Docs format.
Sure, see this [answer](https://stackoverflow.com/questions/34905363/create-file-with-google-drive-api-v3-javascript/44527113?noredirect=1#answer-35182924). Note you can upload a text file or a csv file and set its content type to google doc or google sheets respectively, and google will attempt to convert it. I have tested this for text -> doc and it works. You will need to set the `const contentType` at the start of the code to one of the [supported google mimetypes](https://developers.google.com/drive/v3/web/mime-types).
10,311,701
I'm trying to turn my icons into font glyphs. Now, the problem is antialiasing of the font in Google Chrome on Windows 7 (it looks good on OS X). I took two shots, where on the first one you can see the desired behaviour, as seen on Firefox/Windows 7 and all the other browsers, except Google Chrome, which is the second shot. Is that problem in font itself? Or is it because of system settings? Is it in CSS settings? **Firefox 12 Windows 7** enter image description here ---------------------------- **Google Chrome 18 Windows 7** The most problematic parts are highlighted with red. enter image description here ----------------------------
2012/04/25
[ "https://Stackoverflow.com/questions/10311701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1355580/" ]
Try using [`Range.Value`](http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.value%28v=office.11%29.aspx) property instead of `Text`. So instead of ``` (range.Cells[rCnt, cCnt] as Range).Text; ``` you would write ``` (range.Cells[rCnt, cCnt] as Range).Value; ```
I have seen numerous examples where the Range is read using the property Value OR Value2. Could you try this? ``` data[rCnt - 1, cCnt - 1] = (string)(range.Cells[rCnt, cCnt] as Range).Value.ToString(); ``` The Value2 property is similar to Value but don't translate well the Date columns, so it's better to use the Value if you have date columns in your Excel File. [See here](http://support.microsoft.com/kb/182812) for an article on differences between Value and Value2
10,311,701
I'm trying to turn my icons into font glyphs. Now, the problem is antialiasing of the font in Google Chrome on Windows 7 (it looks good on OS X). I took two shots, where on the first one you can see the desired behaviour, as seen on Firefox/Windows 7 and all the other browsers, except Google Chrome, which is the second shot. Is that problem in font itself? Or is it because of system settings? Is it in CSS settings? **Firefox 12 Windows 7** enter image description here ---------------------------- **Google Chrome 18 Windows 7** The most problematic parts are highlighted with red. enter image description here ----------------------------
2012/04/25
[ "https://Stackoverflow.com/questions/10311701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1355580/" ]
I have seen numerous examples where the Range is read using the property Value OR Value2. Could you try this? ``` data[rCnt - 1, cCnt - 1] = (string)(range.Cells[rCnt, cCnt] as Range).Value.ToString(); ``` The Value2 property is similar to Value but don't translate well the Date columns, so it's better to use the Value if you have date columns in your Excel File. [See here](http://support.microsoft.com/kb/182812) for an article on differences between Value and Value2
use (string) (range.Cells[rCnt, cCnt] as Range).Value as Value will return the actual value of a cell. Text will return what you actually see on the spreadsheet
10,311,701
I'm trying to turn my icons into font glyphs. Now, the problem is antialiasing of the font in Google Chrome on Windows 7 (it looks good on OS X). I took two shots, where on the first one you can see the desired behaviour, as seen on Firefox/Windows 7 and all the other browsers, except Google Chrome, which is the second shot. Is that problem in font itself? Or is it because of system settings? Is it in CSS settings? **Firefox 12 Windows 7** enter image description here ---------------------------- **Google Chrome 18 Windows 7** The most problematic parts are highlighted with red. enter image description here ----------------------------
2012/04/25
[ "https://Stackoverflow.com/questions/10311701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1355580/" ]
Try using [`Range.Value`](http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.value%28v=office.11%29.aspx) property instead of `Text`. So instead of ``` (range.Cells[rCnt, cCnt] as Range).Text; ``` you would write ``` (range.Cells[rCnt, cCnt] as Range).Value; ```
use (string) (range.Cells[rCnt, cCnt] as Range).Value as Value will return the actual value of a cell. Text will return what you actually see on the spreadsheet
151,200
In Harry Potter, the first book, Harry receives a letter from Hogwarts after he turned eleven. Due to the interception of his uncle, he didn't get to read the first letter. They then began to send him dozens of letters, and then they sent Hagrid since they could not reach him by mail. How did they know that he hadn't read the first letter?
2017/01/27
[ "https://scifi.stackexchange.com/questions/151200", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/67324/" ]
He didn't reply. > > Dear Mr Potter, > > > We are pleased to inform you that you have a place at Hogwarts School of Witchcraft and Wizardry. Please find enclosed a list of all necessary books and equipment. > > > Term begins on 1 September. **We await your owl by no later than 31 July.** > > > Yours sincerely, > > > Minerva McGonagall > > > Deputy Headmistress > > > Quite why they started mithering him *before* the deadline is another question, possibly because they normally get responses back earlier?
If you remember they appeared to be monitoring him at all times. Remember how Hagrid was the one sending the letters. And when they noticed them not reading the letters they sent more. *Edit*: Yeah as the other answer said he didn't reply. But also they sent another before the deadline.
151,200
In Harry Potter, the first book, Harry receives a letter from Hogwarts after he turned eleven. Due to the interception of his uncle, he didn't get to read the first letter. They then began to send him dozens of letters, and then they sent Hagrid since they could not reach him by mail. How did they know that he hadn't read the first letter?
2017/01/27
[ "https://scifi.stackexchange.com/questions/151200", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/67324/" ]
If you remember they appeared to be monitoring him at all times. Remember how Hagrid was the one sending the letters. And when they noticed them not reading the letters they sent more. *Edit*: Yeah as the other answer said he didn't reply. But also they sent another before the deadline.
The thing is, is that they actually thought he got the letters. When Hagrid first Came to visit Harry on the island, and he was telling him everything he needed to know, he was talking about magic, and Harry didn't know about them. then Hagrid said Something like " Havn't you been getting the letters?" and then Harry said that he didn't. So to sum it all up Hagrid actually thought that Harry got the letters.
151,200
In Harry Potter, the first book, Harry receives a letter from Hogwarts after he turned eleven. Due to the interception of his uncle, he didn't get to read the first letter. They then began to send him dozens of letters, and then they sent Hagrid since they could not reach him by mail. How did they know that he hadn't read the first letter?
2017/01/27
[ "https://scifi.stackexchange.com/questions/151200", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/67324/" ]
If you remember they appeared to be monitoring him at all times. Remember how Hagrid was the one sending the letters. And when they noticed them not reading the letters they sent more. *Edit*: Yeah as the other answer said he didn't reply. But also they sent another before the deadline.
Actually what Hagrid says In H.P.S.S is this > > "It's them who should be sorry! I knew yeh weren't gettin' yer letters but I never thought ya wouldn't even know about Hogwarts, for crying out loud! Did you never wonder where your parents learned it all?" > Blockquote > > > So no... They knew Harry was NOT getting to read his letters. How they knew this was because Harry never replied. Also the letters are magical. Showing up in eggs and such, Hagrid Bewitched them. > > Be grateful if yeh didn't mention that ter anyone at Hogwarts. he said "I'm not supposed to do magic, strictly speaking I was allowed to do a bit ter follow yeh an' get your letters to yeh and stuff--- one o' the reasons I was so keen to take on the job. > > > H.P.S.S chapter 4 page 45 So the letters themselves could be marked as unread by the person they were meant for.
151,200
In Harry Potter, the first book, Harry receives a letter from Hogwarts after he turned eleven. Due to the interception of his uncle, he didn't get to read the first letter. They then began to send him dozens of letters, and then they sent Hagrid since they could not reach him by mail. How did they know that he hadn't read the first letter?
2017/01/27
[ "https://scifi.stackexchange.com/questions/151200", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/67324/" ]
He didn't reply. > > Dear Mr Potter, > > > We are pleased to inform you that you have a place at Hogwarts School of Witchcraft and Wizardry. Please find enclosed a list of all necessary books and equipment. > > > Term begins on 1 September. **We await your owl by no later than 31 July.** > > > Yours sincerely, > > > Minerva McGonagall > > > Deputy Headmistress > > > Quite why they started mithering him *before* the deadline is another question, possibly because they normally get responses back earlier?
The thing is, is that they actually thought he got the letters. When Hagrid first Came to visit Harry on the island, and he was telling him everything he needed to know, he was talking about magic, and Harry didn't know about them. then Hagrid said Something like " Havn't you been getting the letters?" and then Harry said that he didn't. So to sum it all up Hagrid actually thought that Harry got the letters.
151,200
In Harry Potter, the first book, Harry receives a letter from Hogwarts after he turned eleven. Due to the interception of his uncle, he didn't get to read the first letter. They then began to send him dozens of letters, and then they sent Hagrid since they could not reach him by mail. How did they know that he hadn't read the first letter?
2017/01/27
[ "https://scifi.stackexchange.com/questions/151200", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/67324/" ]
He didn't reply. > > Dear Mr Potter, > > > We are pleased to inform you that you have a place at Hogwarts School of Witchcraft and Wizardry. Please find enclosed a list of all necessary books and equipment. > > > Term begins on 1 September. **We await your owl by no later than 31 July.** > > > Yours sincerely, > > > Minerva McGonagall > > > Deputy Headmistress > > > Quite why they started mithering him *before* the deadline is another question, possibly because they normally get responses back earlier?
Actually what Hagrid says In H.P.S.S is this > > "It's them who should be sorry! I knew yeh weren't gettin' yer letters but I never thought ya wouldn't even know about Hogwarts, for crying out loud! Did you never wonder where your parents learned it all?" > Blockquote > > > So no... They knew Harry was NOT getting to read his letters. How they knew this was because Harry never replied. Also the letters are magical. Showing up in eggs and such, Hagrid Bewitched them. > > Be grateful if yeh didn't mention that ter anyone at Hogwarts. he said "I'm not supposed to do magic, strictly speaking I was allowed to do a bit ter follow yeh an' get your letters to yeh and stuff--- one o' the reasons I was so keen to take on the job. > > > H.P.S.S chapter 4 page 45 So the letters themselves could be marked as unread by the person they were meant for.
151,200
In Harry Potter, the first book, Harry receives a letter from Hogwarts after he turned eleven. Due to the interception of his uncle, he didn't get to read the first letter. They then began to send him dozens of letters, and then they sent Hagrid since they could not reach him by mail. How did they know that he hadn't read the first letter?
2017/01/27
[ "https://scifi.stackexchange.com/questions/151200", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/67324/" ]
Actually what Hagrid says In H.P.S.S is this > > "It's them who should be sorry! I knew yeh weren't gettin' yer letters but I never thought ya wouldn't even know about Hogwarts, for crying out loud! Did you never wonder where your parents learned it all?" > Blockquote > > > So no... They knew Harry was NOT getting to read his letters. How they knew this was because Harry never replied. Also the letters are magical. Showing up in eggs and such, Hagrid Bewitched them. > > Be grateful if yeh didn't mention that ter anyone at Hogwarts. he said "I'm not supposed to do magic, strictly speaking I was allowed to do a bit ter follow yeh an' get your letters to yeh and stuff--- one o' the reasons I was so keen to take on the job. > > > H.P.S.S chapter 4 page 45 So the letters themselves could be marked as unread by the person they were meant for.
The thing is, is that they actually thought he got the letters. When Hagrid first Came to visit Harry on the island, and he was telling him everything he needed to know, he was talking about magic, and Harry didn't know about them. then Hagrid said Something like " Havn't you been getting the letters?" and then Harry said that he didn't. So to sum it all up Hagrid actually thought that Harry got the letters.
146,548
I have confusion about the multicast addresses, I have read an example which is given by. Suppose two applications have been built to send audio over a network. One application accepts and digitizes an audio input stream, and then sends the resulting frame across the network to other application. The second application receives the digitized audio from the network, converts it back to the audio signal and plays the result over a speaker. Unless the two applications use broadcast to send frames, no other computers on the network will receive a copy of the frame. Multicasting provides an excellent solution to the problems of allowing some computers to participate in audio transmission. **To use multicasting , a multicast address must be chosen for the audio application**. And the receiving application passes the multicast address to the network interface. The interface begins to accept the packets sent to that address. **Question: how this multicast address is chosen, how the receiving application knows that the sender using this specific destination address for the audio frames.**
2010/05/29
[ "https://serverfault.com/questions/146548", "https://serverfault.com", "https://serverfault.com/users/44270/" ]
The multicast address is chosen arbitrarily out of the 239.0.0.0/8 range (if the application is enterprise-internal, at least). It is then configured on the source(s) and all subscribers. So, there is in general no "directory service" within the network, it relies on human interaction, to configure the applications correctly.
First off let me state that multicasting is evil. It is extremely hard to set up and really tricky to troubleshoot effectively. That being said, I will attempt to answer your question. The sender chooses what multicast IP address that it uses to send traffic on. The reserved range of multicast IP addresses is 224.0.0.0 through 239.255.255.255. Most ISPs do not support multicasting across their public internet networks, so if you are looking to multicast between locations you will need to have VPNs of some sort set up between them. Each router that the multicast transverses will need to be configured for multicasting. If you are configuring your own equipment, I will try to provide an overview of the processes involved, but for detailed information you will need to do some reading. Fortunately wikipedia has decent articles on IP multicasting. The sending device sends out multicast traffic, you will need to set up each network device (routers, switches, firewalls, etc) you want the multicast traffic to pass over. Each manufacturer's equipment is going to be different so I can't provide much input on how specifically to set it up. You will then need to set up each client that wants to recieve multicast traffic with the Internet Group Management Protocol (IGMP) this is usually built into whatever software package you are running on the client for the multicasting application. What IGMP does is go out to it's local network device and inform it that that client is interested in receiving multicast traffic from a particular multicast address. So, for instance, your sending is set up to send on 224.10.10.123, the client who wants to listen would set up IGMP to connect to it's local network device and request any multicast traffic coming to that device on 224.10.10.123. In order to reduce unnecessary multicast traffic, you will probably also want to look into Protocol Independent Multicast (PIM). You set PIM up on your network devices. What PIM does is keep track of if anyone connected to that network device is actually listening to a multicast, and if no one is, then it will prune the traffic. If you have a large network with mutliple multicasting sources, you will definately want to look into implementing PIM.
146,548
I have confusion about the multicast addresses, I have read an example which is given by. Suppose two applications have been built to send audio over a network. One application accepts and digitizes an audio input stream, and then sends the resulting frame across the network to other application. The second application receives the digitized audio from the network, converts it back to the audio signal and plays the result over a speaker. Unless the two applications use broadcast to send frames, no other computers on the network will receive a copy of the frame. Multicasting provides an excellent solution to the problems of allowing some computers to participate in audio transmission. **To use multicasting , a multicast address must be chosen for the audio application**. And the receiving application passes the multicast address to the network interface. The interface begins to accept the packets sent to that address. **Question: how this multicast address is chosen, how the receiving application knows that the sender using this specific destination address for the audio frames.**
2010/05/29
[ "https://serverfault.com/questions/146548", "https://serverfault.com", "https://serverfault.com/users/44270/" ]
The multicast address is chosen arbitrarily out of the 239.0.0.0/8 range (if the application is enterprise-internal, at least). It is then configured on the source(s) and all subscribers. So, there is in general no "directory service" within the network, it relies on human interaction, to configure the applications correctly.
Windows Media Services has the option of broadcasting live events over multicast. As Lloyd Baker pointed out, this is something that ends up being local to a network. On our University network we would multicast things like Commencement and speeches by the President, which would allow anyone on the network to tune in (which could be thousands) without hammering the snot out of the media server itself. Those who are off-campus would be stuck with unicast to get the live broadcast. The IP we pick to use for our live broadcast is selected from the multicast range, which is goverened by [RFC3171](https://www.rfc-editor.org/rfc/rfc3171). The 239/8 block is for 'internal' use and is not routed over the internet, similar to RFC1918 addresses. Multicast works best when your network has been designed for it. Ours was since we had a dependency on the [Service Location Protocol](http://en.wikipedia.org/wiki/Service_Location_Protocol) for a long time, and that's a multi-cast based protocol. Once we pick an address for our broadcast we then assign a DNS name for it. At that point publishing the broadcast is pretty simple, whether it is an all-campus email or posted to the front of our web-page.
18,098,274
I have two datatable dt1 and dt2 and my stored procedure are as follows ``` ALTER procedure [dbo].[Sp_ShowAllEmpLeaveSummary] @TableName1 nvarchar(128) , @TableName2 nvarchar(128) as begin DECLARE @Columns VARCHAR(MAX) SELECT @Columns = COALESCE(@Columns + ',' + name + '', '' + name + '') FROM ( SELECT DISTINCT 'CAST(ISNULL('+@TableName1 +'.' + name + ',0) AS VARCHAR) + ''/'' + CAST('+@TableName2 +'.' + name + ' AS VARCHAR) AS ' + name + ' ' AS name FROM sys.columns WHERE NAME LIKE '%leave%' AND object_id IN (SELECT object_id FROM sys.tables WHERE name IN (''+@TableName1 +'', ''+@TableName2 +''))) LeaveColumns DECLARE @SQL NVARCHAR(MAX) SET @SQL = N' SELECT '+@TableName1 +'.empid, '+@TableName2 +'.empname, ' + @Columns + ' FROM dt1 INNER JOIN '+@TableName2 +' ON '+@TableName1 +'.empid='+@TableName2 +'.empid' EXECUTE(@SQL) end ``` and in Ui I pass the parameter like this ``` cmd4.Parameters.Add(new SqlParameter("@TableName1", SqlDbType.Structured)).Value = dt1; cmd4.Parameters.Add(new SqlParameter("@TableName2", SqlDbType.Structured)).Value = dt2; ``` but its showing error **Operand type clash: table type is incompatible with nvarchar(128)**. so can i solve this problem Thanks
2013/08/07
[ "https://Stackoverflow.com/questions/18098274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2516261/" ]
We had significant performance problems with boost::property\_tree and JSON. Our approach was to stop using `std::string` and use an in-house string class with a custom allocator, and hash tables for not reallocating the same string twice. This improved performance and memory usage by at least a few orders of magnitude for large JSON files. Our JSON files were large enough that the std::string allocation consumed all available address space on a 32-bit machine. This approach let us run with headroom.
It doesn't matter much what's really in the JSON file. I tried multiple JSON files with different conent. Boost is just slow. Now I already switched to jansson which is much better - fast and nice API to use.
18,098,274
I have two datatable dt1 and dt2 and my stored procedure are as follows ``` ALTER procedure [dbo].[Sp_ShowAllEmpLeaveSummary] @TableName1 nvarchar(128) , @TableName2 nvarchar(128) as begin DECLARE @Columns VARCHAR(MAX) SELECT @Columns = COALESCE(@Columns + ',' + name + '', '' + name + '') FROM ( SELECT DISTINCT 'CAST(ISNULL('+@TableName1 +'.' + name + ',0) AS VARCHAR) + ''/'' + CAST('+@TableName2 +'.' + name + ' AS VARCHAR) AS ' + name + ' ' AS name FROM sys.columns WHERE NAME LIKE '%leave%' AND object_id IN (SELECT object_id FROM sys.tables WHERE name IN (''+@TableName1 +'', ''+@TableName2 +''))) LeaveColumns DECLARE @SQL NVARCHAR(MAX) SET @SQL = N' SELECT '+@TableName1 +'.empid, '+@TableName2 +'.empname, ' + @Columns + ' FROM dt1 INNER JOIN '+@TableName2 +' ON '+@TableName1 +'.empid='+@TableName2 +'.empid' EXECUTE(@SQL) end ``` and in Ui I pass the parameter like this ``` cmd4.Parameters.Add(new SqlParameter("@TableName1", SqlDbType.Structured)).Value = dt1; cmd4.Parameters.Add(new SqlParameter("@TableName2", SqlDbType.Structured)).Value = dt2; ``` but its showing error **Operand type clash: table type is incompatible with nvarchar(128)**. so can i solve this problem Thanks
2013/08/07
[ "https://Stackoverflow.com/questions/18098274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2516261/" ]
We had significant performance problems with boost::property\_tree and JSON. Our approach was to stop using `std::string` and use an in-house string class with a custom allocator, and hash tables for not reallocating the same string twice. This improved performance and memory usage by at least a few orders of magnitude for large JSON files. Our JSON files were large enough that the std::string allocation consumed all available address space on a 32-bit machine. This approach let us run with headroom.
I found that there is a huge difference between Release Build vs Debug Build performance numbers from VS for Property Tree. on my specific hardware a parsing through a 1 MB JSON File using read\_json was taking 8 sec in Debug build , but only 0.7 sec in release version.
24,614,333
Hi I have problem with idle instance When I trying: ``` sqlplus / as sysdba ``` I get result: `Connected to an idle instance.` And when I try startup I get: ``` ORA-01078: failure in processing system parameters ORA-01565 error in identifying file 'C:\oraclexe\app\oracle\product\11.2.0\server\dbs/spfileXE.ora ORA-27041: unable to open file ORA-04002: unable to open file O/S-Error: (OS 2) File not found; ``` My system is Windows 8. Do you any idea how to solve it? SOLUTION: I have to startup using command: ``` startup pfile='<path to file>/init.ora' ``` and change all paths in init.ora where was ``` <ORACLE_BASE> ``` Thx for help
2014/07/07
[ "https://Stackoverflow.com/questions/24614333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3506652/" ]
I just had the same problem. You just have to start the setup to install the database as administrator. After this and a reboot everything works fine.
I highly recommend reading the [Oracle® Database 2 Day DBA](http://docs.oracle.com/cd/E11882_01/server.112/e10897/toc.htm) manual, or hire a dba. You are missing the init{ORACLE\_SID}.ora, the parameter file which contains things like database name, controlfile locations. the init{ORACLE\_SID}.ora is a text file that is edited with a regular text editor. This file can be converted to a spfile{ORACLE\_SID}.ora that can be edited using a database instance. This is also a dynamic parameter file meaning that when you change parameters in an instance, the parameters can also be recorded in the spfile for later reuse. For now add the db\_name and control\_files. Make sure that the contol\_files parameter points to an existing controlfile[s]. If there are no existing control\_file[s], just trash the initXE.ora, spfileXE.ora and start dbca, the Database Configuration Assistant and using that create a new database.
24,614,333
Hi I have problem with idle instance When I trying: ``` sqlplus / as sysdba ``` I get result: `Connected to an idle instance.` And when I try startup I get: ``` ORA-01078: failure in processing system parameters ORA-01565 error in identifying file 'C:\oraclexe\app\oracle\product\11.2.0\server\dbs/spfileXE.ora ORA-27041: unable to open file ORA-04002: unable to open file O/S-Error: (OS 2) File not found; ``` My system is Windows 8. Do you any idea how to solve it? SOLUTION: I have to startup using command: ``` startup pfile='<path to file>/init.ora' ``` and change all paths in init.ora where was ``` <ORACLE_BASE> ``` Thx for help
2014/07/07
[ "https://Stackoverflow.com/questions/24614333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3506652/" ]
I've got that pain too. To install Oracle XE you should login as local admin - NOT domain account. This <https://community.oracle.com/thread/2361291> made me happy :)
I highly recommend reading the [Oracle® Database 2 Day DBA](http://docs.oracle.com/cd/E11882_01/server.112/e10897/toc.htm) manual, or hire a dba. You are missing the init{ORACLE\_SID}.ora, the parameter file which contains things like database name, controlfile locations. the init{ORACLE\_SID}.ora is a text file that is edited with a regular text editor. This file can be converted to a spfile{ORACLE\_SID}.ora that can be edited using a database instance. This is also a dynamic parameter file meaning that when you change parameters in an instance, the parameters can also be recorded in the spfile for later reuse. For now add the db\_name and control\_files. Make sure that the contol\_files parameter points to an existing controlfile[s]. If there are no existing control\_file[s], just trash the initXE.ora, spfileXE.ora and start dbca, the Database Configuration Assistant and using that create a new database.
24,614,333
Hi I have problem with idle instance When I trying: ``` sqlplus / as sysdba ``` I get result: `Connected to an idle instance.` And when I try startup I get: ``` ORA-01078: failure in processing system parameters ORA-01565 error in identifying file 'C:\oraclexe\app\oracle\product\11.2.0\server\dbs/spfileXE.ora ORA-27041: unable to open file ORA-04002: unable to open file O/S-Error: (OS 2) File not found; ``` My system is Windows 8. Do you any idea how to solve it? SOLUTION: I have to startup using command: ``` startup pfile='<path to file>/init.ora' ``` and change all paths in init.ora where was ``` <ORACLE_BASE> ``` Thx for help
2014/07/07
[ "https://Stackoverflow.com/questions/24614333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3506652/" ]
I've got that pain too. To install Oracle XE you should login as local admin - NOT domain account. This <https://community.oracle.com/thread/2361291> made me happy :)
I just had the same problem. You just have to start the setup to install the database as administrator. After this and a reboot everything works fine.
55,453
We are flying from USA to Greece and from Greece to Africa. Can i have some luggage send straight from the US airport to Africa so i don't have to drag them to Greece with me?
2015/09/06
[ "https://travel.stackexchange.com/questions/55453", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/34801/" ]
**No**. Due to the risk of terrorism (bombs in bags etc), plus more pedestrian concerns like customs clearance, airlines will not send passengers' bags unless the passenger accompanies them. You could ship your bags ahead as air cargo, but this tends to be extremely expensive. One cheaper option would be to just leave your bags in storage at the airport in Greece.
There are luggage services that will send your bag to any destination you choose. They will arrange for your bag to be picked up from your home and delivered to your destination. Most work through UPS and FedEx, so the fees are similar to what you would pay if you walked in. They have an advantage over air cargo, as they have their own in-house custom brokers (in-house in FedEx and UPS that is) so bags will be cleared through customs with simple paperwork. <https://www.luggagefree.com/> <https://www.sendmybag.com/>
29,428,904
I am struggling to deduce a way to make dynamic INDIRECT references to cell ranges on other worksheets. Would appreciate any suggestions, details are: The workbook includes 4 worksheets (Product1, Product2, Product3, Warehouses). The Warehouses sheet contains the following formula to populate an inventory list for each warehouse from the three product worksheets (derived from <http://exceltactics.com/make-filtered-list-sub-arrays-excel-using-small/>). This is the formula in cell B3: ``` =IFERROR(INDEX(INDIRECT(B$2&"!B$3:B$400"),SMALL(IF(INDIRECT(B$2&"!$C$3:$C$400")=$B$1,ROW(INDIRECT(B$2&"!B$3:B$400"))-ROW(INDIRECT(B$2&"!B$3"))+1),ROWS(Product1!$B$3:$B3))),"") ``` Where: Warehouses-->$B$1 = Warehouse1 or Warehouse2 Warehouses-->B2, C2, D2 = Column headers for Product1, Product2, Product3 Product Sheets-->Column B = Serial # Product Sheets-->Column C = Location (Warehouse1, Warehouse2) Currently, I have to amend the last part of the formula for each row: `ROWS(Product1!$B$3:$B3)`, `ROWS(Product2!$B$3:$B3)` , `ROWS(Product3!$B$3:$B3)`.I am trying to dynamically link it to the column header like the other parts of the code (e.g. `ROW(INDIRECT(B$2&"!B$3:B$400"))`. I'm stuck though because the range `$B3` has to change with each row, whereas the others are static and are fine enclosed in the quotations. This effort is important because I want less capable users to be able to copy the formula to new columns without having to amend it. Appreciate any thoughts on this!
2015/04/03
[ "https://Stackoverflow.com/questions/29428904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831261/" ]
There are a number of ways to introduce an incrementing number into the [INDIRECT function's](https://support.office.com/en-us/article/indirect-function-21f8bcfc-b174-4a50-9dc6-4dfb5b3361cd) string concatenation. I prefer a simple [ROW function](https://support.office.com/en-us/article/row-function-fde8c59b-a604-4474-90b2-2c69040344f0) like `ROW(1:1)` which returns *1, 2, 3, ...* when filled down. In your case,k yu would start at `ROW(3:3)`. ``` ... -ROW(INDIRECT(B$2&"!B"&ROW(3:3)))+1), ..., ROWS(INDIRECT(B$2&"!B3:B"&ROW(3:3))),"") ``` Just a reminder; leaving the absolute $ designations on the cell addresses that are described with text may be useful as a visual reminder as to what may advance to the next (relative) or not (absolute) but the text representing the row or column is *never* going to actually change so they are at least a bit superfluous.
You can modify your `INDIRECT()` formula to take into account the row number of current cell, for example: ``` =INDIRECT(B$2&"!B$"&ROW()&":B$"&(ROW()+397)) ``` Alternatively, you could use `OFFSET()` function to shift your reference with each row: ``` =OFFSET(INDIRECT(B$2&"!B$3:B$400"),ROW()-3,0) ```
160,802
We have given a certificate chain: `X <-- Y <-- Z` (`X` is an end-entity cert, `Z` is root CA). Certificates are extended with CRL distribution points info. Because of the fact `Y -> X` `Y` is a CA for `X`. Therefore, `Y` can revoke `X` 's certificate by placing it on `Y`'s CRL. `Z` is CA for `Y`. `Z` can revoke certificate `Y`. But, the question is: can `Z` revoke certificate `X`?
2017/05/30
[ "https://security.stackexchange.com/questions/160802", "https://security.stackexchange.com", "https://security.stackexchange.com/users/149645/" ]
Short answer: NO, Z can't revoke X directly. Exception: YES, if Z's CRLs are, due to prior arrangement between Z & Y, in the CRL Distribution Point list of X's certificate that was issued by Y. RFC5280 refers to this as "[Indirect CRL](https://www.rfc-editor.org/rfc/rfc5280#page-55)" - where Z can issue a CRL that includes certificates issued by Y. It only works if the verifier knows where to check. The "[CRL Distributions Points extension](https://www.rfc-editor.org/rfc/rfc3280#page-42)" of certificates is the place they (ought to) look. It is well known however, that most certification verification algorithms are not strictly quality checked against the standards - and hence this system is fallible to a non-negligible extent.
If Z is revoked, Y and X is not revoked, but can't be trusted anymore so we can say it is revoked. As Z didn't signed X it can't revoke it directly in its CRL. By the way, nobody will be looking to Z CRL if X is revoked there but to X CRL. WHat you can theoretically do is to merge both X and Z CRLs, but the problem is with signing. Who will sign such CRL? Z or X? Or both? As it is not standard I would say this can't work. If you take a look to [wiki](https://en.wikipedia.org/wiki/Certificate_revocation_list) you'll find almost everything about CRLs there.
160,802
We have given a certificate chain: `X <-- Y <-- Z` (`X` is an end-entity cert, `Z` is root CA). Certificates are extended with CRL distribution points info. Because of the fact `Y -> X` `Y` is a CA for `X`. Therefore, `Y` can revoke `X` 's certificate by placing it on `Y`'s CRL. `Z` is CA for `Y`. `Z` can revoke certificate `Y`. But, the question is: can `Z` revoke certificate `X`?
2017/05/30
[ "https://security.stackexchange.com/questions/160802", "https://security.stackexchange.com", "https://security.stackexchange.com/users/149645/" ]
*[The two existing answers are good, but since they have no upvotes, I'll try to provide a canonical answer]* --- In general, **No**. I mean, `Z` can revoke `Y`, which automatically revokes `X` and all other certs issued by `Y`, but with commonly used PKIs and TLS engines `Z` has no mechanism to revoke `X` directly. --- Generally speaking, each CA only tracks the certificates that it issues; in a typical PKI `Z` will not know about `X`'s existence, and most cert verification engines will check for `X`'s serial number on `Y`s CRL, and `Y`'s serial number on `Z`'s CRL. You could imagine a system where `Y` reports all the certs it issues to its parent CA so that `Z` does know about `X` and could include it on a CRL (though you'd have to worry about serial number collision and have some scheme to ensure that no two CAs in the hierarchy will issue the same serial number). Then you still need to worry about clients actually looking for `X`'s serial number on `Z`'s CRL, which is not a standard behaviour. As @Sas3 mentions in their answer, [RFC5280](https://www.rfc-editor.org/rfc/rfc5280#page-55) does provide a mechanism for doing this, called "indirect CRLs" (though it seems like it's more intended for `Y` to copy `Z`'d revocations, or for a CA to delegate CRL management to an offboard "CRL signing server" rather than this scenario of having roots be able to bypass their subordinates). That said: 1. To claim that this is secure, you'd need confidence that all cert validation engines consuming your certs support indirect CRLs. 2. I'm a developer on the PKI software that powers the Entrust publcily-trusted CA, as well as many other CAs, and despite our name being on the author list of that RFC, as far as I know, even our software doesn't support indirect CRLs. 3. [RFC 5280](https://www.rfc-editor.org/rfc/rfc5280) has been updated by [RFC 6818](https://www.rfc-editor.org/rfc/rfc6818), which makes no mention of "indirect CRL", so I would argue that while this mechanism is technically standardized, nobody really cares about it. --- Long-story short: in a closed environment where you have full control of all CAs and all cert-consuming clients, you could probably devise a scheme whereby `Z` can revoke `X`, but in a public PKI or any environment using off-the-shelf TLS engines, this is certainly not widely supported.
If Z is revoked, Y and X is not revoked, but can't be trusted anymore so we can say it is revoked. As Z didn't signed X it can't revoke it directly in its CRL. By the way, nobody will be looking to Z CRL if X is revoked there but to X CRL. WHat you can theoretically do is to merge both X and Z CRLs, but the problem is with signing. Who will sign such CRL? Z or X? Or both? As it is not standard I would say this can't work. If you take a look to [wiki](https://en.wikipedia.org/wiki/Certificate_revocation_list) you'll find almost everything about CRLs there.
117,104
As it turns out, conifers are not the only trees to grow in boreal forests, or *taiga*. At the southernmost ends, the evergreens are mixed with such deciduous trees as: * Birch * Alder * Willow * Poplar * Maple * Elm * Lime * Rowan Now in an alternate Earth, the trees listed above either never existed or went extinct in a long-ago extinction even, and conifers grow only on mountainous highlands, which leave the angiosperms to dominate the lowlands (like the bulk of Siberia, for example.) In this scenario, what other kinds of broadleaf trees would thrive in such subarctic conditions as Russia, Alaska and Scandinavia?
2018/07/03
[ "https://worldbuilding.stackexchange.com/questions/117104", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/10274/" ]
I do not live in an artic zone, but I live in an area where it reaches 30f degrees in winter. I also keep a garden, so a little research with some second hand knowledge, this is a list of trees I would think could live on the edge of a tundra forest where maple, willows, and other trees like them grow. * [Malus](https://en.wikipedia.org/wiki/Malus): This type include the apple tree, which survives some pretty harsh winters, at least where I live. Mine survived going down to 20f during one winter. During the winter they go dormant and then come back to life in a sort of way the following spring. As long as there is a sufficient period for the trees to bloom and apples to grow I would think it could survive. * [Rhododendrons](https://en.wikipedia.org/wiki/Rhododendron): These things are impossible to kill sometimes. We had to dig up the one in our backyard fully out of the ground since it grew back from a stump pretty much. They survive our winters and thrive. They would probably move in and fill the niche the other species that died out left open in their environment. * [Cornus](https://en.wikipedia.org/wiki/Cornus): The Cornus, aka flowering dogwood, would be another good candidate. While there are no growing in the area I live in there are lots on the east coast of the USA where they thrive despite the temperatures it can reach during the winter. None of these are concrete things. These are just some of the trees and extremely large bushes that I would think would slide into those niches left open by the dead trees. Sources: <http://www.theplantlist.org/> <https://www.gardenguides.com/>
[**Aspen.**](https://en.wikipedia.org/wiki/Aspen) [![mixed aspen conifer forest](https://i.stack.imgur.com/yCnll.jpg)](https://i.stack.imgur.com/yCnll.jpg) In our world, aspen trees compete with conifers in the subartic boreal forest. The photo above is in the Yukon. You can easily distinguish the yellow-leaved stands of aspen in among the pines. With no conifers, aspens would have the north to themselves and they would be fine with that. Aspens grow as immensely long lived, clonal masses and absent competition, huge clones would spread to be the forests of the north. --- As per comment - no trees on the list and no trees later decided to be related to trees on the list. Then how about [rhododendron](https://en.wikipedia.org/wiki/Rhododendron#Early_history)? [![rhododendron siberia](https://i.stack.imgur.com/dpctA.jpg)](https://i.stack.imgur.com/dpctA.jpg) <https://www.dreamstime.com/stock-photo-ledum-siberia-pink-spring-flowering-shrub-rhododendron-ledebou-siberian-sunny-day-image53953612> This one is from Siberia. A google search with rhododendron and Siberia or Russia will turn up more substantial looking and very beautiful trees on the image for sale sites like alamy. None are as awesome as this Canadian rhododendron - a proper tree to be sure. [![rhododendron tree](https://i.stack.imgur.com/AdQkW.jpg)](https://i.stack.imgur.com/AdQkW.jpg) <https://www.boredpanda.com/rhododendron-tree-ladysmith-british-columbia-canada/> Could you get a forest of rhododendron? Yes! In Ireland it is an invasive species and forms dense forests, outcompeting native plants. [![rhododendron forest](https://i.stack.imgur.com/wVROP.jpg)](https://i.stack.imgur.com/wVROP.jpg) [![rhododendron forest](https://i.stack.imgur.com/JCfKI.jpg)](https://i.stack.imgur.com/JCfKI.jpg) <http://archive.constantcontact.com/fs176/1102209996678/archive/1117755271519.html>
829
I've edited the title to better reflect what I was wanting from this post. The initial title was written in haste, and (admittedly) in frustration as this isn't the first time this has occurred. (See edit history if it is value to you.) Moreover, the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish in consideration of these three facts: 1. The mod who put the question on hold gave only the reason that homework/education questions were off-topic ([the comments were moved to chat](https://chat.stackexchange.com/rooms/87061/discussion-on-question-by-ludwigthestud-nat-translation-table-port-number)) 2. The [post revision claims the question is closed](https://networkengineering.stackexchange.com/posts/55444/revisions) -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? 3. The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. **Which leave us with:** The question is currently "on-hold" for the supposed reason of being "too broad". The implication of it being too broad stems from the Mod believing the output in the question comes from a specific device, and if that is the case then I agree, the question is unanswerable w/o knowing which device. *However*, the output in the question could very well have been typed out by the OP, or by wherever the OP acquired the original question he was asking for clarity on. In which case the question was asking about *concepts* and *network theory*, which is entirely answerable and well within the scope of on-topic of this forum. So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, **we (as a community) need to err on the side of not being dismissive and providing answers when we can**. . And if you're curious about how it turned out, the *OP confirmed the question was asking about theory and not a specific device*. Moreover, when I attempted to communicate to RonMaupin (the mod that put the question on hold) that there is another way of interpreting the question, he [doubled down, stayed entrenched, and then called to question my ability to read](https://chat.stackexchange.com/rooms/87065/discussion-on-answer-by-ron-maupin-seriously-can-we-stop-closing-questions-just) (nice). --- **Where do we go from here?** Here are possible outcomes 1. Someone, somehow, convinces me that the output in the original thread *must absolutely* come from a device and would have been *impossible* for someone to type out. Although being honest, that is unlikely, given the OP confirmed it. 2. Someone can clean up the mess, admit our (the community's) misstep, re-open the question, maybe throw an apology to the OP for "on-holding" the question too hastily. 3. Something else, I'm open to a third (or fourth or fifth) possible outcome.
2018/12/13
[ "https://networkengineering.meta.stackexchange.com/questions/829", "https://networkengineering.meta.stackexchange.com", "https://networkengineering.meta.stackexchange.com/users/3675/" ]
* We edit the question to be obviously a generic protocol-theory question * We edit out the suggestion about "disingenuous" * We reopen the question * Someone with a view answers [struck-through text shows these things were done.] If this meta-post gets suitable comments or votes I'll happily do the edits.
Update based on [SE Meta](https://meta.stackexchange.com/): =========================================================== From the answer to the SE Meta site question [How soon should I “vote to close”?](https://meta.stackexchange.com/questions/98022/how-soon-should-i-vote-to-close): > > **Always vote to close immediately.** I explain the rationale behind this approach in further detail > [here](https://meta.stackexchange.com/questions/92636/why-are-questions-closed-immediately/92638#92638). > > > In summary: Yes, it increases the chances that the question will be > closed, but that's actually a good thing for a couple of reasons: > > > 1. It increases the likelihood that the user will take notice and actually fix their question in response to your suggestions. Unless > you're dealing with a particularly conscientious user (and this is > rare, because their questions are unlikely to be candidates to close > in the first place), it's more likely that they'll ignore your > comments as long as they can continue to get answers. > 2. It prevents a flood of immediate answers (arguably a symptom of the well-known ["Fastest Gun in the West" > problem](https://meta.stackexchange.com/questions/9731/fastest-gun-in-the-west-problem)) > that are speculative at best and/or will be completely invalidated > after the question is modified to turn it into a real question. Those > answers don't do anyone any good, and they're best avoided if at all > possible. > > > And no, it does **not** force the author to re-post his question, not > immediately or ever. Even questions that have been closed can be > edited by the owner. So once the question is closed, that would be an > appropriate time to sit up and take notice of the helpful comments > that have been provided by the close voters. And once the question has > been sufficiently improved, it can be re-opened, either with the vote > of 5 different users (they can be the same ones who voted to close) or > the binding vote of a moderator. > > > If you see a user posting a second question because his first one was > closed, flag and/or close the second one as a duplicate of the first > and ask him to go back and edit the original question instead. > > > --- **Original:** If you look, you will notice that the question was ***not*** closed because it is a homework or home networking question. The question was put On-Hold as too broad because the question cannot be answered without knowing the device model. Different devices choose the port to be used differently, That is implementation-specific; there is nothing in the standard that dictates how to do that. In any case, your premise, the the question in title of your question, "*Seriously, can we stop closing questions just because they include the word “homework” or “home network”?*," is incorrect for the original question to which you refer. That is clearly not the case. --- **Edit:** The question is quite clear that the OP's question is about the table in the embedded answer. Notice the parts I highlighted: > > ***The answer is:*** > > > > ``` > NAT Translation Table > WAN Side LAN Side > 24.34.112.235, 4000 192.168.1.1, 3345 > 24.34.112.235, 4001 192.168.1.1, 3346 > 24.34.112.235, 4002 192.168.1.2, 3445 > 24.34.112.235, 4003 192.168.1.2, 3446 > 24.34.112.235, 4004 192.168.1.3, 3545 > 24.34.112.235, 4005 192.168.1.3, 3546 > > ``` > > With that given, ***my question is regarding the answer***. I understand > the IP addresses. However, are the port numbers randomly chosen or > does the order of 3345, 3346, 3445, etc. have a sort of logic given > behind them? > > > That question is unanswerable, as asked, because we do not know the provenance of the table. --- **Edit for the new question:** ------------------------------ > > Can we err more on the side of leaving questions open when multiple > interpretations exist and some might be off topic/too broad? > > > The problem with questions that are too broad is that I still find open questions from years ago where more information or a narrowing of the scope was requested but never supplied. Some of these questions have no answers, and some have answers with none accepted The additional information or narrowing of the scope was requested, not supplied by the OP, and then everyone lost track of the question, and the OP never got his answer. The proven SE method is to request more information or to narrow the scope, then place the question on hold. This has proven effective to spur the OP to provide the additional information or narrow the scope of the question. As far as off-topic questions, leaving them open encourages answers to off-topic questions which are not wanted on NE. Getting an answer to an off-topic question encourages the OP to ask more off-topic questions. This has happened several times, even when the first off-topic question was closed after being answered. Also, by closing the question with a comment on a better place to ask can get the OP an answer faster than letting an unanswered, off-topic question languish on NE. Even if you point the OP to a better site and do not close the question, then other SE sites consider that cross-posting and often close the question on the correct site because it is cross-posted. In either case, the text box that is placed on the question when it is put on hold explains to the OP what to do to try to get the question reopened. Most off-topic questions are really not salvageable, but some do get rehabilitated and reopened. A lot of questions that are too broad get modified and reopened, but there are some people that simply do not bother. In general, someone asking a question has no interest in modifying the question unless prodded to do so by something like placing it on hold. I would argue that placing a question on hold is not being dismissive, and the SE way is to keep a site on focus of what the community has decided. Placing a question needing work on hold serves the purpose of keeping the site within the SE ideals of a specific question that gets specific answers within the guidelines of the site's purpose. This is very different from other Q/A sites on the Internet, and it is what SE wants for its sites to be distinguished for its quality of questions and answers. One thing that I will point out is that NE is generally more friendly and helpful (especially when it comes to providing guidance for questions that are put on hold) than most of the other SE technology sites where often the best you can hope for is to simply have the question put on hold with no other explanation than is in the box, then completely ignored from then on. The worst case is that you get mercilessly chastised for even considering to ask the question on the site. I have spent a lot of time with people asking questions, going back and forth to rehabilitate a question, then reopening it. That is not something I have observed on the other technology SE sites. --- There is a good explanation of On-Hold or Closed on the [*What does it mean if a question is "closed" or "on hold"?*](https://networkengineering.stackexchange.com/help/closed-questions) page: > > What does it mean if a question is "closed" or "on hold"? > > > Why are some questions marked "on hold"? > > > Questions that need additional work or that [are not a good fit for > this site](https://networkengineering.stackexchange.com/helpcenter/on-topic) may be put on hold by experienced community members. > While questions are on hold, they cannot be answered, but can be > edited to make them eligible for reopening. > > > Questions that are edited within five days of being put on hold are > automatically added to a reopening queue for community review. > Questions that are not reopened within five days will change from `[on hold]` to `[closed]`. > > > Each closed or on-hold question provides a reason that helps the > original poster (or other community members) know what they'd need to > do in order to get the question reopened. > > > --- There is also the [*What if I disagree with the closure of a question? How can I reopen it?*](https://networkengineering.stackexchange.com/help/reopen-questions) page (the highlighted text is highlighted in the original text on the page): > > Stack Exchange is collaboratively built, maintained, and moderated by > the community. If you see a question and you disagree with the stated > [reason of its closure](https://networkengineering.stackexchange.com/helpcenter/closed-questions), you should **first try to edit the > question** to improve it as much as possible. Read the close notice > and any comments carefully to address concerns raised there. Closed > questions that receive edits within the first 5 days of closure are > automatically put into a review queue to be considered for reopening. > > >
829
I've edited the title to better reflect what I was wanting from this post. The initial title was written in haste, and (admittedly) in frustration as this isn't the first time this has occurred. (See edit history if it is value to you.) Moreover, the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish in consideration of these three facts: 1. The mod who put the question on hold gave only the reason that homework/education questions were off-topic ([the comments were moved to chat](https://chat.stackexchange.com/rooms/87061/discussion-on-question-by-ludwigthestud-nat-translation-table-port-number)) 2. The [post revision claims the question is closed](https://networkengineering.stackexchange.com/posts/55444/revisions) -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? 3. The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. **Which leave us with:** The question is currently "on-hold" for the supposed reason of being "too broad". The implication of it being too broad stems from the Mod believing the output in the question comes from a specific device, and if that is the case then I agree, the question is unanswerable w/o knowing which device. *However*, the output in the question could very well have been typed out by the OP, or by wherever the OP acquired the original question he was asking for clarity on. In which case the question was asking about *concepts* and *network theory*, which is entirely answerable and well within the scope of on-topic of this forum. So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, **we (as a community) need to err on the side of not being dismissive and providing answers when we can**. . And if you're curious about how it turned out, the *OP confirmed the question was asking about theory and not a specific device*. Moreover, when I attempted to communicate to RonMaupin (the mod that put the question on hold) that there is another way of interpreting the question, he [doubled down, stayed entrenched, and then called to question my ability to read](https://chat.stackexchange.com/rooms/87065/discussion-on-answer-by-ron-maupin-seriously-can-we-stop-closing-questions-just) (nice). --- **Where do we go from here?** Here are possible outcomes 1. Someone, somehow, convinces me that the output in the original thread *must absolutely* come from a device and would have been *impossible* for someone to type out. Although being honest, that is unlikely, given the OP confirmed it. 2. Someone can clean up the mess, admit our (the community's) misstep, re-open the question, maybe throw an apology to the OP for "on-holding" the question too hastily. 3. Something else, I'm open to a third (or fourth or fifth) possible outcome.
2018/12/13
[ "https://networkengineering.meta.stackexchange.com/questions/829", "https://networkengineering.meta.stackexchange.com", "https://networkengineering.meta.stackexchange.com/users/3675/" ]
> > the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish > > > I would tend to agree. In part because they are both components of the same process. Will circle back to this in a bit. > > The mod who put the question on hold gave only the reason that homework/education questions were off-topic > > > Comments do not give the reason a question is put on hold/closed. The system provides the reason users voted to close and mention it can be edited. This is true of all SE sites. Comments made as part of the process are up to the individual users, be they normal user or moderator. They may give additional reasons (if there were more than one), guidance on how to fix the question, tips on how the process works, or anything else. But these are entirely optional and up to the user. Many of the larger sites simply put questions on hold with no further explanation. I personally think the additional comments are typically helpful and that we are better than many SE sites in providing additional information in comments. Of course, with a long time user like yourself questioning this process, it may be that my opinion is flawed, so perhaps I need to re-evaluate this process. > > The post revision claims the question is closed -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? > > > Six of one, half a dozen of the other. Technically speaking the question is in the close process. Users still vote to close a question, not to put it on hold. So what is and where did this "on hold" component come from? Originally on all SE sites, the question went directly to "closed." Users felt this was too harsh and was contrary to the intention of fostering the OP to edit the question to make it better. So SE staff changed the process to add the "on hold" period to closed posts. Now, when voted to close, the question is initially put into the "on hold" status. The intent was to make it a bit more clear that users were encouraged to make the question better. If it remains unedited and/or isn't reopened, it will eventually move to the closed status (and possibly be deleted). But this is still part of the closed process. > > The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. > > > See above. If you feel this or other parts of the process is wrong, then please take it up with the SE staff on [meta.SE](https://meta.stackexchange.com/). Only they can change how these messages are displayed to the user. This is how many changes originate on the SE network, including the addition of the "on hold" status. > > So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, we (as a community) need to err on the side of not being dismissive and providing answers when we can. > > > This is at best a grey area. Leaving a questionable post open also has it's drawbacks. The system will automatically purge closed questions when they meet [certain criteria](https://meta.stackexchange.com/a/5222/244349). Two of those criteria are zero or negative score (no up votes) on the question and no positive or accepted answers to the question. The longer a question remains open and off-topic or inappropriate in some way, the more chance there will be of the question receiving an upvote or an answer with upvotes from someone. At that point, it is only through a manual deletion process that the question can be purged from a site. So bad questions can linger here as long as the site lasts. Also, remember that moderators have no option when voting but to cast a binding vote, and SE has not added this option despite [nearly eight years of this request's popularity](https://meta.stackexchange.com/q/41062/244349) (and been requested multiple times and closed pointing at that post). The SE stance has always been that if the mod believes a post should be closed enough to cast a vote, they should do so. While this may work fine in the bigger communities, in the smaller ones where there aren't enough close/reopen (or delete/undelete) users, I personally find the binding vote to be both a necessity and a weakness in the system. I (and many other moderators over the years) would prefer to have the option of both. Sorry for getting a bit off track, but keep in mind that SE sites are community moderated. This means that even if a question is closed (by users with the privilege or moderators), users with at least 3k reputation can cast reopen votes to reverse this action. Don't have the reputation to vote yet? You can still edit the question to bring it in line with the community standards. Editing a closed question will also automatically trigger a reopen vote, without anyone casting a reopen vote. We are certainly not adverse to reopening posts here, so if you feel the question was open to interpretation and you feel others misinterpreted the intent, please edit it to make the intent clear. Either the OP will object and roll back the change or they may confirm the change was in line with their request. If that process doesn't work as you hoped, you can always bring the issue here to meta for further discussion.
Update based on [SE Meta](https://meta.stackexchange.com/): =========================================================== From the answer to the SE Meta site question [How soon should I “vote to close”?](https://meta.stackexchange.com/questions/98022/how-soon-should-i-vote-to-close): > > **Always vote to close immediately.** I explain the rationale behind this approach in further detail > [here](https://meta.stackexchange.com/questions/92636/why-are-questions-closed-immediately/92638#92638). > > > In summary: Yes, it increases the chances that the question will be > closed, but that's actually a good thing for a couple of reasons: > > > 1. It increases the likelihood that the user will take notice and actually fix their question in response to your suggestions. Unless > you're dealing with a particularly conscientious user (and this is > rare, because their questions are unlikely to be candidates to close > in the first place), it's more likely that they'll ignore your > comments as long as they can continue to get answers. > 2. It prevents a flood of immediate answers (arguably a symptom of the well-known ["Fastest Gun in the West" > problem](https://meta.stackexchange.com/questions/9731/fastest-gun-in-the-west-problem)) > that are speculative at best and/or will be completely invalidated > after the question is modified to turn it into a real question. Those > answers don't do anyone any good, and they're best avoided if at all > possible. > > > And no, it does **not** force the author to re-post his question, not > immediately or ever. Even questions that have been closed can be > edited by the owner. So once the question is closed, that would be an > appropriate time to sit up and take notice of the helpful comments > that have been provided by the close voters. And once the question has > been sufficiently improved, it can be re-opened, either with the vote > of 5 different users (they can be the same ones who voted to close) or > the binding vote of a moderator. > > > If you see a user posting a second question because his first one was > closed, flag and/or close the second one as a duplicate of the first > and ask him to go back and edit the original question instead. > > > --- **Original:** If you look, you will notice that the question was ***not*** closed because it is a homework or home networking question. The question was put On-Hold as too broad because the question cannot be answered without knowing the device model. Different devices choose the port to be used differently, That is implementation-specific; there is nothing in the standard that dictates how to do that. In any case, your premise, the the question in title of your question, "*Seriously, can we stop closing questions just because they include the word “homework” or “home network”?*," is incorrect for the original question to which you refer. That is clearly not the case. --- **Edit:** The question is quite clear that the OP's question is about the table in the embedded answer. Notice the parts I highlighted: > > ***The answer is:*** > > > > ``` > NAT Translation Table > WAN Side LAN Side > 24.34.112.235, 4000 192.168.1.1, 3345 > 24.34.112.235, 4001 192.168.1.1, 3346 > 24.34.112.235, 4002 192.168.1.2, 3445 > 24.34.112.235, 4003 192.168.1.2, 3446 > 24.34.112.235, 4004 192.168.1.3, 3545 > 24.34.112.235, 4005 192.168.1.3, 3546 > > ``` > > With that given, ***my question is regarding the answer***. I understand > the IP addresses. However, are the port numbers randomly chosen or > does the order of 3345, 3346, 3445, etc. have a sort of logic given > behind them? > > > That question is unanswerable, as asked, because we do not know the provenance of the table. --- **Edit for the new question:** ------------------------------ > > Can we err more on the side of leaving questions open when multiple > interpretations exist and some might be off topic/too broad? > > > The problem with questions that are too broad is that I still find open questions from years ago where more information or a narrowing of the scope was requested but never supplied. Some of these questions have no answers, and some have answers with none accepted The additional information or narrowing of the scope was requested, not supplied by the OP, and then everyone lost track of the question, and the OP never got his answer. The proven SE method is to request more information or to narrow the scope, then place the question on hold. This has proven effective to spur the OP to provide the additional information or narrow the scope of the question. As far as off-topic questions, leaving them open encourages answers to off-topic questions which are not wanted on NE. Getting an answer to an off-topic question encourages the OP to ask more off-topic questions. This has happened several times, even when the first off-topic question was closed after being answered. Also, by closing the question with a comment on a better place to ask can get the OP an answer faster than letting an unanswered, off-topic question languish on NE. Even if you point the OP to a better site and do not close the question, then other SE sites consider that cross-posting and often close the question on the correct site because it is cross-posted. In either case, the text box that is placed on the question when it is put on hold explains to the OP what to do to try to get the question reopened. Most off-topic questions are really not salvageable, but some do get rehabilitated and reopened. A lot of questions that are too broad get modified and reopened, but there are some people that simply do not bother. In general, someone asking a question has no interest in modifying the question unless prodded to do so by something like placing it on hold. I would argue that placing a question on hold is not being dismissive, and the SE way is to keep a site on focus of what the community has decided. Placing a question needing work on hold serves the purpose of keeping the site within the SE ideals of a specific question that gets specific answers within the guidelines of the site's purpose. This is very different from other Q/A sites on the Internet, and it is what SE wants for its sites to be distinguished for its quality of questions and answers. One thing that I will point out is that NE is generally more friendly and helpful (especially when it comes to providing guidance for questions that are put on hold) than most of the other SE technology sites where often the best you can hope for is to simply have the question put on hold with no other explanation than is in the box, then completely ignored from then on. The worst case is that you get mercilessly chastised for even considering to ask the question on the site. I have spent a lot of time with people asking questions, going back and forth to rehabilitate a question, then reopening it. That is not something I have observed on the other technology SE sites. --- There is a good explanation of On-Hold or Closed on the [*What does it mean if a question is "closed" or "on hold"?*](https://networkengineering.stackexchange.com/help/closed-questions) page: > > What does it mean if a question is "closed" or "on hold"? > > > Why are some questions marked "on hold"? > > > Questions that need additional work or that [are not a good fit for > this site](https://networkengineering.stackexchange.com/helpcenter/on-topic) may be put on hold by experienced community members. > While questions are on hold, they cannot be answered, but can be > edited to make them eligible for reopening. > > > Questions that are edited within five days of being put on hold are > automatically added to a reopening queue for community review. > Questions that are not reopened within five days will change from `[on hold]` to `[closed]`. > > > Each closed or on-hold question provides a reason that helps the > original poster (or other community members) know what they'd need to > do in order to get the question reopened. > > > --- There is also the [*What if I disagree with the closure of a question? How can I reopen it?*](https://networkengineering.stackexchange.com/help/reopen-questions) page (the highlighted text is highlighted in the original text on the page): > > Stack Exchange is collaboratively built, maintained, and moderated by > the community. If you see a question and you disagree with the stated > [reason of its closure](https://networkengineering.stackexchange.com/helpcenter/closed-questions), you should **first try to edit the > question** to improve it as much as possible. Read the close notice > and any comments carefully to address concerns raised there. Closed > questions that receive edits within the first 5 days of closure are > automatically put into a review queue to be considered for reopening. > > >
829
I've edited the title to better reflect what I was wanting from this post. The initial title was written in haste, and (admittedly) in frustration as this isn't the first time this has occurred. (See edit history if it is value to you.) Moreover, the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish in consideration of these three facts: 1. The mod who put the question on hold gave only the reason that homework/education questions were off-topic ([the comments were moved to chat](https://chat.stackexchange.com/rooms/87061/discussion-on-question-by-ludwigthestud-nat-translation-table-port-number)) 2. The [post revision claims the question is closed](https://networkengineering.stackexchange.com/posts/55444/revisions) -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? 3. The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. **Which leave us with:** The question is currently "on-hold" for the supposed reason of being "too broad". The implication of it being too broad stems from the Mod believing the output in the question comes from a specific device, and if that is the case then I agree, the question is unanswerable w/o knowing which device. *However*, the output in the question could very well have been typed out by the OP, or by wherever the OP acquired the original question he was asking for clarity on. In which case the question was asking about *concepts* and *network theory*, which is entirely answerable and well within the scope of on-topic of this forum. So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, **we (as a community) need to err on the side of not being dismissive and providing answers when we can**. . And if you're curious about how it turned out, the *OP confirmed the question was asking about theory and not a specific device*. Moreover, when I attempted to communicate to RonMaupin (the mod that put the question on hold) that there is another way of interpreting the question, he [doubled down, stayed entrenched, and then called to question my ability to read](https://chat.stackexchange.com/rooms/87065/discussion-on-answer-by-ron-maupin-seriously-can-we-stop-closing-questions-just) (nice). --- **Where do we go from here?** Here are possible outcomes 1. Someone, somehow, convinces me that the output in the original thread *must absolutely* come from a device and would have been *impossible* for someone to type out. Although being honest, that is unlikely, given the OP confirmed it. 2. Someone can clean up the mess, admit our (the community's) misstep, re-open the question, maybe throw an apology to the OP for "on-holding" the question too hastily. 3. Something else, I'm open to a third (or fourth or fifth) possible outcome.
2018/12/13
[ "https://networkengineering.meta.stackexchange.com/questions/829", "https://networkengineering.meta.stackexchange.com", "https://networkengineering.meta.stackexchange.com/users/3675/" ]
* We edit the question to be obviously a generic protocol-theory question * We edit out the suggestion about "disingenuous" * We reopen the question * Someone with a view answers [struck-through text shows these things were done.] If this meta-post gets suitable comments or votes I'll happily do the edits.
For those of you saying it was impossible to answer this question without more information... Here is the answer I was in the middle of typing out when the question was closed (minus a few supporting links). How about we put it to the OP (@Ludwigthestud) ... If this answer would have sufficed, great, then we know the question was answerable. If this answer would *not* have sufficed, then great, I'll retract my position and happily admit I was wrong. --- For the LAN side: There isn't going to be a clean answer, as every implementation is free to chose their Source ports as they desire. A lot of them (most of them) do so randomly, and in so far as how you should plan the design of traffic flow, you should always assume the source port is random. For the WAN side: It's the same. in a Dynamic PAT, the source port is chosen randomly by the Router. Of course, each vendor is free to implement this in any way they like, the main requirement is the translation device cannot re-use a source-port that is already in use. A lot of Cisco router's will choose Source Ports sequentially. A lot of F5 devices choose Source ports randomly. Every vendor is free to do it their own way. As for "controlling" the Source Ports in the translation, remember, as soon as you configure a Dynamic translation, you are relinquishing the control of the source port to the translation device. The only way to explicitly determine the source port is to configure a *Static* PAT.
829
I've edited the title to better reflect what I was wanting from this post. The initial title was written in haste, and (admittedly) in frustration as this isn't the first time this has occurred. (See edit history if it is value to you.) Moreover, the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish in consideration of these three facts: 1. The mod who put the question on hold gave only the reason that homework/education questions were off-topic ([the comments were moved to chat](https://chat.stackexchange.com/rooms/87061/discussion-on-question-by-ludwigthestud-nat-translation-table-port-number)) 2. The [post revision claims the question is closed](https://networkengineering.stackexchange.com/posts/55444/revisions) -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? 3. The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. **Which leave us with:** The question is currently "on-hold" for the supposed reason of being "too broad". The implication of it being too broad stems from the Mod believing the output in the question comes from a specific device, and if that is the case then I agree, the question is unanswerable w/o knowing which device. *However*, the output in the question could very well have been typed out by the OP, or by wherever the OP acquired the original question he was asking for clarity on. In which case the question was asking about *concepts* and *network theory*, which is entirely answerable and well within the scope of on-topic of this forum. So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, **we (as a community) need to err on the side of not being dismissive and providing answers when we can**. . And if you're curious about how it turned out, the *OP confirmed the question was asking about theory and not a specific device*. Moreover, when I attempted to communicate to RonMaupin (the mod that put the question on hold) that there is another way of interpreting the question, he [doubled down, stayed entrenched, and then called to question my ability to read](https://chat.stackexchange.com/rooms/87065/discussion-on-answer-by-ron-maupin-seriously-can-we-stop-closing-questions-just) (nice). --- **Where do we go from here?** Here are possible outcomes 1. Someone, somehow, convinces me that the output in the original thread *must absolutely* come from a device and would have been *impossible* for someone to type out. Although being honest, that is unlikely, given the OP confirmed it. 2. Someone can clean up the mess, admit our (the community's) misstep, re-open the question, maybe throw an apology to the OP for "on-holding" the question too hastily. 3. Something else, I'm open to a third (or fourth or fifth) possible outcome.
2018/12/13
[ "https://networkengineering.meta.stackexchange.com/questions/829", "https://networkengineering.meta.stackexchange.com", "https://networkengineering.meta.stackexchange.com/users/3675/" ]
> > the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish > > > I would tend to agree. In part because they are both components of the same process. Will circle back to this in a bit. > > The mod who put the question on hold gave only the reason that homework/education questions were off-topic > > > Comments do not give the reason a question is put on hold/closed. The system provides the reason users voted to close and mention it can be edited. This is true of all SE sites. Comments made as part of the process are up to the individual users, be they normal user or moderator. They may give additional reasons (if there were more than one), guidance on how to fix the question, tips on how the process works, or anything else. But these are entirely optional and up to the user. Many of the larger sites simply put questions on hold with no further explanation. I personally think the additional comments are typically helpful and that we are better than many SE sites in providing additional information in comments. Of course, with a long time user like yourself questioning this process, it may be that my opinion is flawed, so perhaps I need to re-evaluate this process. > > The post revision claims the question is closed -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? > > > Six of one, half a dozen of the other. Technically speaking the question is in the close process. Users still vote to close a question, not to put it on hold. So what is and where did this "on hold" component come from? Originally on all SE sites, the question went directly to "closed." Users felt this was too harsh and was contrary to the intention of fostering the OP to edit the question to make it better. So SE staff changed the process to add the "on hold" period to closed posts. Now, when voted to close, the question is initially put into the "on hold" status. The intent was to make it a bit more clear that users were encouraged to make the question better. If it remains unedited and/or isn't reopened, it will eventually move to the closed status (and possibly be deleted). But this is still part of the closed process. > > The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. > > > See above. If you feel this or other parts of the process is wrong, then please take it up with the SE staff on [meta.SE](https://meta.stackexchange.com/). Only they can change how these messages are displayed to the user. This is how many changes originate on the SE network, including the addition of the "on hold" status. > > So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, we (as a community) need to err on the side of not being dismissive and providing answers when we can. > > > This is at best a grey area. Leaving a questionable post open also has it's drawbacks. The system will automatically purge closed questions when they meet [certain criteria](https://meta.stackexchange.com/a/5222/244349). Two of those criteria are zero or negative score (no up votes) on the question and no positive or accepted answers to the question. The longer a question remains open and off-topic or inappropriate in some way, the more chance there will be of the question receiving an upvote or an answer with upvotes from someone. At that point, it is only through a manual deletion process that the question can be purged from a site. So bad questions can linger here as long as the site lasts. Also, remember that moderators have no option when voting but to cast a binding vote, and SE has not added this option despite [nearly eight years of this request's popularity](https://meta.stackexchange.com/q/41062/244349) (and been requested multiple times and closed pointing at that post). The SE stance has always been that if the mod believes a post should be closed enough to cast a vote, they should do so. While this may work fine in the bigger communities, in the smaller ones where there aren't enough close/reopen (or delete/undelete) users, I personally find the binding vote to be both a necessity and a weakness in the system. I (and many other moderators over the years) would prefer to have the option of both. Sorry for getting a bit off track, but keep in mind that SE sites are community moderated. This means that even if a question is closed (by users with the privilege or moderators), users with at least 3k reputation can cast reopen votes to reverse this action. Don't have the reputation to vote yet? You can still edit the question to bring it in line with the community standards. Editing a closed question will also automatically trigger a reopen vote, without anyone casting a reopen vote. We are certainly not adverse to reopening posts here, so if you feel the question was open to interpretation and you feel others misinterpreted the intent, please edit it to make the intent clear. Either the OP will object and roll back the change or they may confirm the change was in line with their request. If that process doesn't work as you hoped, you can always bring the issue here to meta for further discussion.
For those of you saying it was impossible to answer this question without more information... Here is the answer I was in the middle of typing out when the question was closed (minus a few supporting links). How about we put it to the OP (@Ludwigthestud) ... If this answer would have sufficed, great, then we know the question was answerable. If this answer would *not* have sufficed, then great, I'll retract my position and happily admit I was wrong. --- For the LAN side: There isn't going to be a clean answer, as every implementation is free to chose their Source ports as they desire. A lot of them (most of them) do so randomly, and in so far as how you should plan the design of traffic flow, you should always assume the source port is random. For the WAN side: It's the same. in a Dynamic PAT, the source port is chosen randomly by the Router. Of course, each vendor is free to implement this in any way they like, the main requirement is the translation device cannot re-use a source-port that is already in use. A lot of Cisco router's will choose Source Ports sequentially. A lot of F5 devices choose Source ports randomly. Every vendor is free to do it their own way. As for "controlling" the Source Ports in the translation, remember, as soon as you configure a Dynamic translation, you are relinquishing the control of the source port to the translation device. The only way to explicitly determine the source port is to configure a *Static* PAT.
829
I've edited the title to better reflect what I was wanting from this post. The initial title was written in haste, and (admittedly) in frustration as this isn't the first time this has occurred. (See edit history if it is value to you.) Moreover, the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish in consideration of these three facts: 1. The mod who put the question on hold gave only the reason that homework/education questions were off-topic ([the comments were moved to chat](https://chat.stackexchange.com/rooms/87061/discussion-on-question-by-ludwigthestud-nat-translation-table-port-number)) 2. The [post revision claims the question is closed](https://networkengineering.stackexchange.com/posts/55444/revisions) -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? 3. The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. **Which leave us with:** The question is currently "on-hold" for the supposed reason of being "too broad". The implication of it being too broad stems from the Mod believing the output in the question comes from a specific device, and if that is the case then I agree, the question is unanswerable w/o knowing which device. *However*, the output in the question could very well have been typed out by the OP, or by wherever the OP acquired the original question he was asking for clarity on. In which case the question was asking about *concepts* and *network theory*, which is entirely answerable and well within the scope of on-topic of this forum. So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, **we (as a community) need to err on the side of not being dismissive and providing answers when we can**. . And if you're curious about how it turned out, the *OP confirmed the question was asking about theory and not a specific device*. Moreover, when I attempted to communicate to RonMaupin (the mod that put the question on hold) that there is another way of interpreting the question, he [doubled down, stayed entrenched, and then called to question my ability to read](https://chat.stackexchange.com/rooms/87065/discussion-on-answer-by-ron-maupin-seriously-can-we-stop-closing-questions-just) (nice). --- **Where do we go from here?** Here are possible outcomes 1. Someone, somehow, convinces me that the output in the original thread *must absolutely* come from a device and would have been *impossible* for someone to type out. Although being honest, that is unlikely, given the OP confirmed it. 2. Someone can clean up the mess, admit our (the community's) misstep, re-open the question, maybe throw an apology to the OP for "on-holding" the question too hastily. 3. Something else, I'm open to a third (or fourth or fifth) possible outcome.
2018/12/13
[ "https://networkengineering.meta.stackexchange.com/questions/829", "https://networkengineering.meta.stackexchange.com", "https://networkengineering.meta.stackexchange.com/users/3675/" ]
* We edit the question to be obviously a generic protocol-theory question * We edit out the suggestion about "disingenuous" * We reopen the question * Someone with a view answers [struck-through text shows these things were done.] If this meta-post gets suitable comments or votes I'll happily do the edits.
> > the thread in question was put "on-hold" and not actually "closed". However, I do want to point out that the difference between the two is difficult to distinguish > > > I would tend to agree. In part because they are both components of the same process. Will circle back to this in a bit. > > The mod who put the question on hold gave only the reason that homework/education questions were off-topic > > > Comments do not give the reason a question is put on hold/closed. The system provides the reason users voted to close and mention it can be edited. This is true of all SE sites. Comments made as part of the process are up to the individual users, be they normal user or moderator. They may give additional reasons (if there were more than one), guidance on how to fix the question, tips on how the process works, or anything else. But these are entirely optional and up to the user. Many of the larger sites simply put questions on hold with no further explanation. I personally think the additional comments are typically helpful and that we are better than many SE sites in providing additional information in comments. Of course, with a long time user like yourself questioning this process, it may be that my opinion is flawed, so perhaps I need to re-evaluate this process. > > The post revision claims the question is closed -- preferably the revision system doesn't distinguish between "on hold" and "closed"? Maybe it's a bug? > > > Six of one, half a dozen of the other. Technically speaking the question is in the close process. Users still vote to close a question, not to put it on hold. So what is and where did this "on hold" component come from? Originally on all SE sites, the question went directly to "closed." Users felt this was too harsh and was contrary to the intention of fostering the OP to edit the question to make it better. So SE staff changed the process to add the "on hold" period to closed posts. Now, when voted to close, the question is initially put into the "on hold" status. The intent was to make it a bit more clear that users were encouraged to make the question better. If it remains unedited and/or isn't reopened, it will eventually move to the closed status (and possibly be deleted). But this is still part of the closed process. > > The notification that pops ups when you are attempting to answer a question that was put on hold indicates the question is closed. > > > See above. If you feel this or other parts of the process is wrong, then please take it up with the SE staff on [meta.SE](https://meta.stackexchange.com/). Only they can change how these messages are displayed to the user. This is how many changes originate on the SE network, including the addition of the "on hold" status. > > So there are two ways to interpret the question, one that leads to the question being justifiably closed as too broad, and the other that leads to providing a useful answer for an earnest question. In such cases, we (as a community) need to err on the side of not being dismissive and providing answers when we can. > > > This is at best a grey area. Leaving a questionable post open also has it's drawbacks. The system will automatically purge closed questions when they meet [certain criteria](https://meta.stackexchange.com/a/5222/244349). Two of those criteria are zero or negative score (no up votes) on the question and no positive or accepted answers to the question. The longer a question remains open and off-topic or inappropriate in some way, the more chance there will be of the question receiving an upvote or an answer with upvotes from someone. At that point, it is only through a manual deletion process that the question can be purged from a site. So bad questions can linger here as long as the site lasts. Also, remember that moderators have no option when voting but to cast a binding vote, and SE has not added this option despite [nearly eight years of this request's popularity](https://meta.stackexchange.com/q/41062/244349) (and been requested multiple times and closed pointing at that post). The SE stance has always been that if the mod believes a post should be closed enough to cast a vote, they should do so. While this may work fine in the bigger communities, in the smaller ones where there aren't enough close/reopen (or delete/undelete) users, I personally find the binding vote to be both a necessity and a weakness in the system. I (and many other moderators over the years) would prefer to have the option of both. Sorry for getting a bit off track, but keep in mind that SE sites are community moderated. This means that even if a question is closed (by users with the privilege or moderators), users with at least 3k reputation can cast reopen votes to reverse this action. Don't have the reputation to vote yet? You can still edit the question to bring it in line with the community standards. Editing a closed question will also automatically trigger a reopen vote, without anyone casting a reopen vote. We are certainly not adverse to reopening posts here, so if you feel the question was open to interpretation and you feel others misinterpreted the intent, please edit it to make the intent clear. Either the OP will object and roll back the change or they may confirm the change was in line with their request. If that process doesn't work as you hoped, you can always bring the issue here to meta for further discussion.
20,254
I need a utility that can be called from an automation script to convert a CSS-styled HTML document to PDF. The twist is that I want to add page numbers for all the sections in the table of contents (and a page number in the footer of each page). A colleague found a utility called [Prince](http://www.princexml.com/purchase/) which does this, but it's pretty expensive--$3800 for a server license, or $495 per user, per machine. Is there any FOSS alternative, or even some other commercially-available alternative which is less expensive; say, closer to the range of $100 per user or perhaps even $500 for a floating license?
2015/06/11
[ "https://softwarerecs.stackexchange.com/questions/20254", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/9087/" ]
[DocRaptor](https://docraptor.com) is a hosted version of PrinceXML. It has a much less upfront cost than Prince, although sometimes fixed costs are advantageous (client projects, etc). Test documents are always free at DocRaptor. Note: I work at DocRaptor.
[pandoc](http://pandoc.org/) can produce pdfs from a wide viriety of formats including HTML, (some sites pages better than others - beware ones with restricted fonts), via latex and if invoked with the --toc flag will embed in the latex instructions to generate a table of contents which should include page numbers once it has been rendered into a PDF by pdflatex|lualatex|xelatex - recommended for Windows is [MikTeX](http://miktex.org/). You can also either accept the default footer, with the -s flag, or you can design your own template(s). Pandoc is a command line utility and a Haskel library so you should have no problems calling from a script. Both Pandoc and MikTex are free and open source. Pandoc is cross platform and will work with LaTeX engines on other platforms as well as with MikTex on Windows.
12,759,141
I want to encrypt, decrypt, sign and verify data using PKCS#7 Cryptographic Message Syntax. I saw sample code for this with Bouncy Castle. I want to know can I do this without using the Bouncy Castle libraries?
2012/10/06
[ "https://Stackoverflow.com/questions/12759141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1724969/" ]
There is no support for PKCS7 messages in the standard Java libraries. There is no reason not to use an existing implementation like Bouncycastle. It has such a liberal license you can probably just grab it and say you wrote it.
You should have fully compatible results using JCE and PKCS5.
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
This is similar to the smtp4dev except implemented in java so it works for non-windows developers. <http://www.aboutmyip.com/AboutMyXApp/DevNullSmtp.jsp>
You can also use netDumbster. <http://netdumbster.codeplex.com/>
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
There is now a web based version of Papercut. Also the app based version works fine for me.
This is similar to the smtp4dev except implemented in java so it works for non-windows developers. <http://www.aboutmyip.com/AboutMyXApp/DevNullSmtp.jsp>
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
A few ago I came across the following solution for the **.NET platform**. ``` <system.net> <mailSettings> <smtp deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="C:\TestMailMessages\" /> </smtp> </mailSettings> </system.net> ``` Simply place the above code in your App.config or Web.config. When you send a message now it will be stored as a file in the directory you provided as "pickupDirectoryLocation". Works like a charm.
There is also [Papercut](http://invalidlogic.com/papercut/) and [Neptune](http://www.donovanbrown.com/post/2008/10/20/Neptune.aspx), too bad none of these can be run in a portable way.
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
I faced the same problem a few weeks ago and wrote this: <http://smtp4dev.codeplex.com> > > Windows 7/Vista/XP/2003/2010 compatible dummy SMTP server. Sits in the system tray and does not deliver the received messages. The received messages can be quickly viewed, saved and the source/structure inspected. Useful for testing/debugging software that generates email. > > >
Dumbster might be what you want then. It's an open source fake SMTP server written in Java. It takes the place of a real SMTP server, so you can test your app in a realistic setting, without having any code stubbed out. You can make sure the right messages are sent to the SMTP server without actually delivering messages.
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
if you are using java I would use [Wiser](http://code.google.com/p/subethasmtp/wiki/Wiser): Wiser is a simple SMTP server that you can use for unit testing applications that send mail.
You can also use netDumbster. <http://netdumbster.codeplex.com/>
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
Dumbster might be what you want then. It's an open source fake SMTP server written in Java. It takes the place of a real SMTP server, so you can test your app in a realistic setting, without having any code stubbed out. You can make sure the right messages are sent to the SMTP server without actually delivering messages.
I've been using "Test Mail Server Tool" from ToolHeap for years. <http://www.toolheap.com/test-mail-server-tool/> It is a simple app that runs in your system tray and dumps emails to a folder. It can also be configured to open each email in your default mail program.
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
There is also [Papercut](http://invalidlogic.com/papercut/) and [Neptune](http://www.donovanbrown.com/post/2008/10/20/Neptune.aspx), too bad none of these can be run in a portable way.
You can also use netDumbster. <http://netdumbster.codeplex.com/>
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
A few ago I came across the following solution for the **.NET platform**. ``` <system.net> <mailSettings> <smtp deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="C:\TestMailMessages\" /> </smtp> </mailSettings> </system.net> ``` Simply place the above code in your App.config or Web.config. When you send a message now it will be stored as a file in the directory you provided as "pickupDirectoryLocation". Works like a charm.
if you are using java I would use [Wiser](http://code.google.com/p/subethasmtp/wiki/Wiser): Wiser is a simple SMTP server that you can use for unit testing applications that send mail.
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
Dumbster might be what you want then. It's an open source fake SMTP server written in Java. It takes the place of a real SMTP server, so you can test your app in a realistic setting, without having any code stubbed out. You can make sure the right messages are sent to the SMTP server without actually delivering messages.
There is also [Papercut](http://invalidlogic.com/papercut/) and [Neptune](http://www.donovanbrown.com/post/2008/10/20/Neptune.aspx), too bad none of these can be run in a portable way.
1,006,650
I have a lot of apps that send email. Sometimes it's one or two messages at a time. Sometimes it's thousands of messages. In development, I usually test by substituting my own address for any recipient addresses. I'm sure that's what everybody else does, until they get fed up with it and find a better solution. I was thinking about creating a dummy SMTP server that just catches the messages and dumps them in a SQLLite database, or an mbox file, or whatever. But *surely* such a tool already exists? How do you test sending email?
2009/06/17
[ "https://Stackoverflow.com/questions/1006650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
There is now a web based version of Papercut. Also the app based version works fine for me.
There is also [Papercut](http://invalidlogic.com/papercut/) and [Neptune](http://www.donovanbrown.com/post/2008/10/20/Neptune.aspx), too bad none of these can be run in a portable way.
1,770
I first found out there was a club in my city through a [JEF](https://www.jef-hamburg.de/), young European federalists event, but it took quite some time - and the help of a friend - until I went there the first time. How do I find out if there is an Esperanto club in my city?
2016/10/24
[ "https://esperanto.stackexchange.com/questions/1770", "https://esperanto.stackexchange.com", "https://esperanto.stackexchange.com/users/134/" ]
There are a couple of possibilities: 1. google Esperanto + yourcityname (by this way I found an event in my city) 2. search on Facebook for Esperanto + yourcityname 3. ask the Esperanto organization of your country how to contact the local group 4. ask on [Telegram](https://telegramo.org) in one of the language groups or in the main group, be patient 5. ask on Facebook in the biggest Esperanto group (more than 20k people)
I would like to second what Aviadisto said, especially the google search. Esperanto in my own city is very easy to find and comes right up in a google search. I've said before that if people can't find us, they're not really looking. There isn't really one good way to look -- or even five good ways to look - so look every possible. Picking up where Aviadisto left off: 6. Check meetup.com 7. Contact the Esperanto club of a neighboring city. 8. Search Duolingo for references to your city name. 9. Check out the search tips at "Trovu Samurbanon" on FB (<https://www.facebook.com/Trovu-samurbanojn-E-istojn-%C4%89ie-586767024717907/>)
48,949,525
I am trying to make a pixel art maken for an assignment for school, but i am not able to get the button event to work. I am adding an evenListener and bind a function to it but the function is never fired off. I am trying to show a simple text in the log. Can someone tell me what i am doing wrong here? Thanks in advance. HTML: ``` <!DOCTYPE html> <html> <head> <title>Pixel Art Maker!</title> <link rel="stylesheet" href="https://fonts.googleapis.com/css? family=Monoton"> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Lab: Pixel Art Maker</h1> <h2>Choose Grid Size</h2> <form id="sizePicker" onsubmit="return false"> Grid Height: <input type="number" id="inputHeight" name="height" min="1" value="1"> Grid Width: <input type="number" id="inputWeight" name="width" min="1" value="1"> <input type="submit" id="submitButton" value="Draw"> </form> <h2>Pick A Color</h2> <input type="color" id="colorPicker"> <h2>Design Canvas</h2> <table id="pixelCanvas"></table> <script src="designs.js"></script> </body> </html> ``` JavaScript: ``` // When size is submitted by the user, call makeGrid() const btnSubmit = document.getElementById("submitButton"); btnSubmit.addEventListener("click", makeGrid()); function makeGrid() { // Your code goes here! console.log("test"); } ```
2018/02/23
[ "https://Stackoverflow.com/questions/48949525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9184161/" ]
**You're calling the function `makeGrid`:** ``` btnSubmit.addEventListener("click", makeGrid()); ^ ``` **Try this:** ``` // When size is submitted by the user, call makeGrid() const btnSubmit = document.getElementById("submitButton"); btnSubmit.addEventListener("click", makeGrid); // <- Change here! function makeGrid() { // Your code goes here! console.log("test"); } ```
In the Listener, the callback is without an argument function > > btnSubmit.addEventListener("click", makeGrid); > > >
69,190,135
Getting unexpected token error for this tsx code. I couldn't fix this error, I think it is a typescript compiling issue. I have shared some config files below. I have tried resolving the issue but cant locate the any character unexpected. ``` [ error ] ./project/app.tsx SyntaxError: C:\Projects\project\app.tsx: Unexpected token (89:6) 87 | 88 | return ( > 89 | <Container> ``` **tsconfig.json** file, ``` { "compileOnSave": false, "compilerOptions": { "allowJs": true, "allowSyntheticDefaultImports": true, "baseUrl": ".", "jsx": "react", "lib": [ "dom", "es2015", "es2016" ], "module": "commonjs", "moduleResolution": "node", "noUnusedLocals": true, "noUnusedParameters": true, "preserveConstEnums": true, "removeComments": false, "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, "target": "es5", "typeRoots": [ "./node_modules/@types" ] } } ``` **package.json** file ``` { "name": "@project", "version": "1.0", "author": "Author", "description": "project", "repository": { "type": "git", "url": "git@github.com:project.git" }, "main": "index.js", "scripts": { "start": "SET NODE_ENV=production ./node_modules/.bin/node .next/production-server/server/index.js", "build": "next build && tsc --project tsconfig.server.json && cp services.manifest.json .next/production-server", "build:debug": "tsc -p ./tsconfig.debug.json --pretty", "assets:upload": "node scripts/upload_assets.js", "dev": "SET NODE_ENV=dev nodemon server/index.ts", "lint": "tslint -c tslint.json -p tsconfig.json", "test": "NODE_ENV=test jest", "test:ci": "NODE_ENV=test JEST_JUNIT_OUTPUT_DIR=./reports jest --ci --runInBand --reporters=default --reporters=jest-junit", "test:watch": "NODE_ENV=test jest --watch", "type-check": "tsc --noEmit" }, "dependencies": { "@material-ui/core": "^4.7.2", "@material-ui/icons": "^4.5.1", "@zeit/next-css": "^1.0.1", "@zeit/next-typescript": "^1.1.1", "console-polyfill": "^0.3.0", "core-js": "^3.4.8", "csv-string": "^3.1.7", "emotion": "^9.2.12", "emotion-server": "^9.2.12", "emotion-theming": "^9.2.9", "isomorphic-unfetch": "^3.0.0", "mixpanel-browser": "^2.31.0", "next": "^8.1.0", "next-routes": "^1.4.2", "node": "^10.17.0", "nookies": "^2.0.8", "query-string-for-all": "^6.9.0", "react": "^16.12.0", "react-dom": "^16.12.0", "react-emotion": "^9.2.12", "react-ga": "^2.7.0", "react-mixpanel": "^1.0.5", "react-select": "^3.0.8", "react-window": "^1.8.5", "readdirp": "^3.3.0", "s3-sync-aws": "^1.1.1", "slugify": "^1.3.6" }, "devDependencies": { "@babel/core": "^7.7.5", "@babel/plugin-transform-object-assign": "^7.7.4", "@babel/preset-env": "^7.7.6", "@semantic-release/git": "^4.0.1", "@testing-library/jest-dom": "^4.2.4", "@types/isomorphic-fetch": "0.0.35", "@types/jest": "^24.0.23", "@types/next": "^8.0.7", "@types/react": "^16.9.16", "babel-jest": "^24.9.0", "babel-loader": "^8.0.6", "babel-plugin-emotion": "^9.2.11", "eslint": "^6.7.2", "eslint-config-prettier": "^6.7.0", "eslint-plugin-jest": "^23.1.1", "jest": "^24.9.0", "jest-cli": "^24.9.0", "jest-runner-prettier": "^0.3.3", "jest-runner-tslint": "^1.0.7", "nodemon": "^2.0.1", "prettier": "^1.19.1", "semantic-release": "^15.13.31", "ts-node": "^8.5.4", "tslint-config-prettier": "^1.18.0", "tslint-loader": "^3.5.4", "tslint-plugin-prettier": "^2.0.1", "tslint-react": "^4.1.0", "typescript": "^3.7.3" } } ``` **nodemon.json** ``` { "watch": [ "server/*.[ts|js]" ], "execMap": { "ts": "ts-node" } } ``` **.babelrc** ``` { "env": { "production": { "presets": ["@babel/preset-env", "next/babel", "@zeit/next-typescript/babel"], "plugins": [ [ "emotion", { "inline": true } ], "@babel/plugin-transform-object-assign" ] }, "development": { "presets": ["@babel/preset-env", "next/babel", "@zeit/next-typescript/babel"], "plugins": [ [ "emotion", { "sourceMap": true, "autoLabel": true, "labelFormat": "-constName--[local]" } ], "@babel/plugin-transform-object-assign" ] }, "test": { "presets": ["@babel/preset-env", "next/babel", "@zeit/next-typescript/babel"], "plugins": [ [ "emotion", { "inline": true } ], "@babel/plugin-transform-object-assign" ] } } } ``` **\_app.tsx** file ``` import App, { Container } from "next/app" import Head from "next/head" import Router from "next/router" import React from "react" import mixpanel from "mixpanel-browser" import { MixpanelProvider } from "react-mixpanel" import { manifest as mixpanelConfig } from "../lib/utils/manifest" import Locale from "../lib/clients/locale" import { initGA, logPageView } from "../lib/analytics" import ProjectPath from "../lib/path" import ProfileDetails from "../lib/clients/profile-details" import { PageType } from "../lib/page-type" // tslint:disable-next-line: no-var-requires require("console-polyfill") // IE mixpanel.init(mixpanelConfig.aws.mixpanel.token) const DEFAULT_SEO = { title: "Title", description: "description", twitter: { handle: "@acom", cardType: "summary", }, } export default class MyApp extends App { static async getInitialProps({ Component, ctx }) { let pageProps = {} await Locale.buildIndexes() await ProjectPath.indexTopics() if (Component.getInitialProps) { pageProps = await Component.getInitialProps(ctx) } return { pageProps } } async componentDidMount() { if (this.props.pageProps.context) { const trackingIDs = [ "ADA-DA4334", ] const { publishAsRole } = this.props.pageProps.context switch (publishAsRole) { case PageType.INSIGHT_STORY: // rendering const { story } = this.props.pageProps if (story.teamTokens && story.teamTokens && story.teamTokens.googleAnalytics) { trackingIDs.push(...story.teamTokens.googleAnalytics.map(_ => _.trim())) } break default: // We're rendering some content const { organizationSlug } = this.props.pageProps.context.path const organizationsObject = await ProfileDetails.getProfiles() const organization = organizationsObject[organizationSlug] if (organization && organization.teamTokens && Array.isArray(organization.teamTokens.googleAnalytics)) { trackingIDs.push(...organization.teamTokens.googleAnalytics.map(_ => _.trim())) } } initGA(trackingIDs) logPageView() Router.router.events.on("routeChangeComplete", logPageView) // On the client, we want to make sure the locale index is built before // user clicks to navigate away from page, as this takes a bit of time. await Locale.buildIndexes() } } render() { const { Component, pageProps } = this.props return ( <Container> <Head> <meta key="twitter:card" name="twitter:card" content={DEFAULT_SEO.twitter.cardType} /> <meta key="twitter:site" name="twitter:site" content={DEFAULT_SEO.twitter.handle} /> <meta key="twitter:creator" name="twitter:creator" content={DEFAULT_SEO.twitter.handle} /> <meta key="twitter:title" name="twitter:title" content={DEFAULT_SEO.title} /> <meta key="twitter:description" name="twitter:description" content={DEFAULT_SEO.description} /> <meta key="og:url" property="og:url" content={DEFAULT_SEO.openGraph.url} /> <meta key="og:type" property="og:type" content={DEFAULT_SEO.openGraph.type} /> <meta key="og:title" property="og:title" content={DEFAULT_SEO.openGraph.title} /> <meta key="og:description" property="og:description" content={DEFAULT_SEO.openGraph.description} /> <meta key="og:image" property="og:image" content={DEFAULT_SEO.openGraph.image} /> <meta key="og:locale" property="og:locale" content={DEFAULT_SEO.openGraph.locale} /> </Head> <MixpanelProvider mixpanel={mixpanel}> <Component {...pageProps} /> </MixpanelProvider> </Container> ) } } ``` **next.config.js** ``` const deployEnv = process.env.DEPLOY_ENV || "production" const isProd = ["production", "staging"].includes(deployEnv) || (process.ENV === "production") const withTypescript = require("@zeit/next-typescript") const withCSS = require("@zeit/next-css") module.exports = withTypescript( withCSS({ webpack: cfg => { const originalEntry = cfg.entry cfg.entry = async () => { const entries = await originalEntry() if (entries["main.js"] && !entries["main.js"].includes("./client/polyfills.js")) { entries["main.js"].unshift("./client/polyfills.js") } return entries } cfg.module.rules.push({ test: /\.[jt]sx?$/, use: [ { loader: "tslint-loader", options: { isServer: false, }, }, ], exclude: /node_modules/, }) return cfg }, cssLoaderOptions: { url: false, }, // all inside env will be available on compile time in process.env env: { deploy: deployEnv }, assetPrefix: isProd ? `https://assets.project.com/pro/${deployEnv}` : "", poweredByHeader: false, }), ) ``` Thank you in advance.
2021/09/15
[ "https://Stackoverflow.com/questions/69190135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8433332/" ]
I believe you will need to use the `variables` object to pass the other input, as @xadm mentioned. Using Postman, I tested the following code and it worked: ``` { "query": "mutation userUploadPostPhoto($photo: Upload!, $id: String!) { userUploadPostPhoto(photo: $photo, id: $id) }", "variables": { "photo": null, "id": "10" } } ``` You can also remove the `photo` property, since it's not needed. **PS**: Please ensure that you have installed `graphql-upload` and `apollo-server-express`. Another package(`apollo-server`) will not accept express as a middleware as an input to a `applyMiddleware` method.
you can try to use [Altair](https://altair.sirmuel.design/) I think this is better than postman here you can see an example of how to [Upload a file whit altair](https://altair.sirmuel.design/docs/features/file-upload.html) your GraphQL query should looks like this ``` mutation ($Picture: Upload!) { userUploadPostPhoto ( id: 123123123, photo: $Picture, ) } ```
68,117,280
I am having 2 tables, Customers and Customer Contacts table. **Ex: Customers** Column: ``` Id Customer Name ``` **Contacts Table** Column ``` id customer_id contact_no ``` I need to fetch a record by below format.' Customer Name, contact\_no\_1, contact\_no\_2 .... etc. I'm using oracle 11g.
2021/06/24
[ "https://Stackoverflow.com/questions/68117280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5707365/" ]
you must do a default tag option for select, this way on change element this will bind the value to the property ``` <select class="form-select px-4 py-3 w-full rounded" wire:model="team_id"> <option>Select Team</option> @foreach($teams as $team) <option value="{{$team->id}}">{{$team->name}}</option> @endforeach </select> ``` also in the validation rules you can add another for the "team\_id" value that can't be null on submit
`wire:model` should be on `option` tag not on `select`
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't you rather want to keep them separated? ``` $_SESSION['response'] = $_POST; ```
Ignoring the security issues this could cause depending on how you use it, what you could do is use: ``` $_SESSION = array_merge($_POST, $_SESSION); ``` This will only bring in POST vars which have a key not already found in $\_SESSION. Switch them around if you want the POST vars to take precedence of course. Just a quick note on security, if like a lot of people you use the session to store user id, what would happen if i sent a POST request to your script with `userid=1`? All im saying is, be careful what you are doing with this. You'd be better off if possible doing as suggested and using a unique key in $\_SESSION for post vars such as `$_SESSION['post_vars'] = $_POST` (or maybe `['form_data']` if you're using it to persist form data, which is usually why people do this).
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
If you **really** want to do it as you state, you could use something like ``` $_SESSION=array_merge($_SESSION,$_POST); ``` which would work but be a "bad thing" - plenty of scope to overwrite items already in the `$_SESSION` variable: index.php: ``` <form action="2.php" method="post"> <input type="text" name="hidden" value="hidden"> <button type="submit">Click</button> </form> ``` 2.php: ``` <?php session_start(); session_unset(); $_SESSION['hidden']="existing"; $_SESSION=array_merge($_SESSION,$_POST); echo '<pre>'.print_r($_SESSION,true).'</pre>'; ``` Better would be to use ``` $_SESSION['POST']=$_POST; ``` Obviously, perform any data checks you need to before doing this though
Since the POST is made by a payment gateway, the session will be associated with it (and most likely be lost at first request, since it can be assumed that it won't ever bother reading the session cookie). Your client won't ever see this data in their session. If you want to have this data available, you need to persist it somehow, if the payment gateway gives you exploitable client information. Possible solution are a database, key/value store... Alternatively, it is common that the payment gateway will allow you to specify a link to redirect the client's browser to after the purchase. Getting the parameters from the POST, you could append them to the redirect URL to pass them back to your website as GET parameters.
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't use single quotes: ``` foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } ``` I'd encourage you to read about [Strings in PHP](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single). **Note:** This is potentially unsafe for several reasons - mostly injection by key collision. Consider if I *posted* the logged in user id. This could be mitigated through encapsulation: ``` $_SESSION['posted_data'] = $_POST; ```
Don't you rather want to keep them separated? ``` $_SESSION['response'] = $_POST; ```