Search is not available for this dataset
qid
int64
1
74.7M
question
stringlengths
1
70k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
0
115k
response_k
stringlengths
0
60.5k
28,567,868
I'm trying to put datepicker on input inside bootstrap modal.The datepicker it works well inside template except for modals (using JQuery 2+) However, if I'm using JQuery 1.9 for example, the datepicker works well everywhere. I tried [this example](http://jsfiddle.net/sudiptabanerjee/93eTU/) ```js $('#idTourDateDetails').datepicker({ dateFormat: 'dd-mm-yy', minDate: '+5d', changeMonth: true, changeYear: true, altField: "#idTourDateDetailsHidden", altFormat: "yy-mm-dd" }); ``` ```css .clsDatePicker { z-index: 100000; } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <!-- Button trigger modal --> <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">Launch demo modal</button> <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title" id="myModalLabel">Modal title</h4> </div> <div class="modal-body"> <div class="col-md-12"> <div class="row"> <label for="idTourDateDetails">Tour Start Date:</label> <div class="form-group"> <div class="input-group"> <input type="text" name="idTourDateDetails" id="idTourDateDetails" readonly="readonly" class="form-control clsDatePicker"> <span class="input-group-addon"><i id="calIconTourDateDetails" class="glyphicon glyphicon-th"></i></span> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> ``` Here,also when you switch to jQuery 2.0.2 ,that one not works anymore. I need some help in this way, and I don't want to use previous versions of JQuery. Thanks,
2015/02/17
[ "https://Stackoverflow.com/questions/28567868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1856538/" ]
I wouldn't use the `[NotMapped]` attribute as that makes more work for you to insert that data. I know this technique works to make a property read-only, so I'd imagine it could be used to make it write-only. However, since you don't want to load it, you'll have to add `.Select` statements to your queries, otherwise it will pull that data in. Not necessarily the cleanest solution, but it will give you what you want without having to bend over backwards to insert and update that column. What you'll want to do is make the `get;` on the property `protected internal` instead of the default of `public`. That way, EF will not freak out over not having access to the property, and you'll never have read access to the property outside of the data access layer of your project. ``` class Foo { public int Id { get; set; } public string Name { get; set; } public string BigTextColumn { protected internal get; set; } } ``` Then in your queries do something like the following: ``` context.Foos.FirstOrDefault().Select(f => new Foo { Id = f.Id, Name = f.Name }); ```
You can remove the get; property from the bigtext column that will make it write only. And then you can set its value from code. Im not sure that using the not mapped attribute will be of any help as ef will not think tact as if its not a column in your table and you won't be able to write to it.
4,748,669
If I have a class with an array of pointers to another class *Vehicle* : ``` class List { public: //stuff goes here private: Vehicle ** vehicles; } ``` If I now write the destructor of the class `List`, do I manually iterate over the array (I know how many items are in the array) and `delete` every pointer to a vehicle, or will C++ automatically call the destructors of all the Vehicles in the array? (Like it does if there's a private string/... in the class or if it would be a STL container of Vehicle pointers) EDIT: I forgot about `delete [] vehicles`, but if I would do that, would it also delete the memory used by all the vehicles in the array, or would it just delete the memory used by the pointers?
2011/01/20
[ "https://Stackoverflow.com/questions/4748669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/538047/" ]
You have to delete all the entries in the array AND delete the array. There are methods in C++ (STL) to avoid this: use a vector, so you don't have to delete the array. Use scoped\_ptr/shared\_ptr per Vehicle, so you don't have to delete the vehicles.
You have to manually iterate over vehicles and `delete` each and every of them.
4,748,669
If I have a class with an array of pointers to another class *Vehicle* : ``` class List { public: //stuff goes here private: Vehicle ** vehicles; } ``` If I now write the destructor of the class `List`, do I manually iterate over the array (I know how many items are in the array) and `delete` every pointer to a vehicle, or will C++ automatically call the destructors of all the Vehicles in the array? (Like it does if there's a private string/... in the class or if it would be a STL container of Vehicle pointers) EDIT: I forgot about `delete [] vehicles`, but if I would do that, would it also delete the memory used by all the vehicles in the array, or would it just delete the memory used by the pointers?
2011/01/20
[ "https://Stackoverflow.com/questions/4748669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/538047/" ]
If the List owns Vehicle objects (creates them in the constructor) you need to delete every single one and then delete the array of pointers itself.
You have to manually iterate over vehicles and `delete` each and every of them.
4,748,669
If I have a class with an array of pointers to another class *Vehicle* : ``` class List { public: //stuff goes here private: Vehicle ** vehicles; } ``` If I now write the destructor of the class `List`, do I manually iterate over the array (I know how many items are in the array) and `delete` every pointer to a vehicle, or will C++ automatically call the destructors of all the Vehicles in the array? (Like it does if there's a private string/... in the class or if it would be a STL container of Vehicle pointers) EDIT: I forgot about `delete [] vehicles`, but if I would do that, would it also delete the memory used by all the vehicles in the array, or would it just delete the memory used by the pointers?
2011/01/20
[ "https://Stackoverflow.com/questions/4748669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/538047/" ]
> > If i have a class with an array of pointers to another class Vehicle : > > > `Vehicle ** vehicles;` > > > `vehicles` is not an array of pointers rather its a pointer to pointer to a `Vehicle` type. An array of pointers would be defined something like `Vehicle* vehicles[N]`. > > do i manually iterate over the array (i know how many items are in the array) and delete every pointer to a vehicle > > > Yes! You dont want your code to leak memory do you? I would recommend using `Boost::scoped_ptr` from the Boost library. Moreover if you compiler supports C++0x you can also use `std::unique_ptr`
You have to manually iterate over vehicles and `delete` each and every of them.
4,748,669
If I have a class with an array of pointers to another class *Vehicle* : ``` class List { public: //stuff goes here private: Vehicle ** vehicles; } ``` If I now write the destructor of the class `List`, do I manually iterate over the array (I know how many items are in the array) and `delete` every pointer to a vehicle, or will C++ automatically call the destructors of all the Vehicles in the array? (Like it does if there's a private string/... in the class or if it would be a STL container of Vehicle pointers) EDIT: I forgot about `delete [] vehicles`, but if I would do that, would it also delete the memory used by all the vehicles in the array, or would it just delete the memory used by the pointers?
2011/01/20
[ "https://Stackoverflow.com/questions/4748669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/538047/" ]
You have to delete all the entries in the array AND delete the array. There are methods in C++ (STL) to avoid this: use a vector, so you don't have to delete the array. Use scoped\_ptr/shared\_ptr per Vehicle, so you don't have to delete the vehicles.
If the List owns Vehicle objects (creates them in the constructor) you need to delete every single one and then delete the array of pointers itself.
4,748,669
If I have a class with an array of pointers to another class *Vehicle* : ``` class List { public: //stuff goes here private: Vehicle ** vehicles; } ``` If I now write the destructor of the class `List`, do I manually iterate over the array (I know how many items are in the array) and `delete` every pointer to a vehicle, or will C++ automatically call the destructors of all the Vehicles in the array? (Like it does if there's a private string/... in the class or if it would be a STL container of Vehicle pointers) EDIT: I forgot about `delete [] vehicles`, but if I would do that, would it also delete the memory used by all the vehicles in the array, or would it just delete the memory used by the pointers?
2011/01/20
[ "https://Stackoverflow.com/questions/4748669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/538047/" ]
You have to delete all the entries in the array AND delete the array. There are methods in C++ (STL) to avoid this: use a vector, so you don't have to delete the array. Use scoped\_ptr/shared\_ptr per Vehicle, so you don't have to delete the vehicles.
> > If i have a class with an array of pointers to another class Vehicle : > > > `Vehicle ** vehicles;` > > > `vehicles` is not an array of pointers rather its a pointer to pointer to a `Vehicle` type. An array of pointers would be defined something like `Vehicle* vehicles[N]`. > > do i manually iterate over the array (i know how many items are in the array) and delete every pointer to a vehicle > > > Yes! You dont want your code to leak memory do you? I would recommend using `Boost::scoped_ptr` from the Boost library. Moreover if you compiler supports C++0x you can also use `std::unique_ptr`
770,306
How do I solve for $x$ from this equation? $$2\cos\frac {x^2+x}{6}=2^x+2^{-x}$$
2014/04/26
[ "https://math.stackexchange.com/questions/770306", "https://math.stackexchange.com", "https://math.stackexchange.com/users/47820/" ]
$-2\le2\cos(\frac{x^2 + x}{6})\le 2$ and $2\le2^x + 2^{-x}$. Therefore the only possible solution is when both equal $2$.
Get bounds for the left hand side and the right hand side separately ...
770,306
How do I solve for $x$ from this equation? $$2\cos\frac {x^2+x}{6}=2^x+2^{-x}$$
2014/04/26
[ "https://math.stackexchange.com/questions/770306", "https://math.stackexchange.com", "https://math.stackexchange.com/users/47820/" ]
Get bounds for the left hand side and the right hand side separately ...
I will give a hint. :) Looking at the question,you should be able to figure out that ${x = 0}$ is a solution. Apart from that, no solutions exist since ${2^x + 2^{-x} > 2}$. :))
770,306
How do I solve for $x$ from this equation? $$2\cos\frac {x^2+x}{6}=2^x+2^{-x}$$
2014/04/26
[ "https://math.stackexchange.com/questions/770306", "https://math.stackexchange.com", "https://math.stackexchange.com/users/47820/" ]
Get bounds for the left hand side and the right hand side separately ...
Let $y=2^x$, then $$ \begin{align} \ln y&=\ln2^x\\ \ln y&=x\ln 2\\ y&=e^{x\ln 2}. \end{align} $$ Consequently, $2^{-x}=e^{-x\ln 2}$ and $$ \begin{align} 2\cos\left(\frac{x^2+x}{6}\right)&=e^{x\ln 2}+e^{-x\ln 2}\\ \cos\left(\frac{x^2+x}{6}\right)&=\frac{e^{x\ln 2}+e^{-x\ln 2}}{2} \end{align} $$ Now, let $x=i\theta$, then $$ \begin{align} \cos\left(\frac{(i\theta)^2+i\theta}{6}\right)&=\frac{e^{i\theta\ln 2}+e^{-i\theta\ln 2}}{2}\\ \cos\left(\frac{-\theta^2+i\theta}{6}\right)&=\cos(\theta\ln 2)\\ \frac{-\theta^2+i\theta}{6}&=\theta\ln 2\\ \theta^2+(6\ln2-i)\theta&=0\\ \theta(\theta+6\ln2-i)&=0\\ \theta\_1=0&\text{ or }\ \theta\_2=i-6\ln2. \end{align} $$ Thus, $\large x\_1=0$ and $\large x\_2=-(1+6i\ln2)$.
770,306
How do I solve for $x$ from this equation? $$2\cos\frac {x^2+x}{6}=2^x+2^{-x}$$
2014/04/26
[ "https://math.stackexchange.com/questions/770306", "https://math.stackexchange.com", "https://math.stackexchange.com/users/47820/" ]
$-2\le2\cos(\frac{x^2 + x}{6})\le 2$ and $2\le2^x + 2^{-x}$. Therefore the only possible solution is when both equal $2$.
I will give a hint. :) Looking at the question,you should be able to figure out that ${x = 0}$ is a solution. Apart from that, no solutions exist since ${2^x + 2^{-x} > 2}$. :))
770,306
How do I solve for $x$ from this equation? $$2\cos\frac {x^2+x}{6}=2^x+2^{-x}$$
2014/04/26
[ "https://math.stackexchange.com/questions/770306", "https://math.stackexchange.com", "https://math.stackexchange.com/users/47820/" ]
$-2\le2\cos(\frac{x^2 + x}{6})\le 2$ and $2\le2^x + 2^{-x}$. Therefore the only possible solution is when both equal $2$.
Let $y=2^x$, then $$ \begin{align} \ln y&=\ln2^x\\ \ln y&=x\ln 2\\ y&=e^{x\ln 2}. \end{align} $$ Consequently, $2^{-x}=e^{-x\ln 2}$ and $$ \begin{align} 2\cos\left(\frac{x^2+x}{6}\right)&=e^{x\ln 2}+e^{-x\ln 2}\\ \cos\left(\frac{x^2+x}{6}\right)&=\frac{e^{x\ln 2}+e^{-x\ln 2}}{2} \end{align} $$ Now, let $x=i\theta$, then $$ \begin{align} \cos\left(\frac{(i\theta)^2+i\theta}{6}\right)&=\frac{e^{i\theta\ln 2}+e^{-i\theta\ln 2}}{2}\\ \cos\left(\frac{-\theta^2+i\theta}{6}\right)&=\cos(\theta\ln 2)\\ \frac{-\theta^2+i\theta}{6}&=\theta\ln 2\\ \theta^2+(6\ln2-i)\theta&=0\\ \theta(\theta+6\ln2-i)&=0\\ \theta\_1=0&\text{ or }\ \theta\_2=i-6\ln2. \end{align} $$ Thus, $\large x\_1=0$ and $\large x\_2=-(1+6i\ln2)$.
770,306
How do I solve for $x$ from this equation? $$2\cos\frac {x^2+x}{6}=2^x+2^{-x}$$
2014/04/26
[ "https://math.stackexchange.com/questions/770306", "https://math.stackexchange.com", "https://math.stackexchange.com/users/47820/" ]
Let $y=2^x$, then $$ \begin{align} \ln y&=\ln2^x\\ \ln y&=x\ln 2\\ y&=e^{x\ln 2}. \end{align} $$ Consequently, $2^{-x}=e^{-x\ln 2}$ and $$ \begin{align} 2\cos\left(\frac{x^2+x}{6}\right)&=e^{x\ln 2}+e^{-x\ln 2}\\ \cos\left(\frac{x^2+x}{6}\right)&=\frac{e^{x\ln 2}+e^{-x\ln 2}}{2} \end{align} $$ Now, let $x=i\theta$, then $$ \begin{align} \cos\left(\frac{(i\theta)^2+i\theta}{6}\right)&=\frac{e^{i\theta\ln 2}+e^{-i\theta\ln 2}}{2}\\ \cos\left(\frac{-\theta^2+i\theta}{6}\right)&=\cos(\theta\ln 2)\\ \frac{-\theta^2+i\theta}{6}&=\theta\ln 2\\ \theta^2+(6\ln2-i)\theta&=0\\ \theta(\theta+6\ln2-i)&=0\\ \theta\_1=0&\text{ or }\ \theta\_2=i-6\ln2. \end{align} $$ Thus, $\large x\_1=0$ and $\large x\_2=-(1+6i\ln2)$.
I will give a hint. :) Looking at the question,you should be able to figure out that ${x = 0}$ is a solution. Apart from that, no solutions exist since ${2^x + 2^{-x} > 2}$. :))
25,211,679
I have a iron route that searches for a collection item based on the url param. If it finds it, it returns the item as a data context, otherwise it renders a `notFound` template. The code looks like this: ``` this.route('profileView', { path: list_path + '/profiles/:_id', fastRender: true, waitOn: function() { if (Meteor.user()) { return [Meteor.subscribe('singleProfile', this.params._id, Session.get("currentListId"))]; } }, data: function() { var profile = Profiles.findOne({ _id: this.params._id }); if (!profile) { this.render("notFound"); } else return profile; } }); ``` The problem is the `notFound` template gets loaded briefly prior to profile getting returned, although I thought the `waitOn` function would have handled that. What's the correct pattern to have the desired result using iron router? Thanks.
2014/08/08
[ "https://Stackoverflow.com/questions/25211679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1691147/" ]
When you do `line1=file.readlines()[2:]`, the "cursor" moves to the end of the file. Then you ask to write the line with the replaced value, so isn't it copied at the end of the file instead of being just modified in place? Maybe you miss a `file.seek(...)` call before writing.
I think the problem lies in the fact that you want to use the `r+` opening mode for reading and writing. Even to change just one character in your file, here is the best way to proceed (I have written thousands of these): ``` f = open("ex_foce.ext","r") # original file for reading g = open("ex_foce_mod.ext","w") # "output", modified file for _ in range(3): g.write(f.readline()) # copy header lines for line in f: L = line.strip().split() if L[0]=='-1000000000': L[7] = '1.0' g.write(' '.join(L)+'\n') f.close() g.close() ``` This will 1. avoid losing data from the original file if the program fails; 2. always produce the result you want without any problem; 3. never load the entire file in memory (as `readlines()` does); 4. not bother about the line index where you found the result (although you can get it using `enumerate` on `f` instead). When finished sucessfully, you can remove the original manually (or with `os.remove`/`shutil.rmtree`). Forget about in-file editing, although it seems more intuitive at first. If you are afraid of leaving a lot of temporary files in the process, use appropriate tools such as [tempfile](https://docs.python.org/2/library/tempfile.html).
25,211,679
I have a iron route that searches for a collection item based on the url param. If it finds it, it returns the item as a data context, otherwise it renders a `notFound` template. The code looks like this: ``` this.route('profileView', { path: list_path + '/profiles/:_id', fastRender: true, waitOn: function() { if (Meteor.user()) { return [Meteor.subscribe('singleProfile', this.params._id, Session.get("currentListId"))]; } }, data: function() { var profile = Profiles.findOne({ _id: this.params._id }); if (!profile) { this.render("notFound"); } else return profile; } }); ``` The problem is the `notFound` template gets loaded briefly prior to profile getting returned, although I thought the `waitOn` function would have handled that. What's the correct pattern to have the desired result using iron router? Thanks.
2014/08/08
[ "https://Stackoverflow.com/questions/25211679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1691147/" ]
If my understanding of the question is correct, you want the following: **Edit1, after clarification via comment** **Edit2, to preserve preliminary information** ``` # ... define value1, value3 ... with open('ex_foce.ext') as f: lines = f.readlines() prelims = '\n'.join(lines[ : 2]) lines = lines[2: ] toWrite = '' for line in lines: if line.startswith(value1): toWrite += ' '.join(line.split()[ : -1]) + value3 + '\n' else: toWrite += line + '\n' with open('ex_foce.ext', 'w') as f: f.write(prelims + '\n' + toWrite); ``` Replace `value1` and `value3` as required. Hope this helps.
I think the problem lies in the fact that you want to use the `r+` opening mode for reading and writing. Even to change just one character in your file, here is the best way to proceed (I have written thousands of these): ``` f = open("ex_foce.ext","r") # original file for reading g = open("ex_foce_mod.ext","w") # "output", modified file for _ in range(3): g.write(f.readline()) # copy header lines for line in f: L = line.strip().split() if L[0]=='-1000000000': L[7] = '1.0' g.write(' '.join(L)+'\n') f.close() g.close() ``` This will 1. avoid losing data from the original file if the program fails; 2. always produce the result you want without any problem; 3. never load the entire file in memory (as `readlines()` does); 4. not bother about the line index where you found the result (although you can get it using `enumerate` on `f` instead). When finished sucessfully, you can remove the original manually (or with `os.remove`/`shutil.rmtree`). Forget about in-file editing, although it seems more intuitive at first. If you are afraid of leaving a lot of temporary files in the process, use appropriate tools such as [tempfile](https://docs.python.org/2/library/tempfile.html).
25,211,679
I have a iron route that searches for a collection item based on the url param. If it finds it, it returns the item as a data context, otherwise it renders a `notFound` template. The code looks like this: ``` this.route('profileView', { path: list_path + '/profiles/:_id', fastRender: true, waitOn: function() { if (Meteor.user()) { return [Meteor.subscribe('singleProfile', this.params._id, Session.get("currentListId"))]; } }, data: function() { var profile = Profiles.findOne({ _id: this.params._id }); if (!profile) { this.render("notFound"); } else return profile; } }); ``` The problem is the `notFound` template gets loaded briefly prior to profile getting returned, although I thought the `waitOn` function would have handled that. What's the correct pattern to have the desired result using iron router? Thanks.
2014/08/08
[ "https://Stackoverflow.com/questions/25211679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1691147/" ]
A clean way to do it is; * Open the file for reading * Read all the lines from the file. * Close the file * Manipulate the lines how you want * Open the file for writing (this will truncate the file) * Write the changed files back to the file * Close the file You could open the file for reading and writing, and then use `seek` to go back to the beginning. But that would leave garbage at the end of the file if the new contents are smaller than the old one.
I think the problem lies in the fact that you want to use the `r+` opening mode for reading and writing. Even to change just one character in your file, here is the best way to proceed (I have written thousands of these): ``` f = open("ex_foce.ext","r") # original file for reading g = open("ex_foce_mod.ext","w") # "output", modified file for _ in range(3): g.write(f.readline()) # copy header lines for line in f: L = line.strip().split() if L[0]=='-1000000000': L[7] = '1.0' g.write(' '.join(L)+'\n') f.close() g.close() ``` This will 1. avoid losing data from the original file if the program fails; 2. always produce the result you want without any problem; 3. never load the entire file in memory (as `readlines()` does); 4. not bother about the line index where you found the result (although you can get it using `enumerate` on `f` instead). When finished sucessfully, you can remove the original manually (or with `os.remove`/`shutil.rmtree`). Forget about in-file editing, although it seems more intuitive at first. If you are afraid of leaving a lot of temporary files in the process, use appropriate tools such as [tempfile](https://docs.python.org/2/library/tempfile.html).
25,211,679
I have a iron route that searches for a collection item based on the url param. If it finds it, it returns the item as a data context, otherwise it renders a `notFound` template. The code looks like this: ``` this.route('profileView', { path: list_path + '/profiles/:_id', fastRender: true, waitOn: function() { if (Meteor.user()) { return [Meteor.subscribe('singleProfile', this.params._id, Session.get("currentListId"))]; } }, data: function() { var profile = Profiles.findOne({ _id: this.params._id }); if (!profile) { this.render("notFound"); } else return profile; } }); ``` The problem is the `notFound` template gets loaded briefly prior to profile getting returned, although I thought the `waitOn` function would have handled that. What's the correct pattern to have the desired result using iron router? Thanks.
2014/08/08
[ "https://Stackoverflow.com/questions/25211679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1691147/" ]
``` with open('ex_foce.ext','r+') as f: lines = f.readlines() # don't slice, we need to use all lines later for ind, line in enumerate(lines[3:]): # keep track of the index of each line using enumerate from line 4 to the end spl = line.split() if (spl[0]) == '-1000000000': # if we find value lines[ind] = line.replace(spl[7],"1.0") # replace line in lines at ind/index with updated value f.seek(0) # go back to start of file for line in lines: # write updated lines f.write(line) ```
I think the problem lies in the fact that you want to use the `r+` opening mode for reading and writing. Even to change just one character in your file, here is the best way to proceed (I have written thousands of these): ``` f = open("ex_foce.ext","r") # original file for reading g = open("ex_foce_mod.ext","w") # "output", modified file for _ in range(3): g.write(f.readline()) # copy header lines for line in f: L = line.strip().split() if L[0]=='-1000000000': L[7] = '1.0' g.write(' '.join(L)+'\n') f.close() g.close() ``` This will 1. avoid losing data from the original file if the program fails; 2. always produce the result you want without any problem; 3. never load the entire file in memory (as `readlines()` does); 4. not bother about the line index where you found the result (although you can get it using `enumerate` on `f` instead). When finished sucessfully, you can remove the original manually (or with `os.remove`/`shutil.rmtree`). Forget about in-file editing, although it seems more intuitive at first. If you are afraid of leaving a lot of temporary files in the process, use appropriate tools such as [tempfile](https://docs.python.org/2/library/tempfile.html).
27,777,205
Suppose I have a matrix ``` A=[1 2 3] ``` which is row matrix. Not I want to do it "page" matrix, i.e. align elements along 3rd dimension. I noticed, that the following ``` A=permute(A,[3 1 2]) ``` works, while the following ``` A=permute(A,[3 2 1]) ``` does not. Why?
2015/01/05
[ "https://Stackoverflow.com/questions/27777205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1171620/" ]
If `Vector extends Matrix`, you can: ``` public class Matrix { public Matrix scale(int scaleFactor) { ... return Matrix ... } } public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { // <-- return sub type here! ... return Vector ... } } ``` The rule that overridden methods must have the same type has been weakened in Java 5: You can now use subtypes as well to make overridden methods "more specific." The advantage of this approach over generics is that it's clean, no (implicit) casting is required and it exactly limits the types without any generics magic. **[EDIT]** Now `Vector` is just a special kind of `Matrix` (the 1-column/row type) which means that the code in `scale()` is the same. Unfortunately, this doesn't work: ``` public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { // <-- return sub type here! return (Vector) super.scale(scaleFactor); } } ``` since you can't cast `Matrix` instances into a `Vector`. The solution is to move the scale code into a helper method: ``` public class Matrix { protected void doScale(int scaleFactor) { ... original scale() code here... } public Matrix scale(int scaleFactor) { doScale(scaleFactor); return this; } } public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { doScale(scaleFactor); return this; } } ``` If the class is immutable (and it probably should be), then you need to use the copy constructor, of course: ``` public Matrix scale(int scaleFactor) { Matrix result = new Matrix(this); result.doScale(scaleFactor); return result; } ```
You could make `scale` generic. Like ``` public class Matrix<T> { // ... public T scale(int scaleFactor) { // Some code that returns a scaled version of the matrix } } ``` then your sub-classes could `extend Matrix<Vector>`. Note that it would be difficult to practically implement `scale` in `Matrix`; it might be better to make it `abstract` like ``` public abstract class Matrix<T> { // ... public abstract T scale(int scaleFactor); } ``` Then your sub-classes *must* provide an implementation.
27,777,205
Suppose I have a matrix ``` A=[1 2 3] ``` which is row matrix. Not I want to do it "page" matrix, i.e. align elements along 3rd dimension. I noticed, that the following ``` A=permute(A,[3 1 2]) ``` works, while the following ``` A=permute(A,[3 2 1]) ``` does not. Why?
2015/01/05
[ "https://Stackoverflow.com/questions/27777205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1171620/" ]
You could make `scale` generic. Like ``` public class Matrix<T> { // ... public T scale(int scaleFactor) { // Some code that returns a scaled version of the matrix } } ``` then your sub-classes could `extend Matrix<Vector>`. Note that it would be difficult to practically implement `scale` in `Matrix`; it might be better to make it `abstract` like ``` public abstract class Matrix<T> { // ... public abstract T scale(int scaleFactor); } ``` Then your sub-classes *must* provide an implementation.
You're sort of hitting one of the limits of generic types in Java, and I don't see an easy way out without re-defining `public Matrix scale(int scaleFactor)` in the subclass and then re-defining the return type: `public Vector scale(int scaleFactor)`.
27,777,205
Suppose I have a matrix ``` A=[1 2 3] ``` which is row matrix. Not I want to do it "page" matrix, i.e. align elements along 3rd dimension. I noticed, that the following ``` A=permute(A,[3 1 2]) ``` works, while the following ``` A=permute(A,[3 2 1]) ``` does not. Why?
2015/01/05
[ "https://Stackoverflow.com/questions/27777205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1171620/" ]
If `Vector extends Matrix`, you can: ``` public class Matrix { public Matrix scale(int scaleFactor) { ... return Matrix ... } } public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { // <-- return sub type here! ... return Vector ... } } ``` The rule that overridden methods must have the same type has been weakened in Java 5: You can now use subtypes as well to make overridden methods "more specific." The advantage of this approach over generics is that it's clean, no (implicit) casting is required and it exactly limits the types without any generics magic. **[EDIT]** Now `Vector` is just a special kind of `Matrix` (the 1-column/row type) which means that the code in `scale()` is the same. Unfortunately, this doesn't work: ``` public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { // <-- return sub type here! return (Vector) super.scale(scaleFactor); } } ``` since you can't cast `Matrix` instances into a `Vector`. The solution is to move the scale code into a helper method: ``` public class Matrix { protected void doScale(int scaleFactor) { ... original scale() code here... } public Matrix scale(int scaleFactor) { doScale(scaleFactor); return this; } } public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { doScale(scaleFactor); return this; } } ``` If the class is immutable (and it probably should be), then you need to use the copy constructor, of course: ``` public Matrix scale(int scaleFactor) { Matrix result = new Matrix(this); result.doScale(scaleFactor); return result; } ```
An easy thing you can do is to make the method generic: ``` public <T extends Matrix> T scale(int scaleFactor) { ... } ``` When using it, you need to provide the generic type. For example, if you want a `Vector` to be returned, you have to do: ``` Matrix something = .... Vector result = something.<Vector>scale(...); ``` Even better option is to make the `scale` method `abstract`: ``` public <T extends Matrix> T scale(int scaleFactor); ``` Then, in all subclasses of `Matrix`, you'd be forced to implement the method with a return-type that is a sub-type of `Matrix`.
27,777,205
Suppose I have a matrix ``` A=[1 2 3] ``` which is row matrix. Not I want to do it "page" matrix, i.e. align elements along 3rd dimension. I noticed, that the following ``` A=permute(A,[3 1 2]) ``` works, while the following ``` A=permute(A,[3 2 1]) ``` does not. Why?
2015/01/05
[ "https://Stackoverflow.com/questions/27777205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1171620/" ]
An easy thing you can do is to make the method generic: ``` public <T extends Matrix> T scale(int scaleFactor) { ... } ``` When using it, you need to provide the generic type. For example, if you want a `Vector` to be returned, you have to do: ``` Matrix something = .... Vector result = something.<Vector>scale(...); ``` Even better option is to make the `scale` method `abstract`: ``` public <T extends Matrix> T scale(int scaleFactor); ``` Then, in all subclasses of `Matrix`, you'd be forced to implement the method with a return-type that is a sub-type of `Matrix`.
You're sort of hitting one of the limits of generic types in Java, and I don't see an easy way out without re-defining `public Matrix scale(int scaleFactor)` in the subclass and then re-defining the return type: `public Vector scale(int scaleFactor)`.
27,777,205
Suppose I have a matrix ``` A=[1 2 3] ``` which is row matrix. Not I want to do it "page" matrix, i.e. align elements along 3rd dimension. I noticed, that the following ``` A=permute(A,[3 1 2]) ``` works, while the following ``` A=permute(A,[3 2 1]) ``` does not. Why?
2015/01/05
[ "https://Stackoverflow.com/questions/27777205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1171620/" ]
If `Vector extends Matrix`, you can: ``` public class Matrix { public Matrix scale(int scaleFactor) { ... return Matrix ... } } public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { // <-- return sub type here! ... return Vector ... } } ``` The rule that overridden methods must have the same type has been weakened in Java 5: You can now use subtypes as well to make overridden methods "more specific." The advantage of this approach over generics is that it's clean, no (implicit) casting is required and it exactly limits the types without any generics magic. **[EDIT]** Now `Vector` is just a special kind of `Matrix` (the 1-column/row type) which means that the code in `scale()` is the same. Unfortunately, this doesn't work: ``` public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { // <-- return sub type here! return (Vector) super.scale(scaleFactor); } } ``` since you can't cast `Matrix` instances into a `Vector`. The solution is to move the scale code into a helper method: ``` public class Matrix { protected void doScale(int scaleFactor) { ... original scale() code here... } public Matrix scale(int scaleFactor) { doScale(scaleFactor); return this; } } public class Vector extends Matrix { ... @Override public Vector scale(int scaleFactor) { doScale(scaleFactor); return this; } } ``` If the class is immutable (and it probably should be), then you need to use the copy constructor, of course: ``` public Matrix scale(int scaleFactor) { Matrix result = new Matrix(this); result.doScale(scaleFactor); return result; } ```
You're sort of hitting one of the limits of generic types in Java, and I don't see an easy way out without re-defining `public Matrix scale(int scaleFactor)` in the subclass and then re-defining the return type: `public Vector scale(int scaleFactor)`.
70,817
I am new to the finance world, and I keep hearing *fund* and *portfolio*. What is the meaning of these words and how are they related? Can someone please explain with examples? Is there any difference between them?
2016/09/16
[ "https://money.stackexchange.com/questions/70817", "https://money.stackexchange.com", "https://money.stackexchange.com/users/48601/" ]
**A "Fund" is generally speaking a collection of similar financial products, which are bundled into a single investment**, so that you as an individual can buy a portion of the Fund rather than buying 50 portions of various products. e.g. a "Bond Fund" may be a collection of various corporate bonds that are bundled together. The performance of the Fund would be the aggregate of each individual item. Generally speaking Funds are like pre-packaged "diversification". Rather than take time (and fees) to buy 50 different stocks on the same stock index, you could buy an "Index Fund" which represents the values of all of those stocks. **A "Portfolio" is your individual package of investments**. ie: the 20k you have in bonds + the 5k you have in shares, + the 50k you have in "Funds" + the 100k rental property you own. You might split the definition further buy saying "My 401(k) portfolio & my taxable portfolio & my real estate portfolio"(etc.), to denote how those items are invested. The implication of "Portfolio" is that you have considered how all of your investments work together; ie: your 5k in stocks is not so risky, because it is only 5k out of your entire 185k portfolio, which includes some low risk bonds and funds. **Another way of looking at it, is that a Fund is a special type of Portfolio.** That is, a Fund is a portfolio, that someone will sell to someone else (see Daniel's answer below). **For example**: Imagine you had $5,000 invested in IBM shares, and also had $5,000 invested in Apple shares. Call this your portfolio. But you also want to sell your portfolio, so let's also call it a 'fund'. Then you sell half of your 'fund' to a friend. So your friend (let's call him Maurice) pays you $4,000, to invest in your 'Fund'. Maurice gives you $4k, and in return, you given him a note that says "Maurice owns 40% of atp9's Fund". The following month, IBM pays you $100 in dividends. But, Maurice owns 40% of those dividends. So you give him a cheque for $40 (some funds automatically reinvest dividends for their clients instead of paying them out immediately). Then you sell your Apple shares for $6,000 (a gain of $1,000 since you bought them). But Maurice owns 40% of that 6k, so you give him $2,400 (or perhaps, instead of giving him the money immediately, you reinvest it within the fund, and buy $6k of Microsoft shares). Why would you set up this Fund? Because Maurice will pay you a fee equal to, let's say, 1% of his total investment. Your job is now to invest the money in the Fund, in a way that aligns with what you told Maurice when he signed the contract. ie: maybe it's a tech fund, and you can only invest in big Tech companies. Maybe it's an Index fund, and your investment needs to exactly match a specific portion of the New York Stock Exchange. Maybe it's a bond fund, and you can only invest in corporate bonds. **So to reiterate**, a *portfolio* is a collection of investments (think of an artist's portfolio, being a collection of their work). Usually, people refer to their own 'portfolio', of personal investments. A *fund* is someone's portfolio, that other people can invest in. This allows an individual investor to give some of their decision making over to a Fund manager. In addition to relying on expertise of others, this allows the investor to save on transaction costs, because they can have a well-diversified portfolio (see what I did there?) while only buying into one or a few funds.
A fund *is* a portfolio, in that it is a collection, so the term is interchangeable for the most part. Funds are made up of a combination of equities positions (i.e., stocks, bonds, etc.) plus some amount of un-invested cash. Most of the time, when people are talking about a "fund", they are describing what is really an investment strategy. In other words, an example would be a "Far East Agressive" fund (just a made up name for illustration here), which focuses on investment opportunities in the Far East that have a higher level of risk than most other investments, thus they provide better returns for the investors. The "portfolio" part of that is what the stocks are that the fund has purchased and is holding on behalf of its investors. Other funds focus on municipal bonds or government bonds, and the list goes on. I hope this helps. Good luck!
70,817
I am new to the finance world, and I keep hearing *fund* and *portfolio*. What is the meaning of these words and how are they related? Can someone please explain with examples? Is there any difference between them?
2016/09/16
[ "https://money.stackexchange.com/questions/70817", "https://money.stackexchange.com", "https://money.stackexchange.com/users/48601/" ]
**A "Fund" is generally speaking a collection of similar financial products, which are bundled into a single investment**, so that you as an individual can buy a portion of the Fund rather than buying 50 portions of various products. e.g. a "Bond Fund" may be a collection of various corporate bonds that are bundled together. The performance of the Fund would be the aggregate of each individual item. Generally speaking Funds are like pre-packaged "diversification". Rather than take time (and fees) to buy 50 different stocks on the same stock index, you could buy an "Index Fund" which represents the values of all of those stocks. **A "Portfolio" is your individual package of investments**. ie: the 20k you have in bonds + the 5k you have in shares, + the 50k you have in "Funds" + the 100k rental property you own. You might split the definition further buy saying "My 401(k) portfolio & my taxable portfolio & my real estate portfolio"(etc.), to denote how those items are invested. The implication of "Portfolio" is that you have considered how all of your investments work together; ie: your 5k in stocks is not so risky, because it is only 5k out of your entire 185k portfolio, which includes some low risk bonds and funds. **Another way of looking at it, is that a Fund is a special type of Portfolio.** That is, a Fund is a portfolio, that someone will sell to someone else (see Daniel's answer below). **For example**: Imagine you had $5,000 invested in IBM shares, and also had $5,000 invested in Apple shares. Call this your portfolio. But you also want to sell your portfolio, so let's also call it a 'fund'. Then you sell half of your 'fund' to a friend. So your friend (let's call him Maurice) pays you $4,000, to invest in your 'Fund'. Maurice gives you $4k, and in return, you given him a note that says "Maurice owns 40% of atp9's Fund". The following month, IBM pays you $100 in dividends. But, Maurice owns 40% of those dividends. So you give him a cheque for $40 (some funds automatically reinvest dividends for their clients instead of paying them out immediately). Then you sell your Apple shares for $6,000 (a gain of $1,000 since you bought them). But Maurice owns 40% of that 6k, so you give him $2,400 (or perhaps, instead of giving him the money immediately, you reinvest it within the fund, and buy $6k of Microsoft shares). Why would you set up this Fund? Because Maurice will pay you a fee equal to, let's say, 1% of his total investment. Your job is now to invest the money in the Fund, in a way that aligns with what you told Maurice when he signed the contract. ie: maybe it's a tech fund, and you can only invest in big Tech companies. Maybe it's an Index fund, and your investment needs to exactly match a specific portion of the New York Stock Exchange. Maybe it's a bond fund, and you can only invest in corporate bonds. **So to reiterate**, a *portfolio* is a collection of investments (think of an artist's portfolio, being a collection of their work). Usually, people refer to their own 'portfolio', of personal investments. A *fund* is someone's portfolio, that other people can invest in. This allows an individual investor to give some of their decision making over to a Fund manager. In addition to relying on expertise of others, this allows the investor to save on transaction costs, because they can have a well-diversified portfolio (see what I did there?) while only buying into one or a few funds.
Buy-and-Hold Portfolios vs Funds ================================ Oddly enough, in the USA, there are enough cost and tax savings between buy-and-hold of a static portfolio and buying into a fund that a few brokerages have sprung up around the concept, such as [FolioFN](http://www.foliofn.com), to make it easier for small investors to manage numerous small holdings via fractional shares and no commission window trades. Cost Differences ---------------- A static buy-and-hold portfolio of stocks can be had for a few dollars per trade. Buying into a fund involves various annual and one time fees that are quoted as percentages of the investment. Even 1-2% can be a lot, especially if it is every year. Tax Differences --------------- Typically, a US mutual fund must send out a 1099 tax form to each investor, stating that investors share of the dividends and capital gains for each year. The true impact of this is not obvious until you get a tax bill for gains that you did not enjoy, which can happen when you buy into a fund late in the year that has realized capital gains. What fund investors sometimes fail to appreciate is that they are taxed both on their own holding period of fund shares *and* the fund's capital gains distributions determined by the *fund's* holding period of its investments. For example, if ABC tech fund bought Google stock several years ago for $100/share, and sold it for $500/share in the same year you bought into the ABC fund, then you will receive a "capital gains distribution" on your 1099 that will include some dollar amount, which is considered your share of that long-term profit for tax purposes. The amount is not customized for your holding period, capital gains are distributed pro-rata among all current fund shareholders as of the ex-distribution date. Morningstar tracks this as [Potential Capital Gains Exposure](http://www.morningstar.com/InvGlossary/potential_capital_gains_exposure.aspx) and so there is a way to check this possibility before investing. Funds who have unsold losers in their portfolio are also affected by these same rules, have been called "free rides" because those funds, if they find some winners, will have losers that they can sell simultaneously with the winners to remain tax neutral. See ["On the Lookout for Tax Traps and Free Riders", Morningstar, pdf](http://advisor.morningstar.com/enterprise/images/On%20The%20Lookout%20for%20Tax%20Traps%20and%20Free%20Rides.pdf) In contrast, buying-and-holding a portfolio does not attract any capital gains taxes until the stocks in the portfolio are sold at a profit. Active Management ----------------- A fund often is actively managed. That is, experts will alter the portfolio from time to time or advise the fund to buy or sell particular investments. Note however, that even the experts are required to tell you that "past performance is no guarantee of future results."
70,817
I am new to the finance world, and I keep hearing *fund* and *portfolio*. What is the meaning of these words and how are they related? Can someone please explain with examples? Is there any difference between them?
2016/09/16
[ "https://money.stackexchange.com/questions/70817", "https://money.stackexchange.com", "https://money.stackexchange.com/users/48601/" ]
A fund *is* a portfolio, in that it is a collection, so the term is interchangeable for the most part. Funds are made up of a combination of equities positions (i.e., stocks, bonds, etc.) plus some amount of un-invested cash. Most of the time, when people are talking about a "fund", they are describing what is really an investment strategy. In other words, an example would be a "Far East Agressive" fund (just a made up name for illustration here), which focuses on investment opportunities in the Far East that have a higher level of risk than most other investments, thus they provide better returns for the investors. The "portfolio" part of that is what the stocks are that the fund has purchased and is holding on behalf of its investors. Other funds focus on municipal bonds or government bonds, and the list goes on. I hope this helps. Good luck!
Buy-and-Hold Portfolios vs Funds ================================ Oddly enough, in the USA, there are enough cost and tax savings between buy-and-hold of a static portfolio and buying into a fund that a few brokerages have sprung up around the concept, such as [FolioFN](http://www.foliofn.com), to make it easier for small investors to manage numerous small holdings via fractional shares and no commission window trades. Cost Differences ---------------- A static buy-and-hold portfolio of stocks can be had for a few dollars per trade. Buying into a fund involves various annual and one time fees that are quoted as percentages of the investment. Even 1-2% can be a lot, especially if it is every year. Tax Differences --------------- Typically, a US mutual fund must send out a 1099 tax form to each investor, stating that investors share of the dividends and capital gains for each year. The true impact of this is not obvious until you get a tax bill for gains that you did not enjoy, which can happen when you buy into a fund late in the year that has realized capital gains. What fund investors sometimes fail to appreciate is that they are taxed both on their own holding period of fund shares *and* the fund's capital gains distributions determined by the *fund's* holding period of its investments. For example, if ABC tech fund bought Google stock several years ago for $100/share, and sold it for $500/share in the same year you bought into the ABC fund, then you will receive a "capital gains distribution" on your 1099 that will include some dollar amount, which is considered your share of that long-term profit for tax purposes. The amount is not customized for your holding period, capital gains are distributed pro-rata among all current fund shareholders as of the ex-distribution date. Morningstar tracks this as [Potential Capital Gains Exposure](http://www.morningstar.com/InvGlossary/potential_capital_gains_exposure.aspx) and so there is a way to check this possibility before investing. Funds who have unsold losers in their portfolio are also affected by these same rules, have been called "free rides" because those funds, if they find some winners, will have losers that they can sell simultaneously with the winners to remain tax neutral. See ["On the Lookout for Tax Traps and Free Riders", Morningstar, pdf](http://advisor.morningstar.com/enterprise/images/On%20The%20Lookout%20for%20Tax%20Traps%20and%20Free%20Rides.pdf) In contrast, buying-and-holding a portfolio does not attract any capital gains taxes until the stocks in the portfolio are sold at a profit. Active Management ----------------- A fund often is actively managed. That is, experts will alter the portfolio from time to time or advise the fund to buy or sell particular investments. Note however, that even the experts are required to tell you that "past performance is no guarantee of future results."
21,900,159
I've been doing some research about draggable & resizable plugins from jQuery but encountered an issue recently. I've tried to replicate this situation on the following fiddle: ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: 'parent', grid: 12, handles: { 'n': '#ngrip', 's': '#egrip' }, start: function (e, ui) { console.log('resizing started'); }, ``` }); Here's [a fiddle](http://jsfiddle.net/flaszer/M2umR/2/). The resizable south handle doesn't work at all, also the strange thing happens to the north handle -> it decreases size of my div an pushes it rapidly to the right. What am I doing wrong?
2014/02/20
[ "https://Stackoverflow.com/questions/21900159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2305130/" ]
**Your code:** ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: 'parent', grid: 12, handles: { 'n': '#ngrip', 's': '#egrip' }, start: function (e, ui) { console.log('resizing started'); }, }); ``` **Code Needed** ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container' }).resizable({ containment: 'parent', grid: [ 120, 12 ], handles: "n, e, s, w" }); ``` 1) remove trailing comma in the end 2) make handles as `handles: "n, e, s, w"` but there is still some bug after this you can only resize after you have dragged from once and resizing work precisely from a pixel maybe because you are using custom resize handlers, I am not sure. Read the [documentation](http://api.jqueryui.com/resizable/) for more help. **New Code** ``` $('.event').draggable({ cursor: 'move', containment: '#container' }).resizable({ containment: '#container', handles:"n, e, s, w", start: function (e, ui) { console.log('resizing started'); } }); ```
Try this code. Jquery ``` $(document).ready(function (){ $('.blue').resizable(); $(".blue").draggable(); }); ``` Html ``` <div id="container"> <div class="column"> <div class="event blue"> </div> </div> <div class="column"> <div class="event dark-blue blue" id="event" style="margin-top:3px"> </div> </div> </div> ``` Attach jquery files ``` <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/> ```
21,900,159
I've been doing some research about draggable & resizable plugins from jQuery but encountered an issue recently. I've tried to replicate this situation on the following fiddle: ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: 'parent', grid: 12, handles: { 'n': '#ngrip', 's': '#egrip' }, start: function (e, ui) { console.log('resizing started'); }, ``` }); Here's [a fiddle](http://jsfiddle.net/flaszer/M2umR/2/). The resizable south handle doesn't work at all, also the strange thing happens to the north handle -> it decreases size of my div an pushes it rapidly to the right. What am I doing wrong?
2014/02/20
[ "https://Stackoverflow.com/questions/21900159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2305130/" ]
**Your code:** ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: 'parent', grid: 12, handles: { 'n': '#ngrip', 's': '#egrip' }, start: function (e, ui) { console.log('resizing started'); }, }); ``` **Code Needed** ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container' }).resizable({ containment: 'parent', grid: [ 120, 12 ], handles: "n, e, s, w" }); ``` 1) remove trailing comma in the end 2) make handles as `handles: "n, e, s, w"` but there is still some bug after this you can only resize after you have dragged from once and resizing work precisely from a pixel maybe because you are using custom resize handlers, I am not sure. Read the [documentation](http://api.jqueryui.com/resizable/) for more help. **New Code** ``` $('.event').draggable({ cursor: 'move', containment: '#container' }).resizable({ containment: '#container', handles:"n, e, s, w", start: function (e, ui) { console.log('resizing started'); } }); ```
Try this code i think this will helpful you Html: ``` <div id="container"> <div class="column"> <div class="event blue"> <div class="ui-resizable-handle ui-resizable-n" id="ngrip"></div> <div class="ui-resizable-handle ui-resizable-s" id="sgrip"></div> </div> <div class="column"> <div class="event dark-blue" id="event" style="margin-top:3px"> <div class="ui-resizable-handle ui-resizable-n" id="ngrip"></div> <div class="ui-resizable-handle ui-resizable-s" id="sgrip"></div> </div> </div> </div> </div> ``` jquery: ``` $(document).ready(function (){ $('.blue').resizable({ handles: { 's': '#sgrip', 'w': '#wgrip' } }); $('.dark-blue').resizable({ handles: { 's': '#sgrip', 'w': '#wgrip' } }); $(".column").draggable(); }); ```
21,900,159
I've been doing some research about draggable & resizable plugins from jQuery but encountered an issue recently. I've tried to replicate this situation on the following fiddle: ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: 'parent', grid: 12, handles: { 'n': '#ngrip', 's': '#egrip' }, start: function (e, ui) { console.log('resizing started'); }, ``` }); Here's [a fiddle](http://jsfiddle.net/flaszer/M2umR/2/). The resizable south handle doesn't work at all, also the strange thing happens to the north handle -> it decreases size of my div an pushes it rapidly to the right. What am I doing wrong?
2014/02/20
[ "https://Stackoverflow.com/questions/21900159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2305130/" ]
**Your code:** ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: 'parent', grid: 12, handles: { 'n': '#ngrip', 's': '#egrip' }, start: function (e, ui) { console.log('resizing started'); }, }); ``` **Code Needed** ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container' }).resizable({ containment: 'parent', grid: [ 120, 12 ], handles: "n, e, s, w" }); ``` 1) remove trailing comma in the end 2) make handles as `handles: "n, e, s, w"` but there is still some bug after this you can only resize after you have dragged from once and resizing work precisely from a pixel maybe because you are using custom resize handlers, I am not sure. Read the [documentation](http://api.jqueryui.com/resizable/) for more help. **New Code** ``` $('.event').draggable({ cursor: 'move', containment: '#container' }).resizable({ containment: '#container', handles:"n, e, s, w", start: function (e, ui) { console.log('resizing started'); } }); ```
Fix it . Please review it . ``` $('.event').draggable({ grid: [120, 12], cursor: 'move', containment: '#container', start: function (event, ui) { console.log("event dragging started"); } }).resizable({ containment: '#container', grid: 12, handles: { 'n': '#ngrip', 's': '#sgrip' }, start: function (e, ui) { console.log('resizing started'); }, }); ``` change the resizable containment from `parent` to `#container`, and south handle name from `#egrip` to `#sgrip`. nothing else. check fiddle [here](http://jsfiddle.net/malaikuangren/sdZtL/1/).
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
There is now a library dedicated this exact problem [url-normalize](https://pypi.org/project/url-normalize) It does more than just normalising the path as per the docs: > > URI Normalization function: > > > 1. Take care of IDN domains. > 2. Always provide the URI scheme in lowercase characters. > 3. Always provide the host, if any, in lowercase characters. > 4. Only perform percent-encoding where it is essential. > 5. Always use uppercase A-through-F characters when percent-encoding. > 6. Prevent dot-segments appearing in non-relative URI paths. > 7. For schemes that define a default authority, use an empty authority if the default is desired. > 8. For schemes that define an empty path to be equivalent to a path of "/", use "/". > 9. For schemes that define a port, use an empty port if the default is desired > 10. All portions of the URI must be utf-8 encoded NFC from Unicode strings > > > Here is an example: ``` from url_normalize import url_normalize url = 'http://google.com:80/a/../' print(url_normalize(url)) ``` Which gives: ``` http://google.com/ ```
I used @Antony's answer above and used the [url-normalize](https://pypi.org/project/url-normalize) library, but it has one bug that is not currently fixed: When a URL is sent without a scheme, is accidentally sets it to HTTPS. I wrote a function that wraps and fixes it by setting it to HTTP instead: ``` from url_normalize import url_normalize from urllib.parse import urlparse def parse_url(url): return_val = url_normalize(url) wrong_default_prefix = "https://" new_default_prefix = "http://" # If the URL came with no scheme and the normalize function mistakenly # set it to the HTTPS protocol, then fix it and set it to HTTP if urlparse(url).scheme.strip() == '' and return_val.startswith(wrong_default_prefix): return_val = new_default_prefix + return_val[len(wrong_default_prefix):] return return_val ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
This is what I use and it's worked so far. You can get urlnorm from pip. Notice that I sort the query parameters. I've found this to be essential. ``` from urlparse import urlsplit, urlunsplit, parse_qsl from urllib import urlencode import urlnorm def canonizeurl(url): split = urlsplit(urlnorm.norm(url)) path = split[2].split(' ')[0] while path.startswith('/..'): path = path[3:] while path.endswith('%20'): path = path[:-3] qs = urlencode(sorted(parse_qsl(split.query))) return urlunsplit((split.scheme, split.netloc, path, qs, '')) ```
I used @Antony's answer above and used the [url-normalize](https://pypi.org/project/url-normalize) library, but it has one bug that is not currently fixed: When a URL is sent without a scheme, is accidentally sets it to HTTPS. I wrote a function that wraps and fixes it by setting it to HTTP instead: ``` from url_normalize import url_normalize from urllib.parse import urlparse def parse_url(url): return_val = url_normalize(url) wrong_default_prefix = "https://" new_default_prefix = "http://" # If the URL came with no scheme and the normalize function mistakenly # set it to the HTTPS protocol, then fix it and set it to HTTP if urlparse(url).scheme.strip() == '' and return_val.startswith(wrong_default_prefix): return_val = new_default_prefix + return_val[len(wrong_default_prefix):] return return_val ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
This is what I use and it's worked so far. You can get urlnorm from pip. Notice that I sort the query parameters. I've found this to be essential. ``` from urlparse import urlsplit, urlunsplit, parse_qsl from urllib import urlencode import urlnorm def canonizeurl(url): split = urlsplit(urlnorm.norm(url)) path = split[2].split(' ')[0] while path.startswith('/..'): path = path[3:] while path.endswith('%20'): path = path[:-3] qs = urlencode(sorted(parse_qsl(split.query))) return urlunsplit((split.scheme, split.netloc, path, qs, '')) ```
There is now a library dedicated this exact problem [url-normalize](https://pypi.org/project/url-normalize) It does more than just normalising the path as per the docs: > > URI Normalization function: > > > 1. Take care of IDN domains. > 2. Always provide the URI scheme in lowercase characters. > 3. Always provide the host, if any, in lowercase characters. > 4. Only perform percent-encoding where it is essential. > 5. Always use uppercase A-through-F characters when percent-encoding. > 6. Prevent dot-segments appearing in non-relative URI paths. > 7. For schemes that define a default authority, use an empty authority if the default is desired. > 8. For schemes that define an empty path to be equivalent to a path of "/", use "/". > 9. For schemes that define a port, use an empty port if the default is desired > 10. All portions of the URI must be utf-8 encoded NFC from Unicode strings > > > Here is an example: ``` from url_normalize import url_normalize url = 'http://google.com:80/a/../' print(url_normalize(url)) ``` Which gives: ``` http://google.com/ ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
How about this: ``` In [1]: from urllib.parse import urljoin In [2]: urljoin('http://example.com/a/b/c/../', '.') Out[2]: 'http://example.com/a/b/' ``` Inspired by answers to [this question](https://stackoverflow.com/questions/2131290/how-can-i-normalize-collapse-paths-or-urls-in-python-in-os-independent-way). It doesn't normalize ports, but it should be simple to whip up a function that does.
I used @Antony's answer above and used the [url-normalize](https://pypi.org/project/url-normalize) library, but it has one bug that is not currently fixed: When a URL is sent without a scheme, is accidentally sets it to HTTPS. I wrote a function that wraps and fixes it by setting it to HTTP instead: ``` from url_normalize import url_normalize from urllib.parse import urlparse def parse_url(url): return_val = url_normalize(url) wrong_default_prefix = "https://" new_default_prefix = "http://" # If the URL came with no scheme and the normalize function mistakenly # set it to the HTTPS protocol, then fix it and set it to HTTP if urlparse(url).scheme.strip() == '' and return_val.startswith(wrong_default_prefix): return_val = new_default_prefix + return_val[len(wrong_default_prefix):] return return_val ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
Old (deprecated) answer ----------------------- The *[no longer maintained]* [urltools](https://github.com/erazor85/urltools) module normalizes multiple slashes, `.` and `..` components without messing up the double slash in `http://`. Once you do ~~`pip install urltools`~~ *(this does not work anymore as the author renamed the repo)* the usage is as follows: ```python print urltools.normalize('http://example.com:80/a////b/../c') >>> 'http://example.com/a/c' ``` While the module is not pip-installable anymore it is [a single file](https://github.com/erazor85/urltools/blob/master/urltools/urltools.py) so you can re-use bits of it. Updated answer for Python3 -------------------------- For Python3 consider using [`urljoin`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin) from the [`urllib.urlparse`](https://docs.python.org/3/library/urllib.parse.html) module. ```py from urllib.parse import urljoin urljoin('https://stackoverflow.com/questions/10584861/', '../dinsdale') # Out[17]: 'https://stackoverflow.com/questions/dinsdale' ```
There is now a library dedicated this exact problem [url-normalize](https://pypi.org/project/url-normalize) It does more than just normalising the path as per the docs: > > URI Normalization function: > > > 1. Take care of IDN domains. > 2. Always provide the URI scheme in lowercase characters. > 3. Always provide the host, if any, in lowercase characters. > 4. Only perform percent-encoding where it is essential. > 5. Always use uppercase A-through-F characters when percent-encoding. > 6. Prevent dot-segments appearing in non-relative URI paths. > 7. For schemes that define a default authority, use an empty authority if the default is desired. > 8. For schemes that define an empty path to be equivalent to a path of "/", use "/". > 9. For schemes that define a port, use an empty port if the default is desired > 10. All portions of the URI must be utf-8 encoded NFC from Unicode strings > > > Here is an example: ``` from url_normalize import url_normalize url = 'http://google.com:80/a/../' print(url_normalize(url)) ``` Which gives: ``` http://google.com/ ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
Following the [good start](https://stackoverflow.com/a/10587428/1018226), I composed a method that fits most of the cases commonly found in the web. ``` def urlnorm(base, link=''): '''Normalizes an URL or a link relative to a base url. URLs that point to the same resource will return the same string.''' new = urlparse(urljoin(base, url).lower()) return urlunsplit(( new.scheme, (new.port == None) and (new.hostname + ":80") or new.netloc, new.path, new.query, '')) ```
I used @Antony's answer above and used the [url-normalize](https://pypi.org/project/url-normalize) library, but it has one bug that is not currently fixed: When a URL is sent without a scheme, is accidentally sets it to HTTPS. I wrote a function that wraps and fixes it by setting it to HTTP instead: ``` from url_normalize import url_normalize from urllib.parse import urlparse def parse_url(url): return_val = url_normalize(url) wrong_default_prefix = "https://" new_default_prefix = "http://" # If the URL came with no scheme and the normalize function mistakenly # set it to the HTTPS protocol, then fix it and set it to HTTP if urlparse(url).scheme.strip() == '' and return_val.startswith(wrong_default_prefix): return_val = new_default_prefix + return_val[len(wrong_default_prefix):] return return_val ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
Old (deprecated) answer ----------------------- The *[no longer maintained]* [urltools](https://github.com/erazor85/urltools) module normalizes multiple slashes, `.` and `..` components without messing up the double slash in `http://`. Once you do ~~`pip install urltools`~~ *(this does not work anymore as the author renamed the repo)* the usage is as follows: ```python print urltools.normalize('http://example.com:80/a////b/../c') >>> 'http://example.com/a/c' ``` While the module is not pip-installable anymore it is [a single file](https://github.com/erazor85/urltools/blob/master/urltools/urltools.py) so you can re-use bits of it. Updated answer for Python3 -------------------------- For Python3 consider using [`urljoin`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin) from the [`urllib.urlparse`](https://docs.python.org/3/library/urllib.parse.html) module. ```py from urllib.parse import urljoin urljoin('https://stackoverflow.com/questions/10584861/', '../dinsdale') # Out[17]: 'https://stackoverflow.com/questions/dinsdale' ```
I used @Antony's answer above and used the [url-normalize](https://pypi.org/project/url-normalize) library, but it has one bug that is not currently fixed: When a URL is sent without a scheme, is accidentally sets it to HTTPS. I wrote a function that wraps and fixes it by setting it to HTTP instead: ``` from url_normalize import url_normalize from urllib.parse import urlparse def parse_url(url): return_val = url_normalize(url) wrong_default_prefix = "https://" new_default_prefix = "http://" # If the URL came with no scheme and the normalize function mistakenly # set it to the HTTPS protocol, then fix it and set it to HTTP if urlparse(url).scheme.strip() == '' and return_val.startswith(wrong_default_prefix): return_val = new_default_prefix + return_val[len(wrong_default_prefix):] return return_val ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
How about this: ``` In [1]: from urllib.parse import urljoin In [2]: urljoin('http://example.com/a/b/c/../', '.') Out[2]: 'http://example.com/a/b/' ``` Inspired by answers to [this question](https://stackoverflow.com/questions/2131290/how-can-i-normalize-collapse-paths-or-urls-in-python-in-os-independent-way). It doesn't normalize ports, but it should be simple to whip up a function that does.
Following the [good start](https://stackoverflow.com/a/10587428/1018226), I composed a method that fits most of the cases commonly found in the web. ``` def urlnorm(base, link=''): '''Normalizes an URL or a link relative to a base url. URLs that point to the same resource will return the same string.''' new = urlparse(urljoin(base, url).lower()) return urlunsplit(( new.scheme, (new.port == None) and (new.hostname + ":80") or new.netloc, new.path, new.query, '')) ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
Old (deprecated) answer ----------------------- The *[no longer maintained]* [urltools](https://github.com/erazor85/urltools) module normalizes multiple slashes, `.` and `..` components without messing up the double slash in `http://`. Once you do ~~`pip install urltools`~~ *(this does not work anymore as the author renamed the repo)* the usage is as follows: ```python print urltools.normalize('http://example.com:80/a////b/../c') >>> 'http://example.com/a/c' ``` While the module is not pip-installable anymore it is [a single file](https://github.com/erazor85/urltools/blob/master/urltools/urltools.py) so you can re-use bits of it. Updated answer for Python3 -------------------------- For Python3 consider using [`urljoin`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin) from the [`urllib.urlparse`](https://docs.python.org/3/library/urllib.parse.html) module. ```py from urllib.parse import urljoin urljoin('https://stackoverflow.com/questions/10584861/', '../dinsdale') # Out[17]: 'https://stackoverflow.com/questions/dinsdale' ```
Following the [good start](https://stackoverflow.com/a/10587428/1018226), I composed a method that fits most of the cases commonly found in the web. ``` def urlnorm(base, link=''): '''Normalizes an URL or a link relative to a base url. URLs that point to the same resource will return the same string.''' new = urlparse(urljoin(base, url).lower()) return urlunsplit(( new.scheme, (new.port == None) and (new.hostname + ":80") or new.netloc, new.path, new.query, '')) ```
10,584,861
I am searching for a library function to normalize a URL in Python, that is to remove "./" or "../" parts in the path, or add a default port or escape special characters and so on. The result should be a string that is unique for two URLs pointing to the same web page. For example `http://google.com` and `http://google.com:80/a/../` shall return the same result. I would prefer Python 3 and already looked through the `urllib` module. It offers functions to split URLs but nothing to canonicalize them. Java has the `URI.normalize()` function that does a similar thing (though it does not consider the default port 80 equal to no given port), but is there something like this is python?
2012/05/14
[ "https://Stackoverflow.com/questions/10584861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1018226/" ]
This is what I use and it's worked so far. You can get urlnorm from pip. Notice that I sort the query parameters. I've found this to be essential. ``` from urlparse import urlsplit, urlunsplit, parse_qsl from urllib import urlencode import urlnorm def canonizeurl(url): split = urlsplit(urlnorm.norm(url)) path = split[2].split(' ')[0] while path.startswith('/..'): path = path[3:] while path.endswith('%20'): path = path[:-3] qs = urlencode(sorted(parse_qsl(split.query))) return urlunsplit((split.scheme, split.netloc, path, qs, '')) ```
Following the [good start](https://stackoverflow.com/a/10587428/1018226), I composed a method that fits most of the cases commonly found in the web. ``` def urlnorm(base, link=''): '''Normalizes an URL or a link relative to a base url. URLs that point to the same resource will return the same string.''' new = urlparse(urljoin(base, url).lower()) return urlunsplit(( new.scheme, (new.port == None) and (new.hostname + ":80") or new.netloc, new.path, new.query, '')) ```
15,177,105
I have a simple node.js server testing the connect-redis module as a session store. It all works but I've noticed that I get a new sess: key in redis on every single request. I expected only one key since there is only one session. ![redis-cli showing multiple sess: keys](https://i.stack.imgur.com/40ZZ2.png) Here's my code : ``` var connect = require('connect'); var util = require("util"); var RedisStore = require("connect-redis")(connect); var http = require('http'); var app = connect() .use(connect.cookieParser('keyboard cat')) .use(connect.query()) .use(connect.session( { secret:"elms", store:new RedisStore({prefix:'sid_'}), cookie:{maxAge:60000, secure:false} })) .use(function(req, res, next) { var sess = req.session; if (sess.views) { res.setHeader('Content-Type', 'text/html'); res.write("<p>" + util.inspect(req.cookies) + "</p>"); sess.basket = sess.basket || {book1:0, book2:0, book3:0}; if(req.query.buyBook1) {sess.basket.book1 ++;} if(req.query.buyBook2) {sess.basket.book2 ++;} if(req.query.buyBook3) {sess.basket.book3 ++;} if(req.query.expiresession) { sess.cookie.maxAge = 0; } res.write('<p>views: ' + sess.views + '</p>'); res.write('<ul>\ <li>book1 ' + sess.basket.book1 + ' - <a href="/?buyBook1=true">Add</a></li>\ <li>book2 ' + sess.basket.book2 + ' - <a href="/?buyBook2=true">Add</a></li>\ <li>book3 ' + sess.basket.book3 + ' - <a href="/?buyBook3=true">Add</a></li>\ </ul>\ <a href="/?expiresession=true">Expire session</a>'); res.write('<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>'); res.write('<p>httpOnly: ' + sess.cookie.httpOnly + '</p>'); res.write('<p>path: ' + sess.cookie.path + '</p>'); res.write('<p>domain: ' + sess.cookie.domain + '</p>'); res.write('<p>secure: ' + sess.cookie.secure + '</p>'); sess.views ++; } else { sess.views = 1; } res.write("<p>" + util.inspect(req.cookies) + "</p>"); res.end('welcome to the session demo. refresh!'); }); http.createServer(app).listen(3000); ``` I've noticed that the req.session.cookie.domain is always null. I'm on windows 8 and using the hosts file to map 127.0.0.1 to www.gaz-node.com, which is what I exepected the cookie domain to be at the server. Could be related. Any ideas? Thanks
2013/03/02
[ "https://Stackoverflow.com/questions/15177105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/241587/" ]
The answer was very simple. I got up especially early on this sunday morning in order to debug it and the answer became suddenly clear midway through my first mug of coffee, which subsequently tasted better than the first half. **The Revenge of the /favicon.ico Request** I wasn't handling the request from the browser for /favicon.ico which is bit of a gotcha for node newbies like me. Every request is followed by a /favicon.ico request (by Chrome at least) so the browser can display the site's icon. It never gives up until it gets a favicon.ico. The actual session was working perfectly well, there was only one session id for that but the request for /favicon.ico doesn't send any cookies over and it was this that was triggering a new zombie session every request. To fix this I added a module to handle the /favicon.ico request and serve a 404 response. I could just as easily have given the relentless browser a favicon and sent that instead using the "fs" module. It's important that you handle the /favicon.ico and end the response, without calling next(), before you use the session module! Here's the fixed code : ``` var connect = require('connect'); var util = require("util"); var RedisStore = require("connect-redis")(connect); var http = require('http'); var app = connect() .use(function(req, res, next) { if(req.url == '/favicon.ico') { serve404(res); } else { next(); } }) .use(connect.cookieParser())//"elms123")) .use(connect.query()) .use(connect.session( { secret:"elms123", store:new RedisStore({prefix:'sid_'}), cookie:{maxAge:60000, secure:false, domain:"gaz-node.com"} })) .use(function(req, res, next) { var sess = req.session; res.setHeader('Content-Type', 'text/html'); res.write('welcome to the session demo. refresh!'); if (sess.views) { res.write("<p>" + util.inspect(req.cookies) + "</p>"); sess.basket = sess.basket || {book1:0, book2:0, book3:0}; if(req.query.buyBook1) {sess.basket.book1 ++;} if(req.query.buyBook2) {sess.basket.book2 ++;} if(req.query.buyBook3) {sess.basket.book3 ++;} if(req.query.expiresession) {sess.cookie.maxAge=0;} if(req.query.forceerror) {/*idontexist()*/throw new Error('ahhhh!');} res.write('<p>views: ' + sess.views + '</p>'); res.write('<ul>\ <li>book1 ' + sess.basket.book1 + ' - <a href="/?buyBook1=true">Add</a></li>\ <li>book2 ' + sess.basket.book2 + ' - <a href="/?buyBook2=true">Add</a></li>\ <li>book3 ' + sess.basket.book3 + ' - <a href="/?buyBook3=true">Add</a></li>\ </ul>\ <a href="/?expiresession=true">Expire session</a>\ <a href="/?forceerror=true">Force error</a>'); res.write('<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>'); res.write('<p>httpOnly: ' + sess.cookie.httpOnly + '</p>'); res.write('<p>path: ' + sess.cookie.path + '</p>'); res.write('<p>domain: ' + sess.cookie.domain + '</p>'); res.write('<p>secure: ' + sess.cookie.secure + '</p>'); sess.views ++; } else { sess.views = 1; } res.end("<p>" + util.inspect(req.cookies) + "</p>"); }) .use(connect.errorHandler()); http.createServer(app).listen(3000); function serve404(res) { res.writeHead(404, {"content-type": "text/plain"}); res.end("Error : Resource not found"); } ```
I also had this issue. Of course, we should use 'favicon' midlleware. And be sure to place 'session' middleware below 'static'. See my answer <https://stackoverflow.com/a/21094838/3190612>
17,938,248
html ``` <ul id="tabs"> <li><a href="#tab-1" class="active">Tab-1</a></li> <li><a href="#tab-2">Tab-2</a></li> <li><a href="#tab-3">Tab-3</a></li> </ul> <div class="tab-contents" id="tab-1" style="display: block;"> some text </div> ``` css ```css .tab-contents{ background: #2b2a26; padding: 0px 8px; clear: both; } #tabs { border-collapse: separate; border-spacing: 4px 0; float: right; list-style: none outside none; margin: 0 -4px 0 0; padding: 0; } #tabs li { background: none repeat scroll 0 0 #000000; border-radius: 19px 19px 0 0; display: table-cell; height: 47px; margin: 0 4px; text-align: center; vertical-align: middle; width: 145px; } #tab-1:before{ content: ""; display: block; width: 200px; height: 200px; background: #f00; padding-top: 10px; /* not working as expected but giving padding to bottom */ } ``` [demo](http://jsfiddle.net/SmN28/1/) Within gray box the red box should behave the padding top. How can I do that?
2013/07/30
[ "https://Stackoverflow.com/questions/17938248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2313718/" ]
You could use padding-top to `.tab-contents` instead. ``` .tab-contents{ background: #2b2a26; padding: 0px 8px; clear: both; padding-top: 10px; } ``` [Demo](http://jsfiddle.net/SmN28/2/) Alternatively, You could use `position: relative; top: 10px;` to your `#tab-1:before` instead of padding-top. [demo](http://jsfiddle.net/SmN28/6/)
Did you mean to use `margin-top` instead of `padding-top`? <http://jsfiddle.net/SmN28/4/>
9,411,011
in post: [Copy sublist from list](https://stackoverflow.com/questions/9337775/copy-sublist-from-list#comment11791540_9337775) was stayed explained me that for copy a sublist in a list need copy single elements doing so: ``` for iIndex2 := 0 to MyList.Last.Count-1 do MySubList.Add(MyList.Last[iIndex2]); ``` I have verified that this method of copy for elements much much highest in list take much time, in order too of some minetes. Trying to simulate with static array in same condition i take few miliseconds, copying all sublist in an array in one time and not for single element. Just for explain better, i have: ``` program Test_with_array_static; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Generics.Collections; type TMyArray = array [1..10] of Integer; TMyList = TList<TMyArray>; var MyArray: TMyArray; MyList: TMyList; iIndex1, iIndex2: Integer; begin try { TODO -oUser -cConsole Main : Insert code here } MyList := TList<TMyArray>.Create; try for iIndex1 := 1 to 10 do begin if MyList.Count <> 0 then MyArray := MyList.Last; MyArray[iIndex1] := iIndex1; MyList.Add(MyArray); end; for iIndex1 := 0 to Pred(MyList.Count) do begin for iIndex2 := 1 to 10 do Write(MyList[iIndex1][iIndex2]:3); Writeln; end; finally MyList.Free; end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. ``` So i have thinked to use not list as sublist but array and so work, but in my case i don't know in general how much are element in array and need dynamic array for it. I have changed code in: ``` program Test_with_array_dynamic; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Generics.Collections; type TMyArray = array of Integer; TMyList = TList<TMyArray>; var MyArray: TMyArray; MyList: TMyList; iIndex1, iIndex2: Integer; begin try { TODO -oUser -cConsole Main : Insert code here } MyList := TList<TMyArray>.Create; try SetLength(MyArray, 10); for iIndex1 := 1 to 10 do begin if MyList.Count <> 0 then MyArray := MyList.Last; MyArray[iIndex1] := iIndex1; MyList.Add(MyArray); end; for iIndex1 := 0 to Pred(MyList.Count) do begin for iIndex2 := 1 to 10 do Write(MyList[iIndex1][iIndex2]:3); Writeln; end; finally MyList.Free; end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. ``` and so, i have again the problem of before; of course, changing this line: ``` if MyList.Count <> 0 then MyArray := MyList.Last; ``` in mode of copy single element, all work. Now i ask, if really not is possible copy an array in a time, without do a copy for single elements, i need it for question of speed only. And time is very much important. Thanks again very much to all that can solve me this problem. Thanks again.
2012/02/23
[ "https://Stackoverflow.com/questions/9411011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1940338/" ]
You need to add a *copy* of the array. Otherwise, since you keep setting the array variable's length to the same value, you end up working on the same single dynamic array. To make a copy of an array, simply call [`Copy`](http://docwiki.embarcadero.com/Libraries/en/System.Copy) prior to adding it to your list: ``` MyList.Add(Copy(MyArray)); ```
if I understand you correctly, you want to copy memory to improve speed, here's one way to do it: ``` type TMyArray = array of Integer; procedure CopyMyArraytest; var LSrcArray: TMyArray; LDestArray: TMyArray; Index: Integer; begin // set the length, can be later changed SetLength(LSrcArray, 100); // fill the array for Index := Low(LSrcArray) to High(LSrcArray) do LSrcArray[index] := index; // prepare the length of destination array SetLength(LDestArray, Length(LSrcArray)); // copy elements from source to dest, we need Length(LSrcArray) * SizeOf(Integer) // because Move needs the number of bytes, we are using "integer" so a simple // multiplication will do the job Move(LSrcArray[Low(LSrcArray)], LDestArray[Low(LDestArray)], Length(LSrcArray) * SizeOf(Integer)); // compare elements, just to make sure everything is good for Index := Low(LSrcArray) to High(LSrcArray) do if LSrcArray[Index] <> LDestArray[Index] then begin ShowMessage('NOOO!!!'); Exit; end; ShowMessage('All good'); end; ```
244,748
I have a script which runs several commands remotely through ssh. I'm running each command separately because I want to do other things in between executions. However, I don't want to recreate an ssh session every time I issue a new command. I've read about `-oControlMaster` but I can't seem to get it to work. When I run: ``` ssh -oControlMaster=yes -oControlPath=/tmp/test.sock root@host ``` after I enter my password, I just get an ssh session. If I exit out, the `/tmp/test.sock` file is no where to be found. What am I missing?
2015/11/22
[ "https://unix.stackexchange.com/questions/244748", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/6266/" ]
You can use the `ControlPersist` option to leave the socket after you disconnect from the server. e.g in my ssh config file i have this snippet, which leave the connection open 3 sec. ``` Host * ControlMaster auto ControlPath ~/.ssh/master-socket/%r@%h:%p #ControlPath ~/.ssh/%r@%h:%p ControlPersist 3s ```
One master connection needs to be open for a second connection to be able to use the master connection. The socket file is only available while the master connection is open. If you close the master connection then the socket file is removed. Any open "slave connection" will also be closed if the master connection is closed.
20,098,052
the problem is that i don't receive any $\_POST['registerationID'] from android webview i have this code in android java :: ``` @Override protected void onRegistered(Context context, String registrationId) { String URL_STRING = "http://mysite.org/mysite/index.php/user/notification/"; Log.i(MyTAG, "onRegistered: registrationId=" + registrationId); // notification ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1); nameValuePairs.add(new BasicNameValuePair("registrationId",registrationId)); try{ HttpPost httppost = new HttpPost(URL_STRING); httppost.setHeader("Content-Type","text/plain"); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setBooleanParameter("http.protocol.expect-continue", false); HttpResponse response = httpclient.execute(httppost); Log.i("LinkPOST:", httppost.toString()); Log.i("postData", response.getStatusLine().toString()); HttpEntity httpEntity = response.getEntity(); if (httpEntity != null){ //System.out.println("Not Empty"); String responseBody = EntityUtils.toString(httpEntity); System.out.println(responseBody); } else { System.out.println("Empty"); } } catch(Exception e) { Log.e("log_tag", "Error in http connection "+e.toString()); } } ``` and i handle the httprequest post in php (using codeigniter) as the following : ``` function notification() { $registrationId = $_POST['registrationId']; if($this->session->userdata('emailid')) { //echo 'working from inside the if statement'.$this->session->userdata('emailid'); //$query = $this->db->query('INSERT INTO user (`deviceid`) VALUES ('.$_GET['registerationID'].') where `emailid`='.$this->session->userdata('emailid').';'); $data = array( 'deviceid' => $registrationId, ); $this->db->where('emailid', $this->session->userdata('emailid')); $this->db->update('user', $data); if($this->db->affected_rows() == 1) { // some code } else { // some code } } ```
2013/11/20
[ "https://Stackoverflow.com/questions/20098052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1892114/" ]
`gets` (which shall not be used and has actually been removed from the most recent C standards) does not save the `\n` in its buffer (while `fgets` does). And `fputs`, unlike `puts`, does not automatically insert one at the end of the string it writes. So by adding a `fputs("\n", fp);` (or `fputc('\n', fp)`) after outputting each typed line, you insert the missing newline in the file.
`fputs` does not automatically add a newline to the output (in contrast with `puts` which does).
46,469,258
I am new to React-native and enzyme, I am trying to create a custom component here. I will be displaying an Image based on `this.props.hasIcon`. I set default props value for `hasIcon` as `true`. When I check `Image` exists in enzyme ShallowWrapper. I am getting `false`. `tlProgress.js` ``` class TLProgress extends Component { render() { return ( <View style={styles.container}> {this.renderImage} {this.renderProgress} </View> ); } } TLProgress.defaultProps = { icon: require("./../../img/logo.png"), indeterminate: true, progressColor: Colors.TLColorAccent, hasIcon: true, progressType: "bar" }; ``` and `renderImage()` has the `Image` ``` renderImage() { if (this.props.hasIcon) { return <Image style={styles.logoStyle} source={this.props.icon} />; } } ``` Now, If I check `Image` exists in enzyme am getting false. `tlProgress.test.js` ``` describe("tlProgress rendering ", () => { let wrapper; beforeAll(() => { props = { indeterminate: false }; wrapper = shallow(<TLProgress {...props} />); }); it("check progress has app icon", () => { expect(wrapper.find("Image").exists()).toBe(true); // fails here.. }); }); ```
2017/09/28
[ "https://Stackoverflow.com/questions/46469258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2906641/" ]
You are not calling the renderImage function in your render() -- you forgot the brackets, thus it is being interpreted as an undefined variable. It should be: (I am assuming you want to call renderProgress() and not renderProgress as well) ``` class TLProgress extends Component { render() { return ( <View style={styles.container}> {this.renderImage()} {this.renderProgress()} </View> ); } ```
You're searching for a tag called 'Image' instead of looking for your component Image It should be : ``` import Image from '../Image'; wrapper.find(Image) //do your assert here ```
72,227,653
I want to join multiple tables in laravel with query builder. My problem is that my code only works if I specify the id myself that I want like this: ``` $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=','1') ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); ``` But I would want something like this(which I just can't seem to figure out) ``` public function showuser($id) { $userid = User::findOrFail($id); $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=',$userid) ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); } ``` Am I making a syntax mistake? When I check the page for my json response in second page it just returns empty brackets, but when I specify the id it fetches me the right data
2022/05/13
[ "https://Stackoverflow.com/questions/72227653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18367436/" ]
I don't know if I understood correctly, but you want this ? ``` void mymethod(String? s) { print(s ?? "Empty"); } int? a; // this could be null already mymethod(a?.toString()); // "a" could be null, so if it is null it will be set, otherwise it will be set to String ``` [![enter image description here](https://i.stack.imgur.com/JDXJe.png)](https://i.stack.imgur.com/JDXJe.png)
literally shorter, `""` with `$`can help, with more complex you need use `${}` instead of `$`. **Example**: `mymethod(a == null ? null : "$a");` Or you can create an extensiton on `Int?` and just call extension function to transform to `String?`, short, easy and reuseable. you can write the extension code elsewhere and import it where you need it. [![enter image description here](https://i.stack.imgur.com/wNbBl.png)](https://i.stack.imgur.com/wNbBl.png)
72,227,653
I want to join multiple tables in laravel with query builder. My problem is that my code only works if I specify the id myself that I want like this: ``` $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=','1') ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); ``` But I would want something like this(which I just can't seem to figure out) ``` public function showuser($id) { $userid = User::findOrFail($id); $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=',$userid) ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); } ``` Am I making a syntax mistake? When I check the page for my json response in second page it just returns empty brackets, but when I specify the id it fetches me the right data
2022/05/13
[ "https://Stackoverflow.com/questions/72227653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18367436/" ]
You could just do this: ``` mymethod(a?.toString()); ``` But if you want to make the check, my suggestion is to make the function do it. ``` int? a; mymethod(a); void mymethod(int? s) { String text = "Empty"; if (s != null) text = s.toString(); print(text); } ```
literally shorter, `""` with `$`can help, with more complex you need use `${}` instead of `$`. **Example**: `mymethod(a == null ? null : "$a");` Or you can create an extensiton on `Int?` and just call extension function to transform to `String?`, short, easy and reuseable. you can write the extension code elsewhere and import it where you need it. [![enter image description here](https://i.stack.imgur.com/wNbBl.png)](https://i.stack.imgur.com/wNbBl.png)
72,227,653
I want to join multiple tables in laravel with query builder. My problem is that my code only works if I specify the id myself that I want like this: ``` $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=','1') ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); ``` But I would want something like this(which I just can't seem to figure out) ``` public function showuser($id) { $userid = User::findOrFail($id); $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=',$userid) ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); } ``` Am I making a syntax mistake? When I check the page for my json response in second page it just returns empty brackets, but when I specify the id it fetches me the right data
2022/05/13
[ "https://Stackoverflow.com/questions/72227653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18367436/" ]
I don't know if I understood correctly, but you want this ? ``` void mymethod(String? s) { print(s ?? "Empty"); } int? a; // this could be null already mymethod(a?.toString()); // "a" could be null, so if it is null it will be set, otherwise it will be set to String ``` [![enter image description here](https://i.stack.imgur.com/JDXJe.png)](https://i.stack.imgur.com/JDXJe.png)
You could just do this: ``` mymethod(a?.toString()); ``` But if you want to make the check, my suggestion is to make the function do it. ``` int? a; mymethod(a); void mymethod(int? s) { String text = "Empty"; if (s != null) text = s.toString(); print(text); } ```
72,227,653
I want to join multiple tables in laravel with query builder. My problem is that my code only works if I specify the id myself that I want like this: ``` $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=','1') ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); ``` But I would want something like this(which I just can't seem to figure out) ``` public function showuser($id) { $userid = User::findOrFail($id); $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=',$userid) ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); } ``` Am I making a syntax mistake? When I check the page for my json response in second page it just returns empty brackets, but when I specify the id it fetches me the right data
2022/05/13
[ "https://Stackoverflow.com/questions/72227653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18367436/" ]
I don't know if I understood correctly, but you want this ? ``` void mymethod(String? s) { print(s ?? "Empty"); } int? a; // this could be null already mymethod(a?.toString()); // "a" could be null, so if it is null it will be set, otherwise it will be set to String ``` [![enter image description here](https://i.stack.imgur.com/JDXJe.png)](https://i.stack.imgur.com/JDXJe.png)
Try with the following: ``` void mymethod(int? s) { return s?.toString; } int? a = null; mymethod(a); ```
72,227,653
I want to join multiple tables in laravel with query builder. My problem is that my code only works if I specify the id myself that I want like this: ``` $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=','1') ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); ``` But I would want something like this(which I just can't seem to figure out) ``` public function showuser($id) { $userid = User::findOrFail($id); $datauser = DB::table('users') ->join('activitates','users.id','=','activitates.user_id') ->join('taga_cars','taga_cars.id','=','activitates.tagacar_id') ->join('clients','users.id','=','clients.user_id') ->where('users.id','=',$userid) ->select('users.*','activitates.*','taga_cars.model','taga_cars.id','clients.name') ->get(); return response()->json($datauser); } ``` Am I making a syntax mistake? When I check the page for my json response in second page it just returns empty brackets, but when I specify the id it fetches me the right data
2022/05/13
[ "https://Stackoverflow.com/questions/72227653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18367436/" ]
You could just do this: ``` mymethod(a?.toString()); ``` But if you want to make the check, my suggestion is to make the function do it. ``` int? a; mymethod(a); void mymethod(int? s) { String text = "Empty"; if (s != null) text = s.toString(); print(text); } ```
Try with the following: ``` void mymethod(int? s) { return s?.toString; } int? a = null; mymethod(a); ```
49,558,818
I want to change the ordering of this numpy images array to channel\_last training\_data : (2387, 1, 350, 350) to (2387,350,350,1) validation\_data : (298, 1, 350, 350) to (298, 350, 350, 1) testing\_data : (301, 1, 350, 350) to (301, 350, 350, 1) I tried this but it is not working ``` np.rollaxis(training_data,0,3).shape np.rollaxis(validation_data,0,3).shape np.rollaxis(testing_data,0,3).shape ```
2018/03/29
[ "https://Stackoverflow.com/questions/49558818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3257991/" ]
You need the `np.transpose` method like this: ``` training_data = np.transpose(training_data, (0, 2,3,1) ``` The same for the other ones
If the axis you are moving has length `1` a simple reshape will do: ``` a = np.arange(24).reshape(2, 1, 3, 4) # Three different methods: b1 = a.reshape(2, 3, 4, 1) b2 = np.moveaxis(a, 1, 3) b3 = a.transpose(0, 2, 3, 1) # All give the same result: np.all(b1 == b2) and np.all(b2 == b3) # True ```
49,558,818
I want to change the ordering of this numpy images array to channel\_last training\_data : (2387, 1, 350, 350) to (2387,350,350,1) validation\_data : (298, 1, 350, 350) to (298, 350, 350, 1) testing\_data : (301, 1, 350, 350) to (301, 350, 350, 1) I tried this but it is not working ``` np.rollaxis(training_data,0,3).shape np.rollaxis(validation_data,0,3).shape np.rollaxis(testing_data,0,3).shape ```
2018/03/29
[ "https://Stackoverflow.com/questions/49558818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3257991/" ]
You need the `np.transpose` method like this: ``` training_data = np.transpose(training_data, (0, 2,3,1) ``` The same for the other ones
Do it like this: ``` np.rollaxis(array_here,axis_to_roll,to_where) ``` For your case you want to roll axis 0 to last position (beyond 3) so you have to put to\_where as 4 (beyond 3). This will work(personally tested): ``` np.rollaxis(train_data,0,4) ```
49,558,818
I want to change the ordering of this numpy images array to channel\_last training\_data : (2387, 1, 350, 350) to (2387,350,350,1) validation\_data : (298, 1, 350, 350) to (298, 350, 350, 1) testing\_data : (301, 1, 350, 350) to (301, 350, 350, 1) I tried this but it is not working ``` np.rollaxis(training_data,0,3).shape np.rollaxis(validation_data,0,3).shape np.rollaxis(testing_data,0,3).shape ```
2018/03/29
[ "https://Stackoverflow.com/questions/49558818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3257991/" ]
If the axis you are moving has length `1` a simple reshape will do: ``` a = np.arange(24).reshape(2, 1, 3, 4) # Three different methods: b1 = a.reshape(2, 3, 4, 1) b2 = np.moveaxis(a, 1, 3) b3 = a.transpose(0, 2, 3, 1) # All give the same result: np.all(b1 == b2) and np.all(b2 == b3) # True ```
Do it like this: ``` np.rollaxis(array_here,axis_to_roll,to_where) ``` For your case you want to roll axis 0 to last position (beyond 3) so you have to put to\_where as 4 (beyond 3). This will work(personally tested): ``` np.rollaxis(train_data,0,4) ```
6,920,238
I have a List of vectors and a PlayerVector I just want to know how I can find the nearest Vector to my PlayerVector in my List. Here are my variables: ``` List<Vector2> Positions; Vector2 Player; ``` The variables are already declared and all, I just need a simple code that will search for the nearest position to my player. Isn't there a simple way?
2011/08/03
[ "https://Stackoverflow.com/questions/6920238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/858329/" ]
Since you don't need the exact distance (just a relative comparison), you can skip the square-root step in the Pythagorean distance formula: ``` Vector2? closest = null; var closestDistance = float.MaxValue; foreach (var position in Positions) { var distance = Vector2.DistanceSquared(position, Player); if (!closest.HasValue || distance < closestDistance) { closest = position; closestDistance = distance; } } // closest.Value now contains the closest vector to the player ```
I'm writing it from memory, because I don't have access to XNA now: ``` Vector2 nerrest = Positions.Select(vect => new { distance= vect.Distance(Player), vect}) .OrderBy(x => x.distance) .First().vect; ``` Little tips: In this solution you probably can use PLINQ to gain little speedup on distance computing.
6,920,238
I have a List of vectors and a PlayerVector I just want to know how I can find the nearest Vector to my PlayerVector in my List. Here are my variables: ``` List<Vector2> Positions; Vector2 Player; ``` The variables are already declared and all, I just need a simple code that will search for the nearest position to my player. Isn't there a simple way?
2011/08/03
[ "https://Stackoverflow.com/questions/6920238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/858329/" ]
Create a int called distanceToPlayer, set it to 0. Create a int called nearestObject set it to 0. Loop through all the objects with a for loop. It is slightly faster than a foreach loop, and is more useful in this situation. In the loop: Get the distance with Vector2.Distance, and check it against distanceToPlayer, if less, then store the index number of the object in nearestObject, and store the new distance in distanceToPlayer. After the loop is done, you will have the distance in whole pixels, and the index of the item in the list stored. You can access the item using Positions[index].
I'm writing it from memory, because I don't have access to XNA now: ``` Vector2 nerrest = Positions.Select(vect => new { distance= vect.Distance(Player), vect}) .OrderBy(x => x.distance) .First().vect; ``` Little tips: In this solution you probably can use PLINQ to gain little speedup on distance computing.
62,548
I've been trying to figure out for days how <http://quotelicious.com> was able to place thumbnails and category links in a separate box alongside the actual post. Any ideas?
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62548", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19519/" ]
They are actually doing this is one loop, here's an example to show similar structure. ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="article"> <div class="left"> <?php the_post_thumbnail( $size, $attr ); ?> <?php get_the_category(); ?> </div><!-- end left side --> <div class="right"> <?php the_excerpt(); ?> </div> <!-- end right side--> </div> <?php endwhile; else: endif; ?> ```
Wordpress themes such as MH News does this by default for all archive pages. Check this [quotes website](http://www.braintrainingtools.org/skills/category/quotes/time-quotes/) for reference
53,335,006
Being new to VBA I would love some inputs to this code, to improve the speed of it... It doesn't feel so "VBA"-ish currently; however the "result" of the code correct... ``` Sub Rigtig() Set Marketshare = Sheets("Output").Range("p40:p50") 'Select. Sheets("Output").Select Cells(38, 17).Copy Sheets("Input").Select Cells(33, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Marketshare.Cells(1, 1).Copy Sheets("Input").Select Cells(23, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Cells(40, 17).Copy Cells(40, 17).Select Selection.PasteSpecial Paste:=xlPasteValues Marketshare.Cells(2, 1).Copy Sheets("Input").Select Cells(23, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Cells(41, 17).Copy Cells(41, 17).Select Selection.PasteSpecial Paste:=xlPasteValues Marketshare.Cells(3, 1).Copy Sheets("Input").Select Cells(23, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Cells(38, 18).Copy Sheets("Input").Select Cells(33, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Marketshare.Cells(1, 1).Copy Sheets("Input").Select Cells(23, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Cells(40, 18).Copy Cells(40, 18).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Cells(38, 19).Copy Sheets("Input").Select Cells(33, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Marketshare.Cells(1, 1).Copy Sheets("Input").Select Cells(23, 28).Select Selection.PasteSpecial Paste:=xlPasteValues Sheets("Output").Select Cells(40, 19).Copy Cells(40, 19).Select Selection.PasteSpecial Paste:=xlPasteValues Marketshare.Cells(2, 1).Copy Sheets("Input").Select Cells(23, 28).Select Selection.PasteSpecial Paste:=xlPasteValues ``` I would like to do the same "copy paste" approx 10 times in rows, and then change the column. Thanks in advance Best Valdemar
2018/11/16
[ "https://Stackoverflow.com/questions/53335006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10662016/" ]
As @Glitch\_Doctor said - if it's just the values you're after you can do this "this cell = that cell" rather than copy/paste. To shorten your code and make it a bit more "VBA"-ish you could put your cell reference pairs into an array and step through the array: ``` Sub Test() Dim vAddresses As Variant Dim vRef As Variant vAddresses = Array( _ Array("Q38", "AB33"), _ Array("A1", "AB23")) For Each vRef In vAddresses Worksheets("Input").Range(vRef(1)) = Worksheets("Output").Range(vRef(0)) Next vRef End Sub ``` You could also use a [With...End With](https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/with-end-with-statement) block so you don't have to use the sheet name each time: ``` Sub Test1() With Worksheets("Output") Worksheets("Input").Cells(33, 28) = .Cells(38, 17) End With End Sub ``` If you want to copy everything (formula, formatting) then use Copy & paste in a single line: ``` Sub Test2() With Worksheets("Output") Worksheets("Input").Cells(33, 28).Copy Destination:=.Cells(38, 17) End With End Sub ```
So I want it to be something like this: ``` Sub Test() Dim vAddresses As Variant Dim vRef As Variant vAddresses = Array( _ Array("Q38", "AB33"), _ Array("P40", "AB23")) For Each vRef In vAddresses Worksheets("Input").Range(vRef(1)) = Worksheets("Output").Range(vRef(0)) Next vRef Sheets("Output").Cells(40, 17).Value = Sheets("Output").Cells(40, 17).Value vAddresses = Array( _ Array("Q38", "AB33"), _ Array("P41", "AB23")) For Each vRef In vAddresses Worksheets("Input").Range(vRef(1)) = Worksheets("Output").Range(vRef(0)) Next vRef Sheets("Output").Cells(41, 17).Value = Sheets("Output").Cells(41, 17).Value ``` Does this makes sense? So repeating it 10x down in rows, and then move 1 column left and do it again. Hope you get my point, and thanks :) /Valdemar
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
If you just startle him when someone sneezes loudly then looking at them, or even crying, seems like a reasonable response. Hey you just scared the kid. If there are any other reasons to doubt his mental health you should see a professional. Are there any of the expected milestones he is missing (like first steps and/or first words). Those are certainly signs to see a professional. If it's just oversensitive to sound for example. Then still see a professional but personally i wouldn't be worried if my kid looked at me every time i sneezed (the screaming and crying really depends on how inconsolable they are. and what other reasons you have to suspect anything)
My children didn't have that but my 6 month nephew developed a similar response to brushing teeth or hair. Whenever his mother did it, he would burst out crying but when his dad brushed his teeth... nothing. It's a phase. As with all phases it has to run its course. Be careful (stifle a sneeze if it would save you a 20-minute tantrum) but don't make too much out of it and he will stop. I would be more worried if he didn't respond at all to loud noises. If you're unsure, you could try a few things. Try to see how he crawls. Does he reply by moving his head? Does he try to find things when you hide them? Is he affectionate toward those around him? A couple of behavior markers that could help but as always, if you're unsure, you need to seek medical help.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
If you just startle him when someone sneezes loudly then looking at them, or even crying, seems like a reasonable response. Hey you just scared the kid. If there are any other reasons to doubt his mental health you should see a professional. Are there any of the expected milestones he is missing (like first steps and/or first words). Those are certainly signs to see a professional. If it's just oversensitive to sound for example. Then still see a professional but personally i wouldn't be worried if my kid looked at me every time i sneezed (the screaming and crying really depends on how inconsolable they are. and what other reasons you have to suspect anything)
It's normal for kids to jump and have that reaction You may consider going to a doctor to test hearing. An ear infection or nerological disorder may contribute to discomfort with special sounds. Ear infections are common.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
Your child may simply be sensitive to loud, unexpected noises. He might even be overly sensitive, but one behavior does not a mental illness make; if this is the only thing that concerns you at 15 months, I'd just watch and wait. Of course, since you're concerned, if he's in the US, he has a 15 month and an 18 month visit with his pediatrician. Bring up your concerns then.
My children didn't have that but my 6 month nephew developed a similar response to brushing teeth or hair. Whenever his mother did it, he would burst out crying but when his dad brushed his teeth... nothing. It's a phase. As with all phases it has to run its course. Be careful (stifle a sneeze if it would save you a 20-minute tantrum) but don't make too much out of it and he will stop. I would be more worried if he didn't respond at all to loud noises. If you're unsure, you could try a few things. Try to see how he crawls. Does he reply by moving his head? Does he try to find things when you hide them? Is he affectionate toward those around him? A couple of behavior markers that could help but as always, if you're unsure, you need to seek medical help.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
I think it's worth remembering that infants and toddlers, as much as they may be small people, are experiencing new things every day. Them being startled by something and overreacting to it is pretty normal. They don't understand what's going on and they don't know what the "correct" way to react is. A few weeks ago, my husband pulled out his trumpet to see how are 14 month old would react to it. He played a single note and Ben screamed, started crying and ran off. Later that same day, even the sight of the trumpet caused Ben to cry and run. Trumpets are loud. If you've never encountered one before, having one blasted in your vicinity when you don't even know what they do can be scary. Even as an adult, extremely loud sneezes and other noises when I don't expect them may startle me. Sure, I get over them quickly, but I'll probably complain at the source of the sneeze for not trying to make it quieter (usually the source is my spouse). When it happens again, comfort the child, tell them that it's OK. Identify the noise ("Mommy just coughed, it's OK. You cough, too!") and be calm. Show them that it's nothing to be fearful of by not reacting negatively to it. Don't make it traumatic for them by yelling at them for their reaction. With enough exposure, the little one should get used to it (as much as one can) and have a less extreme response. If you are really worried, please see your pediatrician for advice. Don't forget that children may hear more than you do, so they may be reacting to something you aren't sensitive to. As we age, we [lose our ability](http://www.roger-russell.com/hearing/hearing.htm) to hear certain frequencies.
My children didn't have that but my 6 month nephew developed a similar response to brushing teeth or hair. Whenever his mother did it, he would burst out crying but when his dad brushed his teeth... nothing. It's a phase. As with all phases it has to run its course. Be careful (stifle a sneeze if it would save you a 20-minute tantrum) but don't make too much out of it and he will stop. I would be more worried if he didn't respond at all to loud noises. If you're unsure, you could try a few things. Try to see how he crawls. Does he reply by moving his head? Does he try to find things when you hide them? Is he affectionate toward those around him? A couple of behavior markers that could help but as always, if you're unsure, you need to seek medical help.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
My oldest reacted this way to sneezing/nose blowing from about 9-10 months, but then he got used to and over it. So my question would be: how long has it been going on? A week? A month? Three months? If towards (or past!) the three month end of things, then it's definitely worth addressing with the pediatrician - I had a student once who had a physiological auditory sensitivity, and this was one of the early signs his parents had to indicate it. However, if it's only been a few days/weeks, and he doesn't otherwise seem to be suffering, maybe just wait and see if he gets used to it. Note: if you are concerned, it is always best to call the pediatrician and ask whether it's something you should be worried about - most are available by phone even after hours, and they will be much more qualified to speak to any possible medical causes/ramifications than anyone on this site (since they've actually seen your child). Don't worry about them saying "it's nothing," because on the off chance it isn't, better safe than sorry.
My children didn't have that but my 6 month nephew developed a similar response to brushing teeth or hair. Whenever his mother did it, he would burst out crying but when his dad brushed his teeth... nothing. It's a phase. As with all phases it has to run its course. Be careful (stifle a sneeze if it would save you a 20-minute tantrum) but don't make too much out of it and he will stop. I would be more worried if he didn't respond at all to loud noises. If you're unsure, you could try a few things. Try to see how he crawls. Does he reply by moving his head? Does he try to find things when you hide them? Is he affectionate toward those around him? A couple of behavior markers that could help but as always, if you're unsure, you need to seek medical help.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
Your child may simply be sensitive to loud, unexpected noises. He might even be overly sensitive, but one behavior does not a mental illness make; if this is the only thing that concerns you at 15 months, I'd just watch and wait. Of course, since you're concerned, if he's in the US, he has a 15 month and an 18 month visit with his pediatrician. Bring up your concerns then.
It's normal for kids to jump and have that reaction You may consider going to a doctor to test hearing. An ear infection or nerological disorder may contribute to discomfort with special sounds. Ear infections are common.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
I think it's worth remembering that infants and toddlers, as much as they may be small people, are experiencing new things every day. Them being startled by something and overreacting to it is pretty normal. They don't understand what's going on and they don't know what the "correct" way to react is. A few weeks ago, my husband pulled out his trumpet to see how are 14 month old would react to it. He played a single note and Ben screamed, started crying and ran off. Later that same day, even the sight of the trumpet caused Ben to cry and run. Trumpets are loud. If you've never encountered one before, having one blasted in your vicinity when you don't even know what they do can be scary. Even as an adult, extremely loud sneezes and other noises when I don't expect them may startle me. Sure, I get over them quickly, but I'll probably complain at the source of the sneeze for not trying to make it quieter (usually the source is my spouse). When it happens again, comfort the child, tell them that it's OK. Identify the noise ("Mommy just coughed, it's OK. You cough, too!") and be calm. Show them that it's nothing to be fearful of by not reacting negatively to it. Don't make it traumatic for them by yelling at them for their reaction. With enough exposure, the little one should get used to it (as much as one can) and have a less extreme response. If you are really worried, please see your pediatrician for advice. Don't forget that children may hear more than you do, so they may be reacting to something you aren't sensitive to. As we age, we [lose our ability](http://www.roger-russell.com/hearing/hearing.htm) to hear certain frequencies.
It's normal for kids to jump and have that reaction You may consider going to a doctor to test hearing. An ear infection or nerological disorder may contribute to discomfort with special sounds. Ear infections are common.
32,195
I have a fifteen-months-old nephew who reacts strongly when people around him cough or make unwanted loud noises (i.e. sneeze). His reaction is often staring at the whoever made the noise, screaming protesting and crying, even if his mother does that. Should we be worried about his mental health? or is there anything special we should do to prevent future problems?
2017/10/25
[ "https://parenting.stackexchange.com/questions/32195", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/23858/" ]
My oldest reacted this way to sneezing/nose blowing from about 9-10 months, but then he got used to and over it. So my question would be: how long has it been going on? A week? A month? Three months? If towards (or past!) the three month end of things, then it's definitely worth addressing with the pediatrician - I had a student once who had a physiological auditory sensitivity, and this was one of the early signs his parents had to indicate it. However, if it's only been a few days/weeks, and he doesn't otherwise seem to be suffering, maybe just wait and see if he gets used to it. Note: if you are concerned, it is always best to call the pediatrician and ask whether it's something you should be worried about - most are available by phone even after hours, and they will be much more qualified to speak to any possible medical causes/ramifications than anyone on this site (since they've actually seen your child). Don't worry about them saying "it's nothing," because on the off chance it isn't, better safe than sorry.
It's normal for kids to jump and have that reaction You may consider going to a doctor to test hearing. An ear infection or nerological disorder may contribute to discomfort with special sounds. Ear infections are common.
66,772,227
i cant' switch router ### index.js In this project used `ConnectedRouter` ``` ReactDOM.render( <Provider store={store}> <ConnectedRouter history={history}> <App /> </ConnectedRouter> </Provider>, document.getElementById('root') ); ``` ### App.js ``` <nav className="flexVCent row gutterH"> <Link to="/" className="App-logo-wrap"> <img src={logo} className="App-logo" alt="logo" /> </Link> <div className="flexHRight"> <div className="flexExpand"> </div> </div> </nav> ``` How correctly wrap Link ? package.json ``` "dependencies": { ... "connected-react-router": "^6.2.2", "history": "^4.7.2", ... }, ```
2021/03/23
[ "https://Stackoverflow.com/questions/66772227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8865030/" ]
You can't use `indexOf()` for this purpose, unless you abuse the purpose of the `equals()` method. Use a `for` loop over an `int` variable that iterates from `0` to the length of the List. Inside the loop, compare the name if the ith element, and if it's equal to you search term, you've found it. Something like this: ``` int index = -1; for (int i = 0; i < pets.length; i++) { if (pets.get(i).getName().equals(searchName)) { index = i; break; } } // index now holds the found index, or -1 if not found ``` If you just want to find the object, you don't need the index: ``` pet found = null; for (pet p : pets) { if (p.getName().equals(searchName)) { found = p; break; } } // found is now something or null if not found ```
As the others already stated, you cannot use indexOf() for this directly. It would be possible in certain situations (lambdas, rewriting hashCode/equals etc), but that is usually a bad idea because it would abuse another concept. Here's a few examples of how we can do that in modern Java: (as the index topic has already been answered quite well, this only handles direct Object return) ``` package stackoverflow.filterstuff; import java.util.ArrayList; import java.util.Objects; import java.util.function.Function; import java.util.function.Predicate; public class FilterStuff { public static void main(final String[] args) { final Pet dog = new Pet("Orio", 2); // again, naming conventions: variable names start with lowercase letters final Pet cat = new Pet("Kathy", 4); final Pet lion = new Pet("Usumba", 6); final ArrayList<Pet> pets = new ArrayList<>(); pets.add(dog); pets.add(cat); pets.add(lion); try { simpleOldLoop(pets); } catch (final Exception e) { e.printStackTrace(System.out); } try { simpleLoopWithLambda(pets); } catch (final Exception e) { e.printStackTrace(System.out); } try { filterStreams(pets); } catch (final Exception e) { e.printStackTrace(System.out); } try { filterStreamsWithLambda(pets); } catch (final Exception e) { e.printStackTrace(System.out); } } private static void simpleOldLoop(final ArrayList<Pet> pPets) { System.out.println("\nFilterStuff.simpleOldLoop()"); System.out.println("Pet named 'Kathy': " + filterPet_simpleOldLoop(pPets, "Kathy")); System.out.println("Pet named 'Hans': " + filterPet_simpleOldLoop(pPets, "Hans")); } private static Pet filterPet_simpleOldLoop(final ArrayList<Pet> pPets, final String pName) { if (pPets == null) return null; for (final Pet pet : pPets) { if (pet == null) continue; if (Objects.equals(pet.getName(), pName)) return pet; } return null; } private static void simpleLoopWithLambda(final ArrayList<Pet> pPets) { System.out.println("\nFilterStuff.simpleLoopWithLambda()"); System.out.println("Pet named 'Kathy': " + filterPet_simpleLoopWithLambda(pPets, (pet) -> Boolean.valueOf(Objects.equals(pet.getName(), "Kathy")))); System.out.println("Pet named 'Hans': " + filterPet_simpleLoopWithLambda(pPets, (pet) -> Boolean.valueOf(Objects.equals(pet.getName(), "Hans")))); } private static Pet filterPet_simpleLoopWithLambda(final ArrayList<Pet> pPets, final Function<Pet, Boolean> pLambda) { if (pPets == null) return null; for (final Pet pet : pPets) { if (pet == null) continue; final Boolean result = pLambda.apply(pet); if (result == Boolean.TRUE) return pet; } return null; } private static void filterStreams(final ArrayList<Pet> pPets) { System.out.println("\nFilterStuff.filterStreams()"); System.out.println("Pet named 'Kathy': " + filterPet_filterStreams(pPets, "Kathy")); System.out.println("Pet named 'Hans': " + filterPet_filterStreams(pPets, "Hans")); } private static Pet filterPet_filterStreams(final ArrayList<Pet> pPets, final String pName) { return pPets.stream().filter(p -> Objects.equals(p.getName(), pName)).findAny().get(); } private static void filterStreamsWithLambda(final ArrayList<Pet> pPets) { System.out.println("\nFilterStuff.filterStreamsWithLambda()"); System.out.println("Pet named 'Kathy': " + filterPet_filterStreams(pPets, p -> Objects.equals(p.getName(), "Kathy"))); final Predicate<Pet> pdctHans = p -> Objects.equals(p.getName(), "Hans"); // we can also have 'lambda expressions' stored in variables System.out.println("Pet named 'Hans': " + filterPet_filterStreams(pPets, pdctHans)); } private static Pet filterPet_filterStreams(final ArrayList<Pet> pPets, final Predicate<Pet> pLambdaPredicate) { return pPets.stream().filter(pLambdaPredicate).findAny().get(); } } ``` Along with your Pet class, extended by toString(): ``` package stackoverflow.filterstuff; public class Pet { // please stick to naming conventions: classes start with uppercase letters! private final String petName; private final int petAge; public Pet(final String name, final int age) { petName = name; petAge = age; } public String getName() { return petName; } public int getAge() { return petAge; } @Override public String toString() { return "Pet [Name=" + petName + ", Age=" + petAge + "]"; } } ```
9,643,859
I am trying to use this query in Postgres 9.1.3: ``` WITH stops AS ( SELECT citation_id, rank() OVER (ORDER BY offense_timestamp, defendant_dl, offense_street_number, offense_street_name) AS stop FROM consistent.master WHERE citing_jurisdiction=1 ) UPDATE consistent.master SET arrest_id = stops.stop WHERE citing_jurisdiction=1 AND stops.citation_id = consistent.master.citation_id; ``` I get this error: ``` ERROR: missing FROM-clause entry for table "stops" LINE 12: SET arrest_id = stops.stop ^ ********** Error ********** ERROR: missing FROM-clause entry for table "stops" SQL state: 42P01 Character: 280 ``` I'm really confused. The WITH clause appears correct per Postgres documentation. If I separately run the query in the WITH clause, I get correct results.
2012/03/10
[ "https://Stackoverflow.com/questions/9643859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/425477/" ]
From the [fine manual](http://www.postgresql.org/docs/current/static/sql-update.html): > > There are two ways to modify a table using information contained in other tables in the database: using sub-selects, or specifying additional tables in the `FROM` clause. > > > So you just need a FROM clause: ``` WITH stops AS ( -- ... ) UPDATE consistent.master SET arrest_id = stops.stop FROM stops -- <----------------------------- You missed this WHERE citing_jurisdiction=1 AND stops.citation_id = consistent.master.citation_id; ``` The error message even says as much: > > ERROR: missing FROM-clause entry for table "stops" > > >
This can also happen if you mistype a table name. For example: ``` UPDATE profiles SET name = ( profile.first_name ) WHERE id = 1 ``` Instead of `profiles` i incorrectly used `profile` !! This would work: ``` UPDATE profiles SET name = ( profiles.first_name ) WHERE id = 1 ```
47,157,155
Can anyone please help me how to save multiple selection in the `DB`? ``` <div class="col-sm-10"> <select id="tag_list" name="tag_list[]" class="form-control" multiple></select> </div> ``` Controller function is like this: ``` public function store(Request $request) { $comics = new Comic(); $tags = $request->input('tag_list'); $comics->appreance = implode(',', $tags); $comics->save(); return redirect('/comic'); } ``` Please help, thanks.
2017/11/07
[ "https://Stackoverflow.com/questions/47157155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3119809/" ]
Although it's not clear enough how you save your `tags or appearance`, i `assume` it save one tag in a `single` row. If that's the case then you can do something like ``` public function store(Request $request) { $tags = $request->input('tag_list'); foreach($tags as $tag){ $comics = new Comic(); $comics->appreance = tag; $comics->save(); } return redirect('/comic'); } ``` Hope this helps :)
You can use Bootstrap select to choose multiple select. <https://bootsnipp.com/snippets/Ekd8P>
47,157,155
Can anyone please help me how to save multiple selection in the `DB`? ``` <div class="col-sm-10"> <select id="tag_list" name="tag_list[]" class="form-control" multiple></select> </div> ``` Controller function is like this: ``` public function store(Request $request) { $comics = new Comic(); $tags = $request->input('tag_list'); $comics->appreance = implode(',', $tags); $comics->save(); return redirect('/comic'); } ``` Please help, thanks.
2017/11/07
[ "https://Stackoverflow.com/questions/47157155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3119809/" ]
Have you tried json? Try this ``` public function store(Request $request) { $comic = new Comic(); $tags = $request->input('tag_list'); $comic->appreance = json_encode($tags); $comic->save(); return redirect('/comic'); } ``` But I'll suggest to consider separate table for tags and create a relationship for comic and tags. Take a look at this <https://laravel.com/docs/5.3/eloquent-relationships#many-to-many-polymorphic-relations>
You can use Bootstrap select to choose multiple select. <https://bootsnipp.com/snippets/Ekd8P>
47,157,155
Can anyone please help me how to save multiple selection in the `DB`? ``` <div class="col-sm-10"> <select id="tag_list" name="tag_list[]" class="form-control" multiple></select> </div> ``` Controller function is like this: ``` public function store(Request $request) { $comics = new Comic(); $tags = $request->input('tag_list'); $comics->appreance = implode(',', $tags); $comics->save(); return redirect('/comic'); } ``` Please help, thanks.
2017/11/07
[ "https://Stackoverflow.com/questions/47157155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3119809/" ]
Although it's not clear enough how you save your `tags or appearance`, i `assume` it save one tag in a `single` row. If that's the case then you can do something like ``` public function store(Request $request) { $tags = $request->input('tag_list'); foreach($tags as $tag){ $comics = new Comic(); $comics->appreance = tag; $comics->save(); } return redirect('/comic'); } ``` Hope this helps :)
Have you tried json? Try this ``` public function store(Request $request) { $comic = new Comic(); $tags = $request->input('tag_list'); $comic->appreance = json_encode($tags); $comic->save(); return redirect('/comic'); } ``` But I'll suggest to consider separate table for tags and create a relationship for comic and tags. Take a look at this <https://laravel.com/docs/5.3/eloquent-relationships#many-to-many-polymorphic-relations>
16,223,759
I have this page: ``` <?php for($i=1; $i<=3; $i++){ $until_he.$i = htmlentities($_POST['until'.$i]) } ?> <form action="" method...> <?php for($i=1; $i<=3; $i++){ ... print '<input name="until'.$i.'" id="until'.$i.'" class="textinput" value="'.$until_he.$i.'" type="date" min="'.date("Y-m-d").'"/>'; ... } ?> ... ``` Now: ``` $until_he ``` has content only once the form is posted, otherwise it's empty. On the other hand ``` $i ``` is already defined. So as I load the page I get values 1, 2, 3 on the fields. I'd like to get values on the files only once the user post the forum. As I load the page the fields should be empty. Thank you
2013/04/25
[ "https://Stackoverflow.com/questions/16223759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2120569/" ]
Try this: ``` <?php for($i=1; $i<=3; $i++){ $until_he.$i = htmlentities($_POST['until'.$i]); $fieldValue = (trim($until_he.$i)==$i)?"":$until_he; ... print '<input name="until'.$i.'" id="until'.$i.'" class="textinput" value="'.$fieldValue.'" type="date" min="'.date("Y-m-d").'"/>'; ... } ?> ```
Depends on what you want to accomplish and other code you have. In your example, you should use isset($until\_he) which doesn't generate a warning if the variable is not set. Also, it works in the case the variable $until\_he is set but empty. However, it will fail if you initialize $until\_he to an empty value beforehand.
54,975,362
**React 16.8 (Using classes not hooks)** consider the following `if` statement in a function thats called `onClick` ``` if (this.state.opponentIsDead) { this.setState({ disableAttack: 'disabled', }, () => { this.timer = setTimeout(() => { this.props.postFightData({ train_exp: 100, drop_chance: this.state.monster.drop_chance, gold_rush_chance: this.state.monster.gold_rush_chance, gold_drop: this.state.monster.gold_drop, }); }, 1000); }); } ``` What I am trying to do is wait a second before posting the fight data if you have won the fight, the time out piece works. But as you can see I am updating the state to disable the button. What I was thinking of doing is moving the timeout to the `componentDidUpdate` method, that way the component will re-render and the button will be disabled, how ever I feel thats the wrong way to do it. I understand you can wrap the `setState` in an async function, but I also wonder if thats the best approach. **The goal is to disable the button, then wait 1 second and post the data. Whats the best approach?** Whats wrong with this approach? ------------------------------- For those who might not know, the `setState` will be called to update the state, but instead of re-rendering it will then call the callback function thus the button is not disabled while the timer counts down. it will be disabled after the timer, not before, where as I want it before, not after.
2019/03/04
[ "https://Stackoverflow.com/questions/54975362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1270259/" ]
I suspect something else is causing you issue. This code seems to be working the way you want (or I'm misunderstanding). <https://codesandbox.io/s/8nz508y96j> - button click disables the button and post alert appears 3 seconds later Though using `componentDidUpdate` is the recommended approach.. <https://reactjs.org/docs/react-component.html#setstate> > > The second parameter to setState() is an optional callback function that will be executed once setState is completed and the component is re-rendered. Generally we recommend using componentDidUpdate() for such logic instead. > > >
This should do it. ``` if (this.state.opponentIsDead) { this.setState({ disableAttack: 'disabled', }); window.requestAnimationFrame(() => { this.timer = setTimeout(() => { this.props.postFightData({ train_exp: 100, drop_chance: this.state.monster.drop_chance, gold_rush_chance: this.state.monster.gold_rush_chance, gold_drop: this.state.monster.gold_drop, }); }, 1000); }); } ```
8,313,043
I am new to App development , I am using XCode 4.2 I am creating an application that reads QR codes . I would like to be able to save the string (NSString format) and possibly the image in a history list so that even if the user close the application the history of scanned QR codes can be retreived, how can I do that ? a sample code will be appreciated Thanks Alot
2011/11/29
[ "https://Stackoverflow.com/questions/8313043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1051935/" ]
`slideToggle` optionally takes 2 parameters `duration` and a `callback` so passing true/false to show/hide will not work. You might have to write your own plugin which will implement this logic. Something like this ``` $.fn.mySllideToggle = function(show){ if(show){ $(this).slideDown(); } else{ $(this).slideUp(); } } ```
<http://api.jquery.com/slideToggle/> ``` $('something').slideToggle('slow'); ``` <http://jsfiddle.net/WLp9z/1/>
8,313,043
I am new to App development , I am using XCode 4.2 I am creating an application that reads QR codes . I would like to be able to save the string (NSString format) and possibly the image in a history list so that even if the user close the application the history of scanned QR codes can be retreived, how can I do that ? a sample code will be appreciated Thanks Alot
2011/11/29
[ "https://Stackoverflow.com/questions/8313043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1051935/" ]
It is simple like this: ``` $.fn.slideToggleBool = function(bool, options) { return bool? $(this).slideDown(options) : $(this).slideUp(options); } ``` Enjoy!
<http://api.jquery.com/slideToggle/> ``` $('something').slideToggle('slow'); ``` <http://jsfiddle.net/WLp9z/1/>
8,313,043
I am new to App development , I am using XCode 4.2 I am creating an application that reads QR codes . I would like to be able to save the string (NSString format) and possibly the image in a history list so that even if the user close the application the history of scanned QR codes can be retreived, how can I do that ? a sample code will be appreciated Thanks Alot
2011/11/29
[ "https://Stackoverflow.com/questions/8313043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1051935/" ]
It can be shimmed in like so: ```js ;(function($) { var slideToggleOrig = $.fn.slideToggle; $.fn.slideToggle = function(display) { var fn, args = arguments; if ('boolean' != typeof display) { fn = slideToggleOrig; } else { if (display) { fn = this.slideDown; } else { fn = this.slideUp; } args = Array.prototype.slice.call(args, 1);// hide the extra arg from official functions } return fn.apply(this, args); }; })(jQuery); ``` This works by detecting if the first argument to `slideToggle` is a boolean (not just truthy/falsy) and, if so, substituting the up and down functions which have compatible signatures. This means you can use any existing signature, but add an extra argument at the start. It also chains correctly without modifying the stack or creating a new object.
<http://api.jquery.com/slideToggle/> ``` $('something').slideToggle('slow'); ``` <http://jsfiddle.net/WLp9z/1/>
8,313,043
I am new to App development , I am using XCode 4.2 I am creating an application that reads QR codes . I would like to be able to save the string (NSString format) and possibly the image in a history list so that even if the user close the application the history of scanned QR codes can be retreived, how can I do that ? a sample code will be appreciated Thanks Alot
2011/11/29
[ "https://Stackoverflow.com/questions/8313043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1051935/" ]
`slideToggle` optionally takes 2 parameters `duration` and a `callback` so passing true/false to show/hide will not work. You might have to write your own plugin which will implement this logic. Something like this ``` $.fn.mySllideToggle = function(show){ if(show){ $(this).slideDown(); } else{ $(this).slideUp(); } } ```
It is simple like this: ``` $.fn.slideToggleBool = function(bool, options) { return bool? $(this).slideDown(options) : $(this).slideUp(options); } ``` Enjoy!
8,313,043
I am new to App development , I am using XCode 4.2 I am creating an application that reads QR codes . I would like to be able to save the string (NSString format) and possibly the image in a history list so that even if the user close the application the history of scanned QR codes can be retreived, how can I do that ? a sample code will be appreciated Thanks Alot
2011/11/29
[ "https://Stackoverflow.com/questions/8313043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1051935/" ]
`slideToggle` optionally takes 2 parameters `duration` and a `callback` so passing true/false to show/hide will not work. You might have to write your own plugin which will implement this logic. Something like this ``` $.fn.mySllideToggle = function(show){ if(show){ $(this).slideDown(); } else{ $(this).slideUp(); } } ```
It can be shimmed in like so: ```js ;(function($) { var slideToggleOrig = $.fn.slideToggle; $.fn.slideToggle = function(display) { var fn, args = arguments; if ('boolean' != typeof display) { fn = slideToggleOrig; } else { if (display) { fn = this.slideDown; } else { fn = this.slideUp; } args = Array.prototype.slice.call(args, 1);// hide the extra arg from official functions } return fn.apply(this, args); }; })(jQuery); ``` This works by detecting if the first argument to `slideToggle` is a boolean (not just truthy/falsy) and, if so, substituting the up and down functions which have compatible signatures. This means you can use any existing signature, but add an extra argument at the start. It also chains correctly without modifying the stack or creating a new object.
8,313,043
I am new to App development , I am using XCode 4.2 I am creating an application that reads QR codes . I would like to be able to save the string (NSString format) and possibly the image in a history list so that even if the user close the application the history of scanned QR codes can be retreived, how can I do that ? a sample code will be appreciated Thanks Alot
2011/11/29
[ "https://Stackoverflow.com/questions/8313043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1051935/" ]
It is simple like this: ``` $.fn.slideToggleBool = function(bool, options) { return bool? $(this).slideDown(options) : $(this).slideUp(options); } ``` Enjoy!
It can be shimmed in like so: ```js ;(function($) { var slideToggleOrig = $.fn.slideToggle; $.fn.slideToggle = function(display) { var fn, args = arguments; if ('boolean' != typeof display) { fn = slideToggleOrig; } else { if (display) { fn = this.slideDown; } else { fn = this.slideUp; } args = Array.prototype.slice.call(args, 1);// hide the extra arg from official functions } return fn.apply(this, args); }; })(jQuery); ``` This works by detecting if the first argument to `slideToggle` is a boolean (not just truthy/falsy) and, if so, substituting the up and down functions which have compatible signatures. This means you can use any existing signature, but add an extra argument at the start. It also chains correctly without modifying the stack or creating a new object.
16,799,279
I'm not sure if this has been asked before, but I went through a lot of angular 2-way binding posts and frankly couldn't understand what they were talking about. So I'll just state my problem again. Lets say I want to use a tags input plugin such as [this](http://aehlke.github.io/tag-it/examples.html). I define an angular directive called tags and within it, initialize tagsinput on a text input. The text element is bound to a model which is populated in the controller from a service. I have this in Plunker [here.](http://plnkr.co/edit/hIvJjq) The problem is when the directive loads, the model is not populated yet, so the tagsinput plugin is initialized with an empty value. But I want it to be initialized with a server side value. I've come across this problem often and I've been resorting to initializing my plugins in service callbacks within controllers which I know is cardinal sin. I'm unable to get out of thinking that eventually, at some level, the plugin initialization must be delayed until the service returns so the value is available. And am I correct if I say that even in the angular way of doing it, this is somehow achieved? But in any case, I'm not able to figure out how to get this working.
2013/05/28
[ "https://Stackoverflow.com/questions/16799279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/219579/" ]
I think the best way to solve this problem is using a watcher inside your directive. ``` var app = angular.module('app', []); app.controller('Main', function ($scope, $timeout) { //this simulates data being loaded asynchronously after 3 second $timeout(function () { $scope.list = [1, 2, 3, 4]; }, 3000); }); app.directive("mydirective", function() { return { restrict: "A", link: function(scope, element, attrs) { scope.$watch('list', function (newVal, oldVal) { if (newVal) { //initialize the plugns etc scope.result = 'Model has been populated'; } }); } }; }); ``` In my example I am using $timeout inside the controller to simulate an async load of data, once the 'list' model gets populated the watcher inside the directive will realize it (newVal is not empty or undefined) and then the plugin can be initialized. This is a better approach instead of callbacks inside the controller because your code is much more concise. Here is a [jsBin](http://jsbin.com/iwewub/15/edit) EDIT: Just remember that the digest cycle has to be fired when the model is populated. If you are using $resource or $http to fetch the data from the server you don't have to worry, but if you are doing it outside Angular you will have to fire the digest cycle with $scope.$apply() so the watcher can be aware that the model was populated.
As Bertrand said it's achievable by using watchers in directives `link` function. You need to wait for data to appear and this is what watchers are for. Take a look at my update to your plunker here <http://plnkr.co/edit/hb3UYl>. I faked async response with `$timeout` instead of `$http` but it doesn't really matter here. What it does is it sets up watcher in directive's link function which looks for changes of `$scope.list`. If change is detected and `newValue` is something useful it uses it to populate input field and turn it into tag list. Notice I changed your `$('.taginput')` into `element` as this is what you are operating on. Also I think this is good practice to search for DOM elements you want to manipulate only down the hierarchy of current `element`. This makes you sure that if you place directive on given element - no other elements except this one and its children will be impacted.
46,992
So I have a trigger on Order in a certain condition I need to create another opportunity based on the Order's current opportunity. It was pretty straight forward except for getting the products to copy over. I know this is a high level description, but can anyone help with how I should go about doing this? \*removed code because it had unrelated issues. Will add back when resolved.
2014/08/15
[ "https://salesforce.stackexchange.com/questions/46992", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/4739/" ]
Here is an outline solution that should meet your requirements and be bulkified: 1. Get the Ids of the Opportunity records that meet your criteria from your quotes and store them in a `Set<Id>` 2. Query for those Opportunities with the fields you want to clone and store them in a `List<Opportunity>` 3. Loop through this list and add clones of your Opportunities to a `Map<Id, Opportunity>` which maps the original Opportunity Id to the newly cloned Opportunity 4. `insert` your cloned Opportunity records (you can simple call insert on your Map `values()`) 5. Query for all OpportunityLineItem records with `OpportunityId` equal to the `keySet()` of your map and store them in a `List<OpportunityLineItem>` 6. Loop through these and put them in a `Map<Id, List<OpportunityLineItem>>` which maps the `OpportunityId` to it's OpportunityLineItem records 7. Loop through your `Map<Id, Opportunity>` from step 3, use the key of your map (the original Opportunity Id) to get the OpportunityLineItem records from your `Map<Id, List<OpportunityLineItem>>` in step 6, clone the records, update the Id from the value of your map (the Opportunity record your inserted earlier, which will now have an Id) in your `Map<Id, Opportunity>` and then add them to a `List<OpportunityLineItem>` 8. Finally, `insert` your list of OpportunityLineItem
Im guessing your "certain condition" refers to a trigger running After Update on Order. If that is the case, you should have no problem to query for the Opp's OppLineItems, create a new set based on the properties of this old set (all the variables you want to keep, except the ones that are system created like ID and such) and link them properly. But you already seem to know that, what is specifically your problem at "getting the products to copy over?" Do you have any sample code or anything that we could look at to help you? As a wild guess, keep in mind that if you query an object you have to specify every field you want to fetch of it, for example, if you query an Account with the SOQL "[Select Name from Account Where SOMETHING]", and you create a new Account with the info you just fetched, you won't have anything else but the Name of it. Hope any of this helped you and not complicated things more for you! Cheers!
65,023,560
The following example with ducks, is based on the Head First design patterns book. I have a game with different types of ducks. There is a super class Duck and it has two behaviours: fly and quack, which are stored in fields. The concrete classes decide (in the constructor) which behaviour a concrete breed has (see MalardDuck class). I realised I want my ducks to not only have type Duck but also Quackable (so that I can have methods that accept only quackables - assuming that there are other types that quack - see Lake class). When I implement the interface in MallardDuck, the compiler complains that the class does not have the method quack although it is defined in its superclass - Duck class. Now I could think of two solutions: 1. Overwrite a method quack by just calling the method from the superclass: super.quack() <- but that seems unnecessary (in theory) - a child class has a direct access to superclass's public methods, so why the interface Quackable even complains...? 2. Make Duck implement the Quackable -> this is rather illogical cause some Ducks don't Quack (their quackBehaviour is implemented with SiletnQuack class). However in both solutions the duck: * HAS A quackable behaviour, AND * IS A quackable Isn't that fundamentally wrong? What am I missing? ``` abstract class Duck{ protected Flyiable flyBehaviour; protected Quackable quackBehaviour; public void quack(){ quackBehaviour.quack(); } void performFly(){ flyBehaviour.fly(); } void swim(){ // swimming implementation } abstract void display(); } interface Quackable{ void quack(); } class Quack implements Quackable{ @Override public void quack() { System.out.println("Quack!"); } } class Quack implements Quackable{ @Override public void quack() { System.out.println("Quack!"); } } class SilentQuack implements Quackable{ @Override public void quack() { System.out.println("..."); } } class MallardDuck extends Duck{ public MallardDuck(){ quackBehaviour = new Quack(); flyBehaviour = new FlyWithWings(); } @Override void display() { // it looks like a Mallard duck } } ``` What if I want to accept ducks to this method as quackables (along with other animals): ``` class Lake{ ArrayList<Quackable> quackingAnimals; void addQuackingAnimal(Quackable animal){ quackingAnimals.add(animal); } void displayQuackables(){ //... } } ``` Solution 1: ``` class MallardDuck extends Duck implements Quackable { public MallardDuck(){ quackBehaviour = new Quack(); flyBehaviour = new FlyWithWings(); } @Override void display() { // it looks like a Mallard duck } @Override public void quack() { super.quack(); } } ``` Solution 2: ``` abstract class Duck implements Quackable{ protected Flyiable flyBehaviour; protected Quackable quackBehaviour; public void quack(){ quackBehaviour.quack(); } void performFly(){ flyBehaviour.fly(); } void swim(){ // swimming implementation } abstract void display(); } ```
2020/11/26
[ "https://Stackoverflow.com/questions/65023560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11958281/" ]
This is because `Duck` class DOES NOT implement the `quack` method from the `Quackable` interface. Although it has a `quack` method with the same signature, it is not the same method, that is declared in the interface. I do not understand, why Solution 2 (making the `Duck` class implement `Quackable` interface) would be illogical - it does expose public method for quacking, so all of it's descendants will `quack` anyway (but with different `quack` that is declared in the `Quackable` interface). In my opinion (only opinion), the `Duck` class should implement `Quackable`. If (in your case) not all `Ducks` `quack`, then it is reasonable, that a `Duck` can't be treated as something that has `Quackable` behavior and thus it can't be added to the collection of `Quackable` objects. In this case (in my opinion) you could create another abstract class extending `Duck` and implementing `Quackable` interface (like `QuackingDuck`) and in this case (in my opinion) you should remove `quack` method from `Duck` class - as not all `Ducks` `quack`. I hope that it answers your question. To sum up: * the `quack` method from `Duck` is not the implementation of the `quack` method from `Quackable` interface (as it would be the case in e.g. JavaScript) * in current implementation all `Ducks` `quack`, only their `quacking` behavior (implementation) is different (and in the case of `SilentDuck` - it still `quacks`)
[In the context of your question, I prefer to use the term "delegate" over "behaviour", because I personally think it better conveys the concept.] Your interface `Quackable` effectively means "something that can quack". And even the original `Duck` abstract class had that method, so it already followed that interface, but you "forgot" to declare that fact. In a consistent world, you should have had `Duck` implement `Quackable` right from the beginning. Regarding HAS and IS: All `Ducks` have some `quack()` method, so effectively they ARE `Quackable` (in the meaning of "something that can quack"). It doesn't matter how they decide about their quack() implementation, using the inherited delegation method, modifying the inherited version by supplying a different delegete/behaviour, or overriding the method. The fact that they have the `quack()` ability defines them as BEING `Quackable`. Your Duck subclasses also HAVE a `Quackable` and use it as a delegate, deferring the real quacking to some other "behaviour" instance (like politicians who don't publish their opinions himself, but by having a spokesperson). So, there's nothing wrong about a class BEING `Quackable` and HAVING `Quackable` at the same time. In the real world, we all ARE LivingCreatures, and many of us HAVE LivingCreatures as our pets. One remark on behaviour objects: Though this pattern can be useful, be aware that you loose the ability (or at least make it quite complicated) to make the `quack()` behaviour depend on the Duck's state (e.g. sound differently if on water or in the air).
65,023,560
The following example with ducks, is based on the Head First design patterns book. I have a game with different types of ducks. There is a super class Duck and it has two behaviours: fly and quack, which are stored in fields. The concrete classes decide (in the constructor) which behaviour a concrete breed has (see MalardDuck class). I realised I want my ducks to not only have type Duck but also Quackable (so that I can have methods that accept only quackables - assuming that there are other types that quack - see Lake class). When I implement the interface in MallardDuck, the compiler complains that the class does not have the method quack although it is defined in its superclass - Duck class. Now I could think of two solutions: 1. Overwrite a method quack by just calling the method from the superclass: super.quack() <- but that seems unnecessary (in theory) - a child class has a direct access to superclass's public methods, so why the interface Quackable even complains...? 2. Make Duck implement the Quackable -> this is rather illogical cause some Ducks don't Quack (their quackBehaviour is implemented with SiletnQuack class). However in both solutions the duck: * HAS A quackable behaviour, AND * IS A quackable Isn't that fundamentally wrong? What am I missing? ``` abstract class Duck{ protected Flyiable flyBehaviour; protected Quackable quackBehaviour; public void quack(){ quackBehaviour.quack(); } void performFly(){ flyBehaviour.fly(); } void swim(){ // swimming implementation } abstract void display(); } interface Quackable{ void quack(); } class Quack implements Quackable{ @Override public void quack() { System.out.println("Quack!"); } } class Quack implements Quackable{ @Override public void quack() { System.out.println("Quack!"); } } class SilentQuack implements Quackable{ @Override public void quack() { System.out.println("..."); } } class MallardDuck extends Duck{ public MallardDuck(){ quackBehaviour = new Quack(); flyBehaviour = new FlyWithWings(); } @Override void display() { // it looks like a Mallard duck } } ``` What if I want to accept ducks to this method as quackables (along with other animals): ``` class Lake{ ArrayList<Quackable> quackingAnimals; void addQuackingAnimal(Quackable animal){ quackingAnimals.add(animal); } void displayQuackables(){ //... } } ``` Solution 1: ``` class MallardDuck extends Duck implements Quackable { public MallardDuck(){ quackBehaviour = new Quack(); flyBehaviour = new FlyWithWings(); } @Override void display() { // it looks like a Mallard duck } @Override public void quack() { super.quack(); } } ``` Solution 2: ``` abstract class Duck implements Quackable{ protected Flyiable flyBehaviour; protected Quackable quackBehaviour; public void quack(){ quackBehaviour.quack(); } void performFly(){ flyBehaviour.fly(); } void swim(){ // swimming implementation } abstract void display(); } ```
2020/11/26
[ "https://Stackoverflow.com/questions/65023560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11958281/" ]
This is because `Duck` class DOES NOT implement the `quack` method from the `Quackable` interface. Although it has a `quack` method with the same signature, it is not the same method, that is declared in the interface. I do not understand, why Solution 2 (making the `Duck` class implement `Quackable` interface) would be illogical - it does expose public method for quacking, so all of it's descendants will `quack` anyway (but with different `quack` that is declared in the `Quackable` interface). In my opinion (only opinion), the `Duck` class should implement `Quackable`. If (in your case) not all `Ducks` `quack`, then it is reasonable, that a `Duck` can't be treated as something that has `Quackable` behavior and thus it can't be added to the collection of `Quackable` objects. In this case (in my opinion) you could create another abstract class extending `Duck` and implementing `Quackable` interface (like `QuackingDuck`) and in this case (in my opinion) you should remove `quack` method from `Duck` class - as not all `Ducks` `quack`. I hope that it answers your question. To sum up: * the `quack` method from `Duck` is not the implementation of the `quack` method from `Quackable` interface (as it would be the case in e.g. JavaScript) * in current implementation all `Ducks` `quack`, only their `quacking` behavior (implementation) is different (and in the case of `SilentDuck` - it still `quacks`)
You are having the same method in both superclass and interface. The `quack()` method in MallardDuck class **does 2 things at one time**: 1. Override `quack()` in the superclass Duck 2. Implement `quack()` in the Quackable interface. Solution 2 helps you to avoid this situation.
1,518,433
Ofcourse the IL is lanuage independent,can i get the source code back from IL (let the source code be any language C#,VB) ?
2009/10/05
[ "https://Stackoverflow.com/questions/1518433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/160677/" ]
You could use [.NET Reflector](http://www.red-gate.com/products/reflector/) and [Denis Bauer's Reflector.FileDisassembler](http://www.denisbauer.com/NETTools/FileDisassembler.aspx): > > The Reflector.FileDisassembler is a > little add-in for the new version of > Lutz Roeder's .NET Reflector that you > can use to dump the decompiler output > to files of any Reflector supported > language (C#, VB.NET, Delphi). This is > extremely useful if you are searching > for a specific line of code as you can > use VS.NET's "Find in Files" or want > to convert a class from one language > to another. > > >
Yes, to an extent, <http://www.red-gate.com/products/reflector/>.
1,518,433
Ofcourse the IL is lanuage independent,can i get the source code back from IL (let the source code be any language C#,VB) ?
2009/10/05
[ "https://Stackoverflow.com/questions/1518433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/160677/" ]
You could use [.NET Reflector](http://www.red-gate.com/products/reflector/) and [Denis Bauer's Reflector.FileDisassembler](http://www.denisbauer.com/NETTools/FileDisassembler.aspx): > > The Reflector.FileDisassembler is a > little add-in for the new version of > Lutz Roeder's .NET Reflector that you > can use to dump the decompiler output > to files of any Reflector supported > language (C#, VB.NET, Delphi). This is > extremely useful if you are searching > for a specific line of code as you can > use VS.NET's "Find in Files" or want > to convert a class from one language > to another. > > >
Use [MSIL Disassembler (Ildasm.exe)](http://msdn.microsoft.com/en-us/library/f7dy01k1%28VS.80%29.aspx)
1,518,433
Ofcourse the IL is lanuage independent,can i get the source code back from IL (let the source code be any language C#,VB) ?
2009/10/05
[ "https://Stackoverflow.com/questions/1518433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/160677/" ]
You could use [.NET Reflector](http://www.red-gate.com/products/reflector/) and [Denis Bauer's Reflector.FileDisassembler](http://www.denisbauer.com/NETTools/FileDisassembler.aspx): > > The Reflector.FileDisassembler is a > little add-in for the new version of > Lutz Roeder's .NET Reflector that you > can use to dump the decompiler output > to files of any Reflector supported > language (C#, VB.NET, Delphi). This is > extremely useful if you are searching > for a specific line of code as you can > use VS.NET's "Find in Files" or want > to convert a class from one language > to another. > > >
yes, you can using ILDASM.exe <http://msdn.microsoft.com/en-us/library/f7dy01k1%28VS.80%29.aspx>
48,875,492
I have been flabbergasted with this problem since yesterday ``` $('input').click(function(){ var suggid; var state; suggid = $(this).attr("data-notifid"); state = $(this).attr("checked"); $.get('/notifications/toggle_read/', {suggestion_id: suggid, unread: state}); }); ``` I've been trying to send `suggestion_id` and `unread` to my endpoint in a Django app. In a previous iteration, I was also trying `state = $(this).checked;`, since code samples I was finding appeared to do that. The problem is that *I have been testing this code and making minor tweaks maybe about 50 times, and it has only ever sent `unread` once, when I hardcoded it to `"1"`.* Every single other request logged out as something like this: `GET /notifications/toggle_read/?suggestion_id=31` both in my runserver logs and in the console. I always refreshed the page on which the script appeared before testing the code on the widget, and even confirmed it was up-to-date in the browser source. I'm baffled... according to what I've read about `.get()`, this is exactly how you're supposed to send multiple query parameters e.g. `$.get( "test.php", { name: "John", time: "2pm" } );` at [this doc](http://api.jquery.com/jQuery.get/) What am I doing wrong?!
2018/02/19
[ "https://Stackoverflow.com/questions/48875492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459594/" ]
It seems to me that the below makes no sense, and is always FALSE: ``` if (hist.data %in% rcp.data) ``` So nothing happens with `sim_array` I would start by doing something like this: ``` hist.files.pr <- list.files("/historical", full.names = TRUE, pattern="pr") hist.files.tas <- list.files("/historical", full.names = TRUE, pattern="tas") rcp.files.pr <- list.files("/rcp", full.names = TRUE, pattern="pr") rcp.files.tas <- list.files("/rcp", full.names = TRUE, pattern="tas") ``` At this point you can remove the files from "hist" for models that are not in "rcp" ``` hist.files.tas <- c( "/historical/tas_CNRM-CERFACS-CNRM-CM5_CLMcom-CCLM4-8-17_r1i1p1.nc", "/historical/tas_CNRM-CERFACS-CNRM-CM5_CNRM-ALADIN53_r1i1p1.nc", "/historical/tas_CNRM-CERFACS-CNRM-CM5_RMIB-UGent-ALARO-0_r1i1p1.nc", "/historical/tas_CNRM-CERFACS-CNRM-CM5_SMHI-RCA4_r1i1p1.nc", "/historical/tas_ICHEC-EC-EARTH_CLMcom-CCLM4-8-17_r12i1p1.nc", "/historical/tas_ICHEC-EC-EARTH_DMI-HIRHAM5_r3i1p1.nc", "/historical/tas_ICHEC-EC-EARTH_KNMI-RACMO22E_r12i1p1.nc", "/historical/tas_ICHEC-EC-EARTH_KNMI-RACMO22E_r1i1p1.nc", "/historical/tas_ICHEC-EC-EARTH_SMHI-RCA4_r12i1p1.nc", "/historical/tas_IPSL-IPSL-CM5A-MR_INERIS-WRF331F_r1i1p1.nc", "/historical/tas_IPSL-IPSL-CM5A-MR_SMHI-RCA4_r1i1p1.nc", "/historical/tas_MOHC-HadGEM2-ES_CLMcom-CCLM4-8-17_r1i1p1.nc", "/historical/tas_MOHC-HadGEM2-ES_KNMI-RACMO22E_r1i1p1.nc", "/historical/tas_MOHC-HadGEM2-ES_SMHI-RCA4_r1i1p1.nc") # in this example, fut files is a subset of hist files; that should be OK if their filename structure is the same rcp.files.tas <- hist.files.tas[1:7] getModels <- function(ff) { base <- basename(ff) s <- strsplit(base, "_") sapply(s, function(i) i[[2]]) } getHistModels <- function(hist, fut) { h <- getModels(hist) uh <- unique(h) uf <- unique(getModels(fut)) uhf <- uh[uh %in% uf] hist[h %in% uhf] } hist.files.tas.selected <- getHistModels(hist.files.tas, rcp.files.tas) # hist.files.pr.selected <- getHistModels(hist.files.pr, rcp.files.pr) ``` The double loop (k, r) could probably be avoided by doing something like this: ``` library(raster) his.pr <- values(stack(hist.files.pr.selected, var="pr"))) his.tas <- values(stack(hist.files.tas.selected, var="tas")) rcp.pr <- values(stack(hist.files.pr, var="pr")) rcp.tas <- values(stack(hist.files.tas, var="tas")) ``` And the (i, j) loop over the rows and cols can probably be avoided too. R is vectorized. That is, you can do things like `(1:10) - 2`. Either way, your code is very hard to read with all these nested loops. If you actually need them, it would be better to call functions. For more help, provide some example data instead of files that we do not have, or make a few files available.
As there actually are two more variables "tasmax" and "tasmin" besides "tas" and "pr" in my dataset Robert's approach would have been to much writing for my case. Thus, I tried another way, that finally worked out, although it doesn't list the files of each variable separately (a disadvantage, yes!). List and match files of historical and rcp: To match the files I need the pure names of the files without directory, otherwise which(!hist %in% rcp) will always be FALSE (as shown by Robert). hist <- list.files("/historical") rcp <- list.files("/rcp26") no.match.h <- which(!hist %in% rcp) no.match.r <- which(!rcp %in% hist) As I need for nc\_open the filename including directory I must create an according file list and subtract the non-matching files hist.files <- list.files("/data/scratch/lorchdav/cordex\_eur/monmean/historical", full.names = TRUE) rcp.files <- list.files("/data/scratch/lorchdav/cordex\_ber\_mean/rcp26", full.names = TRUE) hist.files.cl <- hist.files[-no.match.h] hist.files.cl rcp.files.cl <- rcp.files[-no.match.r] rcp.files.cl
614,601
I'm in the process of writing a small web app that would allow me to manage several IIS installations on different servers on our network. We have no domain controller. I have written a small impersonation controller that uses the win32 api and its LogonUser method. I then use System.DirectoryServices and the IIS ADSI provider to create a new site. I have the following routine (exchanged some values with clear-text strings for better readability): ``` if (impersonationSvc.ImpersonateValidUser("Administrator@SRV6", String.Empty, "PASSWORD)) { string metabasePath = "IIS://" + server.ComputerName + "/W3SVC"; DirectoryEntry w3svc = new DirectoryEntry(metabasePath, "Administrator", "PASSWORD"); string serverBindings = ":80:" + site.HostName; string homeDirectory = server.WWWRootNetworkPath + "\\" + site.FolderName; object[] newsite = new object[] { site.Name, new object[] { serverBindings }, homeDirectory }; object websiteId = (object)w3svc.Invoke("CreateNewSite", newsite); int id = (int)websiteId; impersonationSvc.UndoImpersonation(); } ``` This routine works when I use the server the web app is hosted on (SRV6). A new site is created. If I use SRV5 for instance, another Server on our network (with no domain), ImpersonateValidUser works, the DirectoryEntry is created, but w3svc.Invoke fails with the following error: **[COMException (0x80070005): Access denied]** ``` System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +377678 System.DirectoryServices.DirectoryEntry.Bind() +36 System.DirectoryServices.DirectoryEntry.get_NativeObject() +31 System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) +53 ``` ... Anyone knows how I could solve this?
2009/03/05
[ "https://Stackoverflow.com/questions/614601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13466/" ]
You cannot use impersonation in this situation. The account you are impersonating needs login priveleges on the local machine. If your web servers are not part of a domain, I think Tant102's idea of web services is your only way to go.
I would look into the eventlog of SRV5 to check what privileges are used when you connect to that server. You may need to change your group policies to log failures in the security log. It sounds easier to setup webservices on your servers, preferably protected by logins and/or ip restrictions, that does these kind of operations.
16,492,135
``` <div class="carousel colorDissolve"> <img class="item" src="car.jpg" /> <img class="item" src="plane.jpg" /> <img class="item" src="train.jpg"/> <img class="item" src="boat.jpg" /> </div> /* colorDissolve */ .colorDissolve { position: relative; overflow: hidden; width: 287px; height: 430px; background: #000000; } .colorDissolve .item { position: absolute; left: 0; right: 0; opacity: 0; -webkit-animation: colorDissolve 24s linear infinite; -moz-animation: colorDissolve 24s linear infinite; -ms-animation: colorDissolve 24s linear infinite; animation: colorDissolve 24s linear infinite; } .colorDissolve .item:nth-child(2) { -webkit-animation-delay: 6s; -moz-animation-delay: 6s; -ms-animation-delay: 6s; animation-delay: 6s; } .colorDissolve .item:nth-child(3) { -webkit-animation-delay: 12s; -moz-animation-delay: 12s; -ms-animation-delay: 12s; animation-delay: 12s; } .colorDissolve .item:nth-child(4) { -webkit-animation-delay: 18s; -moz-animation-delay: 18s; -ms-animation-delay: 18s; animation-delay: 18s; } @-webkit-keyframes colorDissolve { 0%, 25%, 100% { opacity: 0; } 4.17%, 20.84% { opacity: 1;} } @-moz-keyframes colorDissolve { 0%, 25%, 100% { opacity: 0; } 4.17%, 20.84% { opacity: 1;} } @-ms-keyframes colorDissolve { 0%, 25%, 100% { opacity: 0; } 4.17%, 20.84% { opacity: 1;} } @keyframes colorDissolve { 0%, 25%, 100% { opacity: 0; } 4.17%, 20.84% { opacity: 1;} } ``` I cannot seem to get text OVER images this carousel. If I used a button slider, I can, but I just cannot seem to do it this way. It feels like I am not getting the div structure right. I tried to div each slide, but the text shows on the first slide from every div. Any guidance would be appreciated. I need different text over each slide when it appears, but I cannot get it to structurally work.
2013/05/10
[ "https://Stackoverflow.com/questions/16492135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2371762/" ]
[**JS fiddle DEMO**](http://jsfiddle.net/habo/u5dTp/) modified your markup a little ``` <div class="carousel colorDissolve"> <div class="item"> <img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTGNBB_xiix1HdkfCW1OG8NmMqbU23KUIXKE1HuK3RW3UBV_smc" /> <span>Picture Car from Google.com</span> </div> <div class="item"> <img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRMj84NfnxY3l_GbZFFUvmBI3Zg_tPjPutlomjfiU0TyPJFG3O1" /> <span>Picture Plane from Google.com</span> </div> <div class="item"> <img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS_i3dd7B8UkOKEaI4bVBmpyld_5JkZWbwC8vObZiw6PxUTSl53"/> <span>This is train</span> </div> <div class="item"> <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQZT3h9jLlg7yC3RNr8rg8l2JlurpXkJX1MXRrwh9eYI9BMJD316w" /> <span>This is boatm</span> </div> </div> ``` Added styling to span ``` span{ position:absolute; top:0px; left:0px; color:#c30; font-size:2em; -webkit-text-stroke-width: 1px; -webkit-text-stroke-color: black; } ```
I used simple `<p>` instead of image and I gave image as a back-ground...It worked perfectly. might needed little modification for alignment and font's styles... ``` <div id="table_container"> <div id="myCarousel" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <p style="background-image: url('image/Tourist destination (9).jpg'); height: 400px; width: 1000px;"> <font size='14px;' color='white'>Hello...</font><br/> <font size='10px;' color='white'>How are you doing?</font> </p> </div> </div> <!-- Left and right controls --> <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> ```
82,886
In my campaign, I am playing a Hybrid Swordmage who is using the Vigilante Character Theme to allow him to apply marks with the Mark of the Vigilante power. This power reads: > > **Effect:** You assume a stance, the mark of the vigilante. Until the stance ends, you gain the following benefits. > > > * Whenever you hit an enemy with a melee or ranged attack, you can mark the enemy until the end of your next turn. > * You gain a +2 power bonus to all defenses against opportunity attacks that you provoke by moving." > > > My question is about the marking. If the target is marked by the mark of the Vigilante power, can I use my Swordmage Aegis of Assault power? The power reads: > > **Effect:** You mark the target. The target remains marked until you use this power against another target. If you mark other creatures using other powers, the target is still marked. A creature can be subject to only one mark at a time. A new mark supersedes a mark that was already in place. > > > If your marked target makes an attack that doesn't include you as a target, it takes a –2 penalty to attack rolls. If that attack hits and the marked target is within 10 squares of you, you can use an immediate reaction to teleport to a square adjacent to the target and make a melee basic attack against it. If no unoccupied space exists adjacent to the target, you can't use this immediate reaction. > > > Note that it refers to the target as a "marked target". Does the effect apply if the target is marked by another power?
2016/06/19
[ "https://rpg.stackexchange.com/questions/82886", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/29712/" ]
It depends on the class ----------------------- Different classes use marks in different ways, some having generic marks, and some having special, named marks. For example, Paladins have not just one, but two named marks, Divine Challenge and Divine Sanction, which have additional features beyond generic marks. **Swordmage Aegis marks are indeed special marks** with extra features you can apply if the mark is ignored, **and thus must be applied with your appropriate Aegis power** or some other power that specifies that it counts as your Aegis **to gain the extra benefits**. This is further supported by the Aegis Blade magic weapon, which has the following power: > > **Power (Daily):** Minor. Mark each enemy within a close burst 3 (save ends). If you have the Swordmage Aegis class feature, treat each mark as if you applied it with your chosen aegis. > > > Generally speaking, any such effects named within a power that adds the mark only apply for marks created with the same power, while other powers that only specify a mark work with any mark. Paladins and Swordmages have these special marks. Cavaliers, Knights, and Berserkers use a Defender Aura instead of marks. Fighters, Wardens, and Battleminds primarily use generic marks.
In your case, no. The ability for you to to make your Aegis Assault attack is listed as an *effect* of your Aegis of Assault that comes *after* the marking action. If the target was not marked by the Aegis, then it isn't vulnerable to the Aegis attack granted as part of the marking power. The Aegis says "your marked target" as opposed to the fighter's Combat Challenge that says "If a target marked by you". Combat Challenge also does not have an integrated marking ability and therefore is much looser.
74,208,833
I have a table called relationships: [![relationships](https://i.stack.imgur.com/ves46.png)](https://i.stack.imgur.com/ves46.png) And another called relationship\_type: [![relationship type](https://i.stack.imgur.com/aZPAK.png)](https://i.stack.imgur.com/aZPAK.png) A person can have a social worker assigned to them on a specified time period (has start and end time), or specified to them with a start time only. I am writing a query to retieve records of a social worker assigned to someone during a filtered time. My query looks like this : ``` SELECT r.person_a AS patient_id, greatest((r.start_date), (r.end_date)) as relationship_date, concat_ws( ' ', pn.family_name, pn.given_name, pn.middle_name ) AS NAME FROM relationship r INNER JOIN relationship_type t ON r.relationship = t.relationship_type_id INNER JOIN person_name pn ON r.person_b = pn.person_id WHERE t.uuid = '9065e3c6-b2f5-4f99-9cbf-f67fd9f82ec5' AND ( r.end_date IS NULL OR r.end_date <= date("2022-10-26")); ``` I only want to retrieve the patient\_id of the user and name of case worker whose relationship is valid during the filtered time. In an instance where a relationship has no end date, i use the start date. Any advice/recommendation on what i am doing wrong will be appreciated. My current output : [![output](https://i.stack.imgur.com/aiU9B.png)](https://i.stack.imgur.com/aiU9B.png)
2022/10/26
[ "https://Stackoverflow.com/questions/74208833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6480460/" ]
There is an Outlook quirk, `.Display` before editing. Appears it applies in this situation too. ```vb Option Explicit Sub CreateTask() Dim itm As Object Dim msg As MailItem Dim olTask As TaskItem Set itm = ActiveExplorer.Selection.Item(1) If itm.Class = olMail Then Set msg = itm Set olTask = CreateItem(olTaskItem) With olTask .subject = msg.subject .RTFBody = msg.RTFBody .Display ' <--- Earlier rather than later .Attachments.Add msg, , 1 End With End If End Sub ```
Use the [MailItem.MarkAsTask](https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem.markastask) method which marks a `MailItem` object as a task and assigns a task interval for the object.
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
This is already built into the .net framework :-) just check out the compression namespace: <http://msdn.microsoft.com/en-us/library/system.io.compression.aspx>
.net already has built in support for gzip and deflate in [system.io.compression](http://msdn.microsoft.com/en-us/library/3z72378a.aspx)
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
This is already built into the .net framework :-) just check out the compression namespace: <http://msdn.microsoft.com/en-us/library/system.io.compression.aspx>
[DotNetZip](http://dotnetzip.codeplex.com/) is quite a popular open-source library. It uses the `Microsoft Public License (Ms-PL)` license, which you can read about [here](http://dotnetzip.codeplex.com/license) and see if it suits your needs.
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
This is already built into the .net framework :-) just check out the compression namespace: <http://msdn.microsoft.com/en-us/library/system.io.compression.aspx>
If you want ZIP capability, that's not *really* present in the .Net Framework and you'll need to go to a 3rd party library like SharpZipLib or DotNetZip. SharpZipLib is not BSD, it is GPL or LGPL, and may not be suitable for you based on your description. DotNetZip is Ms-PL, which is BSD-like, check <http://www.opensource.org/licenses/ms-pl> . a GZIP stream is available in the System.IO.Compression namespace, which IS builtin to the .NET Framework base class library, but that stream does not read or unpack tar.gz files, which I guess is what you'd want to use if you were bundling multiple files together. GZIP by itself defaults to storing just ONE file in a compressed archive, and you can use that GZipStream to do *that*, but it won't do Tars. SharpZipLib does Tars, but...the license. There are Ms-PL 3rd party (small) tar libraries that, combined with GZIP in .NET, can let you read tar.gz (or .tgz) files easily. <http://cheeso.members.winisp.net/srcview.aspx?dir=Tar>
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
This is already built into the .net framework :-) just check out the compression namespace: <http://msdn.microsoft.com/en-us/library/system.io.compression.aspx>
If you want to package multiple files into one compressed file consider using classes from System.IO.Packaging - <http://msdn.microsoft.com/en-us/library/ms569886.aspx> - allows to put files into Zip file (requires one additional XML file on topof your content).
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
[DotNetZip](http://dotnetzip.codeplex.com/) is quite a popular open-source library. It uses the `Microsoft Public License (Ms-PL)` license, which you can read about [here](http://dotnetzip.codeplex.com/license) and see if it suits your needs.
.net already has built in support for gzip and deflate in [system.io.compression](http://msdn.microsoft.com/en-us/library/3z72378a.aspx)
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
[DotNetZip](http://dotnetzip.codeplex.com/) is quite a popular open-source library. It uses the `Microsoft Public License (Ms-PL)` license, which you can read about [here](http://dotnetzip.codeplex.com/license) and see if it suits your needs.
If you want ZIP capability, that's not *really* present in the .Net Framework and you'll need to go to a 3rd party library like SharpZipLib or DotNetZip. SharpZipLib is not BSD, it is GPL or LGPL, and may not be suitable for you based on your description. DotNetZip is Ms-PL, which is BSD-like, check <http://www.opensource.org/licenses/ms-pl> . a GZIP stream is available in the System.IO.Compression namespace, which IS builtin to the .NET Framework base class library, but that stream does not read or unpack tar.gz files, which I guess is what you'd want to use if you were bundling multiple files together. GZIP by itself defaults to storing just ONE file in a compressed archive, and you can use that GZipStream to do *that*, but it won't do Tars. SharpZipLib does Tars, but...the license. There are Ms-PL 3rd party (small) tar libraries that, combined with GZIP in .NET, can let you read tar.gz (or .tgz) files easily. <http://cheeso.members.winisp.net/srcview.aspx?dir=Tar>
5,941,313
I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...). The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.
2011/05/09
[ "https://Stackoverflow.com/questions/5941313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384016/" ]
[DotNetZip](http://dotnetzip.codeplex.com/) is quite a popular open-source library. It uses the `Microsoft Public License (Ms-PL)` license, which you can read about [here](http://dotnetzip.codeplex.com/license) and see if it suits your needs.
If you want to package multiple files into one compressed file consider using classes from System.IO.Packaging - <http://msdn.microsoft.com/en-us/library/ms569886.aspx> - allows to put files into Zip file (requires one additional XML file on topof your content).
353,081
Imagine a container filled with highly pressurized air. Now imagine that there is some object, maybe a marble, inside the container. Is it possible to cause the marble to "float" within mid-air, due to the forces of the pressurized air acting on it in all directions? Additionally, why is it that objects tend to spread to the edges of the container, rather than the center? I imagine this would also depend on the shape, size, and pressure of the container, as well as the shape and size of the objects inside. [![OP's MS Paint effort. From http://i.imgur.com/4H5qjI6.png as posted in comments.](https://i.stack.imgur.com/FNVIs.png)](https://i.stack.imgur.com/FNVIs.png)
2017/08/22
[ "https://physics.stackexchange.com/questions/353081", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/64624/" ]
Yes. In practice it probably depends on the temperature, but **let's assume not real air, but an ideal gas**. Then, all you have to do is to increase the pressure enough for it to have the same (or infinitesimally higher) density than the marble: at this point [buoyancy](https://en.wikipedia.org/wiki/Buoyancy) equals the weight of the marble and it can "float". That will not depend on the shape or size of the object inside, only on its density. As for the spread you describe, unless there's some sort of flow in the container, there has to be some effective attraction to the wall. * **Edit**: it's important to note that, if the key concepts are not only *pressure* and *flotation*, but also *air*, than, as many pointed out, air cannot be made as dense as a typical marble without changing phase (and or melting the marble).
Just generally, the density of the "fluid" in which the marble's floating has to be greater than the density of the marble. But air liquifies first, see <https://en.wikipedia.org/wiki/Triple_point> I don't know if there's any high-enough temperature where air wouldn't liquify before reaching a typical marble's density.
353,081
Imagine a container filled with highly pressurized air. Now imagine that there is some object, maybe a marble, inside the container. Is it possible to cause the marble to "float" within mid-air, due to the forces of the pressurized air acting on it in all directions? Additionally, why is it that objects tend to spread to the edges of the container, rather than the center? I imagine this would also depend on the shape, size, and pressure of the container, as well as the shape and size of the objects inside. [![OP's MS Paint effort. From http://i.imgur.com/4H5qjI6.png as posted in comments.](https://i.stack.imgur.com/FNVIs.png)](https://i.stack.imgur.com/FNVIs.png)
2017/08/22
[ "https://physics.stackexchange.com/questions/353081", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/64624/" ]
Just generally, the density of the "fluid" in which the marble's floating has to be greater than the density of the marble. But air liquifies first, see <https://en.wikipedia.org/wiki/Triple_point> I don't know if there's any high-enough temperature where air wouldn't liquify before reaching a typical marble's density.
See the other answers about increasing pressure until the density of the gas is equivalent to that of the object. > > Additionally, why is it that objects tend to spread to the edges of the container, rather than the center? > > > That's just entropy. The number of states (e.g., position) of the marble that would count as "near the edges" is vastly, *vastly* larger than the amount of states that we would consider "at the center". Now, divide the volume into an arbitrarily fine grid of voxels (like 3D-pixels) and label each one either "near the edge" or "near the center" by whatever definition you please. You will have hugely more voxels labeled "near the edge". Unless you actively stabilize the marble in the center, *any* wayward motion of the marble will put it at a more or less random other place. If we assume that nothing influences it after getting a little nudge in a random direction with a random amount of energy, then it will bounce around like a 3D billiard ball and eventually come to rest somewhere after some of the energy is bled off through collisions with the box (large effect); and the rest by the constant bombardment of gas molecules (minuscule effect, but it is still there). Simply counting the voxels, it is much more likely that it will come to rest in one that is labeled "near the edge" because there simply are more than those around than the few "in the center" voxels. *(N.B. to address a technicality mentioned in the comments: the above is slightly simplified; in practice you would need 3 categories ("close to the edge", "at the center", "in between"). If the box gets large, a large amount of those voxels would be "in between". Still, the amount "at the center" would be basically constant and very small, while both other categories grow. So you see why it is at least highly improbable that wherever the marble goes, it will not be at the center, or at any other specific place.)*
353,081
Imagine a container filled with highly pressurized air. Now imagine that there is some object, maybe a marble, inside the container. Is it possible to cause the marble to "float" within mid-air, due to the forces of the pressurized air acting on it in all directions? Additionally, why is it that objects tend to spread to the edges of the container, rather than the center? I imagine this would also depend on the shape, size, and pressure of the container, as well as the shape and size of the objects inside. [![OP's MS Paint effort. From http://i.imgur.com/4H5qjI6.png as posted in comments.](https://i.stack.imgur.com/FNVIs.png)](https://i.stack.imgur.com/FNVIs.png)
2017/08/22
[ "https://physics.stackexchange.com/questions/353081", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/64624/" ]
Yes. In practice it probably depends on the temperature, but **let's assume not real air, but an ideal gas**. Then, all you have to do is to increase the pressure enough for it to have the same (or infinitesimally higher) density than the marble: at this point [buoyancy](https://en.wikipedia.org/wiki/Buoyancy) equals the weight of the marble and it can "float". That will not depend on the shape or size of the object inside, only on its density. As for the spread you describe, unless there's some sort of flow in the container, there has to be some effective attraction to the wall. * **Edit**: it's important to note that, if the key concepts are not only *pressure* and *flotation*, but also *air*, than, as many pointed out, air cannot be made as dense as a typical marble without changing phase (and or melting the marble).
See the other answers about increasing pressure until the density of the gas is equivalent to that of the object. > > Additionally, why is it that objects tend to spread to the edges of the container, rather than the center? > > > That's just entropy. The number of states (e.g., position) of the marble that would count as "near the edges" is vastly, *vastly* larger than the amount of states that we would consider "at the center". Now, divide the volume into an arbitrarily fine grid of voxels (like 3D-pixels) and label each one either "near the edge" or "near the center" by whatever definition you please. You will have hugely more voxels labeled "near the edge". Unless you actively stabilize the marble in the center, *any* wayward motion of the marble will put it at a more or less random other place. If we assume that nothing influences it after getting a little nudge in a random direction with a random amount of energy, then it will bounce around like a 3D billiard ball and eventually come to rest somewhere after some of the energy is bled off through collisions with the box (large effect); and the rest by the constant bombardment of gas molecules (minuscule effect, but it is still there). Simply counting the voxels, it is much more likely that it will come to rest in one that is labeled "near the edge" because there simply are more than those around than the few "in the center" voxels. *(N.B. to address a technicality mentioned in the comments: the above is slightly simplified; in practice you would need 3 categories ("close to the edge", "at the center", "in between"). If the box gets large, a large amount of those voxels would be "in between". Still, the amount "at the center" would be basically constant and very small, while both other categories grow. So you see why it is at least highly improbable that wherever the marble goes, it will not be at the center, or at any other specific place.)*
34,864,651
Does Ruby cache the result of a method so that it does not need to evaluate it twice if it is called twice? I am working in Rails, so for example, I could do the following where I store the result of a param passed into a Rails controller in a variable like so: ``` def foo_bar_method case param[:foobar] when 'foo' then 'bar' when 'bar' then 'baz' else 'barbaz' end result = foo_bar_method puts result puts result ``` This way I am only evaluating the `foo_bar_method` once. Does Ruby cache the result of this method (or does Rails do this)? Is it faster to use the code shown above, or will the following code result in the same performance? ``` def foo_bar_method case param[:foobar] when 'foo' then 'bar' when 'bar' then 'baz' else 'barbaz' end puts foo_bar_method puts foo_bar_method ```
2016/01/18
[ "https://Stackoverflow.com/questions/34864651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1351770/" ]
Twilio employee here. This is result of TaskRouter being able to hit your AssignmentCallbackUrl with an HTTP POST request. We've noticed that on your Account there's this notification message: > > Cannot POST /assignment > > > Please enable **POST** for your AssignmentCallback endpoint. TaskRouter will actively cancel the reservation if it cannot hit your AssignmentCallbackUrl or there is an error when issuing an Assignment Instruction. The several updates in the console are due to the fact that TaskRouter cancels the reservation due to not hitting the AssignmentCallbackUrl, moving the Worker back to the previous state (Available), and then trying to assign the Task again, and thus generating another Reservation for the Worker for the same Task (repeat 15x until the Max Task Assignment is hit).
Heard back from twilio support, thanks twilio. Issue was with the Assignment Callback URL on the Workflow. My API was /Get. Changed it from Get to Post, to make it work. As the assignment URL was not reachable (via POST), task router was trying to cancel the reservation.
16,278
I was taking some photo stacks yesterday, and I also took a plenty of random ones (pointed not at a specific object) too at 200mm. However, I've ended with a shot but I have no idea where I pointed my camera at, and because of the narrow angle of 200mm, I'm lost without any guiding star/object. This happened to me before too, so I was wondering whether there is a software or a website that I can upload a photo, and it will analyze the objects, cross match them with known objects and detect which part of the sky it is? Or is there a method that I can use to figure out by myself (remember that there are no well-known bright stars in the image, at least not that I can identify by myself)?
2016/06/17
[ "https://astronomy.stackexchange.com/questions/16278", "https://astronomy.stackexchange.com", "https://astronomy.stackexchange.com/users/13176/" ]
Have you tried [nova.astrometry.net](http://nova.astrometry.net)? They set up a web service for doing more or less what you're talking about.
This type of software is called plate-solving software. There are several other software other than astrometry.net that can achieve this as well. <http://pinpoint.dc3.com/> <http://www.astrosurf.com/pulgar/elbrus/elbrusin.htm> To name a few