id
stringlengths
3
6
prompt
stringlengths
100
55.1k
response_j
stringlengths
30
18.4k
290862
I have an Excel that is using Power Query to get data from a API. What I would like to do is have this data update every day without having to open the excel myself. So I enabled the setting within excel to `Refresh data when opening the file`. So I am trying to create a PowerShell script which open the excel, waits f...
I think your while loop is wrong. You should probably loop over the worksheets in the workbook and for each of them loop over the QueryTables. Then enter a while loop to wait until the `Refreshing` property turns `$false` ``` foreach ($sheet in $Workbook.Sheets) { $sheet.QueryTables | ForEach-Object { whil...
291301
The context is, I am using the caret library with a data set to train and predict using different models. What is the difference between setting the seed at the beginning of an R script or in each of the training and prediction processes? Thanks Manel
Setting the seed makes the following RNG outputs repeatable. So if something strange happens and you want to debug it, setting the seed lets you see it happen again. Doing it once at the beginning means you'll have to repeat the whole sequence, doing it several times means you need to repeat less. So during debugging, ...
291419
I am applying a function to a xarray.DataArray using [xarray.apply\_ufunc()](http://xarray.pydata.org/en/stable/generated/xarray.apply_ufunc.html). It works well with some NetCDFs and fails with others that appear to be comparable in terms of dimensions, coordinates, etc. However there must be something different betwe...
It turned out that the NetCDF files that were problematic as inputs the latitude coordinate values were in descending order. `xarray.apply_ufunc()` appears to require that coordinate values be in ascending order, at least in order to avoid this particular issue. This is easily remedied by reversing the offending dimens...
291622
How can I get the position of an item from a List that I selected from an AutoCompleteTextview? ``` autoSearch = (AutoCompleteTextView) findViewById(R.id.autoSearch); autoSearch.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int...
I have no idea if it's possible to get Jekyll to somehow "find" the MP3 files (without YAML header) and convert the filenames like in your example, so I'd suggest an alternative approach: * Put the MP3s into a different folder (not in `_posts`). * Write a small command-line utility in the language of your choice, that...
291657
I have used **docker-compose.yaml**. I have configured in docker-compose.yml bellow like: **Step 1:** In d**ocker-compose.yaml** I user bellow code ``` services: postgres: image: postgres container_name: postgres hostname: postgres volumes: - db-data:/var/lib/postgres...
For two containers to communicate with each other, they must be on the same Docker network. [By default](https://docs.docker.com/compose/networking/), Compose creates a network named `default` and attaches containers to it; if you specify other `networks:` for a container, then they are not attached to the `default` ne...
291736
I am trying to get my head around programming using tidyeval. I want to write a function to run logistic regression models for selected outcome variables: ``` library(tidyverse) set.seed(1234) df <- tibble(id = 1:1000, group = sample(c("Group 1", "Group 2", "Group 3"), 1000, replace = TRUE), ...
We need to create a formula for `glm` to pick it up. One option is `paste` ``` myfunc <- function(data, outcome){ enquo_var <- enquo(outcome) fit <- tidy(glm(paste(quo_name(enquo_var), "group", sep="~"), data=data, family = binomial(link = "logit")), exponentiate = TRUE, conf.int...
291828
since regular exressions are not supported in Cocoa I find [**RegexKitLite**](http://regexkit.sourceforge.net/RegexKitLite/index.html#RegexKitLiteOverview) very usefull. But all examples extract matching strings. I just want to test if a string matches a regular expression and get a Yes or No. How can I do that?
I've used NSPredicate for that purpose: ``` NSString *someRegexp = ...; NSPredicate *myTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", someRegexp]; if ([myTest evaluateWithObject: testString]){ //Matches } ```
291876
In my React application I have the next situation. On each page I have to create this logic: ``` const user = useUser(); const message = user.auth ? 'Welcome' : 'You are not allowed' <Button>{message}</Button> ``` I have to add this logic on 10 pages. I know that my question is more theoretical, but what is better ...
Personally, I like to create hooks with all relative things of a particular topic (instead of just one constant like `message`). For example: ``` export const useAuth = () => { const user = useUser() const isLoggedIn = user.auth const welcomeMessage = isLoggedIn ? 'Welcome' : 'You are not allowed' /* ...
291935
We are having a table like this to save login tokens per user sessions. This table was not partitioned earlier but now we decided to partition it to improve performance as it contains over a few millions rows. ``` CREATE TABLE `tokens` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned DEF...
* Don't use partitioning. It won't speed up this kind of table. * I have yet to see a case of `BY HASH` that speeds up a system. * It is almost never useful to partition on the `PRIMARY KEY`. * In general, don't have an `AUTO_INCREMENT` id when you have a perfectly good "natural" PK -- `(uid, session)`. Or should it be...
292327
I just spent the better part of a day finding a bug caused by a stray comma at the end of an assignment statement. The difficulty in finding my bug was exacerbated by a third-party callback library that was trapping exceptions but it made me wonder why Python (2.x) doesn't raise a syntax error instead of creating a tup...
Here's the Guido van Rossum, creator of Python, [explaining](http://python-history.blogspot.com/2009_02_01_archive.html) how this bit of syntax came to be: > > One consequence of adding an array-like interface to tuples is that I > had to figure out some way to resolve the edge cases of tuples with > length 0 or 1....
293245
We have some product teams for improving/maintaining the current line of products; but there are also "innovation teams" which try to plan/shape/design the next-generation products. The former teams usually look at short-term goals (small improvements, time frames between few days and few months) while the latter teams...
I don't think the two are mutually exclusive. Why would the long-term innovations limit the short-term improvement? If anything, I would think that the short-term improvements would be influencing the longer term. Think of it as an operating system - MS or Apple release a new OS (innovation), and then continually rele...
293294
Im having trouble with my sql statements. I dont know what im doing wrong but it keeps adding to the database much rather than uploading ``` $result = mysql_query("SELECT id FROM users where fbID=$userID"); if (mysql_num_rows($result) > 0) { mysql_query("UPDATE users SET firstName='$firstName' ...
You need quotes on the first query, `fbID='$userID'` Also, you dont need this `,` before `where`, on the second SQL And last, you use `userID` on the first reference, and `userId` on the last
293680
I have a dataset in R which I am trying to aggregate by column level and year which looks like this: ``` City State Year Status Year_repealed PolicyNo Pitt PA 2001 InForce 6 Phil. PA 2001 Repealed 2004 9 Pitt PA 2002 InForce ...
It may help you to break this up into two distinct problems. 1. Get a table that shows the change in PolicyNo in every city-state-year. 2. Summarize that table to show the PolicyNo in each state-year. To accomplish (1) we add the missing years with `NA` PolicyNo, and add repeals as negative `PolicyNo` observations. ...
293773
When I try to use this sql statement: ``` LOAD DATA INFILE 'url/file.txt' IGNORE INTO TABLE myTbl FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n' (SPEC, PERSON, BLAH, BLUH) ``` I get this error: **Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.** I am trying to insert into a...
Load Data infile is a mysql-only sql command, for ms access db you can use vpa to import text file into table Take a look here : <http://support.microsoft.com/kb/113905>
294169
I have to develop a layer to retrieve data from a database (can be SQL Server, Oracle or IBM DB2). Queries (which are generic) are written by developers, but i can can modify them in my layer. The tables can be huge (say > 1 000 000 rows), and they are a lot of joins (for example, I have a query with 35 joins - no way ...
There are only two ways to do pagination code. The first is database specific. Each of those databases have very different best practices with regards to paging through result sets. Which means that your layer is going to have to know what the underlying database is. The second is to execute the query as is then just...
294580
This seems like rather too much nesting: ``` using (XmlReader reader = XmlReader.Create(filename)) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "Width": map.Width = ParseXMLValue(reader); ...
Yes, much. `XDocument` is the easier way. Though it does not perform as well if your documents are of significant size or performance is absolutely imperative: <http://www.nearinfinity.com/blogs/joe_ferner/performance_linq_to_sql_vs.html> It works like: ``` XDocument someXmlDoc = XDocument.Create(fileName); IEnumerab...
294765
I'm trying to get the text from a Dialog, but it doesn't work. All the code works except `username = txtDialog.getText().toString();` I get a NullpointerException Here is the complete code : ``` btn_next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ...
I think your `Edittext` inside `Dialog` Change this line ``` txtDialog = (EditText)findViewById(R.id.textDialog); ``` into ``` txtDialog = (EditText)dialog.findViewById(R.id.textDialog); ```
294868
I have a client who wishes to use our website as a plugin on his website. His website is being developed in Ruby on Rails. While our website is a PHP website. I was considering using iframes to load my website inside theirs. However I am unsure if this is possible as I have no clue about the Ruby framework. Please hel...
Yes, you can. The HTML that is served to web browsers is independent of the web framework used on the server side. A browser will not be able to distinguish HTML generated by a PHP/Python/Rails web application if the generated HTML is same. For browsers, it's just HTML which it'll parse and display content accordingly....
294871
I have a file named upload\_file.php which uploads an image file to my web server. The problem I am having is that I want to replace all the spaces in the file’s name with an underscore during the upload process. I know this could be done using str\_replace(), but I have no idea where I should use str\_replace() within...
You could read the file one line at a time using`readline`: ``` // this creates a read stream var reader = require('readline').createInterface({ input: require('fs').createReadStream('file.in') }); // then here you would be able to manipulate each line: reader.on('line', function (line) { console.log('The curr...
295531
I've created 2 different applications. One of them sends a text message(SMS), not much to it but it works. The second application is where my problem occurs, this application was created to implement broadcastReceiver and listen to incoming text messages and when a message is recieved it's supposed to set a TextView to...
I found the solution: ``` fld.Document.Blocks.Add(p1); fld.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity)); fld.Arrange(new Rect(new System.Windows.Point(0, 0), fld.DesiredSize)); fld.UpdateLayout(); ``` One has to call exactly these methods. Measure with Double.PositiveInfinity is...
295743
I am trying to create a Javascript Regex that captures the filename without the file extension. I have read the other posts here and *'goto this page:* <http://gunblad3.blogspot.com/2008/05/uri-url-parsing.html>' seems to be the default answer. This doesn't seem to do the job for me. So here is how I'm trying to get th...
``` var url = "http://example.com/index.htm"; var filename = url.match(/([^\/]+)(?=\.\w+$)/)[0]; ``` Let's go through the regular expression: ``` [^\/]+ # one or more character that isn't a slash (?= # open a positive lookahead assertion \. # a literal dot character \w+ # one or more word chara...
295918
I would like to create a application that would respond to receiving SMS messages and display a dialog. How can I register the receiver in the manifest without defining within an activity? I tried to keep the receiver/intent-filter tags in the manifest out of the activity tag but the emulator will not install the apk ...
What you are trying to do is wrong for at least the following reasons... 1. MAIN/LAUNCHER only apply to activities and as you don't have a class which extends Activity in your code, this is what is causing the error. 2. Although there's nothing wrong with an 'app' which implements just a BroadcastReceiver or Service, ...
296287
I'm trying to send the contents of UITextView or UITextField as parameters to a php file ``` NSString *urlstr = [[NSString alloc] initWithFormat:@"http://server.com/file.php?name=%@&tags=%@&entry=%@",nameField.text, tagsField.text, dreamEntry.text]; ``` When i log urlstr, the url format is ok just as long as the UIT...
You're not supposed to URL-escape the entire string, you're supposed to URL-escape the dynamic components. Try ``` NSString *urlStr = [NSString stringWithFormat:@"http://server.com/file.php?name=%@&tags=%@&entry=%@", [nameField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding...
296396
In the following code Mix\_Card\_Reader inherits from Mix\_IO\_Device, the latter being an abstract tagged record. Previously it contained one `Positive` and two `Stream_Access` members. I'd like to alter the code so that it uses `File_Type` members instead. The reason for that is that I want each instance of this ty...
This should do the trick: ``` function Create_Mix_Card_Reader return Mix_IO_Device_Access is Ret : Mix_IO_Device_Access := new Mix_Card_Reader'( 16, Input_Type => <>, Ouptut_Type => <>); begin return Ret; end Create_Mix_Card_Reader; ``` The box notation is a placeholder for the default value. You need at ...
296591
I have 2 aws accounts having their own RDS instances(not publicly accessible) with db engine as postgresql 12.5. I downloaded RDS certificate from "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem". I am using JDBC(postgresql driver) with properties ssl=true and sslrootcert="path to above certificate" ...
Q1. Yes, its same for all accounts. You can download it from docs [here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html). Its about the instances as explained in the docs: > > Using a server certificate provides an extra layer of security by **validating** that the connection is being m...
296861
related to : [Remove duplicates from an array based on object property?](https://stackoverflow.com/questions/10505760/remove-duplicates-from-an-array-based-on-object-property/40941631#40941631) is there a way to do this exact same thing but consider the order? for example if instead of keeping [2] I wanted to keep [1]...
It is trivial to reverse and array. So before processing the array, call `array_reverse()` on it: ``` /** flip it to keep the last one instead of the first one **/ $array = array_reverse($array); ``` Then at the end you can reverse it again if ordering is an issue: ``` /** Answer Code ends here **/ /** flip it back...
297155
Do you know any "best practice" to design a REST method to alter the order of a small collection? I have a collection exposed at "GET /api/v1/items". This endpoint returns a JSON array and every item has a unique id. I was thinking on create "PATCH /api/v1/items" and send an array of ids with the new order. But I won...
Following the REST Uniform Interface constraint, the HTTP `PUT` and `PATCH` methods have to stick to the standard semantics, so you can do that with either one in the following way: With `PUT`, clients can upload a whole new representation with the order they want. They will request `GET /api/v1/items`, change the ord...
297300
When were the major aspects of the Apollo program decided? Multi-stage rocket, CM pulling the LM out of the rocket through a docking maneuver, LOR, and a parachute landing in the ocean. I've seen answers to a few different pieces of this question, like the work of John C. Houbolt and the extensive coverage of the Roga...
> > Multi-stage rocket > > > This was already certain in the mid-to-late 1940s, if not sooner. There's no practical way to reach the moon on chemical propellants without a multistage rocket; the only alternative in that era would have been a [Project Orion](https://en.wikipedia.org/wiki/Project_Orion_(nuclear_prop...
297540
Someone recently asked me this question and I thought I'd post it on Stack Overflow to get some input. Now obviously both of the following scenarios are supposed to fail. #1: ``` DECLARE @x BIGINT SET @x = 100 SELECT CAST(@x AS VARCHAR(2)) ``` Obvious error: > > Msg 8115, Level 16, State 2, Line 3 > > Arithm...
For even more fun, try this one: ``` DECLARE @i INT SET @i = 100 SELECT CAST(@i AS VARCHAR(2)) -- result: '*' go DECLARE @i INT SET @i = 100 SELECT CAST(@i AS NVARCHAR(2)) -- result: Arithmetic overflow error ``` :) --- The answer to your query is: "Historical reasons" The datatypes INT and VARCHAR are older tha...
297996
I am having issues running rails test from within vim. When I issue the `:Rails test` from vim it returns > > /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/lockfile\_parser.rb|72| in `warn\_for\_outdated\_bundler\_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError...
Create a file named `User.php` with the below content in `/src/Model/Entity` folder. This will automatically encrypt your password while saving. ``` use Cake\Auth\DefaultPasswordHasher; use Cake\ORM\Entity; class User extends Entity { protected function _setPassword($value) { if (strlen($value)) {...
298120
I created a JAR file with my Java program. This piece of code will open a few files inside a dir "Test", which is in the same dir as the JAR file. Like this: ``` / -- program.jar -- /Test -- * ``` If I run via terminal with: java -jar program.jar, it runs perfectly. But if I run graphically (right clicking on...
Yes, you will get another current working directory... There would be two solutions: **1)** Find the cwd by doing this hack: ``` public class Test { public static void main(String... args) { ClassLoader cl = Test.class.getClassLoader(); String f = cl.getResource("").getFile(); ...
298130
I have a LAN with a Linux server running BIND for addressing of local computers. When a workstation is connected to the local network (where there is no Internet access), I can successfully address devices using hostnames without any problems: ``` $ host server1.local $ server1.local has address 192.168.2.2 $ host 19...
Certain versions of OS X assign preferences to DNS servers. This may cause your internal DNS server to be pushed down the preference order. Try running this command to find out which server is being used: ``` scutil --dns | grep nameserver\[[0-9]*\] ``` Sources: * <https://discussions.apple.com/thread/1660439> * <...
298977
In the art of electronics book, page 49, 2nd edition, they show a signal rectifier circuit (a circuit that tosses away the negative part of a signal). Here it is: ![schematic](https://i.stack.imgur.com/u0c60.png) [simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fu0c60.png) – Schematic...
Assuming ideal components, when the diode is "on", the equivalent circuit is: ![schematic](https://i.stack.imgur.com/6pWoW.png) [simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f6pWoW.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) The charging current clockw...
298999
I have write a code to calculate average of an area temperature in the map. At start, the `initial()`will be invoked then `loadtempdata()` then `averagetemp()` and finally `cleanup()`. And I have use a global pointer to point to a heap dynamic array in function so that it can be used in other funcion. Finally, I use ...
I am a Program Manager in the Service Bus team. There is no plan to support WebSockets on HTML as an output pipe for Notification Hubs. At the moment your best bet is to use SignalR, which can be scaled out using Service Bus. What are the characteristics of Notification Hubs that make you say that it would be preferab...
299136
The Economist isn't a fan of Donald Trump as a presidential candidate. In an analysis of his ascendence to the Republican nomination they try to discern some of the factors. As part of their list of factors driving Trump support [they argue](http://www.economist.com/news/briefing/21698252-donald-trump-going-be-republ...
It depends on your definition of terrorism and your interpretation of the quote: is it about American lives anywhere in the world, or about death in America including non-Americans. For the purpose of this answer I'll assume the second interpretation. If terrorism only includes Islamic terrorism, it would be true, alt...
299173
I am trying to send an email. When I send it without an attachment, it sends the email correctly. If I try to attach something, then it doesn't work. The Class: ``` import com.sun.mail.smtp.SMTPTransport; import java.io.File; import java.security.Security; import java.util.Date; import java.util.Properties; import ...
Remove ``` message.setText(mensagem); ``` Change ``` messageBodyPart.setContent(message, "multipart/mixed"); ``` to ``` messageBodyPart.setText(mensagem); ``` and move it and the following line above the "for" loop. Also, see t[his JavaMail FAQ entry of common mistakes](http://www.oracle.com/technetwork/java/...
299237
We can prove the fundamental theorem of calculus without any reference to empirical data. We can't "prove" coulomb's law, we make experiments and describe the phenomena using mathematical tools. Where does Probability fall on that spectrum? if Probability suppose to predict natural phenomenon wouldn't you need to verif...
Use Euler's identity to split the solution into its real and imaginary parts: $$e^{(2+3i)t}=e^{2t+i3t}=e^{2t}\*e^{i3t}$$ $$e^{i3t} = \text{cos}(3t)+i\text{sin}(3t)$$ Therefore: $$e^{\lambda\_1t}\vec v\_1 = e^{2t}\*e^{i3t}\begin{bmatrix} 2+3i\\ 13 \end{bmatrix} $$ $$= e^{2t}\*[\text{cos}(3t)+i\text{sin}(3t)]\*\left...
299498
I'm new in php, I'm trying to display stdClass Object data via foreach loop inside table. But it's not working. ``` include("../config.php"); $get_data = $conn->query("SELECT * FROM `prd_rgistration`"); $prd_data = $get_data->fetchObject(); print_r($prd_data); ``` Data Print ``` stdClass Object ( [id] => 24 ...
You're only getting one object, not an array, so wrap the while loop around fetch ``` while ($prd_data = $get_data->fetchObject()) echo $prd_data->id; ```
299582
Facing a problem that I can't use my function where I try to update my ArrayList element. Receiving error: > > com.wep.Darbuotojas cannot be cast to com.wep.Programuotojas > > > I guess that I try somewhere to cast from String to int or from int to String, but just can't see right now where. Darbuotojas class:...
`Darbuotojas cannot be cast to Programuotojas` is pretty clear, and does not deal with `int to String` or `String to int` Because you have `Programuotojas extends Darbuotojas` you could save a `Programuotojas` instance in a `Darbuotojas` object, but not in the other side, imagine another class `Foo extends Darbuotojas...
299956
I've very much a beginner in Dart and Flutter, and my project is to learn while building an app. I've learned the basics with an online class and I have basis in Java. Now, in my homepage, I'm trying to have 4 buttons take the whole screen. My current layout is to have them all take an equal amount of space and be sta...
Run the following `ls -la /home/dotta/Documents/Udemy\ Codes/surf_shop` you will see that its owned by `root`, why because you run `sudo npm install` at some point. To fix: 1. Delete node\_modules: `sudo rm -rf /home/dotta/Documents/Udemy\ Codes/surf_shop/node_modules` 2. Then fix ownership permissions: `sudo cho...
300002
Why is the infinite set from the axiom of infinity the natural numbers? Is there any reason such set was chosen? Couldn't the axiom yield a set that looks like $\Bbb R$ for example?
No reason other than canonicity. It is not hard to see in the presence of the other axioms of set theory that if there is an infinite set, then there is a countably infinite one. (And you do not need the axiom of choice for this to be the case, see [here](https://math.stackexchange.com/a/815199/462) for a short sketch....
300133
First of all, thank you in advance for your support. My problem; First I am successfully getting my specific parameters in Employer. However, I also have a constantly changing parameter list in request. I want to get them with Map too. My dto: ``` public class Employee { private String name; private Multipa...
When defining a function with parameters, make sure that these parameters don't come inside the definition of the function. The code also has some indentation and logical mistakes. This is a corrected version. ``` print("I can tell you the maximum of 3 numbers") num1 = input("Enter the first number:") num2 = input("E...
300302
I am creating sample Spring MVC application.In this application i have one form when i submit the form i perform some action. My problem is after the form submit url is changed for example i have url as `http://localhost:8080/SampleWeb/sample/user` this is for my form display when i submit the form the url redirected...
There are a few things to say. 1. The model you are using to predict the most likely correction is a simple, cascaded probability model: There is a probability for `W` to be entered by the user, and a *conditional probability* for the misspelling `X` to appear when `W` was meant. The correct terminology for P(X|W) is ...
301267
I was wondering how does .NET's string.Remove() method operates regarding memory. If I have the following piece of code: ``` string sample = "abc"; sample = sample.Remove(0); ``` What will actually happen in memory? If I understand correctly, We've allocated a string consisting of 3 chars, and then we removed al...
First `Remove` is going to create a new string that has no characters in it (an empty string). This will involve the allocation of a char array an a `string` object to wrap it. Then you'll assign a reference to that string to your local variable. Since the string `"abc"` is a literal string, it'll still exist in the i...
301344
I have a view pager that returns same fragment with different data from adapter every time i swap but despite of the fact that different data is received it displaying the same data over and over again, how can i make fragment update its data the structure is, there is a fragment that has a listview and when i click o...
Instead of `addFragment`, `replace` is better choice. ``` FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.container_body, fragment); fragmentTransaction.commit(); ```
301626
I want to access the engine from inside my eventReceiver object. They are fellow members of the game class, but how do I reach it? ``` // game.h class game { public: game(); 3dEngine* engine; eventReceiver* receiver; }; // eventReceiver.h class eventReceiver { public: eventRec...
Implement the class as a [Singleton](http://en.wikipedia.org/wiki/Singleton_pattern) and write a getter for the `engine` property. Accessing code could then look like: ``` game::getInstance()->getEngine()->quit(); ``` I would recommend you though, that you create a `quite()` method in the game class itself hiding im...
301628
I have a string(variable) having value of database cell. Actually that value is html code. I have to print that code into html page. I found that how to convert HTML string into DOM string. But I don't know that How to convert string into HTML string. If anyone know answer then please explain or suggest me link from wh...
try this ``` $dbstr = html_entity_decode("&lt;p&gt;Just install and use this app.&amp;nbsp;&lt;strong&gt;MENU -&amp;gt; SETTINGA&lt;/strong&gt;&lt;/p&gt;"); ```
301805
[LATER EDIT: As I found, the issue is related to Android version, not device type. So my code was perfect for Android till 4.0, not above. The fix is in the answer.] I have wasted at least 2 days with this problem. I have few webpages packed as an Android application. And working perfectly on browser, and on my Androi...
I found what I needed. Android 4.1 and 4.2 introduce this new method: getAllowUniversalAccessFromFileURLs Since it's not working on API below 16 the solution needs some few more lines, to assure that this inexistent method do not cause errors in previous API. ``` public class MainActivity extends Activity { /** Calle...
301860
I have a Shapefile (.shp, .dbf, .shx, .prj) that's supposed to represent street data for San Francisco, which I'm writing a parser for. The problem is, when I parse the bounding box according to the ESRI format for Shapefile [here](https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf), I get back around (5979762...
Welcome to GIS SE! No worries here, you've got a shapefile whose coordinates subscribe to a [State Plane Coordinate System](https://en.wikipedia.org/wiki/State_Plane_Coordinate_System), recorded in feet. The minimum bounding geometry coordinate you've retrieved can be thought of as the bottom-left bounding geometry co...
302046
I need assistance in retrieving the element country and Its value 1 in the first file and element Name and Its value XYZ in the second file. I am taking Input from app.config and i have stored both the files is C:\Test\ and the file are. Sample.xml ``` <?xml version="1.0" encoding="utf-8"?> <env:Contentname xmlns:e...
`gets` is deprecated, use `fgets` and replace the trailing newline with a white space: ``` void addDataToTextFile(FILE *fileptr) { char text[100]; char *ptr; fileptr = fopen("textfile.txt", "a"); printf("\n\nPlease enter some text: "); fflush(stdin); /* You want fflush(stdout); */ fgets(text, ...
302100
I am tearing my hair out trying to center the text right in the middle of the li container. It seems like it centers left to right. But top to bottom it is not. I have tried to add a span to the text and move it via the margin, and padding. I have been unsuccessful to move the text at all. I expect the text to be cen...
Answering the latter requirement, please try: ``` awk ' { split($0, a, "] +") gsub("[[,]", "", a[1]) printf("%s %.21f\n", a[1], a[2]) }' file ```
302436
I'm using a VF page as a "dispatcher" to display different pages based on an object recordtype. ``` <!-- OverrideCaseView If Case is a XXXX, show in the XXXXX user interface Otherwise, show the normal Case page. --> <apex:page standardController="Case" action="{!IF(case.RecordType.DeveloperName='XXXXXXXX...
**Visualforce Pages and Action Overrides.** Currently there is no context other than that passed in the standard controller given to you by the platform. Which really just gives you the SObject and not the action invoked apone it. However this allows your controller code to be generic at least. Allowing you to reuse ...
302483
I'm trying to do very basic form validation with Bootstrap 4. For some reason, when adding class 'is-valid' to my 2nd input in my example, because the 1st input has the 'is-invalid' class, the 2nd input will have green borders (as it should since it's valid!), **BUT** it'll also have the invalid-feedback div showing (t...
The reason its not working is that you are not wrapping your label and input in `form-group` div Validation has changed the way it used to be for bootstrap - Which means the `is-valid` and i`s invalid` does not know where to look so when its not in the form-group div wrapped it applies the `is-invalid` message to all ...
302821
I have a combo-box that contains lots of entries like this small extract ``` 1R09ST75057 1R11ST75070 1R15ST75086 1R23ST75090 2R05HS75063 2R05ST75063 3R05ST75086 2R07HS75086 ``` The user now enters some information in the form that result in a string being produced that has a wildcat (unknown) character in it at the ...
You could use regular expressions. Something like this: ``` string[] data = new string[] { "1R09ST75057", "1R11ST75070", "1R15ST75086", "1R23ST75090", "2R05HS75063", "2R05ST75063", "3R05ST75086", "2R07HS75086" }; string pattern = "3*05ST75086"; string[] results = data .Where(x => S...
303112
This is basically a follow-on to the question [Newtonsoft Object → Get JSON string](https://stackoverflow.com/questions/6690395/newtonsoft-object-%E2%86%92-get-json-string) . I have an object that looks like this: ``` [JsonConverter(typeof(MessageConverter))] public class Message { public Message(string original)...
You want `fillna` with `backfill` First, you need to make sure your empty values are actually null values recognized by pandas, so ``` import pandas as pd import numpy as np df = df.replace('', np.NaN).fillna(method='bfill', limit=3).replace(np.NaN, '') trial 0 1 2 3 4 a 5 ...
303409
Rather annoying issue, but it seems as though there's some default behavior on a scroll view, that when you change orientation, it auto-scrolls to top. `ShouldScrollToTop` is a property available on a `UIScrollView` but doesn't seem to be available in a XF ScrollView. But it does it anyway? Is there a way to stop?
I just did a quick test on this and only found it to be an issue on iOS. On Android the ScrollView did not scroll to the top after rotation. I did not test UWP/WinPhone. If it is iOS only, a bug should be filed against Xamarin.Forms. In the meantime, here is a workaround for iOS. You will need to create a custom rende...
303567
I have been working on playing videos using VideoView in Android. OnPause of fragment i am pausing the video and storing the seektime ``` @Override public void onPause() { super.onPause(); if (videoview != null && videoview.isPlaying()) { videoview.pause(); seekTi...
Try to reverse order of operations : ``` @Override public void onResume() { super.onResume(); videoview.start(); videoview.seekTo(seekTime); } ```
303570
I migrated from Visual Studio 2017 to Visual Studio 2019 and now, when I run my AspNet Core application with IIS Express, i receive an infinite waiting for site page. Browser is opened but page is loading forever. Can anyone help me understanding the reason? With VS2017 that problem never happened. Thanks in advance...
The reason why you are receiving that error is because your return statement is inside the for loops. More specifically, it can happen that neither of the loops execute (e.g. mapChunkSize == 0. Then 0 isn't less than 0 and the program doesn't enter the for loops) and that thus nothing gets returned. So either move the ...
303612
I am generating the contents of a div's content on a page by calling getJSON on a razor/cshtml file. 90% of the code works - from 2013 down through 1960 - as you can see at <http://www.awardwinnersonly.com/> by selecting "Hugos (Science Fiction)" from the book dropdown, but something in the last few "records" I added (...
``` public static void main(String[] args) throws JSONException { String jsonString = "{" + " \"MyResponse\": {" + " \"count\": 3," + " \"listTsm\": [{" + " \"id\": \"b90c6218-73c8-30bd-b532-5ccf435da766\"," + " \"si...
303708
I'm not understanding something. I am trying to build a server on a Raspberry Pi with Apache. I can access it from my own network, but not outside. I already got the port forwarding and all that setup. I think I may have the answer to my problem but I am not understanding it. So, I gave a friend my Internal IP Addres...
That's pretty much it. Http requests for example will normally come in on port 80 so if you want the Pi to serve web pages externally you'd forward port 80 on the router to port 80 on the Pi. The Pi also needs configuring to accept external requests on that port (usually using a UFW rule)
303811
I want to create a functional test for an action that receives a POST method with data in JSON format. This is what I have: ``` info('set car')-> post('/user/'.$user->getId().'/set-car/'.$car->getId()'-> with('request')->ifFormat('json')->begin()-> isParameter('module', 'myModule')-> isParameter('actio...
Did you checked out the [page](http://www.symfony-project.org/jobeet/1_4/Doctrine/en/09) from Jobeet tutorial? The first example is ``` $browser = new sfBrowser(); $browser-> get('/')-> click('Design')-> get('/category/programming?page=2')-> get('/category/programming', array('page' => 2))-> post('search'...
303929
I'm currently writing a program in CLI/C++ using an imported C# package. I need to use one of the functions in one of the C# objects which takes in an array. Unfortunately it isn't allowing me to use a CLI array, defined like so: ``` array<float>^ knots = gcnew array<float>(nurbs->GetNumKnots()); ``` (and then popul...
I'm not sure if it's the same `NURBSCurveKit`, but according to an [online API reference](http://docs.techsoft3d.com/hps/core_graphics/ref_manual/cs/class_h_p_s_1_1_n_u_r_b_s_curve_kit.html#a005e69001a746259bd8197eeda388955) I found, the `SetKnots` method takes one parameter, not two. Since a managed array knows how lo...
304219
I'm running ubuntu 10.04. I have a newly purchased TATA Photon+ Internet connection which supports Windows and Mac. On the Internet I found a article saying that it could be configured on Linux. I followed the steps to install it on Ubuntu from this [link](http://digitizor.com/2010/06/28/how-to-use-tata-photon-plus-in-...
From [How to configure TATA PHOTON+ EC1261 on UBUNTU 10.04 Lucid Lynx](http://www.botskool.com/geeks/how-configure-tata-photon-ec1261-ubuntu-1004-lucid-lynx) by [Aamir Aarfi](http://www.botskool.com/author/aamir-aarfi): > > 1.- follow this guide : > > > How to install Tata Photon+ on Ubuntu 10.04 > > > ### STEP #...
304356
I have a single task to produce a jar like this: ``` task contentJar(type: Jar, overwrite: true) { ... } artifacts { archives contentJar } ``` How do I include the jar produced by the contentJar task as a testRuntime dependency? I was able to define the dependency like this: `testRuntime fileTree(dir: 'build/...
In your library project, Create a new configuration: ``` configurations { foo } ``` Add your artifact to this configuration: ``` artifacts { foo contentJar } ``` Use this project as a dependency in a different project, and use your configuration to limit artifacts to contentJar: ``` testCompile project(path:...
304644
We have a legacy embedded system which uses SDL to read images and fonts from an NFS share. If there's a network problem, TTF\_OpenFont() and IMG\_Load() hang essentially forever. A test application reveals that open() behaves in the same way. It occurred to us that a quick fix would be to call alarm() before the c...
I've had exactly the same error CS0012: ...TaskAwaiter<>... This is a known issue in VS2015. <https://support.microsoft.com/en-us/kb/3025133> To solve it go to Debug - Options - General - Use the legacy C# and VB expression evaluator (tick)
304745
I have a controls.Image that I put in my Flex4 AIR App. I set it to x=0, y=0. Width=100%, Height=100%. The problem with this, is that The source image I am using does not fit the whole app screen. The actual controls.Image covers the entire screen, but the source image contained in the controls.Image does not fill th...
If by 'controls.Image', you mean `mx.controls.Image`, which is technically a Flex 3 component, but is applicable in Flex 4.1 and earlier, you want to set `maintainAspectRatio` to `false`, and make sure that `scaleContent` is `true` (which is the default value). On the other hand, if you are using Flex 'Hero' SDK (Flex...
304790
I'm trying to a simple insert list of rows from a `DataGridView` to a database. I have made a `checkedbox` that upon checked, the item will be added to the `DataGridView`. Now i'm attempting to do the INSERT part. This what I have come up so far: ``` try { string strAppointment = "SELECT appointmentID FROM APPOIN...
Try this: (initialize the datareader) ``` for (int i = 0; i < dataPrescription.Rows.Count; i++) { string firstColumn = dataPrescription[0, dataPrescription.CurrentCell.RowIndex].Value.ToString(); string strMedications = "SELECT medicationID FROM MEDICATION WHERE medicationName= ('" +...
305121
I've been using GnuCash to track only my money and securities. Now, I wanna use it to track also my fixed assets so that I have a more accurate estimation of my net worth. One fixed asset I have is a motorcycle, a Honda CG 150 Titan. It was bought in 2006 for 4,100 BRL at market price, but today it's worth 6,500 BRL. ...
The capital gains subject to exclusion are not per calendar days you live in the property, since no-one can actually attribute your gain to a specific date. Instead, it is being prorated. For example, you lived in the property 2 years and rented it out for 8 years before moving into it yourself. So 20% of your capital...
305185
I have a small set of data that I need to fit a curve to (see image and data below). [![enter image description here](https://i.stack.imgur.com/w18Wt.jpg)](https://i.stack.imgur.com/w18Wt.jpg) ``` algaeConc adultDens 2.934961 6665.145469 2.921015 6665.144453 2.910769 6665.142377 2.908331 6665.138925 2....
Here's the unflipped version of your plot: [![plot of data from question](https://i.stack.imgur.com/J0m4P.png)](https://i.stack.imgur.com/J0m4P.png) No choices of $a$ and $b$ in $y=ax^{-b}$ (where $y$ is adult density and $x$ is algae concentration) will fit that shape of relationship; they don't increase and flatten...
305186
Consider a series $a\_n \in {\mathbb R}\_+$ ($n \in {\mathbb Z}\_+$) with \begin{equation} \lim\_{n\rightarrow \infty} a\_n = 0. \end{equation} It is easy to find an example that \begin{equation} \lim\_{n\rightarrow \infty} \sum\_{i=1}^{n}a\_i = \infty. \end{equation} For example $a\_n = 1/n$ or $a\_n = 1/\log(n)$. H...
If a sequence $(a\_n)$ is convergence and $a\_n\to L$, it can be shown that $$ \lim\_{n\rightarrow \infty} \frac {1}{n}\sum\_{i=1}^{n}a\_i = L $$ also. So basically, you **cannot** find a sequence $(a\_n)$ such that $lim\_{n\to\infty} a\_n=0$ while $\lim\_{n\rightarrow \infty} \frac {1}{n}\sum\_{i=1}^{n}a\_i > 0$ ...
305192
Towards the end of *Avengers: Age of Ultron* JARVIS uploads himself into a lifeless Virbranium android. This process creates Vision. Then before the final battle we see Tony Stark uploading a program called FRIDAY into his suit. During the battle we hear a feminine voice in The Iron Man suit instead of JARVIS'. So did ...
JARVIS was gone, Tony thought... then he found him in pieces, in the internet, protecting the access to the launch codes from Ultron's attempted hack. Tony re-collected JARVIS and took him back to the tower. Tony wanted to put JARVIS into the new fancy body to fight against Ultron. I'm guessing he figured that JARVIS...
305539
I have a list of tens of thousands of file names. I want to find which of those files actually exist on disk (in a particular directory). I'm not sure how to start. I could try it with either Python or bash. The list of file names is an ascii file with one file name per line and no other content.
Let's assume your file names are absolute paths, and all files are in one directory, and you want to find only files (not directories, special files, etc), and you don't have spaces or special characters in your file names. ``` sort < yourlist >yourlist_sorted find <absolute path to dir> -type f |sort |comm -1 -3 - y...
305808
I need to create highly scalable solution - where field devices in thousands of sites are delivering data in real time to a back end system, and SQL Azure seems to fit the bill nicely in terms of adding sql databases and application servers. Each field device is effectively sending 400 sensor values every second - fo...
Since no one else has answered, I'll share some opinions and do some hand-waving. As long as you aren't locking common resources, or are locking resources in the same order, you shouldn't have problems with deadlocks. I'd look at separate tables before separate databases. Each additional database will definitely cost...
306056
Within my custom `UIButton` class called "ComingHomeButton", I'm not able to change the backgroundcolor I would like to change it without creating images, but if it is the only way I will have to. I also want to change the background color every time the button is tapped. Here is what I have that doesnt work: ``` U...
You can create a counter, and then loop through colors when a button is tapped: ``` -(IBAction)buttonTapped:(id)sender { if (!counter) { counter = 0 } if (counter%3 == 0) { self.backgroundColor = [UIColor redColor]; //or whatever custom color you want to use } else if (counter%3 == 1) { sel...
306330
i have a form having some textfields and a textarea (ckeditor), after onclick button art\_title field value is sent to art\_save.php page, but value from textarea is not sent. ``` <script src="ckeditor/ckeditor.js"></script> function saveArt() { var title = document.getElementById('art_title'), art_title...
You can force CKeditor to update the textarea value using: ``` for (instance in CKEDITOR.instances) { CKEDITOR.instances[instance].updateElement(); } ``` Also, you can use `.serialize` for the data - then you won't have to maintain the AJAX code if parameters change: ``` <script src="ckeditor/ckeditor.js"></scr...
306601
I have a table say `Configs` in which I have the column names ``` id | Name ------------- 1 | Fruits 2 | Vegetables 3 | Pulses ``` I have another table say `Details` ``` id |Field1 | Field2| Field3 | Active | Mandatory ------------------------------------------------- 1 |Apple |Potato |Red gram | 1 ...
``` declare @sql nvarchar(max) select @sql = isnull(@sql + ',' ,'') + N'Field' + convert(varchar(10), id) + ' as ' + quotename(Name) from Config -- Form the dynamic SQL select @sql = 'SELECT id,' + @sql + ',Active, Mandatory ' + 'FROM Details' -- Print to verify print ...
306738
Here is my config of YAML (all PV, Statefulset, and Service get created fine no issues in that). Tried a bunch of solution for connection string of Kubernetes mongo but didn't work any. Kubernetes version (minikube): 1.20.1 Storage for config: NFS (working fine, tested) OS: Linux Mint 20 YAML CONFIG: ``` apiVersio...
I have found few issues in your configuration file. In your service manifest file you use ``` selector: role: mongo ``` But in your statefull set pod template you are using ``` labels: app: mongo ``` One more thing you should use `ClusterIP:None` to use the headless service which is recommended for ...
306855
I'm trying to answer this > > In $\Bbb {R^3} $ consider the ellipsoid: > $2x^2+3y^2+4z^2=1$ It exists a subspace of dimension 2 which intersection with the ellipsoid is a circle. Justify any answer. > > > I know that I must search for a plane since these are the only linear subspaces of $\Bbb {R^3} $ of dimensio...
The problem becomes easier if you go to parametric equations: $$x=a\cos(u)\cos(v)\\ y=b\cos(u)\sin(v)\\ z=c\sin(v)$$ you know that the equation of a circle is $x^2+y^2+z^2=r^2$, being $r$ the radius of the circle. You only have to find $v$ for example, such that the equation of the circle holds: $$r^2=(a^2\cos(v)^2+b^2...
307738
Currently I am receiving the following error when using Java to decrypt a Base64 encoded RSA encrypted string that was made in C#: > > javax.crypto.BadPaddingException: Not PKCS#1 block type 2 or Zero padding > > > The setup process between the exchange from .NET and Java is done by creating a private key in the ...
Check that you have correctly exchanged the key. Trying to decrypt with an incorrect key is indistinguishable from decrypting badly padded data.
308029
I have a `TestMethod` that will loop through all pages that contain a certain user control on them. The issue I'm running into is that when/if my assertion fails I'm not able to see the page it failed on in the error message or stack trace. Is there a way to customize or add in additional parameters to be shown in the ...
Sunshirond idea, works perfect for me, and I made some changes in <http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application> source code. The main activity to login and twitt will be something like that: ``` public class PrepareRequestTokenActivity extends Activity { fi...
308408
I have a unique problem which I'm hoping someone can assist with. I have One big text file, our **Production** file. The data in the file is delimited in the following format ``` Reference|Cost Centre|Analytics Base Value|.... UMBY_2288|023437|2883484|... NOT_REAL|1343534|283434|... ``` The average size of this f...
The solution is to read each file once, storing the date in memory. Keep an associative array or similar data structure where the key is the reference number. Then, as you process the master file, looking up each reference should take just microseconds. If the data is too big to fit in memory, you can create a tempora...
308832
I'm learning the [Hibernate Search Query DSL](http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html/search-query.html#search-query-querydsl), and I'm not sure how to construct queries using boolean arguments such as AND or OR. For example, let's say that I want to return all person records that have a `firs...
Yes your example is correct. The boolean operators are called *should* instead of *OR* because of the names they have in the Lucene API and documentation, and because it is more appropriate: it is not only influencing a boolean decision, but it also affects scoring of the result. For example if you search for cars "of...
309629
Suppose $P$ is a polyhedron whose representation as a system of linear inequalities is given to us: $$ P = \{ x ~|~ Ax \leq b\}$$ Define $P'$ be the image of $P$ under the linear transformation which maps $x$ to $Cx$: $$ P' = \{ Cx ~|~ x \in P \}.$$ Given $A,b,C$, our goal is to compute a representation of $P'$ as a...
I would say the following should be not too controversial: * $\emptyset$ and $\varnothing$ are typographical variants of the same mathematical symbol designating the empty set * The symbol was introduced by Bourbaki, was inspired by the Norwegian character Ø, but is a distinct character from it * The intention was mos...
309748
I have an Angular reactive form with works most of the time. But sometimes, randomly, I get an error ``` ERROR Error: Cannot find control with name: 'username' at _throwError (forms.js:2337) at setUpControl (forms.js:2245) at FormGroupDirective.push../node_modules/@angular/forms/fesm5/forms.js.FormGroupDir...
Looking at the [source code](https://github.com/angular/angular/blob/master/packages/forms/src/directives/reactive_directives/form_control_name.ts) of `FormControlName` and thinking about [when ngOnChanges() can run](https://angular.io/guide/lifecycle-hooks), I reckon `ngOnChanges()` is running before `ngOnInit()` has ...
310445
I have this form validation i copied from a youtube video but it is coded using cakephp 1.3. so i'm having a hard time migrating it to 2.1 CommentsController.php - function validate\_form() ``` function validate_form() { if($this->RequestHandler->isAjax()) { $this->request->data['Comme...
With your current code, `$error` is only set if the submitted form does not validate, but it is not set when the form does validate properly. You'll want to add a check to your view, prior to spitting it out, like: ``` if(isset($error)) { echo $error; } else { echo "Form is valid"; // Optionally echo something...
310808
I have this query interface: ``` public interface IMyDocDao extends MongoRepository<MyDoc, String> { @Query(value = "{ 'stuff.in.nested.doc' : ?0, 'another.stuff.in.nested.doc' : ?1 }") List<MyDoc> findByFoo(String foo, String bar); } ``` If a call `findByFoo("a", "b")` it works correctly. If a call `findByF...
No you won't need an Apache server. Because Node itself will serve as a Server Especially if you are working with Frameworks like Express. You don't need Nginx or Apache at all, but you can use if you want. It's very cosy to some people use Nginx to do the load balance, or even other stuff like handle the https or ser...
311024
I'm wanting to setup Bootstrap alerts for successful and unsuccessful inserts. I've had a look around and couldn't find any examples of people having 2 redirects one for a successful insert and one for a failed insert. ``` if(isset($_POST['CountryID'])) { $CountryID = $_POST['CountryID']; if(...
It's very easy with Flex box. Check [this awesome guide here](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) ```css /* Normalize */ html,body { height: 100%; margin: 0; padding: 0; } /* Flex power */ .flex-container { display: flex; flex-direction: column; height: 100%; } .flex-cont...
311198
This is my test: ``` @Test public void shouldProcessRegistration() throws Exception { Spitter unsaved = new Spitter("Gustavo", "Diaz", "gdiaz", "gd123"); Spitter saved = new Spitter(24L, "Gustavo", "Diaz", "gdiaz", "gd123"); SpitterRepository spittlerRepository = Mockito.mock(SpitterRep...
Use an `ArgumentCaptor` to capture the value passed to save, and then assert on it. ``` ArgumentCaptor<Spitter> spitterArgument = ArgumentCaptor.forClass(Spitter.class); verify(spittlerRepository, atLeastOnce()).save(spitterArgument.capture()); assertEquals("Gustavo", spitterArgument.getValue().getName()); ``` For ...
311498
I have a linked list which takes several input files, then it put them into a linked-list to print them later on. I implemented a print function but it does not work well and gives access violation error. I tried to debug, unfortunetly I could not find the root of problem. Error Line in the function: ``` cout << p...
It appears the response from <http://www.merdeka.com> is gzipped compressed. Give this a try: ``` import gzip import urllib.request def __retrieve_html(self, address): with urllib.request.urlopen(address) as resp: html = resp.read() Helper.log('HTML length', len(html)) Helper.log('HTML con...
311714
I was trying to bind View Bag data to a HTML table. My C# code works fine. Can add data to View Bag as `ViewBag.employeeData = getDBData();` but when i try to access each item, > > Microsoft.CSharp.RuntimeBinder.RuntimeBinderException is thrown. > > > Below given my **C#** code ``` private IEnumerable<Employe...
You don't need to use the ViewBag (and I would recommend never using it). When you return a value from a controller: ``` return empDetails; ``` It becomes the *model* for the *view*. In the view, you need to declare the model type: ``` @model List<Employees> ``` Then you can: ``` @foreach (var item in Model) { ...
312357
I am trying to perform a SQL query that removes all the rows where people have less then 10 people or more then 100 people in their network. ``` SELECT * FROM table1 Where inNetwork > 10 AND < 1000, ``` Basically, by this query what I mean is only show people with more then 10 and less then 1000 people in their net...
It is a bit more subtle. The `self()` call happens inside the `fun()` which is spawned. Since it it spawned, it has another Pid than the one you expect. Hence, the semantics are different.
312474
I want to try and find the employee who has taught the most classes as the position `Teacher`. So in this I want to print out `Nick`, as he has taught the most classes as a `Teacher`. However, I am getting the error: > > ERROR: column "e.name" must appear in the GROUP BY clause or be used in an aggregate function Po...
Your code would work if you make this a rowwise operation so each `start` and `end` represent a single value at a time. ``` library(data.table) a[,S := sum(series[start:end]), 1:nrow(a)] a # start end S #1: 1 4 10 #2: 2 5 14 #3: 3 6 18 ```
312976
I've got quite a few SQL statements like such: `SELECT foo FROM things WHERE user_id IN (1,2,3..n)` Is there a known limit to the number of elements that will safely fit in an IN clause like that?
The 1000 limit in PostgreSQL is not a hard limit, it is a optimization limit, i.e; after 1000 PostgreSQL doesn't handle it very well. Of course I have to ask what in the world are you doing with a 1000 entry IN clause.
313324
I have a basic component that looks as follows. ``` class List extends React.Component { constructor() { super(...arguments); this.state = { selected: null, entities: new Map([ [0, { 'name': 'kot'} ], [1, { 'name': 'blini'} ] ]) }; } render() { return (<div> ...
quizForm is never cleared, so we just keep appending it forever. I added this before the loop that handles that div: quizForm.innerHTML = ""; ``` function askQuestion(){ choices = allQuestions[currentQuestion].choices; question = allQuestions[currentQuestion].question; if(currentQuestion < allQuestions.le...
313721
I have the following map in my game, ``` x------------- y +3 +5 +2 -1 -2 | -1 +4 +2 +1 -1 | -2 +1 -1 -1 -1 | -1 -1 -2 -1 +2 | +2 +2 +2 +2 +4 ``` I want to draw positive points as polygons, like the following: ![willingimg](https://i.stack.imgur.com/X2aRo.png) How can I do that, what algorithm/way I should...
``` use strict; use warnings; use HTML::TreeBuilder; my $str = "Your HTML STRING"; # Now create a new tree to parse the HTML my $tr = HTML::TreeBuilder->new_from_content($str); # And now find all required tags ex li and create an array my @lists = map { $_->content_list } $tr->find_by_tag_name('li'); # And loop t...
313801
A drop down contains an array value. If i select one value from drop down it will remove that value from array its working. But on click of reset button it should reset with old values .Here is my code HTML code ``` <html> <head> <script src="angular/angular.js"></script> <script src="js/controllers.js"></script> </...
You should take a copy of variable while you intialize/get `Layer` data ``` var copyOfLayer = angular.copy($scope.Layer); ``` Then while reseting it you need to do assign old array to the `$scope.Layer` also you need to rewrite your `resetLayer` function to below ``` $scope.resetLayer = function() { $scope.La...
314065
Here's the data I am working with right now: ``` $city = [ [ "name" => "Dhaka", "areas" => ["d1", "d2", "d3"] ], [ "name" => "Chittagong", "areas" => ["c1", "c2", "c3"] ], [ "name" => "Sylhet", "areas" =...
As long as the names are unique you can do this simple trick: **Example 1** ``` $city = [ [ "name" => "Dhaka", "areas" => ["d1", "d2", "d3"] ], [ "name" => "Chittagong", "areas" => ["c1", "c2", "c3"] ], [ "name" => "Sylhet", "areas" => ["s1", "s2", "...
314303
Lets say I have `n` files in a directory with filenames: `file_1.txt, file_2.txt, file_3.txt .....file_n.txt`. I would like to import them into Python individually and then do some computation on them, and then store the results into `n` corresponding output files: `file_1_o.txt, file_2_o.txt, ....file_n_o.txt.` I've ...
Can you use the following snippet to build the output filename? ``` parts = in_filename.split(".") out_filename = parts[0] + "_o." + parts[1] ``` where I assumed in\_filename is of the form "file\_1.txt". Of course would probably be better to put `"_o."` (the suffix before the extension) in a variable so that ...
314757
I am migrating a `.Net Framework` project to `.Net Core`. In my `.Net Framework` code I call a stored procedure and it returns a `list<int>` in a `datatable`: ``` DataTable dt = new DLDistinctWarehousePackingOperation().CreatePacking(packingId, userId, previousOrderId, totalAwaitingOrdersAllowed); List<int>...
Assume the stored procedure name is `CreatePacking`, define the property in your DbContext. For example ``` public class MyContext : DbContext { ............... [NotMapped] public DbSet<CreatePackingResult> CreatePackingResult { get; set; } ............... ............... } ``` And then define ...
314787
I am looking for someone to verify my proof of the problem in the title. Of course, if you believe it to be wrong, you are welcome to shred it into a million pieces and if I made any logical errors please point them out. I'll write my solution out in the most coherent way I know how to. I am also interested, even if t...
Let $e\_i\in W$ satisfy $(e\_i)\_j=1$ if $i=j$ and $(e\_i)\_j=0$ otherwise. Then $$\langle Te\_i,e\_j\rangle=\cases{1\,\,{\rm if}\,\,j\leq i,\\0 \,\,{\rm if}\,\,j>i.}$$ Thus if $T^\*$ exists: $$\langle e\_i,T^\*e\_j\rangle=\cases{1\,\,{\rm if}\,\,j\leq i,\\0 \,\,{\rm if}\,\,j>i.}$$ So we have $(T^\*e\_j)\_i=1$ for al...