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
1,001,784
In essence, I want to put a variable on the stack, that will be reachable by all calls below that part on the stack until the block exits. In Java I would solve this using a static thread local with support methods, that then could be accessed from methods. Typical example: you get a request, and open a database conne...
2009/06/16
[ "https://Stackoverflow.com/questions/1001784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I went ahead and made something that might just do what you want. It can be used as both a decorator and a context manager: ``` from __future__ import with_statement try: import cPickle as pickle except ImportError: import pickle class cached(object): """Decorator/context manager for caching function call...
You could use a global variable wrapped in a getter function: ``` def getConnection(): global connection if connection: return connection connection=createConnection() return connection ```
34,183,343
Tensorflow has a function called [batch\_matmul](https://www.tensorflow.org/versions/master/api_docs/python/math_ops.html#batch_matmul) which multiplies higher dimensional tensors. But I'm having a hard time understanding how it works, perhaps partially because I'm having a hard time visualizing it. [![enter image de...
2015/12/09
[ "https://Stackoverflow.com/questions/34183343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2584721/" ]
You can imagine it as doing a matmul over each training example in the batch. For example, if you have two tensors with the following dimensions: ``` a.shape = [100, 2, 5] b.shape = [100, 5, 2] ``` and you do a batch `tf.matmul(a, b)`, your output will have the shape `[100, 2, 2]`. 100 is your batch size, the othe...
You can now do it using tf.einsum, starting from Tensorflow **0.11.0rc0**. For example, ``` M1 = tf.Variable(tf.random_normal([2,3,4])) M2 = tf.Variable(tf.random_normal([5,4])) N = tf.einsum('ijk,lk->ijl',M1,M2) ``` It multiplies the matrix M2 with every frame (3 frames) in every batch (2 batches) in M1....
37,043
We've got a problem with our network here but first I'll give a bit of background info: DHCP running on a windows server 2000 box is configured to hand out 2 IP Ranges 10.25.104.xxx and 10.25.106.xxx The network infrastructure runs on a Cisco Catalyst 4506 of which are linked via fibre. The network team has configured...
2009/07/07
[ "https://serverfault.com/questions/37043", "https://serverfault.com", "https://serverfault.com/users/10413/" ]
It sounds like you don't have two separate layer 2 broadcast domains when you say "IP isn't released and renewed as DHCP constantly trys to give it the same IP again that won't work on the oppsite network". It's difficult to know what you mean when you say "The network team has configured 1 of the 4506's to only allow...
They might have bind the ip address with mac address in dhcp configuration. when it connected and tries to renew from another pool when it will not work. Remove the mac address binding from dhcp configuration & make it dynamic. Create 2 pools one for desktop machines and another for laptops. I these tips might wo...
2,613,781
I am looking for an **efficient** way of finding the intersection of a line with a cylinder. Several answers are suggested on this site and other places, however I found [this answer](https://math.stackexchange.com/questions/2126565/intersection-between-a-cylinder-and-a-given-line) the most efficient one. The only chal...
2018/01/20
[ "https://math.stackexchange.com/questions/2613781", "https://math.stackexchange.com", "https://math.stackexchange.com/users/523293/" ]
If your cylinder is set along an an axis, one way you could think of this is the following: You "watch" your cylinder with your vision axis colinear with the cylinder axis, you can transform your parameterized line in the same referential as the cylinder then solve for a simple circle-line intersection in 2D. [![ente...
The best way is to parametrize your line and plug into the equation of the cylinder. For example if you have a line starting at $P(1,2,3)$ and the direction vector is $ V=<2,3,5>$. Then the parametrization is $$x=1+2t, y=2+3t,z=3+5t$$ Now suppose your cylinder is $$ x^2 + y^2 =25$$ Plugging your $ x,y,z $of your ...
437,146
I'm planning to deploy an internal app that has sensitive data. I suggested that we put it on a machine that isn't exposed to the general internet, just our internal network. The I.T. department rejected this suggestion, saying it's not worth it to set aside a whole machine for one application. (The app has its own dom...
2009/01/12
[ "https://Stackoverflow.com/questions/437146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
I would rather go with SSL and some certificates, or a simple username / password protection instead of IP filtering.
It depends exactly HOW secure you really need it to be. I am assuming your server is externally hosted and not connected via a VPN. Therefore, you are checking that the requesting addresses for your HTTPS (you are using HTTPS, aren't you??) site are within your own organisation's networks. Using a regex to match IP a...
42,987
I would like to know when is a good time to start teaching your baby sign language. I heard they won't start signing back to you before 6-7 months so starting before 3 months might be pointless. Any thoughts on when you think would be a good time to start for your sake as well as your baby's?
2022/10/27
[ "https://parenting.stackexchange.com/questions/42987", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/43628/" ]
Just do it as normal all the time. They pick up everything all the time. That is how children learn by seeing, hearing and experiencing things.
We incorporated basic signs with our children pretty much right after they started opening their eyes (i.e. around 1 month) and coupled it with words. We are not proficient in sign language, we limited ourselves to 'eat', 'drink', and 'more' and was done with a deliberate goal towards the long game and had demonstrable...
1,896,527
Can sommebody please tell me what is not right about this code? It compiles and everything great but the output is solid zero's all the way down. So it is not counting the letters. ``` #include <iostream> #include <fstream> #include <string> using namespace std; const char FileName[] = "c:/test.txt"; int main () ...
2009/12/13
[ "https://Stackoverflow.com/questions/1896527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230547/" ]
Your `if` concerning upper and lower case letters are incorrectly nested. You don't even look at lowercase letters if `oneLetter` is not uppercase. Those two `if`s should be at the same level. That's the only error I can see. I'd recommend either debugging, as gf suggests, or throwing in some print statements to veri...
How about the printout at the end, where lower case letter counts are printed twice? This explains why it's "zeroes all the way down", because the original code *was* counting the upper case letters correctly wasn't it?
9,712,162
I have a group of 3 `JRadioButtonMenuItem` in a menu, and 3 `JToggleButton` in a toolbar. Each of them is bound to 3 `Action`, so that when I disable one action, both the corresponding item and button will be disabled. When I click a menu item, I would expect also the corresponding toolbar button to get selected, but ...
2012/03/15
[ "https://Stackoverflow.com/questions/9712162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/503900/" ]
I don't know how exactly are you doing it, but this code is working for me: ``` import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.J...
You can link the state of any two (or more) buttons by sharing the button model among them, in this case: ``` itemA.setModel(buttonA.getModel()); itemB.setModel(buttonB.getModel()); itemC.setModel(buttonC.getModel()); ``` That way you can avoid calling the `putValue(Action.SELECTED_KEY, true)`. Not sure whether that...
21,379,093
I have this CLICK function that works for one specific HTML button. I'd like to use it on multiple buttons, but each button needs to pass different variables to the same page. **BUTTON** ``` <input type="button" id="scs" value="TEST" /> ``` **JQUERY** ``` $("#scs").click(function() { $("#status").html("<p>Plea...
2014/01/27
[ "https://Stackoverflow.com/questions/21379093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1932360/" ]
Give your buttons the same class and call the code using the class name, and add a data attribute to each button to retrieve the seperate values. Give this a try: ``` <input type="button" class="clickButton" data-value="go.php?up=1" value="Update" /> <input type="button" class="clickButton" data-value="go.php?new=1" ...
You can check by the value of the clicked button and use a 'url' variable for the ajax request: ``` $("button").click(function() { $("#status").html("<p>Please Wait! TESTING</p>"); var url=''; var value = $(this).val(); if(value == 'update'){ url='go.php?up=1'; } e...
2,865,651
In Visual Studio 2008, the target framework settings for a project are * .NET Framework 2.0 * .NET Framework 3.0 * .NET Framework 3.5 However, in Visual Studio 2010 they are * .NET Framework 2.0 * .NET Framework 3.0 * .NET Framework 3.5 * .NET Framework 3.5 Client Profile * .NET Framework 4 * .NET Framework 4 Client...
2010/05/19
[ "https://Stackoverflow.com/questions/2865651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39709/" ]
The client profile is a smaller version of the full .NET framework that contains only the more commonly used content. Scott [wrote](http://www.hanselman.com/blog/TowardsASmallerNET4DetailsOnTheClientProfileAndDownloadingNET.aspx) a nice post about this. [Here](http://msdn.microsoft.com/en-us/library/cc656912.aspx) and ...
It is a subset of the .NET framework for CLIENT applications (i.e. applications installed on the client computer). As such, they do not incorporate server technologies. THis allows the client download to only install a smaller part. Server technologies are for example ASP.NET. Using ".net client profile" as search o...
497,210
**Important: This question isn't actually really an ASP.NET question.** Anyone who knows anything about URLS can answer it. I just happen to be using ASP.NET routing so included that detail. In a nutshell my question is : "What URL format should I design that i can give to external parties to get to a specific place...
2009/01/30
[ "https://Stackoverflow.com/questions/497210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
This URL: ``` "campaign/{destination}/{partnerid}/{campaignid}/{custom}", ``` ...doesn't look like a resource to me, it looks like a remote method call. There is a lot of business logic here which is likely to change in the future. Also, it's complicated. My gut instinct when designing URLs is that simpler is genera...
Create an URL called <http://mysite.com/gateway> Return an HTML form, tell your partners to fill in the form and POST it. Redirect based on the form values. You could easily provide your partners with the javascript to do the GET and POST. Should be trivial.
9,276,389
Here is my code: ``` template<typename T1, typename T2> class MyClass { public: template<int num> static int DoSomething(); }; template<typename T1, typename T2> template<int num> int MyClass<T1, T2>::DoSomething() { cout << "This is the common method" << endl; cout << "sizeof(T1) = " << sizeof(T1) << end...
2012/02/14
[ "https://Stackoverflow.com/questions/9276389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1173593/" ]
Unfortunately, you can't specialise a template that's a member of a class template, without specialising the outer template: > > C++11 14.7.3/16: In an explicit specialization declaration for a member of a class template or a member template that appears in namespace scope, the member template and some of its enclosi...
Similar to DocValle answer, not to rely on possible compiler optimisation you could use constexpr if to enforce compile time branching ``` template<class T> template<int num> void Classname<T>::methodname() { if constexpr (num == 0) { //implementation for num == 0 } else if constexpr (num == 1...
37,461,278
I just started to learn Groovy and wondering if you can set your own property for an integer. For example, ``` def a = 34.5.plus(34.34) def b = 5.64.minus(3.43) def c = 12.64.multiply(33.43) ``` In the above there are certain methods like `plus` `minus` and `multiply` What should I do if I want to define some of...
2016/05/26
[ "https://Stackoverflow.com/questions/37461278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4546390/" ]
Sure, you can just add methods to the metaClass of `Integer`. Here's an example: ``` Integer.metaClass.zeds = { -> 'z' * delegate } assert 3.zeds() == 'zzz' ``` You can also add methods to a single instance of integer should you wish to, ie: ``` Integer num = 4 num.metaClass.halved = { -> delegate / 2.0 } assert...
Use groovy meta programming, this allows you to create dynamic method creation atruntime in the class that you want to place in . bydefault if a method is not found methodmissing exception throws , this is where groovy allows you add method at runtime for more reference use the below comprehensive link <http://groov...
2,100,184
I am interested in understanding the internals of [JavaScript](http://en.wikipedia.org/wiki/JavaScript). I've tried to read the source for [SpiderMonkey](http://en.wikipedia.org/wiki/SpiderMonkey_%28JavaScript_engine%29) and [Rhino](http://en.wikipedia.org/wiki/Rhino_%28JavaScript_engine%29) but it's quite complex to w...
2010/01/20
[ "https://Stackoverflow.com/questions/2100184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204535/" ]
If you want to understand why those wierd expressions work as they do, you can open firebug console and experiment yourself. I did and I got that `![]` is `false`, `!![]` is `true`, adding an array to a boolean value (`false+[]` or `true+[]`) produces a string-version of this value (`false+[]="false"`). That way the ...
I recommend you obtain and read: * ECMAScript standard (ECMA 262), 5th edition * Adobe document called "AVM 2 overview" which explains the architecture of the AVM2 virtual machine, on which Adobe Flash and its ActionScript run.
5,301,039
I have a set of JPEG's on my server all the same size. Can I convert this into a PDF file server side?
2011/03/14
[ "https://Stackoverflow.com/questions/5301039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356635/" ]
I am using iText for this requirement ``` Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(yourOutFile)); document.open(); for(int i=0;i<numberOfImages;i++){ Image image1 = Image.getInstance("myImage"+i+".jpg"); image1.scalePercent(23f); document.newPage(); document.add...
[DotImage](http://www.atalasoft.com) has built-in classes to do this. If all your jpegs are in one folder, you can do this: ``` FileSystemImageSource source = new FileSystemImageSource(pathToDirectory, "*.jpg", true); PdfEncoder encoder = new PdfEncoder(); using (FileStream outstm = new FileStream(outputPath, FileMode...
106,737
I just received a .jpg file that I'm almost positive contains a virus, so I have two questions about what I am able to do with the image. My first question originates from the fact that I opened the file once and the program I used to open it gave the error "invalid or corrupt image". So I want to know whether or not ...
2015/11/28
[ "https://security.stackexchange.com/questions/106737", "https://security.stackexchange.com", "https://security.stackexchange.com/users/93150/" ]
Based on the description at Virustotal you've linked to this is in reality not an image, but a real PE32 executable (normal windows executable). So only the file name extension was changed to hide the real purpose of the file. PE32 will not be automatically executed when they have the `.jpg` extension like in this cas...
> > "So i want to know whether or not its possible a virus contained > inside the image could still have been executed if the software did > not 'fully' open the image?" > > > Given the other answers say that it is a PE executable, it's very unlikely that you've done anything harmful by opening it in an image ed...
6,807,507
I would like to write an app to follow the price of lists of stocks. There would be three activities containing lists of stocks : * myStocksActivity containing the stocks I'm interested in * searchedStocksActivity containing a list of stocks I could add in the list contained in myStocksActivity * winnersLoosersStocksA...
2011/07/24
[ "https://Stackoverflow.com/questions/6807507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/860302/" ]
If I was you I would try and design(and build) a domain model first. This should end up being a set of classes which allows you to do everything you want with your stocks, independently of the a UI. You should also build in data persistence directly into these classes (i suggest using SQLite for this bit). Then once y...
1. Create a class for a stock, and store the update logic in there 2. I would put the handler - what holds instances of the stock-class and loops over a set to tell them to update - either in its own class purely with static methods and variables, or also in the stock class with static methods/etc. 3. The service then ...
466,683
SSL certificates by default have line breaks after 67 characters. I'm trying to create SSL certificate files using Chef. Essentially I want to create the entire certificate file from a string variable without any line breaks. I've tried this a few times to no avail (Apache complains about not being able to find certifi...
2013/01/13
[ "https://serverfault.com/questions/466683", "https://serverfault.com", "https://serverfault.com/users/75925/" ]
The line length, and so the line breaks, are due to 64-bit encoding used in the certificate files: see this Wikipedia article, for instance, <http://en.wikipedia.org/wiki/Base64> Put newline characters (\n) into your string variable, instead.
If `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----` lines are not required for the CLI tool or API being used to pass the certificate, then just use: ``` awk 'NR>2 { sub(/\r/, ""); printf "%s\\n",last} { last=$0 }' crt.pem ```
1,239,143
i am writing a macro to convert the zeros in the access table to "0000" Zero is text data type so i cast it to int in the if condition to update the records which is only zeros and preventing it in updating records which are non zeros but now all the records are getting updated ..if clause is calling all the time ev...
2009/08/06
[ "https://Stackoverflow.com/questions/1239143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your question includes some very confused code. You define this recordset: ``` Set rst = db.OpenRecordset("SELECT * FROM tblECodes") ``` and then walk through it row by row testing whether the row matches certain criteria and then execute a SQL string that updates rows in the very same table. This makes absolute...
The docmd.RunQuery suggestion from Raj should work well. But if you'd like to stay in VBA: ``` Do While Not rst.EOF If rst!Scheduled = "0001" And rst!testid = "148" Then rst.Edit rst!scheduled = "0000" rst.Update End If rst.MoveNext Loop ```
23,302,257
I want to do something as simple as ``` alias set_then_do if ``` because ``` if x=true puts "x is #{x}" end ``` works. But everyone who looks at the code will instinctively want to change the single equals symbol to two ( '=' to '==' ). Just because of the if word. But I want the assignment to be there withou...
2014/04/25
[ "https://Stackoverflow.com/questions/23302257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1500195/" ]
`if` is not a method; it's a keyword. Ruby doesn't provide any facilities for modifying its syntax, so you can't do this.
I'll start with a disclaimer that I don't recommend doing this. However, as Chuck points you can't do what you want, but you can get "close". Also, I agree `set_then_do` is a poor name and you might want a different one. Maybe `do_if` instead. Having said all that, you can in the global name space make the following ...
8,302,293
The following code raises a syntax error: ``` >>> for i in range(10): ... print i ... try: ... pass ... finally: ... continue ... print i ... File "<stdin>", line 6 SyntaxError: 'continue' not supported inside 'finally' clause ``` **Why isn't a `continue` statement allowed inside a `f...
2011/11/28
[ "https://Stackoverflow.com/questions/8302293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608794/" ]
The use of *continue* in a finally-clause is forbidden because its interpretation would have been problematic. What would you do if the finally-clause were being executed because of an exception? ``` for i in range(10): print i try: raise RuntimeError finally: continue # if the loop co...
I think the reason for this is actually pretty simple. The continue statement after the finally keyword is executed every time. That is the nature of the finally statement. Whether or not your code throws an exception is irrelevant. Finally will be executed. Therefore, your code... ``` for i in range(10): print i ...
18,230,690
I have a list of Question objects and I use a `ForEach` to iterate through the list. For each object I do an `.Add` to add it into my entity framework and then the database. ``` List<Question> add = problem.Questions.ToList(); add.ForEach(_obj => _uow.Questions.Add(_obj)); ``` I need to modify each of the objects in...
2013/08/14
[ "https://Stackoverflow.com/questions/18230690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` foreach(var itemToAdd in add) { Do_first_thing(itemToAdd); Do_Second_Thing(itemToAdd); } ``` or if you will insist on using the `ForEach` method on `List<>` ``` add.ForEach(itemToAdd => { Do_first_thing(itemToAdd); Do_Second_Thing(itemToAdd); }); ``` Personally I'd go with the first, it's clearer...
use a foreach statement ``` foreach (Question q in add) { _uow.Questions.Add(q); q.AssignedDate = DateTime.Now; } ``` or as astander propose do `_obj.AssignedDate = DateTime.Now;` in the `.ForEach(` method
1,091,888
Bluetooth not finding any devices in Ubuntu 18.04. I tried different solutions that were found on the internet but with no success. After Bluetooth is enabled, it keeps searching for devices until it is turned off. All the devices that I am trying to connect with are fully functional, they were paired with other OS a...
2018/11/11
[ "https://askubuntu.com/questions/1091888", "https://askubuntu.com", "https://askubuntu.com/users/635064/" ]
Whilst [Hassan's suggestion](https://askubuntu.com/a/1116767/618353) did not fully solve my issue, it set me on the path that did solve it. I don't have rep to post a comment yet, but just wanted to say thank you SO much to Hassan as part of your solution lead me to find a solution for this issue. It was specifically...
Answer posted by Yadnesh Salvi pointed me in the right direction to my issue on Ubuntu 18.04. In my case, i was missing `BCM43142A0-0a5c-21d7.hcd` and on restart after copying, i found that i am also missing `BCM43142A0-105b-e065.hcd`. Followed the same steps as suggested for the missing [BCM43142A0-105b-e065.hcd](ht...
24,215,900
What happens: ![enter image description here](https://i.stack.imgur.com/8j0k2.png) What I want to happen: ![enter image description here](https://i.stack.imgur.com/cEsjC.png) HTML: ``` <input type="button" onclick="showSpoiler1(this);" value="Front flip variaion (ramp)" /> <input type="button" onclick="showSpoiler...
2014/06/14
[ "https://Stackoverflow.com/questions/24215900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3733200/" ]
Try to add `table` for each div. This should work as you want. ``` <table> <tr> <td> <div1 class="inner" style="display:none;"> ... </div1> </td> <td> <div2 class="inner" style="display:none;"> ... </div2> </td> </tr> </table> ``...
Try toggling to display: inline-block or float them to the left;
444,781
In .NET 3.5, I'd like to create a singleton interface: ``` interface ISingleton <T> { public static T Instance {get;} } ``` Of course that doesn't work but is what I'd like. Any suggestions? EDIT: I just want it to be known that all singeltons will have a static property named Instance of the class type. It is al...
2009/01/14
[ "https://Stackoverflow.com/questions/444781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40106/" ]
An Interface can't, to my knowledge, be a Singleton since it doesn't actually exist. An Interface is a Contract that an implementation must follow. As such, the implementation can be a singleton, but the Interface can not.
Ok I made this answer a Wiki, because I am just going to offer an opinion that is at a tangent to your question. I personally think that Singletons are waaay overused, its a use case that IMO is actually reasonably rare, in most cases a static class would suit the use case much better, and in other cases just a factor...
20,265,475
I have entered this shell script and its showing errors when compiling ``` echo Enter basic Salary read bs if [ $bs -lt 1500 ] then hra= echo ´$bs \* 10 / 100´|bc fi gs= echo ´$bs + $hra´|bc echo $gs ``` The errors are: ``` (standard_in) 1: illegal character: \302 (standard_in) 1: illegal character: \264 (standard...
2013/11/28
[ "https://Stackoverflow.com/questions/20265475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2740691/" ]
One problem is (or, rather, 4 problems are) the use of `´` in place of `'` or `"`. There is another character in there also causing trouble, unless the acute accent is encoded in UTF-8 or UTF-16† Another problem is the use of spaces around assignments; these do not fly in the shell. You must not have spaces on either...
Too many Errors: 1. As stated by Jonathan, is using ´ in place of `. 2. Do not use space while assigning values to variables. 3. Create the data before assigning it to a variable. For e.g. hra=`echo $bs \* 10 / 100|bc` Also, if the input exceeds 1500, then it will give out the error. So you need to do something with...
17,033,247
I have a simple string, where I need to insert a few numbers and strings. Say String a = "My name is %s. I am %d years old". I also need to insert same number or string at several of these holes. I need a solution which works for ancient versions of java atleast upto 1.3 I know about String.format (JDK 5+). I read ab...
2013/06/10
[ "https://Stackoverflow.com/questions/17033247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616809/" ]
Your only option is to use [`MessageFormat`](http://docs.oracle.com/javase/7/docs/api/java/text/MessageFormat.html) here. You'd type: ``` String s = "My name is {0}. I am {1} years old"; ``` and use the appropriate method to render this to a string. For instance: ``` String ret = MessageFormat.format(s, "John", 32...
What about this one ``` String text = "The user {0} has email address {1}." String msg = MessageFormat.format(text, params); ``` And this other ``` String text = "The user {name} has email address {email}."; Object[] params = { "nameRobert", "rhume55@gmail.com" }; Map map = new HashMap(); map.put("name", "Robert")...
29,334,843
The situation is following: ```dart abstract class A { void doSomething() => print('Do something..'); } class B implements A { @override void doSomething() => print('Do something already..'); } class C extends A { } ``` I have an abstract class A. Class B implements A. Therefore it overrides doSomething() me...
2015/03/29
[ "https://Stackoverflow.com/questions/29334843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3650018/" ]
If a class has no constructor a generative constructor is implicitly added. If a class has an explicit constructor no generative constructor is added. You have two options. * make the factory constructor a named factory constructor and add a normal constructor ```dart abstract class A { void doSomething() => print...
I dont know it works but it solves my problem. And I know there are a lot solution for this may be this solution worst. :) but I want to share with you Sometimes backend API returns same model but different by values. like this. ```dart Map<String,dynamic> map1 = { "version": "2.16.0", "language_1":"Dart", "fra...
28,160,533
My Python code needs to be able to randomly generate a number between 1 and 3 to determine what function to perform (addition, multiplication or subtraction). That works fine. I randomly generate two numbers and need to get this random function. So it would be like a basic maths sum like 3 + 6 = 9. The 3 would be store...
2015/01/26
[ "https://Stackoverflow.com/questions/28160533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can use the binary operator functions defined in the `operator` module. The functions `operator.add()`, `operator.sub()` and `operator.mul()` can all be called with two arguments to perform the operation their name suggests. To select one of the three functions at random, you can simply put them in a list and then...
``` number1 = randint(1,20) number2 = randint(1,20) if function == 1: answer = number1 + number2 elif function == 2: answer = number1 - number2 elif function == 3: answer = number1 * number2 ``` You don't have to over think it.
30,832,215
Pattern matching in Kotlin is nice and the fact it does not execute the next pattern match is good in 90% of use cases. In Android, when database is updated, we use Java switch property to go on next case if we do not put a break to have code looking like that: ``` switch (oldVersion) { case 1: upgradeFromV1(); ...
2015/06/14
[ "https://Stackoverflow.com/questions/30832215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/600351/" ]
It is absolutly possible quote from official reference : [Control Flow: if, when, for, while](https://kotlinlang.org/docs/reference/control-flow.html) ``` If many cases should be handled in the same way, the branch conditions may be combined with a comma: when (x) { 0, 1 -> print("x == 0 or x == 1") else ->...
val oldVersion = 6 val newVersion = 10 ``` for (version in oldVersion until newVersion) { when (version) { 1 -> upgradeFromV1() 2 -> upgradeFromV2() 3 -> upgradeFromV3() 4 -> upgradeFromV4() 5 -> upgradeFromV5() 6 -> upgradeFromV6() 7 -> upgradeFromV7() ...
27,248,556
I read the documentation in the MongoDb and I used a simple proves and I only look that: Push is sorting the array but `addtoSet` isn't it. For me visually is the same, I don't know the difference. Could anybody explain me the difference? Another think if it could be in spanish or in a simple english, i'll aprecite ...
2014/12/02
[ "https://Stackoverflow.com/questions/27248556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4312217/" ]
**$push** - adds items in the order in which they were received. Also you can add same items several times. **$addToSet** - adds just unique items, but order of items is not guaranteed. If you need to add unique items in order, you can group and add elements via $addToSet, then $unwind the array with elements, $sort ...
As the name suggest $addToSet (set) wont allow duplicates while $push simply add the element to array
37,241,326
I am working on a project and im learning at the same time and so far everything has been working great! But I want to be able to use the animated css code from Animate.css which should work in concert with the javascript in the wow.js file. Essentially, I need help troubleshooting why the animate.css code (e.g., wow ...
2016/05/15
[ "https://Stackoverflow.com/questions/37241326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6300892/" ]
Exceptions *are* classes, so obviously they each need their own class. It can be a normal class, inner class or a nested class as usual.
1) A custom exception class can be defined either within the class it is intended for or in a separate class. Example of the former - `ThrowingClass.java`: ``` public class ThrowingClass { public static class ThrownInnerException extends Exception { public ThrownInnerException() {}; } public void...
19,257
With [Hadoop](http://en.wikipedia.org/wiki/Hadoop) and [CouchDB](http://en.wikipedia.org/wiki/CouchDB) all over in Blogs and related news what's a distributed-fault-tolerant storage (engine) that actually works. * CouchDB doesn't actually have any distribution features built-in, to my knowledge the glue to automagical...
2009/06/03
[ "https://serverfault.com/questions/19257", "https://serverfault.com", "https://serverfault.com/users/7936/" ]
Take a look at chirp <http://www.cse.nd.edu/~ccl/software/chirp/> and parrot <http://www.cse.nd.edu/~ccl/software/parrot/>
> > Lustre also has a single point of failure as it uses a dedicated metadata server > > > Lustre is designed to support failover and a MDS/MDT/OSS can have a number of addresses which it can be contacted at, heartbeat can be used to migrate the service around. Be aware that some recent versions have had issues w...
3,017,454
High, I need to do some image manipulations on CT volume images. Mainly segmentations. Which open-source library supports 3D algorithms - Filtering, edge detection, deformable objects and so ? Language is not an issue at the moment. 10x
2010/06/10
[ "https://Stackoverflow.com/questions/3017454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363827/" ]
You can try itk: <http://www.itk.org/>
My company processes CT and MR medical images, to perform segmentation, and related shape measurement for industrial clients. We use (and contribute to) [VXL](http://vxl.sourceforge.net "VXL") as our underlying 2D and 3D image, math and geometry library. [ITK](http://www.itk.org/) is also very good.
2,277,633
I've got a program that runs very happily with `-Xmx2g`. With `-Xmx1g`, it grinds to a halt. It never gets an out of memory exception -- or, at least, I've never had the patience to wait long enough. This suggests that the total footprint does fit into 1g, but that the GC has some anxiety about possibly running out of...
2010/02/17
[ "https://Stackoverflow.com/questions/2277633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131433/" ]
It sounds like you have not given the JVM enough heap. Sure, the working set may fit in 1Gbytes, but you still need to give it more. To understand why, read on. Let us assume that when a garbage collector runs, it does an amount of work `W1` that is proportional to the amount of non-garbage that it scans in order to i...
If you wan't to do some fine tuning you should check the `MinHeapFreeRatio` and `MaxHeapFreeRatio` parameters among others desribed here [Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning](http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html) this sould lead to the "tranquillizer effect".
16,214,190
I'm converting an image to **base64** string and sending it from android device to the server. Now, I need to change that string back to an image and save it in the database. Any help?
2013/04/25
[ "https://Stackoverflow.com/questions/16214190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999885/" ]
Convert base64\_string into opencv (RGB): ``` from PIL import Image import cv2 # Take in base64 string and return cv image def stringToRGB(base64_string): imgdata = base64.b64decode(str(base64_string)) img = Image.open(io.BytesIO(imgdata)) opencv_img= cv2.cvtColor(np.array(img), cv2.COLOR_BGR2RGB) ret...
You can try using open-cv to save the file since it helps with image type conversions internally. The sample code: ``` import cv2 import numpy as np def save(encoded_data, filename): nparr = np.fromstring(encoded_data.decode('base64'), np.uint8) img = cv2.imdecode(nparr, cv2.IMREAD_ANYCOLOR) return cv2.im...
31,914,071
I want to create a button group, where button from a group can be selected at once. Let's suppose we have got three buttons, the user should be able to select only one button, so if user selects "Apple" then they shouldn't be able to select the Apple button again. The main purpose will be to stop user selecting the b...
2015/08/10
[ "https://Stackoverflow.com/questions/31914071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4841850/" ]
For Bootstrap 4: ``` <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-secondary active"> <input type="radio" name="options" id="option1" autocomplete="off" checked> Active </label> <label class="btn btn-secondary"> <input type="radio" name="options" id="option2" autoco...
`Button` are used for buttons ``` <div class="btn-group btn-group-lg"> <input type="radio" class="btn btn-primary" value="Apple" name="radio"> Apple <input type="radio" class="btn btn-primary" value= "Samsung" name="radio"> Samsung <input type="radio" class="btn btn-primary" value "Sony"...
16,739,935
You might have noticed in the new Play Music application (from version 5.0.0 onwards) the three dots close to every song, popping up a context menu: ![Play Music app with context menu open in one song](https://i.stack.imgur.com/TZ3fU.png) I prefer the looks of these points when compared to the old triangle, similar t...
2013/05/24
[ "https://Stackoverflow.com/questions/16739935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1062290/" ]
For a showing a popup list from a menu resource, use [PopupMenu](http://developer.android.com/reference/android/widget/PopupMenu.html), (or [PopupMenuCompat](http://developer.android.com/reference/android/support/v4/widget/PopupMenuCompat.html) for API below 11). For a more complex list where you specify the adapter y...
That is the [ListPopupMenu](https://developer.android.com/reference/android/widget/ListPopupWindow.html) basically all you have to do is create an imageview with that drawable and call the `ListPopupMenu` on the image click
11,451,528
I have a ticket system. Messages are placed in a div and that div has hidden sub messages (the replies of that ticket) [Demo](http://www.gc-cdn.com/snippets/java.php) [jsFiddle Hosted Demo](http://jsfiddle.net/cs87W/) Click an Arrow - shows the thread child. Click it again it hides the thread child and the arrow goe...
2012/07/12
[ "https://Stackoverflow.com/questions/11451528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/596952/" ]
Add the following code : ``` $("h1").find('.up').each(function(){$(this).removeClass('up').addClass('down');}); ``` after `$(this).find("#ticket_arrow").removeClass('down');` in `else` part, so code must be : ``` $('h1').click(function(){ if ($(this).next('.parent').hasClass('showMe')){ ...
``` $('h1').click(function(){ var $t = $(this); $t.siblings('h1').children('span').removeClass('up') .end().next().hide(); $t.children('span').toggleClass('up') .end().next().toggle(); }); ``` I would just style the arrow default as down (most items will have it this way) and toggle "up". [jsfiddle](http...
753,436
I'll post my work, but I'm not sure how to calculate variance. The question asks for the expected sum of 3 dice rolls and the variance. I think I got the expected sum. Any help would be awesome :) thanks! ![enter image description here](https://i.stack.imgur.com/jCtYd.jpg)
2014/04/14
[ "https://math.stackexchange.com/questions/753436", "https://math.stackexchange.com", "https://math.stackexchange.com/users/75304/" ]
The variance calculation is incorrect. Let random variables $X\_1,X\_2,X\_3$ denote the results on the first roll, the second, and the third. The $X\_i$ are independent. The variance of a sum of independent random variables is the sum of the variances. Since the variance of each roll is the same, and there are three di...
If your dice are "independant" then the variance of the sum is the sum of the variance
239,331
I would like a plausible way to tank the world economy. I am trying to make a political horror world, that would be very different from today. The basis should be a lack of money or decreased value of money. Can the world's money run out and cause economic collapse?
2022/12/13
[ "https://worldbuilding.stackexchange.com/questions/239331", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/100112/" ]
Fill the [floor with hematite](https://www.latimes.com/archives/la-xpm-2000-sep-16-mn-21968-story.html) ======================================================================================================= This is a yellow powder, an oxide of iron. It's extremely common and long lasting. The Egyptians coated their f...
As others have said, no organic compound would stay stable trough centuries. So you should go for inorganic ones. **Mercury!** It's not hard to work with. In fact, we have [examples](https://en.wikipedia.org/wiki/Mercury_(element)#Historic_uses) of mercury usage that are millenia old. And it cannot spoil, so it's tox...
17,811,991
I want to add custom data attribute to option tag. For example: ``` <select> <option data-image="url 1">Val 1</option> <option data-image="url 2">Val 2</option> <option data-image=" ... "> ... </option> <option data-image="url N">Val N</option> <select> ``` How can I do that?
2013/07/23
[ "https://Stackoverflow.com/questions/17811991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1059419/" ]
That is impossible with the `select` directive (see the [documentation](https://docs.angularjs.org/api/ng/directive/select)). But you can easily make what you want with `ngRepeat` ([see the documentation](https://docs.angularjs.org/api/ng/directive/ngRepeat)): ``` <select ng-model="choice"> <option ng-repeat="item...
have done a little modification to @Blackhole's answer. Try this code pen: [CODEPEN](https://codepen.io/NomeshD/pen/jJoYJd) ``` function loadCountryFlagCtrl($scope) { $scope.countries = [ { country_id: "SL", name:"Sri Lanka", flag:"http://icons.iconarchive.com/icons/gosquared/flag/24/Sri-Lan...
81,865
I am looking here for the best simple and intuitive application that is designed to produce neat looking graphs, for example "number of Ubuntu users in the last 10 years" or "average amounts paid by windows, mac and linux users for each Humble Indie Bundle edition". I just want it to be easy to produce (not too many f...
2011/11/22
[ "https://askubuntu.com/questions/81865", "https://askubuntu.com", "https://askubuntu.com/users/29270/" ]
I recommend [RLPlot](http://apt.ubuntu.com/p/rlplot) [![Install rlplot](https://hostmar.co/software-small)](http://apt.ubuntu.com/p/rlplot) From the RLPlot website. > > RLPlot is is a plotting program to create high quality graphs from data. Based on values stored in a spreadsheet several menus help you to create gr...
I personally like `R` (equivalently `octave`) which essentially gives you all you need and awesome plots quality. Also consider `gnuplot`, much easier and faster to use.
39,432,077
I'm trying to pivot multiple columns of the following table: [![enter image description here](https://i.stack.imgur.com/RoPKp.jpg)](https://i.stack.imgur.com/RoPKp.jpg) The result I would like to get is the following: [![enter image description here](https://i.stack.imgur.com/UGcNr.jpg)](https://i.stack.imgur.com/UGc...
2016/09/11
[ "https://Stackoverflow.com/questions/39432077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068548/" ]
For example, if the country header is in cell `A1` then this formula in `D2`: ``` = "tax rate" & CountIf( $A$2:$A2, $A2 ) ``` then copy the formula cell `D2` and paste it in the cells below it should give you something like: ``` country tax rate Income thresholds count UK 20% 35k t...
Here's a solution using the PQ ribbon, but note the last step (Group By) is not dynamic e.g. you would have to change it if you wanted 4+4 columns per country. ``` let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"country", type text}, {"tax rate", t...
2,485,601
c# .Net 3.5 visual studio 2008, windows xp I have a main form in a project, given a specific set of circumstances another form is instantiated and displayed to the user: ``` Form frmT = new frmTargetFolder(expName, this); frmT.Show(); ``` As you can see, I am passing a reference to the new form from the cur...
2010/03/21
[ "https://Stackoverflow.com/questions/2485601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109614/" ]
it's already discussed something similiar to ur question here.. Anyway to access a variable of a form class, simply make the variable public and you can access it using an object of that class Simple Example: ``` class Test : Form { ___public int variable = 10; // visible! ___public Test() {} } ``` [This](...
Just remember that forms are first-and-foremost classes like any other, they just inherit from System.Windows.Forms.Form to give it special UI functions. So, that being said, any `public` (or `internal` in the same project) field, property or method is accessible provided you have an instance of the object. You don't...
21,144,927
I have the following script: ``` function Start() { var TheData = 'tes"sst3\'k'; var TheHTML = '<div class="SomeClass">' + TheData + '</div>'; TheHTML += '<input type="text" id="TheTextBox" value="'; TheHTML += TheData + '" />'; $('#Dynamic').html(TheHTML); } ``` Basically, I'm creating HTML o...
2014/01/15
[ "https://Stackoverflow.com/questions/21144927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/565968/" ]
It's much safer (for this exact reason) to let jQuery worry about all that and generate your `HTML` like this: ``` var $input = $("<input>").attr("id","TheTextBox").val(TheData); var $div = $("<div>").addClass("SomeClass").text(TheData).append($input); var $wrapper = $("<div>").append($div); var TheHTML = $wrapper.ht...
Here is your answer ``` $(Start); function Start() { var TheData = 'tes"sst3\'k'; var TheHTML = '<div class="SomeClass">' + TheData + '</div>'; TheHTML += '<input type="text" id="TheTextBox" value='; TheHTML += TheData + ' />'; $('#Dynamic').html(TheHTML); } ```
7,957,952
Is there an event in javascript that I could bind some sort of listener to that will tell me when all javascript/jQuery/Ajax is done executing on the page? The page will not be loading/unloading/reloading, etc between the time the execution begins and the time that I need the listener to "listen", so those events don't...
2011/10/31
[ "https://Stackoverflow.com/questions/7957952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/877442/" ]
What you are trying to achieve is a classical concurrent programming problem. It is solved by the use of a [barrier](http://en.wikipedia.org/wiki/Barrier_%28computer_science%29). To put it simply, you need to: 1. Count how many calls you've done. 2. Set a callback on all AJAX completion events. 3. Make that callback ...
What I do: * Create a variable that represents the number of outstanding AJAX calls. * Before making an AJAX call, increment the variable. * At the end of the code that completes an AJAX call, call a function (e.g. ajaxComplete). * ajaxComplete should decrement the count. When it reaches zero, you know all your calls ...
33,401,216
i'm quite new to this. I've spent some hours to go through the various questions on this topic but couldn't find an answer that fits to me question. I have an viewcontroller (not a tableviewcontroller) with a tableview as subview. My question is how to reload the table data inside the :viewwillappear method of the vie...
2015/10/28
[ "https://Stackoverflow.com/questions/33401216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5500118/" ]
Your problem is that `tb` is a local variable, so it is not visible outside of `viewDidLoad()`. If you make `tb` a property (a.k.a. instance variable) of your view controller, then you can use it from any of the controller’s methods: ``` class ViewController3: UIViewController, UITableViewDataSource, UITableViewDeleg...
You can access your `tableView` `IBOutlet` in `viewWillAppear:`, you can also call `reloadData`. I'm not sure why you think you can't, but it should work fine.
16,620,065
I am writing server and client and i have some integers to pass. In my server application i am recieving an integer from the client. In the client do i call ntohl or htonl on the integer? If i call either one of these, when i recieve the integer do i have to call ntohl or htonl again? Or do i only call ntohl/htonl on...
2013/05/18
[ "https://Stackoverflow.com/questions/16620065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2189390/" ]
> > In the client do i call ntohl or htonl on the integer? > > > It has nothing to do with whether you are the client or the server. It has to do with whether you are sending or receiving. If you are sending, you want network byte order, so you call `htonl`(). If you are receiving, you want host order, so you call...
The typical setup in this scenario would be to call `htonl` in the client (because you want to put the integer into *network* i.e. *protocol* order) and `ntohl` in the server (because you want to convert back from network to *host* order). There is no equivalent of `ntohl` etc for strings (although you do have to make...
53,978
When I started a new ME3 game, it asked me to choose if Ashley, Kaiden, or Numerous died. Who are the numerous? I chose *numerous* because I hoped that meant some no-names, but if *numerous* is the entire ME2 cast that would be quite fail. Who are numerous? **In order to clear up some confusion, when you start a new ...
2012/03/07
[ "https://gaming.stackexchange.com/questions/53978", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/2577/" ]
The following is the memorial plaque wall when you start with a new character and select the "numerous" option. As you'll note, most of the squad members from Mass Effect 2 are still alive: ![the numerous that died](https://i.stack.imgur.com/Uho0b.jpg) Those names underlined in blue are the original crew members of t...
Per the [Rarity Guide](http://www.rarityguide.com/articles/articles/1653/1/Mass-Effect-3-Character-Creation-Guide/Page1.html): > > **Numerous** > > > The deaths of numerous squadmates and friends have begun to play a significant role in Commander Shepard's psychological profile. The burden of inevitable combat loss...
232,675
I am trying to figure out how to add user information and specific meta data to a separate table through PHP. I would prefer to do this when a user posted to the `wp_users` and `wp_usermeta` table. I am using the WooCommerce Auction plugin and the Salient theme. Also if I made a PHP file that ran a query to pull the d...
2016/07/20
[ "https://wordpress.stackexchange.com/questions/232675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98590/" ]
Looks to me you should be seeking a woocommerce purchase completion hook. This would be when you could add that a donation has been made and at what amount, then you could grab any user information, amounted donated and other info you need and save it to your donor table. use this: ``` add_action('woocommerce_order_s...
**NOTE:** This answer looks irrelevant to the OP's question after further analysis of the added/updated function in the question. Im leaving this answer in place and creating a new answer for historical use, since part of the question seems applicable. You could use something like the following to create user meta whe...
84,337
EDIT: I have just noticed that the linked page on the Dutch identification requirement has changed. I do not know when or why it changed. It now reads > > Identificeren bij dubbele nationaliteit > > > Heeft u naast de Nederlandse nationaliteit een andere nationaliteit? Dan kunt u zich in Nederland identificeren me...
2016/12/14
[ "https://travel.stackexchange.com/questions/84337", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/19400/" ]
I suppose I may be one of a few people who can actually answer this question from experience - me, some family members, and some friends have all experienced this. This is all assuming your foreign passport is one that you can travel to the Netherlands with. If you are a Dutch citizen but have never been issued any Du...
EDIT: [...als je door de douane gaat, zit je op internationaal grondgebied. (...) Dit heeft echter weinig te maken met rechtspraak. In het Verdrag van Tokyo is vastgelegd wie en wanneer jurisdictie heeft. *In het geval van Schiphol heeft de Nederlandse wetshandhaving de jurisdictie*, welke kan lopen tot in het vliegtui...
19,776,835
iI have a project that part of the goal is to have the shortest code possible. Ive done everything i can think of to make it as compact as i can but I'm wondering if there are any more shortcuts for the following code ``` public static void read(String[] input) throws IOException { for (String s : input) { ...
2013/11/04
[ "https://Stackoverflow.com/questions/19776835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2318068/" ]
It depends what you mean by "compact". You can for example change ``` String[] val = b.readLine().split(" "); for (String c : val) System.out.println(c); ``` into ``` for (String c : b.readLine().split(" ")) System.out.println(c); ``` Or use little different approach using `Scanner` class which would make your c...
Instead of using `split(" ")`, then a for loop to print each element of the result array on a line you may use ``` System.out.println(b.readLine.replace(' ','\n')); ``` that is ``` public static void read(String[] input) throws IOException { for (String s : input) { BufferedReader b = new BufferedReader...
32,654,890
I'm still new to the prepared statement, so forgive me for my stupid mistakes. At the moment I try to select something from outside the database. Either though there is no output. ``` $stmt = $mysqli->prepare("SELECT title FROM media"); $stmt->bind_param("s", $title); $stmt->execute(); $stmt->bind_result($a); $stmt->...
2015/09/18
[ "https://Stackoverflow.com/questions/32654890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3428833/" ]
First, strings are immutable, while lists are mutable. This means you can change an existing list object: ``` >>> l = [1,2,3] >>> id(l) 140370614775608 >>> l.append(4) >>> l [1,2,3,4] >>> id(l) 140370614775608 ``` You cannot change a string object, however; you can only create a new string object using the first as ...
.upper() returns a new string, which you assign to test1. The string you operated on ("hello") is not modified. Indeed, it couldn't be since strings are immutable in Python. .reverse() modifies in-place. That means the object ["hello", "world"] got modified. Unfortunately, you don't have a variable pointing to that ob...
8,002
Most RPGs teach you that casual violence is the best solution to all your in-game problems. This is so well established a part of the vast majority of RPGs that there are entire satire RPGs like Greg Costikyan's [Violence](http://www.costik.com/Violence%20RPG1.pdf) and John Tynes' [Power Kill](http://johntynes.com/revl...
2011/05/21
[ "https://rpg.stackexchange.com/questions/8002", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/140/" ]
Don't Make Killing What the Game is About ----------------------------------------- D&D laid this trap for us ages ago when XP became about what you could kill, not what you could accomplish. RPGs in large part followed suit, and became *The Great Big Game of What Can I Kill?* Asking players in a game like that to not...
Murderous cretins? Love the term. You, as the GM, are totally in control of this. Creating the setting and the cultures is purely under your control. I will tell you from experience, if you create and use cultures with certain values, most players will work with it; and those that work agaainst them will do so from th...
5,111,098
I'm a Java newbie, and also new to OOP. I have been a procedural programmer for years, but now trying to learn OOP. I am trying to write a basic program for practice as I go through an online Java course. It's a program to track people's score for games. Here's what I'd like to happen: 1. Ask user for the number of ...
2011/02/24
[ "https://Stackoverflow.com/questions/5111098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/449077/" ]
The issue ended up being that my code was completely relying on the auto-start functionality that is available only in IIS 7.5. I was able to discover the issue with the help of the Failed Request Tracing feature in IIS, and I have now modified my global.asax.cs file so that the application will be properly initialized...
If you are running your web application on IIS 7.5 or above, please ensure that the role services for IIS are enabled properly. The role services of interest are : ASP.NET, Basic Authentication, HTTP Redirection, ISAPI filters, etc. You could go to the role services via Add or Remove programs - Turn Windows features o...
382,833
Just like $\pi$ is the ratio of a circle's circumference to its diameter? I know that the tangent line to the function $e^x$ has a slope of $e^x$ at that point, but is there some other geometric representation? Thanks!
2013/05/06
[ "https://math.stackexchange.com/questions/382833", "https://math.stackexchange.com", "https://math.stackexchange.com/users/64460/" ]
In this article <http://arxiv.org/abs/0704.1282>, Jonathan Sondow describes a geometric construction of the number $e$ that's different in flavor from the other answers. The idea is that his construction is a geometric representation of the identity $$\sum\_{i=1}^\infty\frac{1}{n!}.$$ It's very readable for anyone who...
I don't think it's just a matter of the tangent line at the general point having slope $e^x$. Rather, as the graph crosses the $y$-axis, the slope is exactly one. In fact, this gives us a way to approximate $e$ in the first place. Examine the graphs of functions of the form $f(x)=a^x$. As $a$ increases, these get stee...
44,838,591
I have a (large) dataframe of the form: ``` Variable Country 2007-Q1 2007-Q2 2007-Q3 2007-Q4 2008-Q1 2008-Q2 2008-Q3 2008-Q4 Var1 AR:Argentina 69.8 67.3 65 63.6 60.4 56.6 54.4 57.3 Var2 AR:Argentina 191.298 196.785 196.918 207.487 209.596 219.171 216.852 213.124 Var3 ...
2017/06/30
[ "https://Stackoverflow.com/questions/44838591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/625609/" ]
[![enter image description here](https://i.stack.imgur.com/SVwEB.png)](https://i.stack.imgur.com/SVwEB.png) ``` <TextView android:textSize="18sp" android:autoLink="web" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" andr...
Just add this attribute to your TextView `android:autoLink="web"` e.g ``` <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:gravity="center" android:autoLink="web" android:clickable="true" and...
4,867,861
Hey, I was wondering how I could make the user being able to change the background of the app? I have 3 Images that the user will be able to choose from. I've seen it in many apps. How would I do this? If possible please provide some code! :) Thank you in advance!
2011/02/01
[ "https://Stackoverflow.com/questions/4867861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547960/" ]
short answer: you don't do it this way. you let grails use the id to link the objects in the database. then if you need to access the fleas name you can override its `toString()` method to return the fleas name. or you access that property like any other in controllers/services or gsps.
If Flea is consistently used in this way, in other words it is not a one off. Such that the Person table also has flea\_name as the foreign key why not ``` static mapping = { id generator: 'assigned', name: 'name' } ``` Depending on the version of Hibernate/Grails you are on, you might loose access to the actua...
28,182,848
I am looking for a correct implementation method to display/hide my adsense ads on mobile and desktops. Right now I am using this current method which gives us 2 console errors. The current method is: We use 2 classes "mobileShow" and "mobileno" to tag the ads accordingly to where we want to show them. So if we wan...
2015/01/28
[ "https://Stackoverflow.com/questions/28182848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4500924/" ]
You have several problems. 1. I don't think your code really is what you posted. Regardless of what other problems you have, the posted code defines the variable `$http`. 2. You are setting `$scope.user` not to a user (as the commented-out code would), not to a *promise to fetch a user* (which would be sensible), but ...
So after some hours reading about AJAX calls and asynchronous programming, I figured it out. I leave it here for anybody who might get stuck as well. Thanks again to @PSL for getting me on the right track. After a while and trying to solve my Problem I ended up with this: ``` groupifyApp.controller('DashboardCtrl', ...
420,800
``` Checkbox[,] checkArray = new Checkbox[2, 3]{{checkbox24,checkboxPref1,null}, {checkbox23,checkboxPref2,null}}; ``` I am getting error . How do I initialize it?
2009/01/07
[ "https://Stackoverflow.com/questions/420800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
OK, I think I see what's happening here. You're trying to initialize an array at a class level using this syntax, and one of the checkboxes is also a class level variable? Am I correct? You can't do that. You can only use static variables at that point. You need to move the init code into the constructor. At the clas...
Initialized each element of array in the constructor and it worked. .
108,585
I have strange problem with Wolfram *Mathematica*'s function `RegionPlot` ``` RegionPlot[x - y == 0, {x, 0, 100}, {y, 0, 100}] ``` the result is: [![enter image description here](https://i.stack.imgur.com/GUquX.jpg)](https://i.stack.imgur.com/GUquX.jpg) But when I try ``` RegionPlot[x - y == 1, {x, 0, 100}, {y, ...
2016/02/28
[ "https://mathematica.stackexchange.com/questions/108585", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/38129/" ]
What do you want ``` ContourPlot[x - y == 1, {x, 0, 100}, {y, 0, 100}] ``` [![enter image description here](https://i.stack.imgur.com/9QDVY.gif)](https://i.stack.imgur.com/9QDVY.gif) or should it be ``` RegionPlot[x - y < 1, {x, 0, 100}, {y, 0, 100}] ``` [![enter image description here](https://i.stack.imgur.com...
Due to the sampling pattern used by RegionPlot, it is lucky that it finds the line in your first example. Consider the output of ``` noisyFunction[x_, y_] := Module[{}, Sow[{x, y}]; x - y ]; ListPlot[ Take[ Reap[ RegionPlot[noisyFunction[x, y] == 0, {x, 0, 100}, {y, 0, 100}] ][[2, 1]], {4, -...
139,695
Say I had a cellphone, let's call it cellphone A, and made a perfect copy of it - SIM card and all - and let's call this one cellphone B. If I were to call someone on cellphone A, what exactly would happen to both cellphone A and B? This stems from a short film I'm planning where a character goes back in time with hi...
2019/02/21
[ "https://worldbuilding.stackexchange.com/questions/139695", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/61612/" ]
1. At every moment in time the network (= the central computers of the mobile communications operator) has an idea of where a certain SIM is. (Or it has an idea that a certain SIM is nowhere.) This is accomplished by the phone actively broadcasting its identity (SIM + IMEI) to the network and selecting one of the tower...
Depends on where you are. Much of europe allows cloned sims. The most recently used one will be used for incoming calls. Apparently in the U.S. this gets the cellular network *really* confused.
62,138
What Windows (preferably XP) batch command will list all of the network connections that appear in the Network Connections dialog? I've tried `RASDIAL`, `IPCONFIG`, `NETSTAT`, and `NET` commands with various option combinations, but they only seem to show those that are actually connected. I want to see the ones not co...
2009/10/28
[ "https://superuser.com/questions/62138", "https://superuser.com", "https://superuser.com/users/9240/" ]
See this Windows script : [List Items in the Network Connections Folder](https://web.archive.org/web/20150514022917/http://www.thescriptlibrary.com/default.asp?Action=Display&Level=Category3&ScriptLanguage=VBScript&Category1=Desktop%20Management&Category2=Special%20Folders&Title=List%20Items%20in%20the%20Network%20Conn...
Maybe this from a batch file? ``` NetSh Interface httpstunnel Show Interfaces NetSh Interface IPv4 Show Interfaces NetSh Interface IPv6 Show Interfaces ```
1,397,199
My team uses sourcetree as our git client. There is a third-party plugin in our project. It needs several configuration files. These files cannot be generated automatically. They store account name, login tokens and some temporary options, which shouldn't be shared. But everyone still needs this file, otherwise it will...
2019/01/22
[ "https://superuser.com/questions/1397199", "https://superuser.com", "https://superuser.com/users/988539/" ]
This is what you want to do: 1. Add all the files, individually or in a folder, that you want to remove from the repo but keep locally to **.gitignore**. 2. Execute **git rm --cached put/here/your/file.ext** for each file or **git rm --cached folder/\\*** if they are in a folder. (It is /\\* because you need to escape...
There is no easy solution to this. But you can try out the following: A) Put `foo.cfg` in `.gitignore` and push. Ask everyone to keep a save copy of `foo.cfg` outside their local repository. Let them push and copy that deleted file `foo.cfg` back in place. B) Rename `foo.cfg` to `foo.default.cfg` put `foo.cfg` in gi...
31,448,504
I have created 30 scrollable tabs using tablayout. So first three tabs are visible on screen and rest of them are invisible which can be scroll using swipe gesture. The problem is when I am selecting last tab programmatically but it is not get visible (tab layout not get scrolled to last tab). How can I make tablayo...
2015/07/16
[ "https://Stackoverflow.com/questions/31448504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1308763/" ]
If your `TabLayout` is used in conjunction with a `ViewPager`, which is common, simply add the following in the `onCreate()` method in your Activity: ``` tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager); viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeList...
This solution worked for me. My situation is a little bit different though; in my case, I am using the TabLayout with a ViewPager and adding more views and calling notifyDataSetChange(). The solution is to set a callback on the observer of TabLayout and scroll when the children are actually added to the TabLayout. Her...
2,647,384
Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of $n^3$, the cube above will have volume of $(n-1)^3$ and so on until the top which will have a volume of $1^3$. You are given the total volume of the building. Being given m can you find the number n of cu...
2018/02/12
[ "https://math.stackexchange.com/questions/2647384", "https://math.stackexchange.com", "https://math.stackexchange.com/users/527628/" ]
Here's a cute trick. *If the problem is well-posed*, then the solution must be independent of $f$. Therefore, you can take $$ f(x)\equiv1 $$ which is consistent with the hypotheses, and calculate $$ \int\_{-2}^8x\ \mathrm dx\equiv 30 $$ Easy peasy!
You're given: $$I=\int\_{-2}^8xf(x)dx$$ Use the $a+b-x$ property on this definite integral to get: $$\begin{align} I&=\int\_{-2}^8 (6-x)\cdot f(6-x)dx \\ &=\int\_{-2}^8 (6-x)\cdot f(x)dx \tag{$\because f(6-x)=f(x)$ given} \\ &=6\int\_{-2}^8f(x)-I \end{align}$$ and you can solve it from here.
74,389,040
In my program, I have a RecyclerView with an adapter, in which I'm checking which element of RecyclerView is clicked. ``` override fun onBindViewHolder(holder: ViewHolder, position: Int) { val currentBreakfast = breakfastList[position] holder.breakfastTitle.text = context.getText(currentBreakfast.breakfastStri...
2022/11/10
[ "https://Stackoverflow.com/questions/74389040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15158080/" ]
You need to send your fragment to the adapter from where you are calling i guess it's breakfastFragment, just add `this` to it: ``` BreakfastAdapter( requireActivity(), breakfastList, this ) ``` And your Adapter get that `fragment`: ``` open cl...
There are several ways to it. I suggest you have a look at this answer (the accepted one) : [How to pass data from adapter to fragment?](https://stackoverflow.com/questions/71888926/how-to-pass-data-from-adapter-to-fragment) And then go to the section called "A more Kotlin way to do it is to ignore interfaces and jus...
11,535
I have been trying to analyse NDE stories from a meditator's point of view. The way people change after a NDE is, in some cases, similar to the changes a person goes through after meditating for a while (i. e. less materialist, more calm, serene, not affraid of dying, less attachment to the "I"...). It is a life changi...
2015/09/14
[ "https://buddhism.stackexchange.com/questions/11535", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/533/" ]
I recommend studying the [Six Yogas of Naropa](https://en.wikipedia.org/wiki/Six_Yogas_of_Naropa#The_six_yogas) and The Tibetan Book of the Dead, specificlaly the pre-[Bardo](https://en.wikipedia.org/wiki/Bardo) stages which is the Buddhist equivalent of NDE. One thing in particular that is mentioned is that people's ...
I think the psychics who are able to see the spirit world says that some people goes to hell. Because their minds are so corrupted, they believe that they deserve to be in hell and as a result they go these lower planes. The near death experiences are so peaceful and blissful because people become free from body. Its...
2,502,660
Here's the sample code: ``` class TestAO { int[] x; public TestAO () { this.x = new int[5] ; for (int i = 0; i<x.length; i++) x[i] = i; } public static void main (String[]arg) { TestAO a = new TestAO (); System.out.println (a) ; ...
2010/03/23
[ "https://Stackoverflow.com/questions/2502660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/282315/" ]
Declaring variable like this is impossible. Just write "Z[1] = new TestAO();" and if you want another reference "TestAO b = Z[1]";
What you're really doing here is assigning the result of an assignment to Z[1]. The return type of an assignment in Java is boolean, so the way you're doing it is not going to work. Try: ``` Z[1] = new TestAO(); ```
3,909,711
I'm currently trying to implement the A\* pathfinding algorithm using C++. I'm having some problems with pointers... I usually find a way to avoid using them but now I guess I have to use them. So let's say I have a "node" class(not related to A\*) implemented like this: ``` class Node { public: int x; Node ...
2010/10/11
[ "https://Stackoverflow.com/questions/3909711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/395386/" ]
One problem is that push\_back can force a reallocation of the vector, i.e. it creates a larger block of memory, copies all existing elements to that larger block, and then deletes the old block. That invalidates any pointers you have to elements in the vector.
just adding to the existing answers; instead of the raw pointers, consider using some form of smart pointer, for example, if boost is available, consider shared\_ptr. ``` std::vector<boost::shared_ptr<Node> > nodes; ``` and ``` std::list<boost::shared_ptr<Node> > list; ``` Hence, you only need to create a single...
3,051,257
I have many nodes and some of them are under the screen's edge. Tho treeview is scrollable, there is no vertical scrollbar on the right. How can i show it?
2010/06/16
[ "https://Stackoverflow.com/questions/3051257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47672/" ]
I wrote an S-Expression parser in C# using [OMeta#](http://ometasharp.codeplex.com/). It can parse the kind of S-Expressions that you are giving in your examples, you just need to add decimal numbers to the parser. The code is available as [SExpression.NET](https://github.com/databigbang/SExpression.NET) on github and...
Here's a relatively simple (and hopefully, easy to extend) solution: ``` public delegate object Acceptor(Token token, string match); public class Symbol { public Symbol(string id) { Id = id ?? Guid.NewGuid().ToString("P"); } public override string ToString() => Id; public string Id { get; private set; } }...
626,605
I'm trying to localy add a dir to the global `$PATH` variable. I added the following to my `.bashrc`. ``` export PATH=$PATH:$VRS/bin ``` But `PATH` seems to get concatenated to itself over & over every time I open a shell (i.e. `PATH` keeps growing). Any ideas?
2013/08/01
[ "https://superuser.com/questions/626605", "https://superuser.com", "https://superuser.com/users/183983/" ]
In your script/`.bashrc`, just use: ``` PATH=$PATH:$VRS/bin ``` so that the change is temporarily only for the script/shell session you're running. The `export` command will make the change permanent.
Indeed, each time you open a shell, your `.bashrc` is executed. And thus, with your current code, your `PATH` will grow indefinitely. If you only need this change to path for your shell, you can just remove the `export`, and let in your `.bashrc`: ``` PATH=$PATH:$VRS/bin ``` If your need to have this change more gl...
31,209,665
Why Javascript relational operator showing weird result when comparing three strings? Am i wrong or Javascript got buggy? ``` var number1 = 1 var number2 = 1 var number3 = 1 number1 == number2 //true number1 == number3 //true number2 == number3 //true number1 == number2 == number3 //true. Good! ``` Now the problemet...
2015/07/03
[ "https://Stackoverflow.com/questions/31209665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5072169/" ]
This: ``` string1 == string2 == string3 ``` means: ``` (string1 == string2) == string3 ``` which is to say: ``` true == string3 ``` That's not `true`, so it's `false`. If you want to see if the three strings are all the same, you need ``` string1 == string2 && string2 == string3 ``` *edit* — it all has to ...
First, best practice in Javascript is to avoid `==` and use `===` instead. The `==` operator tries very hard - some would say too hard - to come up with a valid way to compare its operands, so it can yield some surprising results. In your first example, this code: ``` number1 == number2 == number3 ``` is actually ...
27,711,131
I am trying to add AutoComplete in my html [JQUERY AUTOCOMPLETE FILE LINK](http://www.java2s.com/Open-Source/Javascript_Free_Code/UI/Download_jquery_ui_extensions_Free_Java_Code.htm) Here is how i have added it ``` <script src="<?php echo $site_root?>js/autocomplete/jquery.ui.autocomplete.autoSelect.js"></script> `...
2014/12/30
[ "https://Stackoverflow.com/questions/27711131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1921872/" ]
Azure SQL Databases are always UTC, regardless of the data center. You'll want to handle time zone conversion at your application. In this scenario, since you want to compare "now" to a data column, make sure `AcceptedDate` is also stored in UTC. [Reference](http://blogs.msdn.com/b/cie/archive/2013/07/29/manage-timez...
In this modern times where infrastructure is scaled globally, it is good idea to save data in UTC and convert to a timezone based on users location preference. Please refere: <https://learn.microsoft.com/en-us/dotnet/api/system.datetime.utcnow?view=netframework-4.7.2>
51,678,049
Lets say I have a client that gives me db credentials, and they want to connect to the db with a secure/encrypted. They also enabled ssl in their mysql setup. When they give me their db creds, i dont want to ask them for keys and certs. So is it possible to have a encrypted secure connection via ssl when connecting to ...
2018/08/03
[ "https://Stackoverflow.com/questions/51678049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9059013/" ]
@rickjerrity i connect to my remote db via command line, and check the status by running `\s` and says `SSL: Cipher in use is DHE-RSA-AES256-SHA`. But when i connect to the same database using php and using the same credentials it says the cipher is empty. here is the code I used to connect to the remote db ``` $db = ...
No client side certificate or key should be needed for a secure db connection, besides the db credentials. PHP should verify SSL cert integrity upon connection. Any other PHP methods capable of verifying the connection's encryption status would be for sanity sake, like you mentioned. If you show some specific code exam...
12,122,346
I'm developing an email client in PHP for IMAP accounts. Which would be the most secure way to store the account's password being able to retrieve it afterward to check emails? I guess I should encrypt it somehow. However, how can I make sure that only my app will be able to decrypt it?
2012/08/25
[ "https://Stackoverflow.com/questions/12122346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77247/" ]
If you require login without any user interactions, then there is no secure solution. You'll need to rely on your OS's storage options which might prevent hostile unprivileged applications from reading the password. If the user entering a single password on startup is fine, then you can encrypt the other passwords wit...
Store the passwords in an encrypted file; require the decryption key when starting the app.
61,181,987
The problem I have is that when I compile the image caption is displayed with brackets "[fig caption]"....................................................................................................................................... ``` \documentclass{elsarticle} \usepackage{verbatim} \usepackage{xcol...
2020/04/13
[ "https://Stackoverflow.com/questions/61181987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6819651/" ]
This issue has been addressed at Tex Stack Exchange, see [here.](https://tex.stackexchange.com/questions/538316/how-to-eliminate-brackets-from-caption-for-subfigures-in-latex) The proposed solution is to use the `subcaption` package, instead of `subfig`.
I had the same issue and found a solution here: <https://answerbun.com/tex-latex/latex-how-to-remove-round-brackets-in-the-caption-of-subfigures-using-subfloat/> I used the following package: \usepackage[caption=false]{subfig} And the following structure: \begin{figure}[H] ``` \captionsetup[subfloat]{labelformat=s...
12,588,318
I am currently getting a relative url route as a String via: ``` String url = controllers.directory.routes.Directory.viewOrganisation( org.id ).url(); ``` This works fine however I would like to get the full absolute url. I am sure this is simple, I just can't seem to find it. Alternatively, how can I get the curre...
2012/09/25
[ "https://Stackoverflow.com/questions/12588318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1534099/" ]
Indeed it is simple and it was also answered on the Stack Follow this question: [How to reverse generate an absolute URL from a route on Play 2 Java?](https://stackoverflow.com/questions/11158750/how-to-reverse-generate-a-url-from-a-route-on-play-2-java) In very general you need: ``` routes.MyController.myMethod()....
For Scala programmer: in Play 2.2.x the absoluteURL is overloaded in this way: ``` def absoluteURL(secure: Boolean = false)(implicit request: RequestHeader): String ``` So if you write just ``` routes.MyController.myMethod().absoluteURL(request) ``` you'll get an error: ``` Overloaded method value [absoluteURL]...
160,837
The [Nightwalker](https://www.dndbeyond.com/monsters/nightwalker) has the “Life Eater” trait, which says (MToF, p. 216; emphasis mine): > > A creature reduced to 0 hit points from damage dealt by the nightwalker **dies and can't be revived** by any means short of a *wish* spell. > > > The demon lord [Juiblex](htt...
2019/12/05
[ "https://rpg.stackexchange.com/questions/160837", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/38414/" ]
Juiblex lives ============= One of the core guiding principles in 5e is that the [specific overrules the general](https://www.dndbeyond.com/sources/basic-rules/introduction#SpecificBeatsGeneral): > > This book contains rules, especially in parts 2 and 3, that govern how the game plays. That said, many racial traits,...
Juiblex lives to ooze again. ---------------------------- Normally, the Nightwalker's attack dropping someone to 0 HP would kill them instantly. However, Juiblex doesn't die because Juiblex can only die at the start of his own turn. Then at the start of his turn, he regenerates and doesn't die. Why does Juiblex's pro...
61,147,352
Whenever dynamically loading a class using the URLClassLoader I get a NoSuchMethodException when trying to execute a method with a custom data type as a parameter. It finds methods with standard types like String and int but not the custom type. **Loaded Class:** ``` public void execute(ProcessingData data){ Sys...
2020/04/10
[ "https://Stackoverflow.com/questions/61147352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7940371/" ]
The best solution would be to alter the styles with a class. This is typically how themes work. You set a class on the body that alters the things you want changed. ```js window.setTimeout( function () { document.body.classList.add("luckyGreen") }, 4000) window.setTimeout( function () { document.body.classLis...
In this case you need to use `getElementsByTagName` as follows: ``` var tags = document.getElementsByTagName("pre"); for(var i = 0; i < tags.length; i++) tags[i].style.color = "white"; ```
29,881,052
I just start to using angularjs and I want to display youtube thumbnail image from the youtube video url ... is there a way to display video thumbnail when people insert url in input and then click the button, ``` PLUNKER ``` <http://plnkr.co/edit/9SBbTaDONuNXvOQ7lkWe?p=preview>
2015/04/26
[ "https://Stackoverflow.com/questions/29881052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1978703/" ]
Youtube provide default thumbnail image of its video. You can use below sample URL to create thumbnail image. ``` http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg ``` Where you need to search id from the given url & create url like above will give you thumbnail image. **Controller** ``` app.c...
this works for me :D ``` <video> <source [src]="yourvideo.mp4"> </video> ```
35,491,913
i am passing a url as a param value via URL. <http://www.domain1.com?url=http://domain.com> i would like to set conditions for adding additional param to a querystring of that passed url. (for example: if domain is 111.com, foo=123 should be added). i tried ``` $url = preg_replace('{http://www.111.com}','http://www....
2016/02/18
[ "https://Stackoverflow.com/questions/35491913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1908654/" ]
`npm install -g graceful-fs graceful-fs@latest` works for me. This installs the latest version of graceful-fs!!
You don't need to worry about it and there's nothing wrong with the dependency as it only affects development. The gulp team is aware of the issue. > > We are aware of the graceful-fs deprecation warning upon install of gulp 3.x. > > > This is due to: > 1. our graceful-fs devDependency > 2. the vinyl-fs dependenc...
38,879,470
I'm trying to make a program which checks if an entered number is a [happy number](https://en.wikipedia.org/wiki/Happy_number). My code finds each of the numbers after squaring and adding but when it reaches 1, i'd expect it to print "that is a happy number". I cant see anything wrong with the code but i could be mis...
2016/08/10
[ "https://Stackoverflow.com/questions/38879470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6701353/" ]
avoid all that `Select`/`Selection` an refer to fully qualified ranges try this (commented) code: ``` Option Explicit Sub copytoarchive() Dim destSht As Worksheet Workbooks.Open ("C:\...\FileToCopyTo.xlsx") '<- at opening a workbook it becomes the active one Set destSht = ActiveWorkbook.Worksheets("Arch...
You can certainly copy a range from a closed workbook. <http://www.rondebruin.nl/win/s3/win024.htm> I don't believe you can save data to a closed workbook. I can't even imagine how that would work.
26,020,990
I have a problem when I pass data through from one function to a class that it is updating the data that I am passing in the origination class in even though I am not doing it by reference. ``` <?php namespace core\Test\Libraries; public function hasPurchasedCorrectProducts() { $testData = []; ...
2014/09/24
[ "https://Stackoverflow.com/questions/26020990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968337/" ]
You should be able to just use: ``` \File ``` Namespaces are relative to the namespace you declare for the class you are writing. Adding a "\" in front of a call to a class is saying that we want to look for this class in the root namespace which is just "\". The Laravel File class can be accessed this way because i...
Assuming you have file something like that: ``` <?php namespace Chee\Image; class YourClass { public function method() { File::delete('path'); } } ``` you should add `use` directive: ``` <?php namespace Chee\Image; use Illuminate\Support\Facades\File; class YourClass { public function method() ...
6,929,019
Can [F-Script](http://www.fscript.org/) be used to inspect iOS applications that are running on the simulator or iPhone/iPad hardware? If so, how do I attach the object browser to my custom objects?
2011/08/03
[ "https://Stackoverflow.com/questions/6929019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/259912/" ]
I think it would make sense to store a schema update version in the database. The update script would read the current version and based on that, have it execute all of the previous update scripts in order until it is current. This would be a going-forward approach, since your old schema versions would not have the ver...
What I have done is maintain a dev copy of each database version, as it exists for a particular version, and use the redgate tools to generate the scripts I need. If I need a script to upgrade from V1.3 to V2.5, I pick those two databases and the scripts get generated. You might be able to do it all in a single script...
26,454,879
Can a textarea adapt it's height while inserting text? I want to hide the textarea's borders, so that users feel they'r typing in an unlimited space. (The textarea's height should be increased by height of one line when a new line starts) One way I guessed, is to; copy all texts into a div with same width on each k...
2014/10/19
[ "https://Stackoverflow.com/questions/26454879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2543240/" ]
Here is What you want First: html here is the text area with id : ta ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <textarea rows="10" cols="10" id="ta"> </textarea> ``` And here is the jquery code which works as follows: which increases the height (the ro...
You can easily achieve what you're trying to do using **[elastic.js](http://unwrongest.com/projects/elastic/)**, it's a simple one-line solution. ```js $('#note').elastic(); ``` ```css textarea#note { width:100%; display:block; resize: none; border: none; } textarea:focus { outline: none; } ``` ```html...
38,597
I need to create a PDF file automatically (preferable via a batch process / command-line, the optimum would be something XSLT/SAXON-based). The PDF will have many pages (ca. 500), and each page contains nothing but a set of (partially overlapping) images (in scalable format, e.g. SVG or WMF). But there is only a basi...
2017/01/06
[ "https://softwarerecs.stackexchange.com/questions/38597", "https://softwarerecs.stackexchange.com", "https://softwarerecs.stackexchange.com/users/28829/" ]
For any platform I cannot recommend [GIMP](https://www.gimp.org/) enough. * Cross Platform OS-X, Linux, Windows * Free, gratis & open source * Very powerful You can also extend it with a large number of plug-ins but I would recommend starting with [GMIC](http://gmic.eu/gimp.shtml)
For many years, the main alternative to Photoshop I have found is [Pixelmator](http://www.pixelmator.com/mac/), although the new kid on the block is [Affinity Photo](https://affinity.serif.com/photo/). Both are built for the Mac and are in the $30-40.
7,337
Puffer fish is known for having a anti-predation defense mechanism of having toxin-exuding spikes. Are there predators which evolved specifically to prey on puffer fish? (presumably, by evolving immunity to the toxin)? I know that sharks eat them, but I doubt sharks evolved to be immune specifically to puffer fish to...
2013/02/24
[ "https://biology.stackexchange.com/questions/7337", "https://biology.stackexchange.com", "https://biology.stackexchange.com/users/185/" ]
[Wikipedia](http://en.wikipedia.org/wiki/Tetraodontidae#Natural_defenses) has some revealing information here: > > Not all puffers are necessarily poisonous; Takifugu oblongus, for example, is a fugu puffer that is not poisonous, and *toxin level varies wildly even in fish that are*. A puffer's neurotoxin is not nec...
I know there are species of sea snakes that actually aren't bothered by the puffer fish's toxins! So they will eat them easily because puffer fish are extremely slow swimmers. Besides that sharks are the only other species, in specific Tiger Sharks don't have any consequences to consuming pufferfish.
47,964,293
Let's say i have a java method: ``` private String (StringUtility stringUtil) { String maxValue = stringUtil.getMaxValue() } ``` Now, the StringUtility holds the maxValue and read it from configuration field loaded by Spring and **won't be changed during run time**. this method is going to be called every 1ms. So...
2017/12/24
[ "https://Stackoverflow.com/questions/47964293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2603808/" ]
Try this: ``` Array(0...9).map({String($0)}).map({ Character($0) }) ``` In the **code** above, we are taking each `Int` from `[Int]`, transform it into `String` using the String constructor/initializer (in order words we're applying the String initializer **(a function that takes something and returns a string)** to...
``` func convertArray(array: [Int]) -> [Character] { return array.map { Character(String($0)) } } ```
1,904,782
I recently discovered that a method in a derived class can only access the base class's protected instance members through an instance of the derived class (or one of its subclasses): ``` class Base { protected virtual void Member() { } } class MyDerived : Base { // error CS1540 void Test(Base b) { b.Memb...
2009/12/15
[ "https://Stackoverflow.com/questions/1904782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/231049/" ]
UPDATE: This question was the subject of my blog in January 2010. Thanks for the great question! See: <https://blogs.msdn.microsoft.com/ericlippert/2010/01/14/why-cant-i-access-a-protected-member-from-a-derived-class-part-six/> --- > > Does anyone have an example of a > problem that would be caused by > letting M...
<http://msdn.microsoft.com/en-us/library/bcd5672a.aspx> > > A protected member of a base class is > accessible in a derived class **only** if > the access occurs through the derived > class type. > > > There's documentation of the "what?" question. Now I wish I knew "Why?" :) Clearly `virtual` has nothing to ...
58,007,014
My flutter app sends a http request to my google-app-engine backend. In this request, a user's vote on a simple either-or-question is send and then stored in a mysql database. When that is done, the user sees another question and again votes. So, question, voting, question, voting, question, voting and so on. Now, th...
2019/09/19
[ "https://Stackoverflow.com/questions/58007014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9372863/" ]
I come late but have more info for future readers. I just met this bug in my App for iOS 11 and iOS 12. The bug is solved by Apple since iOS 13.0. So if you support previous version, you still need to apply the workaround from @AlanS, or not use custom colors in storyboard and xib : ``` func viewWillLayoutSubviews(...
Faced with this issue recently I had xib file for table cell and custom colors in xcasset. Colors are single appearance (dark mode not supported). In cell swift class I have bool variable with didSet, where few outlets are modified: view.backgroundColor and label.textColor. Their values are based on variable value. Th...
44,141,165
I have a file that I want to import into a database table, but I want to have a piece in each row. In the import, I need to indicate for each row the offset (first byte) and length (number of bytes) I have the following files: ``` *line_numbers.txt* -> Each row contains the number of the last r...
2017/05/23
[ "https://Stackoverflow.com/questions/44141165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8054688/" ]
Awsome question, I wondered about the same thing recently, thanks! I did it, with **tabulizer** `‘0.2.2’` as @hrbrmstr also suggests. If you are using *R > 3.5.x*, I'm providing following solution. Install the three packages in specific order: ``` # install.packages("rJava") # library(rJava) # load and attach 'rJava'...
Here is a different approach that works well on the PDF "https://sedl.org/afterschool/toolkits/science/pdf/ast\_sci\_data\_tables\_sample.pdf". You have the result of the output below. ``` library(RDCOMClient) path_PDF <- "C:\\ast_sci_data_tables_sample.pdf" path_Word <- "C:\\Temp.docx" #############################...
15,314,781
I want to try and get the latest movie I checked on the IcheckMovies site and display it on my website. I don't know how, I've read about php\_get\_contents() and then getting an element but the specific element I want is rather deep in the DOM-structure. Its in a div in a div in a list in a ... So, this is the link I...
2013/03/09
[ "https://Stackoverflow.com/questions/15314781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1401273/" ]
``` import re with open('myLargeFile.txt', 'r') as myFile: numbersList = re.findall('{"number":(\d{9})', myFile.read(), re.DOTALL) print numbersList ``` This will create a list that only contains 9 digit numbers that appear after the string `{"number":` If the numbers you are looking for might have more or less...
``` import re s = '76360247039795},{"number":522141635,"catalog"' nl = re.findall('"number":(\d{9})', s) ```
22,487,878
I'm receiving a JSON package like: ``` { "point_code" : { "guid" : "f6a0805a-3404-403c-8af3-bfddf9d334f2" } } ``` I would like to tell Rails that both `point_code` and `guid` are required, not just permitted. This code seems to work but I don't think it's good practice since it returns a string, not the full obj...
2014/03/18
[ "https://Stackoverflow.com/questions/22487878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/563762/" ]
OK, ain't pretty but should do the trick. Assume you have params :foo, :bar and :baf you'd like to require all for a Thing. You could say ``` def thing_params [:foo, :bar, :baf].each_with_object(params) do |key, obj| obj.require(key) end end ``` `each_with_object` returns obj, which is initialized to be para...
This question came up in my google search for a different case ie, when using a "multiple: true" as in: ``` <%= form.file_field :asset, multiple: true %> ``` Which is a totally different case than the question. However, in the interest of helping out here is a working example in Rails 5+ of that: ``` form_params = ...
29,261,917
I'm just learning how to use python and lists. I have a sample list like the one below. ``` list = [['Ferrari','200,000','10,000km'],['Porsche','230,000','10,000km'],['Ferrari','150,000','10,000km'],['Ferrari','200,000','10,000km'],['Porsche','230,000','10,000km'],['Porsche','200,210','10,000km'],['Ferrari','110,000',...
2015/03/25
[ "https://Stackoverflow.com/questions/29261917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266768/" ]
Firstly do not name your variable `list` as it shadows the builtin. This is a very simple approach of solving your problem ``` >>> l = [['Ferrari','200,000','10,000km'],['Porsche','230,000','10,000km'],['Ferrari','150,000','10,000km'],['Ferrari','200,000','10,000km'],['Porsche','230,000','10,000km'],['Porsche','200,2...
The answer above is excellent, though for anyone just starting out with programming in general you may be confused with the following: ``` int(`i[1]`.replace(',','')) ``` What that is doing is taking your item in the list, for example `['Porsche', '400,000', '10,000km']`, and next if finds the second element in that...
41,452,847
I need to make a function that reads a string input and converts the odd indexed characters in the string to upperCase and the even ones to lowerCase. ``` function alternativeCase(string){ for(var i = 0; i < string.length; i++){ if (i % 2 != 0) { string[i].toUpperCase(); } else...
2017/01/03
[ "https://Stackoverflow.com/questions/41452847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7317826/" ]
``` function alternativeCase(string){ return string.split('').map(function(c,i) { return i & 1 ? c.toUpperCase() : c.toLowerCase(); }).join(''); } ``` --- ### Update 2019 These days it's pretty safe to use ES6 syntax: ```js const alternativeCase = string => string.split('') .map((c,i) => i & 1 ? c.toUppe...
Strings in JavaScript are immutable, Try this instead: ```js function alternativeCase(string){ var newString = []; for(var i = 0; i < string.length; i++){ if (i % 2 != 0) { newString[i] = string[i].toUpperCase(); } else { newString[i] = string[i].toLowerCa...
65,805,249
I want to update the UI whenever a new document is added to a collection: this is the tricky part because using this code: ``` db.collection("Messages").addSnapshotListener { querySnapshot, error in guard let snapshot = querySnapshot else { print("Error fetching snapshots: \(error!)") return } ...
2021/01/20
[ "https://Stackoverflow.com/questions/65805249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14220454/" ]
``` cartItem.map((food,index)=> { if(food.food_id == newFoodItem.food_id && food.id == newFoodItem.id){ const AllFoodData = cartItem AllFoodData[index] = newFoodItem AsyncStorage.setItem('@Add_cart_Item', JSON.stringify(AllFoodData)) .then(() => {}) ...
So basically what i want to achieve here is to add the msg object to the existing Messages Array. Since lsitings is an Array of objects using the `.map` i can spread through each object and check if the id of that object is each to my `msg.id`. if that is true then i want to return a copy the that specific listing and...
72,479,232
This shader works on laptop but for some reason it keeps failing on mobile I assume i'm doing something wrong with the precision but i don't know what here is the error: > > THREE.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog > invalid shaders THREE.WebGLShader: gl.getShaderInfoLog() fragment > 0:434...
2022/06/02
[ "https://Stackoverflow.com/questions/72479232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3112634/" ]
**OpenGL** specification doesn't define precision qualifier for fragment shaders, this means you should define it by yourself. You should add these two lines to your shader code under **const \_PS\_1** declaration: ``` precision highp float; // Define float precision precision highp int; // Define int precision ``...
I had the exact same issue as you on certain Android phones (Android 12). It has to do with the way you're initializing your arrays `weightIndices` and `weightValues`. **Replace:** ```c float weightIndices[4] = float[4](vWeights1.x, vWeights1.y, vWeights1.z, vWeights1.w); ``` **With (same for weightValues):** ```c...
218,562
In [Stack Overflow is getting a place of its own](https://meta.stackexchange.com/q/212631/152515), the estimated time of arrival was around the middle of January: > > I'm *extremely* pleased to announce that we've finally worked out the remaining details, and will be proceeding with the split in six to eight weeks. N...
2014/02/04
[ "https://meta.stackexchange.com/questions/218562", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/152515/" ]
***Update - March 2nd 2014*** *Work on the back end of this is well underway, there's a lot of code specific checks to see if Meta SO is actually Meta SO, and some other stuff that's currently being addressed. I will put out a meta post when we near the ~1 week to blast off milestone to let folks know. I don't think i...
In [a comment on January 22](https://meta.stackexchange.com/questions/212631/stack-overflow-is-getting-a-place-of-its-own#comment703507_212631) Tim Post said: > > We just met again about it today, due to a bit of backlog with the SSL stuff, it's probably going to be around the first week of Feb. I'll update the post ...