qid
int64
10
74.7M
question
stringlengths
15
26.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
27
28.1k
response_k
stringlengths
23
26.8k
867,967
It might be a silly question, but to me it is not obvious why the following expression holds: $$ \lim\limits\_{x\rightarrow 0}\frac{0}{x}=0 ? $$
2014/07/15
[ "https://math.stackexchange.com/questions/867967", "https://math.stackexchange.com", "https://math.stackexchange.com/users/113891/" ]
A limit $L$ of a function $f(x)$ evaluated at a point $x = a$ is not necessarily the value $f(a)$ itself. It is a value for which $f(x)$ approaches $L$ "as close as we like" if we make $x$ "sufficiently close" **but not equal** to $a$. The subtlety is in how we mathematically formalize the language in quotation marks, ...
This is true simply because as you take $x \to 0$ (for $x\ne 0$), we have $0/x=0$. (Think about the convergence of the sequence $0,0,0,0,\ldots$.) When you take the limit, you don't care about what happens when $x=0$; you only care about what happens around it.
6,018,293
I need to get the last part of current directory, for example from `/Users/smcho/filegen_from_directory/AIRPassthrough`, I need to get `AIRPassthrough`. With python, I can get it with this code. ``` import os.path path = "/Users/smcho/filegen_from_directory/AIRPassthrough" print os.path.split(path)[-1] ``` Or ``...
2011/05/16
[ "https://Stackoverflow.com/questions/6018293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/260127/" ]
Well, to *exactly* answer your question title :-) ``` var lastPartOfCurrentDirectoryName = Path.GetFileName(Environment.CurrentDirectory); ```
This works perfectly fine with me :) ``` Path.GetFileName(path.TrimEnd('\\') ```
42,941,927
I currently run this code: ``` searchterm = "test" results = resultsArray.filter { $0.description.contains (searchterm!) } ``` My question is how do I search in `company_name` or `place` or any other field in my model and add it to the results. Do I need to use filters together and then append the results to a new...
2017/03/22
[ "https://Stackoverflow.com/questions/42941927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7237391/" ]
The easiest way to do this would be to create a custom `contains` method in your model which can you can use to match the search term against any property in the model: ``` class YourModel { var company_name: String var description: String var place: String // ... func contains(_ searchTerm: Stri...
Is this **resultsArray** a *dictionary* or an *array*? You can do something like this ``` let searchTerm = "test" let filter = resultsArray.filter{ $0.company_name!.contains(searchTerm) || $0.place!.contains(searchTerm) } ``` Edit ``` class TestClass: NSObject { var place: String? var company_name: String...
27,475,831
On Excel 2011 for Mac, OsX 10.9 `=DATEVALUE("08/22/2008")` returns a `#VALUE` error on my Mac. I tried the same command on Excel 2013 on Windows, as well as Office 365, both places work fine. Also a different variation `=DATEVALUE("22-AUG-2008")` works fine on my mac. According to the help doc, both are supposed to ...
2014/12/15
[ "https://Stackoverflow.com/questions/27475831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4360666/" ]
What you are trying to do can be done with LINQ. What you are basically asking for is a *projection*. [MSDN describes a projection](http://msdn.microsoft.com/en-us/library/bb546168.aspx) as this: > > Projection refers to the operation of transforming an object into a new form that often consists only of those proper...
``` var firstNames = the_people.Select(p => p.first_name).ToArray(); var dates_of_birth = the_people.Select(p => p.date_of_birth).ToArray(); ```
14,216
Why is a pre fade aux used for monitoring and a post fade aux for effects?
2012/06/05
[ "https://sound.stackexchange.com/questions/14216", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/243/" ]
+1 to Sonsey's explanation of Pre and Post-fade sends. However, I'd add that you don't ALWAYS send monitor mixes prefade, either. I have a large vocal ensemble that I mix regularly, whose monitors sends I almost always send POST-fader. Why? Because I want them to hear in their monitors the same mix that the house is...
In a building changing levels on the main mix only will change the sound in the main mix if you don't change the levels in the monitor mix together in most rooms, EQ all speakers the same and go (Post Fader) All Aux sends or Monitor sends set at unity, And all adjustments will be made at the main fader, Made my sound 1...
21,043,147
I have a list of integers with 50 items: ``` List<int> list = CreateList(); ``` How could I split it into chunks of 9 items? ``` List<List<int>> chunks = CreateChucks(list); ``` I've written this, is there any better way? ``` private static List<List<T>> GetChunks<T>(List<T> list, int maxChunkSize = 1000) { ...
2014/01/10
[ "https://Stackoverflow.com/questions/21043147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133212/" ]
I suggest you to use `Batch` operator of [MoreLINQ](http://code.google.com/p/morelinq/wiki/OperatorsOverview) (available from NuGet): ``` IEnumerable<IEnumerable<int>> chuncks = list.Batch(9); ``` If you want list of lists, then you can create own extension: ``` public static List<List<T>> Batch(this IEnumerable<T>...
Try this, ``` var list = new List<int>(); for (var i = 0; i < 50; i++) list.Add(i); var chunk = new List<List<int>>(); var chunkSize = list.Count / 9; for (var i = 0; i < 9; i++) { var p = list.Skip(i * chunkSize).Take(chunkSize).ToList(); chunk.Add(p); } ```
619,205
I am currently trying to build a shutdown script for a windows server 2012 which will perform a planned failover to my replica server when the primary shuts down. My problem is that the shutdown script gets executed *after* the Hyper-V service has been stopped. Is there any possibility to get it executed before?
2013/07/12
[ "https://superuser.com/questions/619205", "https://superuser.com", "https://superuser.com/users/239195/" ]
This may be overkill, but one might create a service that depends on the Hyper-V service and performs the required action during service termination ...
Actually you can try to use schedule to create an task which trigger on the service stop event, and then perform shutdown -a, do the failover, and the shutdown -r. The keypoint is get the right event to launch the tasks, and make sure it can abort the shutdown. also, do not let window update to do auto-reboot, use th...
258,960
Is there a way for me to serialize an object in .NET without the XML Namespaces automatically serializing also? It seems that by default .NET believes the XSI and XSD namespaces should be included, but I don't want them there.
2008/11/03
[ "https://Stackoverflow.com/questions/258960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13611/" ]
If you want to get rid of the extra `xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"` and `xmlns:xsd="http://www.w3.org/2001/XMLSchema"`, but still keep your own namespace `xmlns="http://schemas.YourCompany.com/YourSchema/"`, you use the same code as above except for this simple change: ``` // Add lib namespace...
``` XmlWriterSettings settings = new XmlWriterSettings { OmitXmlDeclaration = true }; XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); StringBuilder sb = new StringBuilder(); XmlSerializer xs = new XmlSerializer(typeof(Ban...
12,855,448
``` console.log("20">10); //true console.log("20a">"10"); //true console.log("20a">10); //false ``` I want to know why the last one turns false. And "20a" transforms to what before comparing.
2012/10/12
[ "https://Stackoverflow.com/questions/12855448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1726273/" ]
From the MDN page on [comparison operators](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Comparison_Operators): > > For relational abstract comparisons (e.g. <=), the operands are first converted to primitives, then the same Type, before comparison. > > > ``` console.log("20">10); //tr...
For the last case, Notice that even `"20a" < 10` return false. This highlights the evaluation of `"20a"` at `NaN` during the comparison, as `NaN` compared to any number always returns `false`.
51,525,234
I am trying to do something like this on **global scope** in nodejs REPL. As per my understanding both the following statements are valid. [see docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await) ``` let x = await Promise.resolve(2); let y = await 2; ``` However, both these state...
2018/07/25
[ "https://Stackoverflow.com/questions/51525234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6903290/" ]
since node 10, you can run node process with --experimental-repl-await to allow top level await <https://nodejs.org/api/repl.html#repl_await_keyword>
You could wrap all the code in the global scope in an async function. For example: ``` // ...global imports... new Promise (async () => { // ...all code in the global scope... }).then() ```
106,270
I have often wondered what the purpose of monopods is. It seems to me that they remove only two degrees of freedom out of three possible degrees of freedom of camera shake. And the situation is even worse for telephoto lenses, where one of the removed degrees of freedom isn't problematic, so that's one out of two remov...
2019/03/30
[ "https://photo.stackexchange.com/questions/106270", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/81735/" ]
It's instructive to look where monopods are most often used: sporting events, and shooting wildlife. In all of these cases, it's not a matter of "how many stops" a monopod can provide. It's simply a matter of increasing the keeper rate of shots. ### Competitive Sports (football, soccer, etc.) Monopod are ubiquitous a...
To be precise monopode do not remove completely pitch and roll. It just move the point of rotation to be not the camera itself but the point where monopod touch the ground. This mitigate a lot but do not remove completely. About yaw shake - you should be not afraid of. You should name it freedom and I think many sport...
26,180,822
I'm trying to figure this out since last week without going any step further. Ok, so I need to apply some **constraints** ***programmatically*** in **Swift** to a `UIView` using this code: ``` var new_view:UIView! = UIView(frame: CGRectMake(0, 0, 100, 100)); new_view.backgroundColor = UIColor.redColor(); view.addSubvi...
2014/10/03
[ "https://Stackoverflow.com/questions/26180822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3588489/" ]
If you find the above to be ugly. You should consider using a DSL for constraints. Such as [SnapKit](https://github.com/SnapKit/SnapKit) Makes constraint API much more user-friendly ``` view.snp.makeConstraints { make in make.edges.equalToSuperview() } ```
``` var xCenterConstraint : NSLayoutConstraint! var yCenterConstraint: NSLayoutConstraint! xCenterConstraint = NSLayoutConstraint(item: self.view, attribute: .CenterX, relatedBy: .Equal, toItem: (Your view NAme), attribute: .CenterX, multiplier: 1, constant: 0) self.view.addConstraint(xCenterConst...
24,316,071
I have a lot of experience with AngularJS and I'm also playing around with Web Components and Polymer for a long time now. What I really love about the these libraries and technologies, is the fact that they let me build my own components. AngularJS gives me something called "Directives" and Web Components consists o...
2014/06/19
[ "https://Stackoverflow.com/questions/24316071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1531806/" ]
This does not answer your specific question ``` if [[ $h>=11 ]]; then if [[ $h<=18 ]] && [[ $s<=00 ]]; then ``` **All** of those tests **always return true**. The `test`, `[` and `[[` commands act differently based on the number of arguments they see. All those tests have 1 single argument. In that ...
If I add the command "wc -l" at the end of my loop, I can get exactly what I wanted, means that number of lines (9 lines). But I want to know if there is a way to get it exactly inside the loop, maybe using the same command "wc -l" or not. ``` #!/bin/bash let count=0 while read cdat ctim clat clon do ...
28,786,473
I'm trying to compile the following simple C++ code using Clang-3.5: test.h: ``` class A { public: A(); virtual ~A() = 0; }; ``` test.cc: ``` #include "test.h" A::A() {;} A::~A() {;} ``` The command that I use for compiling this (Linux, uname -r: 3.16.0-4-amd64): ``` $clang-3.5 -Weverything -std=c++1...
2015/02/28
[ "https://Stackoverflow.com/questions/28786473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3129160/" ]
We don't want to place the vtable in each translation unit. So there must be some ordering of translation units, such that we can say then, that we place the vtable in the "first" translation unit. If this ordering is undefined, we emit the warning. You find the answer in the [Itanium CXX ABI](https://mentorembedded.g...
For a moment, let's forget about pure virtual functions and try to understand how the compiler can avoid emitting the vtable in all translation units that include the declaration of a polymorphic class. When the compiler sees the declaration of a class with virtual functions, it checks whether there are virtual functi...
8,156,448
I have a random string of numbers (numbers can only be used once, only from 1-9, almost any length(min 1,max 9)): ``` var Input: String; begin Input := '431829576'; //User inputs random numbers ``` **And now I need to get specified number to front**. How about `5`. ``` var Number: Integer; begin Number := 5; ``...
2011/11/16
[ "https://Stackoverflow.com/questions/8156448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/715707/" ]
Do you mean like this? ``` function ForceDigitInFront(const S: string; const Digit: Char): string; begin result := Digit + StringReplace(S, Digit, '', []); end; ``` A more lightweight solution is ``` function ForceDigitInFront(const S: string; const Digit: Char): string; var i: Integer; begin result := S; f...
Here is a solution that reduces the numer of String allocations needed, as well as checks if the digit is already in the front: ``` function ForceDigitInFront(const S: string; const Digit: Char): string; var dPos : Integer; begin Result := s; for dPos := 1 to Length(Result) do begin if Result[dPos] = ...
2,716,596
In Java I need to put content from an OutputStream (I fill data to that stream myself) into a ByteBuffer. How to do it in a simple way?
2010/04/26
[ "https://Stackoverflow.com/questions/2716596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/311865/" ]
Though the above-mention answers solve your problem, none of them are efficient as you expect from NIO. ByteArrayOutputStream or MyByteArrayOutputStream first write the data into a Java heap memory and then copy it to ByteBuffer which greatly affects the performance. An efficient implementation would be writing ByteB...
// access the protected member **buf** & **count** from the extend class ``` class ByteArrayOutputStream2ByteBuffer extends ByteArrayOutputStream { public ByteBuffer toByteBuffer() { return ByteBuffer.wrap(buf, 0, count); } } ```
906,486
The following doesn't work... (at least not in Firefox: `document.getElementById('linkid').click()` is not a function) ``` <script type="text/javascript"> function doOnClick() { document.getElementById('linkid').click(); //Should alert('/testlocation'); } </script> <a id="linkid" href="/testloc...
2009/05/25
[ "https://Stackoverflow.com/questions/906486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45311/" ]
The best way to solve this is to use Vanilla JS, but if you are already using jQuery, there´s a very easy solution: ``` <script type="text/javascript"> function doOnClick() { $('#linkid').click(); } </script> <a id="linkid" href="/testlocation" onclick="alert(this.href);">Testlink</a> ``` Tested in I...
Granted, OP stated very similarly that this didn't work, but it did for me. Based on the notes in my source, it seems it was implemented around the time, or after, OP's post. Perhaps it's more standard now. ``` document.getElementsByName('MyElementsName')[0].click(); ``` In my case, my button didn't have an ID. If y...
10,190,332
I'm trying to write a Perl script which writes to a file and then uses linux's mail command to send whatever the Perl script wrote to the file. My code is the following: ``` my $pathfile='some_pathfile'; open(W_VAR,">>$pathfile"); print W_VAR 'hello'; close W_VAR; my $email_command='mail -s'." header".' some_email_ad...
2012/04/17
[ "https://Stackoverflow.com/questions/10190332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322537/" ]
I suspect the problem is that your program doesn't terminate the line with a newline `"\n"` character. No doubt you put one into the file when you edited it manually? Something like this may fix it, but I don't have a Linux box to hand so I can't test it. ``` use strict; use warnings; my $pathfile = 'path/to/file'; ...
My bet is that your command is not well formed: Try: ``` my $header = "My Subject"; my $some_email_address = "myaccount@myemail.com"; my $email_command="mail -s \"$header\" $some_email_address < $pathfile"; ```
2,219,566
I was asked a question in an interview and i wasn't able to answer it... Here is the question * How will you define an instance[c#]? My answer was it is an other name of an `object`... what is the right answer for this question...
2010/02/08
[ "https://Stackoverflow.com/questions/2219566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146857/" ]
I would describe instance as a single copy of an object. There might be one, there might be thousands, but an instance is a specific copy, to which you can have a reference.
**Instance is synonymous of object and when we create an object of class then we say that we are creating instance of class** in simple word instance means creating reference of object(copy of object at particular time) and object refer to memory address of class
64,894,785
What standard-defined integer type should I use for holding pointer to functions? Is there a `(void*)`-like type for functions that can hold any functions? It's very certain that it's not `[u]intptr_t` because the standard said explicitly it's for pointers to objects and the standard makes a clear distinction between ...
2020/11/18
[ "https://Stackoverflow.com/questions/64894785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6230282/" ]
There is no specified type for an integer type that is sufficient to encode a function pointer. Alternatives: * Change code to negate the need for that integer type. Rarely is such an integer type truly needed. * Use an array: `unsigned char[sizeof( int (*)(int)) )]` and `int (*f)(int))` within `union` to allow some ...
> > It's very certain that it's not `[u]intptr_t` > > > It's true. But the distinction is **only** made to guarantee the correctness of some essential conversions. If you look at the 2nd edition of "The C Programming Language", then the distinction is more subtle to notice than the current wording in the standard....
22,157,780
What I have is php that updates the database field after a client signs a form. This works, but I want it to redirect to a new page after it is confirmed that the user signed it by clicking OK. It they click CANCEL it will leave them on the same page. ``` <?php $username = 'joeblow'; require_once ("/mypath/inc...
2014/03/03
[ "https://Stackoverflow.com/questions/22157780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3376610/" ]
You could post the form via **ajax** and in your php you can return a response to the javascript. That was you could use a callback to fire the new window. Heres a jquery example: ``` $.post('/myscript.php', {foo: 'bar'}).done(function (response) { window.open(......); }); ```
Try: ``` if (r==true) { window.open("http://smartpathrealty.com/smart-path-member-page/"); } else { window.location = "PAGE THAT YOU WANT"; } ```
7,855,060
Is there a c++ operator that i could use for a for loop where it would add or subtract to variables based on whether one of the variables is less than or greater 0. For instance ``` int a; int b; for(int i=0;i<some_number; i++) result = a +< b result = a-> b ```
2011/10/21
[ "https://Stackoverflow.com/questions/7855060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1003543/" ]
No. You can combine with the `?:` operator. ``` int a; int b; for(int i=0;i<some_number; i++) result = (a < b)? result+b:result-b; ``` That is if I understood your example correctly. `->` is an existing dereference operator. Operator `?:` is an equivalent to the `if...else` construct. If the statement before `?...
Not sure if this would be any help? ``` result = a + (b*(a < b)); result = a - (b*(a > b)); ``` Basically, `(a < b)` is converted into a boolean, which is basically either 1 (true) or 0 (false). `b` multiplied by 0 is of course zero, so nothing is added, and `b` multiplied by 1 is exactly `b`'s value.
20,609,654
I have the following code. ``` $resu = array_map(function($aVal, $bVal){ return "$bVal [$aVal]"; }, $result, $intersect); $sorAr = array(); array_walk($resu, function($element) use (&$sorAr) { $parts = explode(" ", $element); $sorAr[$parts[0]] = trim($parts[1], ' []'); }); ``` The problem lies when i need to use th...
2013/12/16
[ "https://Stackoverflow.com/questions/20609654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2685296/" ]
Anonymous functions are **not** available in **5.2** See the changelog [here](http://www.php.net/manual/en/functions.anonymous.php). > > **5.3.0** Anonymous functions become available. > > >
``` function arr1($aVal, $bVal){ return "$bVal [$aVal]"; } function arrayWalk($element){ $parts = explode(" ", $element); $sorAr[$parts[0]] = trim($parts[1], ' []'); } function arrSwap(){ $resu = array_map('arr1', $result, $intersect); $sorAr = array(); array_walk($resu, 'arrayWalk'); } ``` if still prob there let...
18,957,200
I have confusion that what is the differnce between the two ? Cycle and circuit so please make me sure by diagrams if possible. what i have in mind is that the cycle is always in undirected graph the circuit is always a directed graph. please correct me if i am wrong ?
2013/09/23
[ "https://Stackoverflow.com/questions/18957200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2058543/" ]
A cycle is a closed path. A path is a walk with no repeated vertices. Circuits refer to the closed trails. Trails refer to a walk where no edge is repeated.
There's no official and/or widely accepted definition of a **difference** between `cycle` and `circuit`. Most literature I've seen uses them interchangeably; if it doesn't: you should expect it to define this somewhere in its glossary of terms (if it has one).
4,849,985
I've just started learning C (coming from a C# background.) For my first program I decided to create a program to calculate factors. I need to pass a pointer in to a function and then update the corresponding variable. I get the error 'Conflicting types for findFactors', I think that this is because I have not shown t...
2011/01/31
[ "https://Stackoverflow.com/questions/4849985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/596684/" ]
I apologise for adding yet another answer but I don't think anyone has covered every point that needs to be covered in your question. 1) Whenever you use `malloc()` to dynamically allocate some memory, you must also `free()` it when you're done. The operating system will, usually, tidy up after you, but consider that ...
EDIT: no reference in C (C++ feature) Don't forget to modify numberOfFactors in the method (or remove this parameter if not useful). The signature at the beginning of your file must also match the signature of the implementation at the end (that's the error you receive). Finally, your malloc for results is not correc...
43,757,455
Why doest this script return diff error on Windows10 and Mac for the same Powershell Version? Script executed: [![enter image description here](https://i.stack.imgur.com/Na8b2.jpg)](https://i.stack.imgur.com/Na8b2.jpg) [![Mac error](https://i.stack.imgur.com/1uLUu.png)](https://i.stack.imgur.com/1uLUu.png) [![Windows ...
2017/05/03
[ "https://Stackoverflow.com/questions/43757455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3101813/" ]
If they are coded as lists, you can just take the `[0]` element
Are you sure it was a numpy array? I think just use ``` my_list[0] ``` to get the first element (in the first element is `[0,3.49,0,4.55]`)
17,021,852
Is there a widget for PointField as separate latitude/longitude inputs? Like SplitDateTimeWidget for DateTimeField.
2013/06/10
[ "https://Stackoverflow.com/questions/17021852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/820807/" ]
The answers are great for building your own solution, but if you want a simple solution that looks good and is easy to use, try: <http://django-map-widgets.readthedocs.io/en/latest/index.html> You can: * enter coordinates * select directly on the map * look up items from Google places. [![Screen Shot from Django Ma...
Create a custom widget for this, you can get inspired by `SelectDateWidget` [here](https://github.com/django/django/blob/master/django/forms/extras/widgets.py).
36,005,518
I want too create a php loop table with 10 row and 1 column. There should be a loop of every odd row should print "H" and even row need to have select menu of year. I'm beginner of php I tried this : ``` <?php function year() { echo '<select>'; for ($i = 1998; $i<2015;) { echo "<option>$i</option>";...
2016/03/15
[ "https://Stackoverflow.com/questions/36005518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6032796/" ]
@tommus solution is the best approach. --- If you want to go with simple or less code approach, You can use a boolean flag to ensure that both are executed and move forward based on condition. Declare a volatile boolean variable that will be used as a flag. ``` private volatile boolean flag = false; ``` flag wou...
Not Perfect But I hope this logic works for you ``` onDatafromServer1Fetched{ flag1 = true; } onDataFromServer2Fetched{ flag2=true; } main(){ boolean flag1 = false; boolean flag2 =false; getDataFromSerVer1(); getDataFromServer2(); while(!flag1 && !flag2){/**no code ...
58,132,841
I have a program that do several things. Two of them is **read a date from a txt** and **rewrite a date in the same txt**. The read of the date is a regex expression like: ``` [0-9]{2}/[0-9]{2}/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-5]{1}[0-9]{1}) ``` The problem is that my regex expression only works in the format "DD/MM...
2019/09/27
[ "https://Stackoverflow.com/questions/58132841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7974748/" ]
You need to use the same format string and culture in every place where you convert the `DateTime` to string as well. In your sample code, you're doing ``` DateTime.Now.ToString() ``` This uses the default culture for the thread, and the default format. Unless assigned otherwise, the thread is probably using the loc...
If you need > > to make sure my program run's in **every system**, regardless the system datetime.now > > > you can adapt *international standard* for this, say, [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). In order to validate the `DateTime`, *regular expressions* like you have are not enough (just imagi...
44,888,223
I am getting the `java.io.IOException: No space left on device` that occurs after running a simple query in `sparklyr`. I use both last versions of `Spark` (2.1.1) and `Sparklyr` ``` df_new <-spark_read_parquet(sc, "/mypath/parquet_*", name = "df_new", memory = FALSE) myquery <- df_new %>% group_by(text) %>% summariz...
2017/07/03
[ "https://Stackoverflow.com/questions/44888223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1609428/" ]
I ve had this problem multiple times before. The reason behind is the temporary files. most of servers have a very small size partition for `/tmp/` which is the default temporary directory for spark. Usually, I used to change that by setting that in `spark-submit` command as the following: ``` $spark-submit --mas...
Once you set the parameter, you can see the new value of spark.local.dir in Spark environment UI. But it doesn't reflect. Even I faced the similar problem. After setting this parameter, I restarted the machines and then started working.
38,759,018
I have db with few 1000 of contacts and would like to delete all duplicated records. Sql query I have at the moment works well ( when in records - **tel**, **email**, **name1** are duplicated). Query deletes duplicates with lower id then last occurring record. But in some cases another fields of the record a filled in ...
2016/08/04
[ "https://Stackoverflow.com/questions/38759018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1826668/" ]
Use `order by` in `group_concat`, you can try this: ``` DELETE c1 FROM contacts c1 JOIN ( SELECT substring_index(group_concat(id ORDER BY ((title IS NULL OR title ='') AND (name2 IS NULL OR name2 = '')), id DESC), ',', 1) AS id, name1, tel, email FROM contacts GROUP BY name1, tel, email ) ...
I have got solution using NOT EXIST clause instead of NOT IN ``` DELETE FROM contacts WHERE NOT EXISTS ( SELECT 1 FROM ( SELECT * FROM ( SELECT * FROM contact AS tmp ORDER BY title DESC, name1 DESC, name2 DESC, email DESC, tel DESC ) as tbl group by name1) as test WHERE contact.id= ...
56,568,232
I've have had a working version of mongoose instance methods working before. I'm not sure what is different about it this time around. The only thing I have done differently this time is that I separated the mongoose connection function outside of the `server.js` file into a config file that will be imported and call t...
2019/06/12
[ "https://Stackoverflow.com/questions/56568232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4567394/" ]
Technically, it doesn't work with any of them. From [[dcl.constexr]](http://eel.is/c++draft/dcl.constexpr#5): > > For a constexpr function or constexpr constructor that is neither defaulted nor a template, if no argument values exist such that an invocation of the function or constructor could be an evaluated subexp...
It doesn't. You need to use it to force a compile time error. ``` constexpr int a = f(), 0; // fails constexpr int b = g(), 0; // fails ``` `constexpr` functions that never produce a constant expression are ill-formed; no diagnostic required. This means that compilers do a best effort check to see if that is the cas...
43,490,938
I'm currently searching how to write correctly a regex for this application : 1 - A number without "." with a length of 1 to 5 digits => `/^(\d{1,5})$/` 2 - A number with "." with a length of 1 to 5 digits before the "." and 1 to 4 digits after the "." or a number starting with "." with a length of 1 to 4 digits af...
2017/04/19
[ "https://Stackoverflow.com/questions/43490938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7888406/" ]
You could check the second part as optional. ```js function check(v) { return /^(?=.)\d{0,5}(\.\d{1,4})?$/.test(v); } console.log(['', '.123', 123, 12345, 12345.2156, 123456, 123456.12, 12345.12345].map(check)); ```
`^(\d{1,5}|\d{1,5}\.\d{1,4}|\.\d{1,4})$` with a double | works just fine here <https://regex101.com/r/jTVW2Z/1>
2,719,279
I have mapped a simple entity, let's say an invoice using Fluent NHibernate, everything works fine... after a while it turns out that very frequently i need to process 'sent invoices' (by sent invoices we mean all entities that fulfill invoice.sent==true condition)... is there a way to easily abstract 'sent invoices' i...
2010/04/27
[ "https://Stackoverflow.com/questions/2719279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/309588/" ]
I just found this one: <http://web.archive.org/web/20141001063046/http://elliottjorgensen.com/nhibernate-api-ref/index.html> It doesn't seem to be official, but at least it *looks* like an API reference... unlike the official reference, which mostly describes concepts and mappings without any information about classe...
If you're on Windows, get [ILSpy](http://wiki.sharpdevelop.net/ILSpy.ashx) and point it at NHibernate.dll. It's not quite the same as real API documentation, but it's not half bad.
29,819,947
I am trying to implement a custom directive for a **counter** widget. I have been able to implement it, but there are many things i need some light to be thrown on. * Can this directive be written in a better way ? * How do i use the `scope:`(isolate scope) in a better way ? * on click of any reset button i want all ...
2015/04/23
[ "https://Stackoverflow.com/questions/29819947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4112077/" ]
First, pass in your startnumber attribute, so we can reset to that number instead of having to hard code in a number. You want to isolate the scope if you are going to have multiple counters. But here is how you can implement a global reset: ``` app.directive("counterWidget",function(){ return{ restrict:"E", ...
You can use ng-repeat in your html.you can define count = 3 ``` <body> <div ng-repeat="index in count"> <counter-widget startnumber=1 ></counter-widget></div> </body> ``` Also follow the link .They have explained scope inheritance in a better way <http://www.sitepoint.com/practical-guide-angularjs-directives-p...
4,428,048
I am writing code to use a library called SCIP (solves optimisation problems). The library itself can be compiled in two ways: create a set of .a files, then the binary, OR create a set of shared objects. In both cases, SCIP is compiled with it's own, rather large, Makefile. I have two implementations, one which compi...
2010/12/13
[ "https://Stackoverflow.com/questions/4428048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/532441/" ]
I doubt the difference has to do with how the two programs are built. `malloc` does not initialize the memory it allocates. It may so happen by chance that the memory you get back is filled with zeroes. For example, a program that's just started is more likely to get zero-filled memory from `malloc` than a program tha...
On Linux, according to [this thread](http://www.linuxquestions.org/questions/linux-general-1/in-linux-malloc-initializes-to-zero-843577/), memory will be zero-filled when first handed to the application. Thus, if your call to `malloc()` caused the program's heap to grow, the "new" memory will be zero-filled. One way t...
5,146,621
For several reasons I prefer to configure my editor to insert spaces when `TAB` is pressed. But recently I discovered that tabs should remain as tabs in make files. How do I insert tab (`\t`, not `" "`) without reconfiguring editors each time I need to write make files? I use the following editors: [Emacs](http://en...
2011/02/28
[ "https://Stackoverflow.com/questions/5146621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/638231/" ]
To manually insert a tab in Emacs, use ctrl-Q TAB. control-Q causes the next key to be inserted rather than interpreted as a possible command.
Emacs' Makefile mode takes care of where to insert tabs and spaces as long as you press the right keys at the right places. Either that, or I missed some details in the question.
55,017,122
So I know how to get the selected value using the ionChange event, but how do I get the selected index. For example if i was to select the 3rd value down in a dropdown how can I get the selected index (2) rather than the value selected?
2019/03/06
[ "https://Stackoverflow.com/questions/55017122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4372290/" ]
You can do something like ths:- ``` <ion-select placeholder="Select One"> <ion-select-option value="id1">Value1</ion-select-option> <ion-select-option value="id2">Value2</ion-select-option> </ion-select> ``` By this when you will select any particular option, then on its change event you will get that ob...
This is what you can do to get the id. Add a local variable to your ion-select *#selectedIndex*. After add your value like this ***[value]=[prices.w, id]*** ``` <ion-select slot="end" (ionChange)="changePrice($event)" #selectIndex> <ion-select-option text-uppercase [value]="[prices.w, id]" *ngFor="let prices of prod...
31,852,339
The array ``` Array ( [0] => CLG 0% [1] => TSM 0% [2] => 7sway 10% [3] => Nostalgie 90% [4] => K1CK.pt 9% [5] => E-Frag 91% [6] => HR 86% ``` So I want to print the elements of this array into the same div by using the for loop. I want to print 2 array parts into the same element The imageined output ``` <div> CL...
2015/08/06
[ "https://Stackoverflow.com/questions/31852339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5197523/" ]
As a temporarily solution, I would introduce an extension method: ``` public static class ZipFileExtensions { public static Task SaveAsync(this ZipFile zipFile, string filePath) { zipFile.Save(filePath); return Task.FromResult(true); } } ``` Then the usage would be: ``` public static asy...
Some of the answers suggest that zipping a file is not a process that you should do asynchronously. I don't agree with this. I can imagine that zipping files is a process that might take some time. During this time you want to keep your UI responsive or you want to zip several files simultaneously, or you want to uplo...
10,856,545
Is the locking object used for synchronization arbitrary or is there reasoning behind choosing a specific object?
2012/06/01
[ "https://Stackoverflow.com/questions/10856545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/925922/" ]
You'd be better off using one of the more modern locking techniques where much of the complexity and pitfalls have been removed/smoothed over. [Package](http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/locks/package-summary.html) `java.util.concurrent.locks` would be a good start.
The locking object needs to represent the exclusive part. if you lock the whole object meaning using it exclusively by an thread, you may use the object "this" to lock. This is the way "synchronize" work on methods work. ``` public class A { public synchronized void do1 () { ... } public synchro...
59,449,692
I have written the following code to simulate an unbiased random walk on Z^2. With probability 1/4, the "destination" is supposed to move one unit up, left, right, or down. So I made "destination" a matrix with two columns, one for the x-coordinate and one for the y-coordinate, and increment/decrement the appropriate c...
2019/12/23
[ "https://Stackoverflow.com/questions/59449692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3457277/" ]
Use a dictionary instead of having 2 separate list for ids and names of includes The code below creates a dictionary with include id as keys and the corresponding include's name as the value. later this dict is used to print file name In case you want to save each include as separate file,First isolate the include usi...
Assuming ids is actually just the elements in hugo: ``` a=[id for id in hugo] print(a) ``` Or ``` a=hugo.copy() print(a) ``` Or ``` print(hugo) ``` Or ``` a=hugo print(a) ``` Or ``` string = "[" for elem in hugo: string.append(elem + ",") print(string[:-1] + "]") ``` Edit: Added more amazing answers. T...
6,179,617
I happened to fail to set character encoding in Python terminal on Windows. According to official guide, it's a piece of cake: ``` # -*- coding: utf-8 -*- ``` Ok, now testing: ``` print 'Русский' ``` Produces piece of mojibake. What am doing wrong? **P.S.** IDE is Visual Studio 2010, if it matters
2011/05/30
[ "https://Stackoverflow.com/questions/6179617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476756/" ]
Update: See [J.F. Sebastian's answer](https://stackoverflow.com/a/29352343/252687) for a better explanation and a better solution. `# -*- coding: utf-8 -*-` sets the source file's encoding, not the output encoding. You have to encode the string just before printing it with the exact same encoding that your terminal i...
In case anyone else gets this page when searching easiest is to set the windows terminal code page ``` CHCP 65001 ``` or for power shell start it with ``` powershell.exe -NoExit /c "chcp.com 65001" ``` from [Is there a Windows command shell that will display Unicode characters?](https://stackoverflow.com/question...
4,889,336
I am decoding a base64string I need to show the decoded contents in a window. But when i print that i am getting only the bytearrayObject and not the data. How to get the data? ``` private function copyByteArray(content:String):void{ try{ byteData = new ByteArray(); //byteData.wr...
2011/02/03
[ "https://Stackoverflow.com/questions/4889336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/358435/" ]
I tried it and got a string in Alert, not byteArray object. By the way, you should use a variable of class Error (or inherited classes), not any Events.
Try something like this: ``` var bytes:ByteArray = new ByteArray(); var bDecoder : Base64Decoder = new Base64Decoder(); bDecoder.decode(urlModifiedString); bytes = bDecoder.toByteArray() ; bytes.position = 0; var returnObj : * = bytes.readObject(); ``` --- after posting i just saw someone else's readUTFBytes... i...
29,674,656
Hi I have child ul and parent li which is being targeted by jquery which toggles class "shown" on click event within it. The problem I face is that for some reason when I click child ul li elements it also triggers that event. How to prevent that? Here is my code. ``` <script> $(document).ready(function() { ...
2015/04/16
[ "https://Stackoverflow.com/questions/29674656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4061068/" ]
What you're experiencing is called [event bubbling](http://javascript.info/tutorial/bubbling-and-capturing). Events triggered on elements deeper in the hierarchy will "bubble" up towards the root of the DOM tree, hence the parent `<li>` element receives click events instantiated by the child elements. The easiest way ...
Try [stopImmediatePropagation()](http://api.jquery.com/event.stopimmediatepropagation/) like this: ``` $(document).on('click', '#child_element', function(event) { event.stopImmediatePropagation(); }) ```
8,320,993
What happens if I annotate a constructor parameter using `@JsonProperty` but the Json doesn't specify that property. What value does the constructor get? How do I differentiate between a property having a null value versus a property that is not present in the JSON?
2011/11/30
[ "https://Stackoverflow.com/questions/8320993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14731/" ]
Summarizing excellent answers by [Programmer Bruce](https://stackoverflow.com/a/8321074/14731) and [StaxMan](https://stackoverflow.com/a/8321255/14731): 1. Missing properties referenced by the constructor are assigned a default value [as defined by Java](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatyp...
In addition to constructor behavior explained in @Programmer\_Bruce's answer, one way to differentiate between null value and missing value is to define a setter: setter is only called with explicit null value. Custom setter can then set a private boolean flag ("isValueSet" or whatever) if you want to keep track of val...
25,463,744
I'm tearing my hair out over this one. I'm trying to pass an image URL from my `TableViewController` to my `DetailViewController` (`FullArticleViewController`) so that I can set the `UIImageView`, and nothing I try seems to be working. See my code below: **`MyTableViewController.h`** ``` @interface MyTableViewControl...
2014/08/23
[ "https://Stackoverflow.com/questions/25463744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3030060/" ]
If you check the types: ``` >>> type(df.groupby('Date').groups) <class 'dict'> ``` therefore, as a dictionary, `df.groupby('Date').groups` does not provide any *order guarantee* when you access items or keys; in your example `grouped.groups.keys()`; So you will lose consistency and correspondence between `dates` and...
The `avg` series will have the timestamps in the right order as the index, and can be passed directly to the bokeh plotting functions, like this. ``` line(avg.index, avg, line_color="grey", line_width=8, line_join="round") asterisk(avg.index, avg, line_color="black", size=15) ```
78,713
I'm confused by my books treatment of the Schrödinger equation. In steado f listing my questions at the end of my post, I'll add them as questions in parentheses after the line in question. For a free particle: $$i \hbar \left| \dot{\Psi} \right \rangle = H\left| \Psi \right \rangle = \frac{P^2}{2m}\left| \Psi \rig...
2013/09/27
[ "https://physics.stackexchange.com/questions/78713", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/23094/" ]
> > (where did the potential go?) > > > A potential implies a force and a *free* particle is not under the influence of a force (else it wouldn't be *free from force*). > > this follows from the eigen-equation, where the eigenvalue must be > equal to E? > > > It is not uncommon, *when the context is appropr...
To answer your question: I assume your book is talking about the free particle and not the more general problem. The free particle itself (eg wavepackets spreading, or just simple time evolution of free partiles initial condition) is an interesting problem in itself. In this case, the potential is constant---and we can...
34,440,333
I want to share the following class between at least two wpf windows: ``` namespace WPF { class dd_internals { public int current_process_index; public class process_class { public string process_name; public List<string> parm_list; public List<string...
2015/12/23
[ "https://Stackoverflow.com/questions/34440333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There are several options, for example: 1. As I can guess one window can open another window, so you can just pass an instance of this object to the second window before opening it. 2. You can store it in Application.Properties Application.Current.Properties["Key"] = myobject; 3. The best option for bigger applicatio...
I think you would need to make the class public or internal before sharing it anywhere.
64,809,597
I'm trying to compute the combined potential between the first and and last `SuperHero` instance of the `_superHeroes` array, and display the result. I created a method in the `SuperHero` class that computed the combined potential between two instances of a class. When I try to perform this method I get the following e...
2020/11/12
[ "https://Stackoverflow.com/questions/64809597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13295595/" ]
To understand the problem: `_superHeroes` is an array of `SuperHero` and you are trying to call a method of that class on the array. But the array does not inherrit the methods of the class. Instead you need to call the method on an instance that is stored inside of the array. ``` _superHeroes[0].combinedPotential(_su...
This should be a `static` method: ``` public static double combinedPotential(...) { ... } ``` which you then call as ``` SuperHero.combinedPotential(_superHeroes[0], _superHeroes[2]); ```
8,836,276
Hy, I have this jquery code , what it does is saving in database (through ajax) the position of div in a database , but i don`t know how to get the id of div dragged , on the drop event ``` $().ready(function () { $('.dragDiv').Drags({ handler: '.handler', onMove: function (e) { //$('...
2012/01/12
[ "https://Stackoverflow.com/questions/8836276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1069937/" ]
Use this: ``` $('.dragDiv').attr("id"); ``` --- **EDIT** If you would like to try this, you can try getting the id in the onDrag function using: ``` var id = $(this).attr('id'); ``` Verify that this is the correct id for the div, and if it is, this would be the recommended methodology. --- **EDIT** Good point...
I think you can just use the "this" keyword to get the object that is being dragged. So that would mean you could write `$(this).attr("id")`
650,555
I have been a VB.net developer for a long time and changed recently to C#. When I was using VB.net, to call user settings, I just need to create a new setting using the designer and then call it from code with the My namespace. Here's the code `My.settings.anysetting` I can change or get data from it. However ...
2009/03/16
[ "https://Stackoverflow.com/questions/650555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12637/" ]
`Settings` are stored under the `Application` folder and as such, use that as their namespace. ``` int myInt = Properties.Settings.Default.myVariable; Properties.Settings.Default.myVariable = 12; Properties.Settings.Default.Save(); ``` [Using Settings in C#](http://msdn.microsoft.com/en-us/library/aa730869.aspx)
``` // Retrieving connection string from Web.config. String connStringMSQL = WebConfigurationManager.ConnectionStrings["andi_msql"].ToString(); ``` In my case this was for my connectionStrings setting but depending on what node your setting is in you can change this accordingly. Hope this helps
1,897,181
When showing a secondary form from the main form and from the second form showing a third form and then closing both forms will cause the main form to lose focus. Using Delphi 2009 with XP SP3 Here are my steps for reproducing the problem: 1. Create a new VCL forms applications 2. Drag a button onto the created form...
2009/12/13
[ "https://Stackoverflow.com/questions/1897181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40007/" ]
I don't see how what you describe creates a "child" Form. But anyway, I just tried with exactly what you described in your steps and could not reproduce it in D2009 (updates 3 & 4), whether I create the 2nd "child" from the main Form or from the 1st "child", and whatever the order in which I close them. So, there mu...
Try the following (and avoid the with): ``` with TForm1.Create(nil) do begin show; activate; bringtofront; end; ```
781,357
I think my Webapplication gets shut down after a while. It returns a new session if I haven't used the application in maybe 5 minutes. The session timeout is set to 720 minutes so that can't be the issue. Is it maybe a setting in the Application Pool or something like that? I figure it is some sort of resource manage...
2009/04/23
[ "https://Stackoverflow.com/questions/781357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/70283/" ]
IIS has a feature in properties where you can stop recycle your IIS on intervals 1. Go to your "IIS Manager" 2. Select "Application Pool" the instance you want to manage. 3. Select "Advanced settings" action 4. Under "Recycling" and set "Regular Time Interval" to 0, which means the application pool does not recycle.
After failed at configuring IIS pool. I come out with this simple windows service. [github code](https://github.com/ChinhPLQ/Windows-Service) It can save some minutes of you.
98,455
I am writing a science fiction novel where dead humans are turned into diamonds by compacting cremated remains. What size of diamond would the amount of carbon in a human body form? I know that the size would vary somewhat depending on the weight of the person. Specifically, would the diamond be small enough to be w...
2017/11/21
[ "https://worldbuilding.stackexchange.com/questions/98455", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/44959/" ]
Prior Art ========= First it's worth noting that there is at least one company that actually does this. LifeGem creates diamonds from carbon extracted from cremated remains. Per wikipedia: > > The company can extract enough purified carbon from a single cremated human body to synthesize up to 50 gems weighing one c...
According to [wikipedia](https://en.wikipedia.org/wiki/Composition_of_the_human_body), humans are 18% carbon by mass. So a 70 kg human is made up of roughly 16 kg carbon. The density of a [diamond](https://en.wikipedia.org/wiki/Diamond) is roughly 3.5 g/cm^3 Assuming a lossless process where every atom of carbon is...
15,472,814
I have problem with .lib files not found. I would like to check linker properties. However, in Project->Properties, I cannot find linker tab. What am i missing here ? Actually, I fear that I am not looking at project properties, but at properties for solution or whatever. What is a project exactly (which icon in VS for...
2013/03/18
[ "https://Stackoverflow.com/questions/15472814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If there is no linker options, it is possible that the project is set to build a \*.lib. In this case you will be able to select 'Librarian' on the left of the project options. You can modify what the project is configured to build by going to General and then changing the Configuration type. To get to the Project pr...
For clarification of the concept of "Projects" in Visual Studio: The topmost node you see in the Solution Explorer (The panel which is (I believe) by default on the left of your window) is called the **Solution**. You can imagine it as a big bag to put everything related to solving a problem into. This "everything"...
8,675,206
Is there any difference between `:key => "value"` (hashrocket) and `key: "value"` (Ruby 1.9) notations? If not, then I would like to use `key: "value"` notation. Is there a gem that helps me to convert from `:x =>` to `x:` notations?
2011/12/30
[ "https://Stackoverflow.com/questions/8675206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/927667/" ]
Yes, there is a difference. These are legal: ``` h = { :$in => array } h = { :'a.b' => 'c' } h[:s] = 42 ``` but these are not: ``` h = { $in: array } h = { 'a.b': 'c' } # but this is okay in Ruby2.2+ h[s:] = 42 ``` You can also use anything as a key with `=>` so you can do this: ``` h = { C.new => 11 } h = { 23 ...
Ruby hash-keys assigned by hash-rockets can facilitate strings for key-value pairs (*e.g*. `'s' => x`) whereas key assignment via **symbols** (*e.g.* `key: "value"` or `:key => "value"`) *cannot be assigned with strings.* Although hash-rockets provide freedom and functionality for hash-tables, *specifically allowing st...
26,070,464
I have created a new "Database" project in Visual Studio 2013. I have set the Target platform to "Windows Azure SQL Database". The project is nearly empty, with the exception of one .sql file to create a Schema. When I try to publish the project, it takes several minutes and ends with: Creating publish preview... Fai...
2014/09/27
[ "https://Stackoverflow.com/questions/26070464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2503327/" ]
Like Hesham mentioned in the comments, I also had this issue with the new Basic tier of Azure SQL Database. Switching the tier to Standard S0 size fixed the issue. So if you're having issues with the Basic tier, try scaling up to publish, then scale back down when you're finished.
Check this answer from MSDN forum, worked with me perfectly! > > In order to change the command timeouts used in Visual Studio 2013 you > will need to change the following registry setting: > > > HKEY\_CURRENT\_USER\Software\Microsoft\VisualStudio\12.0\SQLDB\Database\QueryTimeoutSeconds > > > Source: <http://...
49,169,802
I need to create a string like this to make works the mapserver request: `filterobj = "POLYGON((507343.9 182730.8, 507560.2 182725.19999999998, 507568.60000000003 182541.1, 507307.5 182563.5, 507343.9 182730.8))";` Where the numbers are map coordinates `x` `y` of a polygon, the problem is with Javascript and OpenLaye...
2018/03/08
[ "https://Stackoverflow.com/questions/49169802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6447610/" ]
Look at code snippet : Help method : setCharAt , Take all commas , take all odds commas with i % 2 == 0 ```js // I need to start from somewhere function setCharAt(str,index,chr) { if(index > str.length-1) return str; return str.substr(0,index) + chr + str.substr(index+1); } var POLYGON = [507343.9, 18...
One approach would be using `Array.reduce()`: ``` var input = '1.0, 2.0, 3.0, 4.0, 5.0, 6.0'; var output = input .split(',') .reduce((arr, num, idx) => { arr.push(idx % 2 ? arr.pop() + ' ' + num : num); return arr; }, []) .join(','); // output = '1.0 2.0, 3.0 4.0, 5.0 6.0' ```
15,552,581
I'm currently developing an OpenGL framework for video games. This framework contains a specific program that loads shaders. In the class of said program I have these three functions: ``` InitShaderProgram(...); CreateShader(...); CreateProgram(...); ``` The InitShaderProgram calls CreateShader and CreateProgram in ...
2013/03/21
[ "https://Stackoverflow.com/questions/15552581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1849415/" ]
Unresolved External Symbol means the compiler has looked at the code you have written and has generated all code in the source file you are compiling and a set of symbols it needs for the linker to look up. The linker takes all of the object code files and maps all of the defined symbols from one [translation unit](htt...
> > If I get this right (I most likely don't), the compiler does not understand where these functions come from. > > > Unfortunally no. The error is not from compiler but from linker. Do you have already implemented this two functions: ShaderLoader::CreateShader and ShaderLoader::CreateProgram? Or just declarated...
1,450,623
I am using VB.net code and SQL server 2005. I am havng below code for sending email in my vb.net code. ``` Protected Sub ibtnSendInvites_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ibtnSendInvites.Click Try Dim emailList As New List(Of String) For Each curRow As...
2009/09/20
[ "https://Stackoverflow.com/questions/1450623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30394/" ]
There's no one answer. Depends on the business situation. I do agile/XP development, and get the software in a stable and usable state as early as possible. I encourage our clients to get it out there to start getting feedback. This is great, as it always affects how you view the software you are building. And it def...
**No Software is ever fully-functional.** Use cases evolve as users come along and find new and interesting uses for your product. You'd be far better off designing the site to be easy to update and with minimal downtime during update then trying to guess who your users will be and how they will use it.
6,031,468
Can I use preg\_match to validate phone number in jQuery? Here is my code which does not work: ``` if (!preg_match("/^[0-9]{3}-|\s[0-9]{3}-|\s[0-9]{4}$/", phone.val() )) { phone.addClass("needsfilled"); phone.val(phonerror); } ``` HTML `<input id="phone" type="text" value="" name="ph...
2011/05/17
[ "https://Stackoverflow.com/questions/6031468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/756928/" ]
Javascript includes a regular expression engine, which is accessed via the `string.match()`, `string.replace()` and `string.split()` functions. For example: ``` var mystring = "this is a sentence"; mystring = mystring.replace(/sentence/,'string'); var matches = mystring.match(/\b\w+\b/); ``` That should provide yo...
Instead of using `preg_match`, which is a PHP function, you should use the String object's `match` function. See the [Mozilla docs](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/match) for information on using the match function.
448,271
What is [`__init__.py`](https://docs.python.org/3/tutorial/modules.html#packages) for in a Python source directory?
2009/01/15
[ "https://Stackoverflow.com/questions/448271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
`__init__.py` will treat the directory it is in as a loadable module. For people who prefer reading code, I put [Two-Bit Alchemist's](https://stackoverflow.com/users/2588818/two-bit-alchemist) comment here. ``` $ find /tmp/mydir/ /tmp/mydir/ /tmp/mydir//spam /tmp/mydir//spam/__init__.py /tmp/mydir//spam/module.py $ c...
One thing \_\_init\_\_.py allows is converting a module to a package without breaking the API or creating extraneous nested namespaces or private modules\*. This helps when I want to extend a namespace. If I have a file util.py containing ``` def foo(): ... ``` then users will access `foo` with ``` from util i...
19,324,397
What's the difference between the declaring an uninitialized final variable and setting a final variable to null? ``` void A(String pizza) { String retVal = null; if (StringUtils.isBlank(pizza)) { retVal = "blank" } else { retVal = computeString(pizza); } } void A(String pizza) { f...
2013/10/11
[ "https://Stackoverflow.com/questions/19324397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/973391/" ]
Maybe I didn't understand, but in your second example, you won't be able to reassign `retVal` after your `if-else` block. [A `final` variable](http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.12.4) > > may only be assigned to once. Declaring a variable final can serve as > useful documentation that ...
The difference is that a final variable can never be changed to have another value.
39,686,844
``` select p.ProduitNom,v.VonduDate,p.ProduitPrix from Produits p,Vondus v where p.ProduitId = v.ProduitId and p.CentreId=1 ``` How to do this request in entity framework ?
2016/09/25
[ "https://Stackoverflow.com/questions/39686844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5296683/" ]
Yes, it's because Google has been blocked in Iran since 2012. You can use a proxy app like Shadowsocks to change your country. After activating your proxy app, in Android Studio go to file->setting->Appearance & Behavior->System Setting->HTTP Proxy active 'Manual proxy configuration' and set: * host name:127.0.0.1 (...
Put this info in your Android Studio **proxy settings**: ``` address: fodev.org port:8118 ``` Put these lines on **gradle.properties** file in your project: ``` systemProp.http.proxyHost=fodev.org systemProp.http.proxyPort=8118 systemProp.https.proxyHost=fodev.org systemProp.https.proxyPort=8118 ``` [![enter imag...
15,055,073
I have just downloaded and installed the new opencv version. The fact that it natively supports java is quite exiting. However I am having some trouble porting my javacv code over. I can no longer seem to use IplImage as it can not be resolved, even though I have imported org.opencv.core.\*; Switching to Mat does not s...
2013/02/24
[ "https://Stackoverflow.com/questions/15055073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2041427/" ]
First, some preliminaries: Using `O_NONBLOCK` and `poll()` is common practice -- not the other way around. To work successfully, you need to be sure to handle all `poll()` and `read()` return states correctly: * `read()` return value of `0` means EOF -- the other side has closed its connection. This corresponds (usua...
Just keep an open O\_WRONLY file descriptor in the reading process alongside the O\_RDONLY one. This will achieve the same effect, ensuring that read() never returns end-of-file and that poll() and select() will block. And it's 100% POSIX
34,409,780
``` <tr id="Any_22" class="value-table list-row-even"> <td class="selection-column"> <input id="Checkbox_1_1" type="checkbox" onclick="doCheck( this, 'value-table-selected', 'value-table' )" name="Checkbox_1_1"> </td> <td id="columnValues_19" class="first-selection" onmouseover="sCC(this)"> <span>...
2015/12/22
[ "https://Stackoverflow.com/questions/34409780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3622632/" ]
This is one possible XPath that works for the HTML snippet posted : ``` //tr[td[normalize-space()='I_am_here']]/td/input[@type='checkbox'] ``` **`[`xpathtester demo`](http://www.xpathtester.com/xpath/e70ace1299a95ff28fd747baef57cab1)`** **brief explanation :** * `//tr[td[normalize-space()='I_am_here']]` : find `tr...
Because you didn't provide any code, the answer will be also conceptual. So, you should get the nodes tree by known text (`I_am_Here`) and then find nearest node with name `input` and type `checkbox`. The nodes tree can be obtained by traveling through `parents` and `siblings` of found node.
17,305,437
Im trying to get the following script to work, but Im having some issues: ``` g++ -g -c $1 DWARF=echo $1 | sed -e `s/(^.+)\.cpp$/\1/` ``` and Im getting - ``` ./dcompile: line 3: test3.cpp: command not found ./dcompile: command substitution: line 3: syntax error near unexpected token `^.+' ./dcompile: command sub...
2013/06/25
[ "https://Stackoverflow.com/questions/17305437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1305516/" ]
You actually need to execute the command: ``` DWARF=$(echo $1 | sed -e 's/(^.+)\.cpp$/\1/') ``` The error message is a shell error because your original statement ``` DWARF=echo $1 | sed -e `s/(^.+)\.cpp$/\1/` ``` is actually parsed like this ``` run s/(^.+)\.cpp$/\1/ set DWARF=echo run the command $1 | ... ```...
You can use `awk` for this: ``` $ var="testing.cpp" $ DWARF=$(awk -F. '{print $1}' <<< $var) $ echo "$DWARF" testing ```
37,977
I have two lists, say `a` and `b`, both of length `n`. I'd like to compute the following: * minimum of $a[i]/b[i]$ where $i=1, 2, ...n$ and $b[i]>0$ I'd also like to know the index of the element where the min occurs.
2013/11/28
[ "https://mathematica.stackexchange.com/questions/37977", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/10831/" ]
One way to enforce the positivity condition on `b` is to locate the positions of all the positive elements of `b` and use those to index into the division of `a` by `b`. ``` a = RandomReal[{-10, 10}, 10]; b = RandomReal[{-10, 10}, 10]; pos = Flatten[Position[b, _?(0 < # &)]] Min[a[[pos]]/b[[pos]]] ```
``` a = RandomReal[{1, 10}, 10]; b = RandomReal[{1, 10}, 10]; lst = a/b; Min[lst] (*0.442821447015283*) Position[lst, Min[lst]] (* {{4}} *) ``` **Update to answer comment below** `How can I implement the b[i]>0 condition` One way can be to use [MapThread](http://reference.wolfram.com/mathematica/ref/MapThread.htm...
407,987
I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime. When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're not. Eac...
2009/01/02
[ "https://Stackoverflow.com/questions/407987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17312/" ]
This post at comp.lang.forth lists a few "minimal Forths". <http://groups.google.com/group/comp.lang.forth/msg/10872cb68edcb526> Why do I know this? My brother, Mikael, wrote #3 and he also wrote a [paper](http://libris.kb.se/bib/879246) about making a "minimal Forth" (in Swedish, though). If I remember correctly he ...
You might also want to take a look at Hans Bezemer's [4tH compiler](http://www.xs4all.nl/~thebeez/4tH/).
2,910,587
what is the difference between deleting a pointer, setting it to null, and freeing it. ``` delete ptr; ``` vs. ``` ptr=NULL; ``` vs. ``` free(ptr); ```
2010/05/26
[ "https://Stackoverflow.com/questions/2910587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/350593/" ]
Your question suggests that you come from a language that has garbage collection. **C++ does not have garbage collection.** If you set a pointer to NULL, this does not cause the memory to return to the pool of available memory. If no other pointers point to this block of memory, you now simply have an "orphaned" block...
When you create an object using new, you need to use delete to release its memory back to the system. The memory will then be available for others to reuse. ``` int* a = new int; delete a; ``` NULL is just a pre-defined macro that can be assigned a pointer to mean that it does not point to anything. ``` int* a = ...
45,117,470
I have following select drop-down which is dynamically created,which does not have select id but have name. I have JavaScript array like var t=[125,43,89]. I want to remove above array values from below drop-down. ``` <select name="UF_DEPT"> <option value="">no</option> <option value="125"> . Volkswagen</option> <opti...
2017/07/15
[ "https://Stackoverflow.com/questions/45117470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7461933/" ]
```js var t = [125, 43, 89]; t.forEach(function(item) { $("select[name='UF_DEPT'] option[value='" + item + "']").remove(); }); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select name="UF_DEPT"> <option value="">no</option> <option value="125"> . Volksw...
``` var child=$("select [name='UF-DEPT']").children(); foreach(child as sub-child){ if($.inArray(sub-child.val(),array){ subchild.remove(); } } ```
4,675,241
Using [Joda Time's pattern syntax](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html) below, this input string: ``` Sunday, January 09, 2011 6:15:00 PM ``` becomes this datetime: ``` 2011-01-09T06:15:00.000Z ``` Code: ``` String start = "Sunday, January 09, 2011 6:15:00 PM"; DateTim...
2011/01/12
[ "https://Stackoverflow.com/questions/4675241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/559894/" ]
You've only shown the *parsing* code - not how you've converted the `DateTime` value back to a `String`. I strongly suspect you're just calling `toString()`, which use the default `DateTime` ISO8601 format. Don't forget that a `DateTime` value represents an instant in time in a particular time zone and calendar syste...
T: Denotes start of "time part" of the string. Zone: 'Z' outputs offset. I suppose in thise case is GMT. Source:<http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html> I always use this format string: `yyyy-MM-dd'T'HH:mm:ss.SSSZ` And, yes, they are not incorrect, if they are present in you...
120,894
<https://stackoverflow.com/questions/9086369/how-does-a-browser-render-a-page-using-the-dom-model-constructed-from-html> One of the comments is that it is not programming related. Possible answers to the question in question might be code snippets or links to a specific implementation i.e. IE and that wouldn't be off...
2012/01/31
[ "https://meta.stackexchange.com/questions/120894", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/177768/" ]
Hmm. No, I agree with the off-topic voters. This kind of behaviour is how a piece of software works in the general sense, which is more like [HowStuffWorks](http://www.howstuffworks.com/) (i.e. probably a question for [Super User](https://superuser.com/)). If you were asking how a specific part of the code *within* a b...
This question falls foul of this paragraph of [What kind of questions should I *not* ask here?](https://stackoverflow.com/faq#dontask): > > Your questions should be reasonably scoped. If you can imagine an > *entire book* that answers your question, you’re asking too much. > > > Given that there exist both the D...
1,432
I understand that in order to get a visa to visit Russia you need an invitation before you can get a visa. If you don't have family or friends that you are visiting and you aren't part of an organised tour, how can you obtain an invitation?
2011/08/05
[ "https://travel.stackexchange.com/questions/1432", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/155/" ]
Well, everything is for sale. There are companies out there that will provide you with an official invitation for set prices. (try Google) I've bought a (single entry) business invitation some years ago, and everything worked out fine. I've met several travellers (in Russia) who bought tourist visa invitations. Some ...
Hotels can sponsor you if you spend the first nights with them.
27,056,876
I have initialized a JSON document in my code like this: ``` var json = []; ``` I use the '.push()' method to add elements to this document like this: ``` json.push({title: "abc", link: "xxx"}); ``` In the end I get a JSON document that looks like this: ``` [ { "title": "abc", "link": "xxx" } { ...
2014/11/21
[ "https://Stackoverflow.com/questions/27056876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2679979/" ]
By doing ``` var json = []; ``` You initialize an array, not an object. To have an object you can do: ``` var json = {}; ``` Then to add a field: ``` json.links = []; ``` then push to you links object: ``` json.links.push({title: "abc", link: "xxx"}); ```
``` var json = { links: [] }; json.links.push({title: "abc", link: "xxx"}); ```
23,375,740
When I attempt to run "rake test" on a local postgres database, it throws the above exception. Here is my pg\_hba.conf file: # Database administrative login by Unix domain socket local all postgres peer ``` # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket c...
2014/04/29
[ "https://Stackoverflow.com/questions/23375740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270511/" ]
If your hb\_conf has already been modified to force passwords, then make sure your rails app's database configuration includes a password in both development and test environments. ``` default: &default adapter: postgresql encoding: unicode pool: 5 host: localhost username: your_user password: your_passwor...
**initialize dot environment in your project** ``` # dot gem gem 'dotenv-rails', groups: [:development, :test] ``` than `bundle install` and than make a .env file in your project and add the following line ``` POSTGRES_HOST=localhost POSTGRES_USER= user_name POSTGRES_PASSWORD= your_password RAILS_MAX_THREADS=5...
5,127,401
I am a newbie in python programming, what I understand is that a process can be a daemon, but a thread in a daemon mode, I couldn't understand the usecase of this, I would request the python gurus to help me in understanding this.
2011/02/26
[ "https://Stackoverflow.com/questions/5127401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571105/" ]
#### In simple words... ### What is a Daemon thread? * **daemon threads** can *shut down any time* in between their flow ***whereas*** **non-daemon** (i.e. user threads) *execute completely*. * **daemon threads** run *intermittently in the background* as long as other **non-daemon threads** are running. * When all of...
I've adapted @unutbu's answer for python 3. Make sure that you run this script from the command line and not some interactive environment like jupyter notebook. ```py import queue import threading def basic_worker(q): while True: item = q.get() # do_work(item) print(item) q.task_do...
69,465
> > How many different combinations of $X$ sweaters can we buy if we have > $Y$ colors to choose from? > > > According to my teacher the right way to think about this problem is to think of partitioning $X$ identical objects (sweaters) into $Y$ different categories (colors). Well,this idea however yields the rig...
2011/10/03
[ "https://math.stackexchange.com/questions/69465", "https://math.stackexchange.com", "https://math.stackexchange.com/users/2109/" ]
There are many general approaches. One of the simplest and best is Newton's Method, which you will find in any calculus text, or by searching the web. By the way, I think your first formula should be $f(x)=(1/2)(x+(3/x))$, no?
The link below shows to some extent the rationale behind the formula you have provided as well as others - See in particular the "Babylonian method" [Approximating square roots](http://en.wikipedia.org/wiki/Methods_of_computing_square_roots)
54,625,221
I want to extract a specific portion from a text file. **example** - ``` PASSED: 1 GETFILE /root/test/misc/ptolemy/erase_flash.csv PASSED: 4 MegaSCU -cfgclr -a0 PASSED: 8 MegaSCU -adphwdevice -read devicetype 5 bus 1 slaveaddr 82 start 0 sz 256 -f SK83100192.vpd -a0 PASSED: 28 VALUECHECK PACKAGE= 24.0.2-00...
2019/02/11
[ "https://Stackoverflow.com/questions/54625221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9447298/" ]
``` class Test end obj = Test.new ``` Here are some ways to create the hash, other than ``` class << obj def greet ... end end ``` and (as mentioned in another answer) ``` def obj.greet ... end ``` **#1** ``` obj.singleton_class.class_eval do def greet1 'Welcome' end end obj.greet1 #=> "Wel...
As per @mu\_is\_too\_short comment, another way is, ``` class Test; end obj1 = Test.new def obj1.pancakes p 'Where is pancakes house?' end obj1.pancakes # "Where is pancakes house?" obj2 = Test.new obj2.pancakes Traceback (most recent call last) : NoMethodError (undefined method `pancakes' for #<Test:0x0000564fb35...
66,212,883
every time I try to display my data out of my MySQL database on a `html` page it will only show the first column of the record or only the name of the column itself. For example: MyDatabase db ``` id names 1 Harry 2 Snape ``` main.py ``` @app.route("/db", methodes = ["POST", "GET"]) def db(): if request...
2021/02/15
[ "https://Stackoverflow.com/questions/66212883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13472449/" ]
you can search for Dictionary in Python . here is some changes in your db.html code : ``` {% extends "base.html" %} {% block title %}db{% endblock %} {% block content %} <form method="POST"> <input type="submit" value="show data"> </form> <!-- Output 1 --> <p>{{data['names']}}</p> <!-- Output 2 --> {% for key, val...
This fixed it for me db.html ``` <p>{{data.names}}</p> ``` main.py ``` else: return render_template("db.html", data = "") ``` This is to avoid getting the error that "data" is undefined when restarting the server.
40,574,177
Is there a way that I for example use my website called `www.mywebsite.com` and in address bar to show `www.wikipedia.com`? And of course to load my contents from `mywebsite.com`?
2016/11/13
[ "https://Stackoverflow.com/questions/40574177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7152893/" ]
In my case it was a file not found, I typed the path to the javascript file incorrectly.
After searching for a while I realized that this error in my Windows 10 64 bits was related to JavaScript. In order to see this go to your browser DevTools and confirm that first. In my case it shows an error like "MIME type ('application/javascript') is not executable". If that is the case I've found a solution. Here...
35,843,696
I am trying to set the x and y limits on a subplot but am having difficultly. I suspect that the difficultly stems from my fundamental lack of understanding of how figures and subplots work. I have read these two questions: [question 1](https://stackoverflow.com/questions/3777861/setting-y-axis-limit-in-matplotlib) [...
2016/03/07
[ "https://Stackoverflow.com/questions/35843696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5255941/" ]
You probably misunderstood the comment. It means that ``` for my $t (qw( housecats house )) { my ($m) = $t =~ /house(cat|)/; print "[$m]\n"; } ``` will print ``` [cat] [] ``` i.e. the regex will match both `housecat` and `house`. If the pattern didn't match at all then `$m` would be `undef`
``` my $t = "housecats"; my ($m) = $t=~m/house(cat|)/gn; print $m; ```
14,525
How do you target a radio telescope on the precise object you wish to observe? You can point it in the general direction but how do you get the information from the exact point in the sky that you are investigating? This seems self evident with an optical telescope but not with a radio telescope.
2016/04/13
[ "https://astronomy.stackexchange.com/questions/14525", "https://astronomy.stackexchange.com", "https://astronomy.stackexchange.com/users/11542/" ]
Large radio telescope have pretty good pointing accuracy: * the individual dishes of the [VLA are accurate](https://science.nrao.edu/facilities/vla/docs/manuals/oss/performance/sensitivity) to about 10 arcsec. * the giant [Lovell telescope](http://www.jodrellbank.net/visit/whats-here/lovell-telescope/) at Jodrell Bank...
This is a complicated question with a number of good answers already posted. It's complicated since there are (broadly) two kinds of radio telescopes -- single dishes and interferometers -- and (even more broadly) two kinds of observation -- imaging, and spectroscopy/photometry. The most important thing to remember is...
3,782,217
I am using c# on a windows mobile 6.1 device. compact framework 3.5. I am getting a OutofMemoryException when loading in a large string of XML. The handset has limited memory, but should be more than enough to handle the size of the xml string. The string of xml contains the base64 contents of a 2 MB file. The code wil...
2010/09/23
[ "https://Stackoverflow.com/questions/3782217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/961042/" ]
I would recommend that you use the XmlTextReader class instead of the XmlDocument class. I am not sure what your requirements are for reading of the xml, but XmlDocument is very memory intensive as it creates numerous objects and attempts to load the entire xml string. The XmlTextReader class on the other hand simply s...
I'm unsure why you are reading the xml in the way you are, but it could be very memory inefficient. If the garbage collector hasn't kicked in you could have 3+ copies of the document in memory: in the string builder, in the string and in the XmlDocument. Much better to do something like: ``` XmlDocument xDoc = new Xm...
48,509,134
If I created an entity with this JSON with `options=keyValues`: ``` { "id": "waterqualityobserved:Sevilla:D3", "type": "WaterQualityObserved", "location": "41.3763726, 2.186447514" } ``` Then request: `localhost:1026/v2/entities/waterqualityobserved:Sevilla:D3` ``` { "id": "waterqualityobse...
2018/01/29
[ "https://Stackoverflow.com/questions/48509134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8539530/" ]
I had been experiencing this issue on emulated devices running 7.0 and 8.0 and consistently the location callback was not being triggered when the screen was off (cmd+P). I was finally able to get my hands on a real 7.0 device (Galaxy S7) and I was not able to replicate the issue. Sorry if I wasted anyone's time, appar...
one solution might be this : check if location is not received in 2 minutes stop/start whole start location update again . although foreground service must have solve the problem
772
The website I'm working on has different sections and each section different types of entries. I would like the types of entries to be shown in the URL. I have followed [this tutorial to do so](http://buildwithcraft.com/help/entry-type-urls). In a site example.com where we have: * A Section called: My Section * With...
2014/07/06
[ "https://craftcms.stackexchange.com/questions/772", "https://craftcms.stackexchange.com", "https://craftcms.stackexchange.com/users/47/" ]
You could just set your "Entry URL Format" to: ``` my-section/{type.name}/{slug} ``` Your entry type names couldn't be as clean when composing entries in the CP as you'd need to set them to something like "example-entry-type", but it would work. --- Now for the really clean way: Install the [Low Regex for Craft](...
You can use twig filters in url structures as mentioned by RhealPoirier in a comment above, no need for a plugin: ``` my-section/{type.handle|replace('/(^|[a-z])([A-Z])/', '\\1-\\2')|lower}/{slug} ``` or ``` my-section/{type.name|kebab}/{slug} ```
26,446,684
I'm trying to delete an object that I created in an ArrayList: ``` turtles.add(new Turtle()); ``` I want to get rid of the last turtle in the ArrayList, something like this: ``` turtles.get(turtles.size() - 1) = null; ``` Any ideas? Simply removing from the list doesn't work, and Java won't let me nullify in the ...
2014/10/19
[ "https://Stackoverflow.com/questions/26446684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2558418/" ]
In JAVA, only creation of objects is in our hands, destroying them is at the discretion of Garbage Collector (GC). When you execute the line **turtles.add(new Turtle())**, the JVM creates a new Turtle object in the java HEAP and adds the corresponding reference to list. Similarly, when you execute **turtles.get(turt...
If you are trying to destroy an object in Java you just have to set it `null`: ``` object = null; ```
61,236,082
Usually the multiple dispatch in julia is straightforward if one of the parameters in a function changes data type, for example `Float64` vs `Complex{Float64}`. How can I implement multiple dispatch if the parameter is an integer, and I want two functions, one for even and other for odd values?
2020/04/15
[ "https://Stackoverflow.com/questions/61236082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2820579/" ]
You may be able to solve this with a `@generated` function: <https://docs.julialang.org/en/v1/manual/metaprogramming/#Generated-functions-1> But the simplest solution is to use an ordinary branch in your code: ``` function foo(x::MyType{N}) where {N} if isodd(N) return _oddfoo(x) else return _...
As @logankilpatrick pointed out the dispatch system is type based. What you are dispatching on, though, is well established pattern known as a trait. Essentially your code looks like ``` myfunc(num) = iseven(num) ? _even_func(num) : _odd_func(num) ```
14,946,472
So, I have a vast quantity of `NSString`s and my problem is I need to cut them into smaller strings at a specific point. This may sound complicated but what I need basically is this: ``` NSString *test =" blah blah blah - goo goo goo."; NSString *str1 = "blah blah blah "; NSString *str2 = "goo goo goo"; ``` How do I...
2013/02/18
[ "https://Stackoverflow.com/questions/14946472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2069876/" ]
You could do this many ways. Two answers above show a few approaches. Many Objective-C solutions will include NSRange usage. You could also do more flexible things with NSScanner or NSRegularExpression. There is not going to be one right answer.
``` NSString *cutString = [text substringFromIndex:3]; cutString = [text substringToIndex:5]; cutString = [text substringWithRange:NSMakeRange(3, 5)]; ```
22,910,327
I'm currently writing a simple painting app in Java using the Swing libraries. Everything seems to be working fine -- mousePressed and mouseDragged both get called -- but the program does not paint anything on the drawing board. I'd be very happy if somebody could tell me why nothing ever gets drawn here. **Code:** `...
2014/04/07
[ "https://Stackoverflow.com/questions/22910327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1790803/" ]
Don't call `repaint` directly or indirectly within any paint method, doing so will cause a new paint event to be scheduled onto the event queue over and over again, quickly consuming your CPU. You're not actually painting to the screen device, in order to do that, you need to paint to the supplied `Graphics` context ...
It seems that the `drawPan` is obstructing you from seeing the image. Remove its creation and addition to the content pane.
46,599,757
This is the code I have so far: ``` questions = ["What is 1 + 1","What is Batman's real name"] answer_choices = ["1)1\n2)2\n3)3\n4)4\n5)5\n:","1)Peter Parker\n2)Tony Stark\n3)Bruce Wayne\n4)Thomas Wayne\n5)Clark Kent\n:"] correct_choices = ["2","3",] answers = ["1 + 1 is 2","Bruce Wayne is Batman"] score = 0 answer_c...
2017/10/06
[ "https://Stackoverflow.com/questions/46599757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8291259/" ]
You should get rid of this line in order for your code to work: ``` answer_choices = [c.split()[:3] for c in answer_choices ``` Notice that you don't have to split `answer_choices` since you don't treat the answers of each question as an array. Moreover, you have more bugs in your code, like the scoring at the end...
If you remove/comment the line ``` answer_choices = [c.split()[:3] for c in answer_choices] ``` you'll get the output as you expect. Since answer\_choices is already a String array, in for loop you are accessing each array element of answer\_choices. Also, since each string in answer\_choices are in the format you ...
9,950,827
I'm creating a list of class "Task" in a way such as this. ``` List<Task> toDoList = new List<Task>; ``` Task is a base class and have designed it as such: ``` public class Task : IDetail { string _taskName; //Task title. string _taskDescription; //Task description. public Task(string t...
2012/03/30
[ "https://Stackoverflow.com/questions/9950827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1300895/" ]
Filter the list and convert them to notes, like: ``` var noteList = toDoList.Where(x => x is Note) .Select(x => (Note)x) .ToList(); ``` then write ``` noteList.ElementAt(x).noteDescription; ```
`toDoList` contains `Task` elements, not `Note` elements. Now a `Note` element is a type of `Task` element, sure, but polymorphism only works in one direction: you can treat a subclass like its superclass, but you can't treat a superclass like a subclass without casting it first. If you think about it, you'll realize ...
50,747,048
I have a variable that is defined like as an Error and this is what it looks like when I print it: ``` Optional(Error Domain=com.apple.LocalAuthentication Code=-2 "Canceled by user." UserInfo={NSLocalizedDescription=Canceled by user.}) ``` What I am trying to do is get that Code of -2...how would I do that?
2018/06/07
[ "https://Stackoverflow.com/questions/50747048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/979331/" ]
You can unwrap the optional `error` first and compare the `-2` case. ``` if let error = error { switch error._code { case LAError.userCancel.rawValue: // or -2 if you want // do something default: break } } ```
I'm pretty sure you want use the `code` property on `NSError`: ``` var e = NSError(domain: "Pizza", code: 31, userInfo: nil) e.code // 31 ```
28,806,763
I have a .net MVC project which works with Code first approach, I need to add a new table and the migration folder already exists and contains a lot of migrations files that have been made before; when I run `Add-Migration`: > > Unable to generate an explicit migration because the following > explicit migrations are...
2015/03/02
[ "https://Stackoverflow.com/questions/28806763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153930/" ]
The error message is probably misleading. It will be linked to the extended data type with table relation. Try following 1) Check if the EDT you are using is in the 2012 style or 2009 style (2009 has relations). If it is in the old style try to use new style datatype with table reference instead of relation. 2) Add ...
You have to delete existing relation and add new relation to the same table. Then add relation fields and select `New -> ForeignKey -> PrimaryKey based`. AX will create all three fields.
21,765,647
I'm trying to compute the difference in pixel values of two images, but I'm running into memory problems because the images I have are quite large. Is there way in python that I can read an image lets say in 10x10 chunks at a time rather than try to read in the whole image? I was hoping to solve the memory problem by r...
2014/02/13
[ "https://Stackoverflow.com/questions/21765647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1272809/" ]
You can use numpy.memmap and let the operating system decide which parts of the image file to page in or out of RAM. If you use 64-bit Python the virtual memory space is astronomic compared to the available RAM.
If you have time to preprocess the images you can convert them to bitmap files (which will be large, not compressed) and then read particular sections of the file via offset as detailed here: [Load just part of an image in python](https://stackoverflow.com/questions/19695249/load-just-part-of-an-image-in-python) Conv...
9,761,804
When I use: ``` include "../common/common_functions.php"; include "../common/functions.php"; include '../../common/global_functions.php'; ``` my browser gives me a lot of warnings, but when i use: ``` @include "../common/common_functions.php"; @include "../common/functions.php"; @include '../../common/global_functi...
2012/03/18
[ "https://Stackoverflow.com/questions/9761804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/710592/" ]
@ is the error suppresion operator in php <http://php.net/manual/en/language.operators.errorcontrol.php> Errors are good, it's php's way of communicating with you. They might be worth looking into. Perhaps you are using deprecated functionality, you should post your errors too.
If in doubt how relative paths work and how PHP sets the working directory to the invoked script, then make all paths absolute: ``` include "$_SERVER[DOCUMENT_ROOT]/common/constants.php"; include "$_SERVER[DOCUMENT_ROOT]/common/functions.php"; ``` They are absolute in relation to the "web server root directory". (No...
2,590
In a book I'm typesetting, I want the tabular environment to be in footnote size and the other body of the book to be in normalsize font. To do this, I've tried something like the following: ``` ‎‎‎‎‎‎‎\re‎newenvironment‎{‎‎tabular‎‎}[1][t‎]{\footnotesize‎‎‎‎‎ \begin{tabular}‎ ‎‎‎‎‎‎‎‎‎‎‎‎‎[#1]}{‎‎‎‎\end{tabular}‎\nor...
2010/08/31
[ "https://tex.stackexchange.com/questions/2590", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/885/" ]
A better approach is to define a new tabular environment with your own customizations ``` \newenvironment{smalltabular}{\footnotesize\tabular}{\endtabular} ``` And then use `smalltabular` instead of `tabular`. A few things to note: * In the definition of a new environment, instead of `\begin{tabular}` and `\end{tab...
Using the `\tabular` macro inside a redefinition of the same macro will produce an infinite loop. Try the following: ``` \makeatletter \renewcommand{\tabular}{\let\@halignto\@empty\footnotesize\@tabular} \makeatother ```
113,151
If you are a financially responsible person, you know how a credit card works, you pay back the loans in full before the due date, you don't take out money form the ATM or otherwise do something that gets taxed, etc. Are there any ways that you could still end up paying interest, fees, penalties, or whatever? I guess...
2019/08/31
[ "https://money.stackexchange.com/questions/113151", "https://money.stackexchange.com", "https://money.stackexchange.com/users/81192/" ]
Some credit cards will charge an annual fee. If you qualify for a card with no annual fee, don't get cash advances, and pay in full each month, you won't be charged any interest. I think I've been charged a month's interest twice in the last five years, both times because I spaced out and missed the billing due date. T...
One way banks/credit cards can get you is by being having terms that are subtly different from the norm. **An example**: On every credit card I had ever had, if you paid the balance in full in the previous statement period then you would have a grace period where purchases in the current statement wouldn’t be assess...
37,337,477
I need some advices on how to mock a rest api. My application is in MVP architecture. My interface for API: ``` public interface MyAPI { @GET("{cmd}/{userName}/{password}") Observable<Response> login( @Path("cmd") String cmd, @Path("userName") String userName, @Path("password") String...
2016/05/20
[ "https://Stackoverflow.com/questions/37337477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118562/" ]
You can do it in next way: ``` @Test public void testLoginWithCorrectUserNameAndPassword() throws Exception { // create or mock response object when(service.login(anyString(), anyString(), anyString).thenReturn(Observable.just(response)); mLoginPresenter.login("user@email.com","password"); verify(view)...
Thanks for **@Ilya Tretyakov**, I came out this solution: ``` private ArgumentCaptor<Subscriber<Response>> subscriberArgumentCaptor; @Test public void testLoginWithCorrectUserNameAndPassword() throws Exception { mLoginPresenter.login("user@email.com","password"); // create the mock Response object Respons...
53,712
In what cases it is correct to say "in the school"? Are there any situations, in which that combination of words placed in the end of a sentence would be correct?
2015/03/28
[ "https://ell.stackexchange.com/questions/53712", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/650/" ]
In school vs in the school. When you talk about activities other than school actvities, you use the phrase "in the school". Otherwise, you use "in school" about school/educational activities. look at the following sentences to distinguish between these phrases: My kids are still in/at school. Some visitors are in th...
Not really, 'in the school' is perhaps more common American English while 'at school' is more British but both are equally 'correct'. Similarly an American would probably say 'in college' while a Brit would say 'at university'. In tends to be used for institutions, so your are 'in hospital' or rather than 'at hospital...