source
stringclasses
1 value
task_type
stringclasses
1 value
in_source_id
stringlengths
1
8
prompt
stringlengths
209
40.4k
gold_standard_solution
stringlengths
0
56.7k
verification_info
stringclasses
1 value
metadata
stringlengths
138
225
problem_id
stringlengths
9
10
stackexchange
llm_judgeable_groundtruth_similarity
37750
Below is a question asked on the forum security.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Does a self destructing HDD (physically destruction) that will destroy after a certain time exist, or when I use some software to initiate its self-destruction? I guess it need to be set in BIOS or on some other "lower" level? I mean, a HDD that I can buy as a casual customer, and I don't need to be part of a government or some agency. Why I would want something like that? If somebody stole my laptop and accessed my data using the right password, then after 24h I want to destroy the HDD, unless the attacker knows that I have set my HDD to self-destruct on some BIOS-level, and re-enable the next 24 or 48 or some other time hour period e.t.c. But this is just an example, in reality it could be done differently. Now provide the response and nothing else.
There is no hard disk drive, or a solid state drive, or any other non-volatile computer memory on the market that would have self-destruct capabilities and a casual customer could buy. There's also a good reason for this. Let's, as an example, see what a military grade RunCore's InVincible SSD does: XBitLabs.com: RunCore InVincible SSD Features Physical Self Destruction Capability Besides typical elimination of all data through overwriting, the InVincible SSD can completely destroy the data by physically destroying memory and other chips inside the drive by burning chips down physically. The RunCore InVincible SSDs allow to protect sensitive data from third party access in two ways with a single click. One method is an intelligent elimination of all the data by overwriting the entire disk with meaningless code. This overwrite-deletion method ensures that there is no way to potentially recover previous data stored to the device, effectively setting the SSD back to factory default. Still, there are various data recovery devices not available commercially which can, perhaps, recover data even after overwriting. A less subtle method is the physical destruction of memory chips inside SSD by applying an over-current to the NAND flash memory and thereby physically destroying them. Here is a YouTube video presentation from the manufacturer. But let's make one thing perfectly clear. I'm not in any way endorsing this product. In fact, I don't know of a single store that would be selling them, the presentation documentation and the video are lacking on detail, credibility * and quality. And all of it was a bit of a joke among friends back when this story hit the web. If you watch the presentation video , you'll see what I mean for yourself. But let's for a minute assume this drive is real, and it does what it says on the box. Would you be able to buy it as a casual customer ? No: This is supposedly how the circuitry looks like after self-destruction. There's been a lot of speculation on the web this image (the only one you'll find) was faked. I can't say it doesn't look like it was faked to me also. Note the PCB assembly helper lines (white) next to the storage chips that seem to have melted too. RunCore positions its InVincible SSDs for aerospace, military and general industrial applications, it is unclear whether the company plans to sell such SSDs to general public and whether the company will be allowed to do so. There's a good reason for that too, considering it's at the very least a fire hazard, and if you'd use it in your laptop, let's not even consider what all would start happening, if you forgot about it and wanted to board an airplane (although same should be true for any other public transportation vehicles, possibly public places too). * I didn't manage to find a single proof this product actually exists, or that the presentation slides and video were not faked, possibly as a demonstration of planned capabilities for military contractors.
{}
{'log_upvote_score': 4, 'links': ['https://security.stackexchange.com/questions/37750', 'https://security.stackexchange.com', 'https://security.stackexchange.com/users/-1/']}
jdg_75741
stackexchange
llm_judgeable_groundtruth_similarity
53994501
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Just trying to understand on why Buzz doesn't appear in the newline after Fizz for 15. Trying to learn JavaScript from Eloquent Javascript and just got into doing the FizzBuzz exercise. Note that I've included a commented out solution where it does work (although not elegantly) but the thing I've notice that some solutions searched online show their 15 appearing with Fizz but Buzz is on a newline while my solution (which is not commented out) only shows Fizz. Can anyone explain to me why does it do this? Just curious. The only thing I've noticed is when I use if ((int%3 == 0) && (int%5 == 0)) either at the end or the beginning of the block is when the changes are visible. Note : I'm not asking for solutions. I just want an explanation to my question above. The commented solution does give me FizzBuzz for 15. Please do not misunderstand and thank you for taking your time to answer this. My solution: for(let int = 1; int <= 100; int++){ if(int%3 == 0){ console.log('Fizz'); } else if(int%5 == 0){ console.log('Buzz'); } else if ((int%3 == 0) && (int%5 == 0)){ console.log('Fizz'+'Buzz'); } /*if ((int%3 == 0) && (int%5 == 0)){ console.log('Fizz'+'Buzz'); } else if(int%3 == 0){ console.log('Fizz'); } else if(int%5 == 0){ console.log('Buzz'); }*/ else{ console.log(int); }} Now provide the response and nothing else.
As it is a specific question based on dplyr 1 ) after the group_by , use slice on the row_number() library(tidyverse)df %>% group_by(a) %>% slice(tail(row_number(), 2))# A tibble: 8 x 2# Groups: a [4]# a b# <dbl> <dbl>#1 1 343 #2 1 54 #3 2 55 #4 2 62 #5 3 59 #6 3 -9 #7 4 0 #8 4 -0.5 2 ) Or use filter from dplyr df %>% group_by(a) %>% filter(row_number() >= (n() - 1)) 3 ) or with do and tail df %>% group_by(a) %>% do(tail(., 2)) 4 ) In addition to the tidyverse , methods, we can also use compact data.table library(data.table)setDT(df)[df[, .I[tail(seq_len(.N), 2)], a]$V1] 5 ) Or by from base R by(df, df$a, FUN = tail, 2) 6 ) or with aggregate from base R df[aggregate(c ~ a, transform(df, c = seq_len(nrow(df))), FUN = tail, 2)$c,] 7 ) or with split from base R do.call(rbind, lapply(split(df, df$a), tail, 2))
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/53994501', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7983852/']}
jdg_75742
stackexchange
llm_judgeable_groundtruth_similarity
39798542
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a file that looks as below: { "repositories": [ { "id": "156c48fc-f208-43e8-a631-4d12deb89fa4", "namespace": "rhel12", "namespaceType": "organization", "name": "rhel6.6", "shortDescription": "", "visibility": "public" }, { "id": "f359b5d2-cb3a-4bb3-8aff-d879d51f1a04", "namespace": "rhel12", "namespaceType": "organization", "name": "rhel7", "shortDescription": "", "visibility": "public" } ] } I want to get only name values with each of them in a new line so that I can use while read -r line .I need only rhel6.6 rhel7 I am using jq as follows which doesn't seem to work: jq -r '.[].name' Please suggest correct use of jq here Now provide the response and nothing else.
You need to combine filters by means of | operator: $ jq -r '.[] | .[] | .name' test.json rhel6.6rhel7 The first .[] fetches repositories array. The next .[] fetches all the items of the repositories array. Finally, .name extracts properties from the array items(objects). Note, the first .[] works on object because it is a documented feature: .[] If you use the .[index] syntax, but omit the index entirely, it will return all of the elements of an array... You can also use this on an object, and it will return all the values of the object.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/39798542', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5632400/']}
jdg_75743
stackexchange
llm_judgeable_groundtruth_similarity
42099925
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: In my small node.js application, using express, I wanted to log all the incoming requests, so I ended up with this: var bodyParser = require('body-parser');module.exports = function(app) { app.set("port", 50001); app.set("json spaces", 2); app.use(bodyParser.json()); app.use(function (error, req, res, next) { app.logger.info("received from "+req.get("X-Forwarded-For")+" : "+req.method+" "+req.originalUrl+" (Authorization: "+req.get("Authorization")+")"); //does not work if json is malformed //app.logger.info("content :"+JSON.stringify(req.body)); if (error /*instanceof SyntaxError*/) { res.status(400); app.logger.error(error); res.json({ error:{msg: error.message}}); } else { next(); } }); app.use(app.auth.initialize());}; Unfortunately, I only get the logs via the app.logger.info line when there's an error (in my case a malformed JSON string in the body). What am I missing here? Now provide the response and nothing else.
Expressjs adapts its functionality based on what type of callback you give it (this is not common in JS libraries so it is not surprising that people get confused by it). If you do this where your callback has four arguments: app.use(function(error, req, res, next) {...}); then Express assumes this is an error-only middleware handler and will only be called when there are errors. In the express doc , see the section labeled Error-handling middleware . Note this specific part of that page: Define error-handling middleware functions in the same way as other middleware functions, except with four arguments instead of three, specifically with the signature (err, req, res, next)): And, here's a whole section of the documentation devoted to error handling middleware . If you use just three arguments: app.use(function(req, res, next) {...}); then, it is a normal middleware that is called when there are not errors. I'm not sure if they provide a single way to get both. But, certainly as a workaround, you could put your logging code into a function and then call that function from two separate middleware handlers, one for errors and one for non-errors.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/42099925', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7473954/']}
jdg_75744
stackexchange
llm_judgeable_groundtruth_similarity
677590
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: There is a point written in my book (S.L. Arora- Simplified Physics Part-1)- Electric Potential is meaningful only for electric fields produced by stationary charges. It has no meaning for electric fields set up by magnetic induction. What are they trying to convey by saying that it has no meaning for electric fields set up magnetic induction. I tried googling it and understood it a bit, but there is still no clarity. Now provide the response and nothing else.
After the 1st hour, the first train would have moved 45 km, the second train will just start moving. Therefore, the distance between the two trains is 45 km. In the next hour, the second train moves 60km, the first train moves only 45 km, so the second train would have caught up by 15 km. The distance between the two trains is now 30km. Repeat this for another 2 hours and the second train will have caught up with the first train. The best way to see this will be to draw out the distance travelled by each train per hour, or the sketch the displacement-time graph for each train. The idea of 'relative velocity' is a more complicated way to reason the above situation, although it can be very useful in certain problems.
{}
{'log_upvote_score': 4, 'links': ['https://physics.stackexchange.com/questions/677590', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/306854/']}
jdg_75745
stackexchange
llm_judgeable_groundtruth_similarity
17168088
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am using CSS transitions to animate a background colour on mouse hover. I have the following code: div { width: 100px; height: 100px; background: red;}div:hover { background: green; transition: all 0.5s ease-in-out;} <div></div> This code only animates the background colour on mouse on. It doesn't reanimate the mouse off. I have 2 questions: How do I animate the mouse off using CSS? How do I do this using jQuery only ? jsfiddle: http://jsfiddle.net/fz39N/ Now provide the response and nothing else.
1) You change your css to div { width: 100px; height: 100px; background: red; transition: background 0.5s ease-in-out;}div:hover { background: green;} FIDDLE setting the transition to the element, and not the pseudo class. 2) With jQuery you'll either need two elements to cross fade, or a color animation plugin. jQuery UI has color animation built in, and then you can do : $('div').on({ mouseenter: function() { $(this).animate({backgroundColor: 'green'},1000) }, mouseleave: function() { $(this).animate({backgroundColor: 'red'},1000) }}); FIDDLE If you're not already using jQuery UI for something else, I'd suggest using one of the much smaller plugins, like this one !!
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/17168088', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2094106/']}
jdg_75746
stackexchange
llm_judgeable_groundtruth_similarity
341066
Below is a question asked on the forum softwareengineering.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I have recently mastered the Lambda expression that was introduced in java 8. I find that whenever I am using a functional interface, I tend to always use a Lambda expression instead of creating a class that implements the functional interface. Is this considered good practice? Or are their situations where using a Lambda for a functional interface is not appropriate? Now provide the response and nothing else.
There are a number of criteria that should make you consider not using a lambda: Size The larger a lambda gets, the more difficult it makes it to follow the logic surrounding it. Repetition It's better to create a named function for repeated logic, although it's okay to repeat very simple lambdas that are spread apart. Naming If you can think of a great semantic name, you should use that instead, as it adds a lot of clarity to your code. I'm not talking names like priceIsOver100 . x -> x.price > 100 is just as clear as that name. I mean names like isEligibleVoter that replace a long list of conditions. Nesting Nested lambdas are really, really hard to read. Don't go overboard. Remember, software is easily changed. When in doubt, write it both ways and see which is easier to read.
{}
{'log_upvote_score': 8, 'links': ['https://softwareengineering.stackexchange.com/questions/341066', 'https://softwareengineering.stackexchange.com', 'https://softwareengineering.stackexchange.com/users/258776/']}
jdg_75747
stackexchange
llm_judgeable_groundtruth_similarity
44696
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I am totally confused about Euler's rotation theorem. Normally I would think that an asteroid could rotate around two axes simultaneously. But Euler's rotation theorem states that: In geometry, Euler's rotation theorem states that, in three-dimensional space, any displacement of a rigid body such that a point on the rigid body remains fixed, is equivalent to a single rotation about a fixed axis that runs through the fixed point. It also means that the composition of two rotations is also a rotation. But asteroids do rotate around two axes. Look at the videos from this website: http://csep10.phys.utk.edu/astr161/lect/asteroids/features.html The Spin of Asteroid Toutatis By making a series of observations, it is possible to study the rotation of some asteroids. Most have simple rotations around a fixed axis, with periods typically between one hour and one day. For example, here is a movie (83 kB MPEG) made by the Hubble Space Telescope of the asteroid Vesta in rotation (Ref). However, the asteroid 4179 Toutatis (which crosses Earth's orbit) has been found through radio telescope observations to have an irregular shape and a complex tumbling rotation---both thought to arise from a history of violent collisions. Here is a short animation (47 kB MPEG) of the spin of Toutatis; here is a longer animation (288 kB MPEG). Here are the movies: http://csep10.phys.utk.edu/astr161/lect/asteroids/toutspin.mpg and http://csep10.phys.utk.edu/astr161/lect/asteroids/toutspin2.mpg You can clearly see that those rotations are not possible around one axis. But then isn't it contradicting Euler's rotation theorem? Now provide the response and nothing else.
I think you are confusing a single rotation (as a fixed displacement) with a rotational motion. Euler theorem says that the composition of two individual rotations (say, I rotate a body 15 degrees around a vertical axis, then I rotate it 10 degrees around some horizontal axis) is equivalent to a single rotation around some axis. But suppose I do the same double rotation, with the same axes but, say, double angles ( 30 and 20 degrees): they would be, again, equivalent to a single rotation, but the equivalent axis would be different. Hence, the composition of two rotation (motions) with fixed axis is not equivalent to some other rotation (motion) with another (fixed) axis. Then, to speak of the superposition of two rotational motions (that cannot be reduced to a single rotational motion) makes perfect sense. Example: Take a long cilinder, make it rotate quicky along its longitudinal axis. Superpose to that a slow rotation along a transversal axis. If both axis passes through the center of the cylinder, there is a fixed point. However, the resulting rotational motion cannot be expressed as a single rotational motion (with a fixed axis).
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/44696', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/10861/']}
jdg_75748
stackexchange
llm_judgeable_groundtruth_similarity
36042967
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Mongoose 4.4 now has an insertMany function which lets you validate an array of documents and insert them if valid all with one operation, rather than one for each document: var arr = [{ name: 'Star Wars' }, { name: 'The Empire Strikes Back' }];Movies.insertMany(arr, function(error, docs) {}); If I have a very large array, should I batch these? Or is there no limit on the size or array? For example, I want to create a new document for every Movie, and I have 10,000 movies. Now provide the response and nothing else.
I'd recommend based on personal experience, batch of 100-200 gives you good blend of performance without putting strain on your system. insertMany group of operations can have at most 1000 operations. If a group exceeds this limit, MongoDB will divide the group into smaller groups of 1000 or less. For example, if the queue consists of 2000 operations, MongoDB creates 2 groups, each with 1000 operations. The sizes and grouping mechanics are internal performance details and are subject to change in future versions. Executing an ordered list of operations on a sharded collection will generally be slower than executing an unordered list since with an ordered list, each operation must wait for the previous operation to finish.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/36042967', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1534912/']}
jdg_75749
stackexchange
llm_judgeable_groundtruth_similarity
977233
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm getting a number of these warnings when compiling a few binaries: warning: incompatible implicit declaration of built-in function ‘strcpy’warning: incompatible implicit declaration of built-in function ‘strlen’warning: incompatible implicit declaration of built-in function ‘exit’ To try to resolve this, I have added #include <stdlib.h> at the top of the C files associated with this warning, in addition to compiling with the following flags: CFLAGS = -fno-builtin-exit -fno-builtin-strcat -fno-builtin-strncat -fno-builtin-strcpy -fno-builtin-strlen -fno-builtin-calloc I am using GCC 4.1.2: $ gcc --versiongcc (GCC) 4.1.2 20080704 What should I do to resolve these warnings? Now provide the response and nothing else.
In C, using a previously undeclared function constitutes an implicit declaration of the function. In an implicit declaration, the return type is int if I recall correctly. Now, GCC has built-in definitions for some standard functions. If an implicit declaration does not match the built-in definition, you get this warning. To fix the problem, you have to declare the functions before using them; normally you do this by including the appropriate header. I recommend not to use the -fno-builtin-* flags if possible. Instead of stdlib.h , you should try: #include <string.h> That's where strcpy and strncpy are defined, at least according to the strcpy (2) man page. The exit function is defined in stdlib.h , though, so I don't know what's going on there.
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/977233', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/19410/']}
jdg_75750
stackexchange
llm_judgeable_groundtruth_similarity
1977
Below is a question asked on the forum security.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: There's recently been some discussion (to be generous) about the pros and cons of having a firewall deployed in front of servers. The con mainly being that it's a point of failure in case of a DDoS. Microsoft has been talking about doing away with the standalone firewall and instead basing security on PKI and IPsec, meaning you can't talk to the server if you don't have an appropriate certificate (no source for this, it was a talk I attended). So , given a simplistic scenario where you have, say, a web server, a mailserver and a database server backing the webserver, what's the current best practices firewall/network design, according to you? I'm well aware most deployments aren't this straight forward, but I think the example works well enough to base a discussion on. I'm also aware that the traditional, theoretical best practices would be to add as many layers of defense as possible -- but is this the design that results in the maximum availability, all things considered? (Assume that the servers are appropriately hardened and don't expose any services they shouldn't be running, that the switches don't add anything to the security equation, and that management is either out-of-band or from the cloud part of the drawing. Which ever you prefer, since it adds it's own complications either way...) Scenario #1, simple routed A clear, routed, non-firewalled design. The edge router may apply an ACL, some rate limiting. The DB server might be on private addresses that aren't routable from the internet. The hosts would each be running a firewall, such as Windows built-in or iptables etc. The admin running the hosts should consider the environment around the hosts hostile. Scenario #2, traditional firewalled The router may or may not provide any functionality above simply forwarding packets. The firewall implements the complete policy and segmentation. The hosts may, optionally, have some kind of firewalling, but probably wont. The admin running the hosts will probably consider the environment safe-ish. Scenario #3, we really like firewalls As #2, but more segmented. I've traditionally been building either #2 or #1, and I'm more and more leaning towards #1. I'm probably lured by the "simplicity" of the design and the "purity" of wanting the hosts to be able to survive in a hostile environment. I'm aware this is in contrast to defense in depth. :) Now provide the response and nothing else.
I am sure you are aware that for many security threats and/or compliance requirements there exists both network-based and host-based mitigation controls. Microsoft, being essentially a host-oriented company, is naturally going to be on the side of host-based security solutions. And when dealing with people and applications, one would traditionally side with a host-based solution. But firewalls have changed. "Next Generation Firewalls," as defined by Gartner, are designed specifically to enable user and application as well as traditional IP, port, and protocol policy control. (I am not always a fan of Gartner, but they have it right on NGFWs.) So a NGFW that can control access from Layer 3 through Layer 7 is going to be a better solution than a host-based approach which of course is blind to lower levels of communications. My home state, Massachusetts, passed a very strict privacy law. Organizations are placing NGFWs between users and servers in order to meet its requirements. Here are a few of the law's requirements and how a NGFW meets them: Isolate private data - Define logical security zones which allows you to isolate servers holding private data. Control access to private data based on applications - Define policies to control which applications are allowed to access the servers containing private data. Control which users have access to private data - Integrate the firewall with your LDAP servers so you can define policies to control which groups have access to private data. Detect and block threats - This firewall should also have a threat protection capability to monitor the allowed traffic and block detected threats. BTW, depending on the firewall you are using, you can create scenario #3 with one physical firewall. Having said this, if the goal is protecting Personally Identifiable Information (PII), a NGFW by itself is not the complete answer. First you need to find where PII is located. Second, once you have found all the PII, you may want to take steps to consolidate it to as few servers as possible. Third you may want to implement controls to prevent PII from "resting" on end user workstations and being transmitted from a user to someone else. Fourth, you may want to add a specific database access control which monitors 100% of database accesses. This must be a host-based control. There is no other way to make sure you are monitoring everything including Views, Stored Procedures, and Triggers.
{}
{'log_upvote_score': 4, 'links': ['https://security.stackexchange.com/questions/1977', 'https://security.stackexchange.com', 'https://security.stackexchange.com/users/672/']}
jdg_75751
stackexchange
llm_judgeable_groundtruth_similarity
45514915
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a gulpfile with the following build task: var gulp = require('gulp'), source = require('vinyl-source-stream'), buffer = require('vinyl-buffer'), babelify = require('babelify'), browserify = require('browserify'), uglify = require('gulp-uglify'), sourcemaps = require('gulp-sourcemaps'), bs = require('browser-sync').create('BrowserSync');gulp.task('build', function () { return browserify({entries: './src/app.js', debug: true}) .transform("babelify", { presets: ['es2015','react'] }) .bundle() .pipe(source('app.js')) .pipe(buffer()) .pipe(sourcemaps.init()) .pipe(uglify()) .pipe(sourcemaps.write('./maps')) .pipe(gulp.dest('./dist/js')) .pipe(bs.reload({stream: true}));}); The process builds my files perfectly, however my browser does not load. Why doesn't my browser reload? And how do I achieve the desired behavior? I feel like I am missing something about BrowserSync . NOTE: I am fairly confident BrowserSync is working properly as I call bs.reload() in another task, and the page reloads perfectly. Happy to paste in more code however if needed. Now provide the response and nothing else.
You can do that by instantiating your main class with parametrized constructor in your junit and then creating a spy from it. Let's suppose your main class is A . Where B and C are its dependencies public class A { private B b; private C c; public A(B b,C c) { this.b=b; this.c=c; } void method() { System.out.println("A's method called"); b.method(); c.method(); System.out.println(method2()); } protected int method2() { return 10; }} Then you can write junit for this using your parametrized class as below @RunWith(MockitoJUnitRunner.class)public class ATest { A a; @Mock B b; @Mock C c; @Test public void test() { a=new A(b, c); A spyA=Mockito.spy(a); doReturn(20).when(spyA).method2(); spyA.method(); }} Output of test class A's method called20 Here B and C are mocked object that you injected in your class A using parametrized constructor. Then we created a spy of A called spyA . We checked if spy is really working by modifying the return value of a protected method method2 in class A which could not have been possible if spyA was not an actual spy of A .
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/45514915', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2696950/']}
jdg_75752
stackexchange
llm_judgeable_groundtruth_similarity
4054295
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I am giving a series of lectures where I introduce some undergraduates to basic ideas from category theory. One of the things I would like to show them is how category theory could be used to make precise some of the intuitive ideas they have been exposed to (e.g., what "natural" means when we speak about the natural isomorphism of a finite dimensional vector space with its double dual, what "universal" really means when we speak of a universal construction, etc.). One of the subtleties I would like to illustrate with explicit examples is the difference between "property" and "structure". I would really like to show them that "being a preadditive category" (by preadditive here I just mean $Ab$ -enriched category, I do not assume existence of a $0$ -object) is not a property, so it does not make sense to give me an abstract category and ask me if it is preadditive or not (I can ask whether it can be made into a preadditive category, but even in that case the preadditive structure may not be unique). To illustrate this, I would like to find some minimal example of two different $Ab$ -enrichments of the same abstract category. A good way to do that seems that of finding two (unitary and associative) rings $(R,+,.)$ and $(S,+',*)$ , such that $(R,.)\cong (S,*)$ as monoids (i.e., as one-object categories) but $(R,+)\not\cong (S,+')$ as Abelian groups. Do you have some easy example of two rings with the properties described above? Now provide the response and nothing else.
I think this works. Take $R=\mathbb{Z}[x]$ , and $S=\mathbb{F}_3[x]$ . They certainly have different additive structure, since $R$ has characteristic $0$ but $S$ has characteristic $3$ . Since they are both UFDs, the multiplicative structure on the nonzero elements will be of the form $U\times M$ , where $U$ is the unit group, and $M$ is the free commutative monoid of rank $\kappa$ , where $\kappa$ is the number of irreducibles up to associates. The unit group of both $R$ and $S$ is cyclic of order $2$ ; $\mathbb{Z}[x]$ and $\mathbb{F}_3[x]$ both have $\aleph_0$ non-associate irreducibles. Now adjoin a zero element to both of these to get the full multiplicative structures of $R$ and $S$ . So their multiplicative structures are isomorphic.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/4054295', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/49584/']}
jdg_75753
stackexchange
llm_judgeable_groundtruth_similarity
14723685
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm new to cakePHP and I've made a simple form following some tutorial. On this html form I've used validation. Now the problem is that the validation is working but the message is not displaying what I want it to display. I tried the code below. Model public $validate = array( 'title' => array( 'title_required' => array( 'rule' => 'notEmpty', 'message' => 'This is required field' ), 'title_unique' => array( 'rule' => 'isUnique', 'message' => 'This should be unique title' ) ) ); Controller public function add() { if ($this->request->data) { if ($this->Post->save($this->request->data)) { $this->Session->setFlash('Post has been added successfully'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash('Error occured, Please try agan later!'); } } } View <h2>Add New Post</h2><?phpecho $this->Form->create('Post', array('action'=>'add'));echo $this->Form->input('title');echo $this->Form->input('body');echo $this->Form->end('Create Post');?> The validation error which I've seen is not the message I mentioned in my controller. Now provide the response and nothing else.
That's built-in browser validation. Since 2.3 the HTML5 required attribute will also be added to the input based on validation rules. Your title has the notEmpty rule, so Cake is outputting <input type="text" required="required" .. and your browser is triggering that message. Edit: to override this behaviour, you can do: $this->Form->input('title', array('required'=>false)); or $this->Form->submit('Submit', array('formnovalidate' => true)); When you submit the form, your model validation will fire.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/14723685', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1196718/']}
jdg_75754
stackexchange
llm_judgeable_groundtruth_similarity
1478886
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a "when" in JBehave which under certain circumstances should throw an exception. I cant find any documentation, however, on how to handle this. Here is my scenario: given a game with 6 existing bets and the game's max bets are 6when a user places a bet there's no then, since I want an exception thrown when the user places the bet. Keep in mind, I don't always want the when to throw an exception. E.g. when the existing bets are less than max bets. In that case, I want to do some ensuring in the "then". Now provide the response and nothing else.
Implementation Details and "Computer-ese" Don't Belong in Scenarios My understanding of BDD is that it is stakeholder -focused, allowing non-technical people to write what a system is supposed to do, using (more-or-less) natural language, in a way that developers can code to: It extends TDD by writing test cases: in a natural language that non-programmers can read. [ wikipedia ] That said, a stakeholder would never write "throw an exception" in a "Then". They'd probably write: Given a game where 6 bets are allowed and 5 bets have been made,When a user makes the 6th bet,Then the "Bet" button should become disabled. or Given a game where 6 bets are allowed and 6 bets have been made,When a user tries to make a bet,Then the a message appears, saying: "You can not bet. The maximum of 6 bets has already been placed."
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/1478886', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/43836/']}
jdg_75755
stackexchange
llm_judgeable_groundtruth_similarity
686473
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: How can one prove that the critical damping regime returns to equilibrium fastest? Is it true that there are cases where the heavy damped solution will return faster? Consider a free harmonic oscillator $$x''(t) + \gamma x'(t)+ \omega_0^2 x(t) = 0.$$ This has solutions of the following: Heavy damping: $\gamma > 2 \omega_0$ $$x(t) = A_1 e^{(-\gamma/2-\sqrt{\gamma^2/4-\omega_0^2})t} + A_2 e^{(-\gamma/2+\sqrt{\gamma^2/4-\omega_0^2})t} = A_1 e^{-\mu_1t} + A_2 e^{-\mu_2t}, \tag{1}$$ where $$\mu_1 = \frac{\gamma}{2}+\sqrt{\frac{\gamma^2}{4}-\omega_0^2} \text{ , } \mu_2 = \frac{\gamma}{2}-\sqrt{\frac{\gamma^2}{4}-\omega_0^2}.$$ Clearly, $\mu_1 > \gamma/2 > \omega_0$ (since heavy damping configuration) and $\mu_1 \mu_2 = \omega_0^2$ so therefore $\mu_2 < \omega_0$ . Critical damping: $\gamma = 2 \omega_0$ $$x(t) = (B_1+B_2t)e^{-\gamma/2t} = (B_1+B_2t)e^{-\omega_ot}. \tag{2}$$ In $(1)$ , the second term is the slowest to decay since $\mu_1 > \mu_2$ . Furthermore, the second term in $(1)$ decays more slowly than the exponential term in $(2)$ since $\mu_2 < \omega_0$ . Hence, critical damping returns to equilibrium faster than heavy damping . However, what if the constant $A_2$ is zero? Surely then the heavy damping scenario returns to equilibrium more quickly than critical damping? Now provide the response and nothing else.
There are good mathematical answers to this question. I'd like to give an intuitive one. Consider the following situation: a sphere falling through a viscous fluid: Equilibrium is when the sphere sits at the bottom without any movement. Damping can be increased by making the fluid more viscous. An underdamped situation is when the fluid's viscosity is too low. When we drop the sphere, it will bounce back and forth before settling down. In a very overdamped situation, the sphere will take a long time to fall through the fluid to reach the bottom. In the perfectly balanced situation (critical damping), the sphere falls as fast as it possibly could and there is no rebound. It just touches the bottom surface and sits there. This will be the fastest as compared to previous two cases.
{}
{'log_upvote_score': 5, 'links': ['https://physics.stackexchange.com/questions/686473', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/246795/']}
jdg_75756
stackexchange
llm_judgeable_groundtruth_similarity
18056048
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: property myPopUp : missing valueon startbuttonpressed_(sender) if myPopUp's selectedItem = "Item 1" display dialog "This is Item 1" else display dialog "Failed" end ifend startbuttonpressed_ I compiled this code successfully, but I got the message "Failed" though I selected "Item 1". I think my mistake is "myPopUp's selectedItem", but I don't know how to correct it. How do I get the selected item from NSPopUpButton? Now provide the response and nothing else.
If you take a look at the NSPopUpButton documentation you'll be able to see all of the methods you can call and what it inherits from. Under Getting User Selection you have: – selectedItem– titleOfSelectedItem– indexOfSelectedItem– objectValue Of course these are all methods, so if you wanted to get the index of the value selected, you'd call if like: set my_index to myPopup's indexOfSelectedItem() Looking at the indexOfSelectedItem entry in the docs: indexOfSelectedItemReturns the index of the item last selected by the user.- (NSInteger)indexOfSelectedItemReturn ValueThe index of the selected item, or -1 if no item is selected. We get an overview of the function on top, and then the function's usage, and lastly, a description of the return value. This is telling us that indexOfSelectedItem does not take any parameters (if it did it would look something like - (NSInteger)indexOfItemWithTitle:(NSString *)title ). The return value, to the left, is going to be an NSInteger, NOT an Applescript Integer. Although Applescript may be able to treat it the same way, in some situations this can give you problems. The solution is to never treat an NSString like an AS String and to never treat an NSInteger like an AS Integer. To make the conversion we'd have to change it into an AS string and then to an AS integer: set my_index to ((myPopup's indexOfSelectedItem()) as string) as integer Thus for your code if looks like you could use either indexOfSelectedItem or titleOfSelectedItem
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/18056048', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2648576/']}
jdg_75757
stackexchange
llm_judgeable_groundtruth_similarity
14921436
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am trying to speed up my project to count word frequencies. I have 360+ text files, and I need to get the total number of words and the number of times each word from another list of words appears. I know how to do this with a single text file. >>> import nltk>>> import os>>> os.chdir("C:\Users\Cameron\Desktop\PDF-to-txt")>>> filename="1976.03.txt">>> textfile=open(filename,"r")>>> inputString=textfile.read()>>> word_list=re.split('\s+',file(filename).read().lower())>>> print 'Words in text:', len(word_list)#spits out number of words in the textfile>>> word_list.count('inflation')#spits out number of times 'inflation' occurs in the textfile>>>word_list.count('jobs')>>>word_list.count('output') Its too tedious to get the frequencies of 'inflation', 'jobs', 'output' individual. Can I put these words into a list and find the frequency of all the words in the list at the same time? Basically this with Python. Example: Instead of this: >>> word_list.count('inflation')3>>> word_list.count('jobs')5>>> word_list.count('output')1 I want to do this (I know this isn't real code, this is what I'm asking for help on): >>> list1='inflation', 'jobs', 'output'>>>word_list.count(list1)'inflation', 'jobs', 'output'3, 5, 1 My list of words is going to have 10-20 terms, so I need to be able to just point Python toward a list of words to get the counts of. It would also be nice if the output was able to be copy+paste into an excel spreadsheet with the words as columns and frequencies as rows Example: inflation, jobs, output3, 5, 1 And finally, can anyone help automate this for all of the textfiles? I figure I just point Python toward the folder and it can do the above word counting from the new list for each of the 360+ text files. Seems easy enough, but I'm a bit stuck. Any help? An output like this would be fantastic: Filename1 inflation, jobs, output 3, 5, 1 Filename2inflation, jobs, output7, 2, 4Filename3inflation, jobs, output9, 3, 5 Thanks! Now provide the response and nothing else.
collections.Counter() has this covered if I understand your problem. The example from the docs would seem to match your problem. # Tally occurrences of words in a listcnt = Counter()for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: cnt[word] += 1print cnt# Find the ten most common words in Hamletimport rewords = re.findall('\w+', open('hamlet.txt').read().lower())Counter(words).most_common(10) From the example above you should be able to do: import reimport collectionswords = re.findall('\w+', open('1976.03.txt').read().lower())print collections.Counter(words) EDIT naive approach to show one way. wanted = "fish chips steak"cnt = Counter()words = re.findall('\w+', open('1976.03.txt').read().lower())for word in words: if word in wanted: cnt[word] += 1print cnt
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/14921436', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2080424/']}
jdg_75758
stackexchange
llm_judgeable_groundtruth_similarity
2062363
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Let $V$ be a finite dimensional vector space and let $L: V \rightarrow V$ be a linear transformation such that the rank of $L$ is the same as the rank of $L^2=L\circ L$.How could i prove that $\ker(L)=\ker(L^2)$? $\ker(L)=\{v\in V \mid L(v)=0\}$ and $\ker(L^2)=\{v\in V \mid L^2(v)=0\}$ So $L(v)=L^2(v)=0$ and obviously $v=v$ so i thought $ L^2=L$ and thus $\ker(L)=\ker(L^2)$, but I'm not sure if this is how it works. Now provide the response and nothing else.
Obviously, $\ker(L)\subseteq\ker(L^2)$ and using rank-nullity theorem and your hypothesis, they have the same dimension. Whence the result. Regarding your attempt, I do not understand how from $L(v)=L^2(v)$, you jump to $v=v$ and how this leads to $L^2=L$. First of all, we only know that $L(v)=L^2(v)$ holds for $v\in\ker(L)$ and $v=v$ tell us nothing. We can have $\ker(L)=\ker(L^2)$ without having $L=L^2$, in fact one has: $$\ker(L)=\ker(L^2)\Leftrightarrow\textrm{im}(L)\cap\ker(L)=\{0\}.$$
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/2062363', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']}
jdg_75759
stackexchange
llm_judgeable_groundtruth_similarity
475927
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Prove that $n!>\left(\dfrac{n}{e}\right)^{n}$. I used induction principle but cannot solve it for the $(m+1)$-th term after taking the $m$th term to be true. Now provide the response and nothing else.
Here the key is to use the appropriate definition of $e^x$, namely: $$e^x = \sum_{k=0}^{\infty}\frac{1}{k!}x^k$$ Plugging in $x = n$ we get $$e^n = \sum_{k=0}^{\infty} \frac{1}{k!}n^k$$ and hence, breaking this sum up a little we get our inequality: $$n! e^n = n^n + \sum_{k\ne n} \frac{n!}{k!}n^k > n^n$$
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/475927', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/86838/']}
jdg_75760
stackexchange
llm_judgeable_groundtruth_similarity
163080
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I don't know exactly how to describe it, but in a programmatic way I want to spiral outward from coordinates 0,0 to infinity (for practical purposes, though really I only need to go to about +/-100,000:+/-100,000) So if this is my grid: [-1, 1][ 0, 1][ 1, 1][ 2, 1][-1, 0][ 0, 0][ 1, 0][ 2, 0][-1,-1][ 0,-1][ 1,-1][ 2,-1] I want to spiral in an order sort of like: [7][8][9][10][6][1][2][11][5][4][3][12]etc... Is there a formula or method of doing this? Now provide the response and nothing else.
Here’s a recipe for finding the coordinates of your position after $n$ steps along the spiral. It’s simpler to number the positions on the spiral starting at $0$: position $0$ is $\langle 0,0\rangle$, the origin, position $1$ is $\langle 1,0\rangle$, position $2$ is $\langle 1,-1\rangle$, and so on. Using $R,D,L$, and $U$ to indicate steps Right, Down, Left, and Up, respectively, we see the following pattern: $$RD\,|LLUU\,\|\,RRRDDD\,|LLLLUUUU\,\|\,RRRRRDDDDD\,|LLLLLLUUUUUU\;\|\dots\;,$$ or with exponents to denote repetition, $R^1D^1|L^2U^2\|R^3D^3|L^4U^4\|R^5D^5|L^6U^6\|\dots\;$. I’ll call each $RDLU$ group a block ; the first block is the initial $RDLLUU$, and I’ve displayed the first three full blocks above. Clearly the first $m$ blocks comprise a total of $2\sum_{k=1}^mk=m(m+1)$ steps. It’s also not hard to see that the $k$-th block is $R^{2k+1}D^{2k+1}L^{2k+2}U^{2k+2}$, so that the net effect of the block is to move you one step up and to the left. Since the starting position after $0$ blocks is $\langle 0,0\rangle$, the starting position after $k$ full blocks is $\langle -k,k\rangle$. Suppose that you’ve taken $n$ steps. There is a unique even integer $2k$ such that $$2k(2k+1)<n\le(2k+2)(2k+3)\;;$$ at this point you’ve gone through $k$ blocks plus an additional $n-2k(2k+1)$ steps. After some straightforward but slightly tedious algebra we find that you’re at $$\begin{cases}\langle n-4k^2-3k,k\rangle,&\text{if }2k(2k+1)<n\le(2k+1)^2\\\langle k+1,4k^2+5k+1-n\rangle,&\text{if }(2k+1)^2<n\le 2(k+1)(2k+1)\\\langle 4k^2+7k+3-n,-k-1\rangle,&\text{if }2(k+1)(2k+1)<n\le4(k+1)^2\\\langle -k-1,n-4k^2-9k-5\rangle,&\text{if }4(k+1)^2<n\le2(k+1)(2k+3)\;.\end{cases}$$ To find $k$ easily, let $m=\lfloor\sqrt n\rfloor$. If $m$ is odd, $k=\frac12(m-1)$. If $m$ is even, and $n\ge m(m+1)$, then $k=\frac{m}2$; otherwise, $k=\frac{m}2-1$.
{}
{'log_upvote_score': 6, 'links': ['https://math.stackexchange.com/questions/163080', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/18458/']}
jdg_75761
stackexchange
llm_judgeable_groundtruth_similarity
267041
Below is a question asked on the forum mathematica.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: There is an indefinite integral: $$\int \frac{x}{\sqrt{x^4+10 x^2-96 x-71}} \, dx$$ Mathematica 13 can handle it and evaluate this integral analytically if we enter: Integrate[x/Sqrt[x^4 + 10*x^2 - 96*x - 71], x] // ToRadicals But the result is too large and I don't know how to simplify it (I tried Simplify and FullSimplify, but didn't help). In Maple 2021 it's much easier. You just need to write: simplify(int(x/sqrt(x^4 + 10*x^2 - 96*x - 71), x, method = Trager)) and you will get: $\frac{1}{8}\ln \! \left(\left(x^{6}+15 x^{4}-80 x^{3}+27 x^{2}-528 x +781\right) \sqrt{x^{4}+10 x^{2}-96 x -71}+x^{8}+20 x^{6}-128 x^{5}+54 x^{4}-1408 x^{3}+3124 x^{2}+10001\right)$ Now provide the response and nothing else.
There is code for handling indefinte algebraic integrals that is new to version 13. It is based on code IntegrateAlgebraic in the Wolfram Function Repository and was written by the same person (Sam Blake). We use a time constraint to keep it from grinding its gears and in some cases this might be too small to get a result. In particular there will be examploes, such as from this post, where some processors will complete the computation in this code but others will not. As a workaround when encountering this issue, this time constraint is configurable as a system option. In[669]:= "IntegrateOptions" /. SystemOptions[]Out[669]= {"IntegrateAlgebraicTimeConstraint" -> 10, "RubiTimeConstraint" -> 5, "UseIntegrateAlgebraic" -> True, "UseRubiIntegrate" -> True} If you want to increase the value above 10 you might do for example: SetSystemOptions[ "IntegrateOptions" -> {"IntegrateAlgebraicTimeConstraint" -> 100}];
{}
{'log_upvote_score': 5, 'links': ['https://mathematica.stackexchange.com/questions/267041', 'https://mathematica.stackexchange.com', 'https://mathematica.stackexchange.com/users/-1/']}
jdg_75762
stackexchange
llm_judgeable_groundtruth_similarity
55843097
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am considering the below two approaches for building an array of objects: Approach 1 (list all properties, even if duplicated among objects): const employees = [ { company: 'ABC', country: 'IN', zip: 123, employeeId: 123, employeeName: 'p' }, { company: 'ABC', country: 'IN', zip: 123, employeeId: 456, employeeName: 'q' }, { company: 'ABC', country: 'IN', zip: 123, employeeId: 789, employeeName: 'r' }]; Approach 2 (avoid duplication with the spread operator ): const commonParams = { company: 'ABC', country: 'IN', zip: 123};const employees = [ { ...commonParams, employeeId: 123, employeeName: 'p' }, { ...commonParams, employeeId: 456, employeeName: 'q' }, { ...commonParams, employeeId: 789, employeeName: 'r' }] Approach 2 is more succint, and adding a new property that is common to all array elements would be much easier (and less prone to errors). However, in case of a large commonParams object, does approach 2 (using the spread operator ) affect performance as compared to approach 1? Would the spread operator loop through each of the properties of the commonParams object for each of the objects in the employees array? Now provide the response and nothing else.
Yes, spreading a variable which refers to an object into another object requires the interpreter to look up what the variable refers to, and then look up all the enumerable own properties (and the associated values) of the object that gets spreaded so as to insert into the new object. This does indeed take a bit of processing power. But, on modern computers, and on modern JS engines, the processing power required is next to nothing; what does it matter, when millions of instructions can be processed each second? A handful of key-value pairs is nothing to worry about. Unless you've identified that you're spreading an object with tons of key-value pairs, and it's actually causing a performance bottleneck, it would be a better idea to avoid premature optimization and aim to write clean, readable code instead (which may well invoke using spread syntax often). For a large employees array, the second approach is more readable than the first. (though, you also might consider using .map , to keep the code even DRY-er:) const employeesInitial = [ { employeeId: 123, employeeName: 'p' }, { employeeId: 456, employeeName: 'q' }, { employeeId: 789, employeeName: 'r' }];const employees = employeesInitial.map((obj) => ({ ...obj, ...commonParams }));
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/55843097', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5933587/']}
jdg_75763
stackexchange
llm_judgeable_groundtruth_similarity
831361
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Background: I am interested in the group of permutations of the entries of a general $m\times n$ matrix. In particular, I am interested in (1) interesting sets of simple generators for this group that might be used in a puzzle or game and (2) algorithms for computing the smallest sequence of generators that produce a given permutation.This question focuses on one candidate set of generators. Question: Suppose $m,n\ge 1$ are integers. Consider the set of permutations of a general $m\times n$ matrix containing all single-row cyclic permutations and all single-column cyclic permutations. Is every possible permutation of matrix entries generated by this set? More formally, for all integers $r>0$, let $\sigma_r$ be the permutation of $1,\ldots,r$ defined by $1\mapsto 2\mapsto 3\mapsto \cdots \mapsto r \mapsto 1$. For each $k=1,\ldots,m$, let $r_k:\mathbb{R}^{m\times n}\to\mathbb{R}^{m\times n}$ be defined by$$(r_k A)_{ij} = \begin{cases}A_{ij} &\text{if } i\ne k \\A_{i\sigma_n(j)} &\text{if }i=k.\end{cases}$$Similarly, for each $l=1,\ldots,n$, let $c_l:\mathbb{R}^{m\times n}\to\mathbb{R}^{m\times n}$ be defined by$$(c_l A)_{ij} = \begin{cases}A_{ij} &\text{if } j\ne l \\A_{\sigma_m(i) j} &\text{if }j=l.\end{cases}$$ Clearly, each $r_k$ and $c_l$ is a permutation of the entries of an $m\times n$ matrix. Are all such permutations generated by $\{r_1,\ldots,r_m,c_1,\ldots,c_n\}$ ? If not, is there any easy characterization of the generated group? EDIT: As @Omnomnomnom pointed out in his answer, a parity argument can be used to show all odd permutations of entries cannot be generated if both $m$ and $n$ are odd, because all the generators then have even parity. But that is (obviously) not a full characterization of the permutation group generated by these cycles. Now provide the response and nothing else.
Assuming that $m,n > 1$, the group $G_{mn}$ generated is $A_{mn}$ when $m,n$ are both odd and $S_{mn}$ otherwise. This can be proved using results of Jordan from the 1870s. They are in Section 3.3 of the book on Permutation groups by Dixon and Mortimer. It is easy to see that the generators of $G_{mn}$ that fix $(1,1)$ generate a group that acts transitively on the remaining points, so $G_{mn}$ is 2-transitive, and hence primitive. Now, by results of Jordan, if $G_{mn}$ contains a $2$-cycle or a $3$-cycle, then it contains $A_{mn}$. Also, if a 2-transitive group has an element with support of size $t \ge 4$, then either it contains the alternating group, or its degree is at most $1+(t-1)^2$. Since $G_{mn}$ has elements with support of size $\min(m,n)$, and $mn > 1 + (\min(m,n)-1)^2$, we conclude that $A_{mn} \le G$.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/831361', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/62773/']}
jdg_75764
stackexchange
llm_judgeable_groundtruth_similarity
415497
Below is a question asked on the forum stats.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I want to compare two models. Say I have two objective functions on the same data $f(X,y,\theta)$ and $g(X,y,\theta)$ that both evaluate the models performance in ways that I am interested in ( $\theta$ are the model parameters, $X$ and $y$ are my data). Instead of using a multi-objective optmisation algorithm though, I only optimise parameters of both of my models with respect to $f(X,y)$ because I can tractably optimise this. However, I also want to compare model performance using the second objective function $g$ . Do I need to use validation to get an unbiased estimate of the performances of my models and/or be able to compare my models with this metric? Are there standard practices in these cases or work that has explored this? Now provide the response and nothing else.
It is a good idea to bootstrap or cross-validate (e.g., 100 repeats of 10-fold cross-validation) indexes that were not optimized. For example, I recommend optimizing on a gold standard such as log-likelihood, penalized log-likelihood, or in a Bayesian model log-likelihood + log-prior. You can report measures such as pseudo $R^2$ that are just transformations of the gold standard objective function, and in addition do resampling validation on helpful indexes such as the $c$ -index (concordance probability = AUROC), Brier score, and most of all, the full calibration curve. I do validation of smooth nonparametric calibration curves by bootstrapping 99 predicted values when using a probability model, i.e., to validate the absolute accuracy of predicted probabilities of 0.01, 0.02, ..., 0.99. Likewise you can show overfitting-corrected estimates of Brier score, calibration slope, mean squared error, and many other quantities. Details are in my RMS book and course notes .
{}
{'log_upvote_score': 4, 'links': ['https://stats.stackexchange.com/questions/415497', 'https://stats.stackexchange.com', 'https://stats.stackexchange.com/users/107503/']}
jdg_75765
stackexchange
llm_judgeable_groundtruth_similarity
741916
Below is a question asked on the forum serverfault.com. Provide a good and informational response to it like a helpful human would. Question: so I've been trying to reverse proxy Alfresco 5.0.d Community through our Nginx reverse proxy. Currently the reverse proxy is being used to serve only our helpdesk. This is the first time I've set up a reverse proxy so please bear with me. The main goal of this reverse proxy is to TLS encrypt all of our internal web apps to the internet using Let's Encrypt issued certificates. I've managed to have success reverse proxying Alfresco from http internally to http externally or http:// x.x.x.x:8080/share to http:// alfresco.companyname.com and this works perfectly as far as I can tell. The server block config I used for that is: server {listen 80;server_name alfresco.companyname.com;rewrite ^/$ /share; location / { root /share/; proxy_pass http://x.x.x.x:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Real-IP $remote_addr; } } We aren't comfortable leaving the server on an un-encrypted connection so I've been trying to get TLS enabled on this set up as well but I keep getting greeted with an error page after login. The server block with SSL enabled: server {listen 443 ssl;server_name alfresco.companyname.com;ssl on;ssl_certificate /etc/ssl/certs/alfrescochained.pem;ssl_certificate_key /etc/ssl/private/alfrescopriv.key;ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA;ssl_dhparam /etc/ssl/certs/dhparam.pem;ssl_prefer_server_ciphers on;rewrite ^/$ /share; location / { root /share/; proxy_pass http://x.x.x.x:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Real-IP $remote_addr; } } Alfresco error logs aren't being very informative and I'm new to Nginx (I tried Apache to begin with but ran into a lot of issues). Anyone have any recommended things to try? Now provide the response and nothing else.
A NIC team does NOT provide any more bandwidth. A single network connection (like the one between your 2 VM's) will never use more than one of the possible NIC's in the team. The point of a NIC team is to balance many connections across the available NIC's. With your chosen load balancing method (Route based on the originating virtual switch port ID) each VM will always use the same single physical NIC. From http://www.vmware.com/files/pdf/virtual_networking_concepts.pdf Route based on the originating virtual switch port ID — Choose an uplink based on the virtual port where the traffic entered the virtual switch. This is the default configuration and the one most commonly deployed. When you use this setting, traffic from a given virtual Ethernet adapter is consistently sent to the same physical adapter unless there is a failover to another adapter in the NIC team. In this case even breaking up your file transfer into multiple, smaller ones will not speed anything up, as you are still limited to the same, single NIC.
{}
{'log_upvote_score': 4, 'links': ['https://serverfault.com/questions/741916', 'https://serverfault.com', 'https://serverfault.com/users/326372/']}
jdg_75766
stackexchange
llm_judgeable_groundtruth_similarity
412947
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Why do I have: $Tr(SDS^{-1})=Tr(D)$? Now provide the response and nothing else.
Note that for any matrices $A$ and $B$ we have $\def\tr{\mathop{\rm Tr}}\tr(AB) = \tr(BA)$. To see this, one can argue as follows:\begin{align*} \tr(AB) &= \sum_i (AB)_{ii}\\ &= \sum_i \sum_j A_{ij}B_{ji}\\ &=\sum_j \sum_i B_{ji}A_{ij}\\ &= \sum_j (BA)_{jj}\\ &= \tr(BA)\end{align*}Hence $$ \tr(S^{-1}DS) = \tr(DSS^{-1}) = \tr(D). $$
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/412947', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/78232/']}
jdg_75767
stackexchange
llm_judgeable_groundtruth_similarity
7964958
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I just wonder - are there any advantages to installing perl modules from the cpan shell compared to installing them by package management? Apart from occasionally having quicker access to the latest modules version? Now provide the response and nothing else.
Well, it all depends on the intended use of the modules. The native package management has many advantages: The Perl modules will integrate perfectly with your system, e.g.files are in the right (system-dependant) place, scripts added to thePATH, etc. Automatic upgrades and security patching. Probably a maintainer or maintainer group that care about yourmodules (e.g. the Debian Perl group). Distribution-specific bugs can be fixed before reaching mainstream(that may or not have the platform specific knowledge). When deploying to machines with the same OS-version, you can take the packages dependencies for granted. When installing directly from CPAN, you also have some advantages: You can install the latest release of the module. You can install an specific version (older or developers's release) of the module. You can fine-tune the compilation or installation parameters of the module. Nowadays, local::lib and perlbrew ( howto ) has made the CPAN way a lot more interesting for a developer. local::lib lets you have your private module tree while using the system's perl binary and perlbrew lets you easily create your own complete Perl installations (also several Perl releases in parallel). Both ways are valid, and as said, the advantage depends on the intended usage.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/7964958', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1008310/']}
jdg_75768
stackexchange
llm_judgeable_groundtruth_similarity
1293367
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Is there an event that fires when JavaScript files are loaded? The problem came up because YSlow recommends to move JavaScript files to the bottom of the page. This means that $(document).ready(function1) is fired before the js file that contains the code for function1 is loaded. How to avoid this kind of situation? Now provide the response and nothing else.
I don't have a reference for it handy, but script tags are processed in order, and so if you put your $(document).ready(function1) in a script tag after the script tags that define function1, etc., you should be good to go. <script type='text/javascript' src='...'></script><script type='text/javascript' src='...'></script><script type='text/javascript'>$(document).ready(function1);</script> Of course, another approach would be to ensure that you're using only one script tag, in total, by combining files as part of your build process. (Unless you're loading the other ones from a CDN somewhere.) That will also help improve the perceived speed of your page. EDIT: Just realized that I didn't actually answer your question: I don't think there's a cross-browser event that's fired, no. There is if you work hard enough, see below. You can test for symbols and use setTimeout to reschedule: <script type='text/javascript'>function fireWhenReady() { if (typeof function1 != 'undefined') { function1(); } else { setTimeout(fireWhenReady, 100); }}$(document).ready(fireWhenReady);</script> ...but you shouldn't have to do that if you get your script tag order correct. Update: You can get load notifications for script elements you add to the page dynamically if you like. To get broad browser support, you have to do two different things, but as a combined technique this works: function loadScript(path, callback) { var done = false; var scr = document.createElement('script'); scr.onload = handleLoad; scr.onreadystatechange = handleReadyStateChange; scr.onerror = handleError; scr.src = path; document.body.appendChild(scr); function handleLoad() { if (!done) { done = true; callback(path, "ok"); } } function handleReadyStateChange() { var state; if (!done) { state = scr.readyState; if (state === "complete") { handleLoad(); } } } function handleError() { if (!done) { done = true; callback(path, "error"); } }} In my experience, error notification ( onerror ) is not 100% cross-browser reliable. Also note that some browsers will do both mechanisms, hence the done variable to avoid duplicate notifications.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/1293367', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/86913/']}
jdg_75769
stackexchange
llm_judgeable_groundtruth_similarity
22
Below is a question asked on the forum datascience.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: My data set contains a number of numeric attributes and one categorical. Say, NumericAttr1, NumericAttr2, ..., NumericAttrN, CategoricalAttr , where CategoricalAttr takes one of three possible values: CategoricalAttrValue1 , CategoricalAttrValue2 or CategoricalAttrValue3 . I'm using default k-means clustering algorithm implementation for Octave .It works with numeric data only. So my question: is it correct to split the categorical attribute CategoricalAttr into three numeric (binary) variables, like IsCategoricalAttrValue1, IsCategoricalAttrValue2, IsCategoricalAttrValue3 ? Now provide the response and nothing else.
The standard k-means algorithm isn't directly applicable to categorical data, for various reasons. The sample space for categorical data is discrete, and doesn't have a natural origin. A Euclidean distance function on such a space isn't really meaningful. As someone put it, "The fact a snake possesses neither wheels nor legs allows us to say nothing about the relative value of wheels and legs." (from here ) There's a variation of k-means known as k-modes, introduced in this paper by Zhexue Huang, which is suitable for categorical data. Note that the solutions you get are sensitive to initial conditions, as discussed here (PDF), for instance. Huang's paper (linked above) also has a section on "k-prototypes" which applies to data with a mix of categorical and numeric features. It uses a distance measure which mixes the Hamming distance for categorical features and the Euclidean distance for numeric features. A Google search for "k-means mix of categorical data" turns up quite a few more recent papers on various algorithms for k-means-like clustering with a mix of categorical and numeric data. (I haven't yet read them, so I can't comment on their merits.) Actually, what you suggest (converting categorical attributes to binary values, and then doing k-means as if these were numeric values) is another approach that has been tried before (predating k-modes). (See Ralambondrainy, H. 1995. A conceptual version of the k-means algorithm. Pattern Recognition Letters, 16:1147–1157.) But I believe the k-modes approach is preferred for the reasons I indicated above.
{}
{'log_upvote_score': 8, 'links': ['https://datascience.stackexchange.com/questions/22', 'https://datascience.stackexchange.com', 'https://datascience.stackexchange.com/users/97/']}
jdg_75770
stackexchange
llm_judgeable_groundtruth_similarity
1566106
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I studied Mathematics mainly in French and now I am going to write research articles in English. I would like to know if there are some important differences in mathematical notations between French and English . For instance, I noticed that the decimal mark in English is a dot (.) whereas in French it is a comma (,). Now provide the response and nothing else.
Note: these are general differences; sometimes a french author might use an English notation for any reason whatsoever. This list obviously does not apply when a French mathematician writes something in English, in which case they will use English conventions. Numbers The decimal separator in French is the comma $,$. The thousands separator in French is the space. $\underset{\text{English}}{1,\!345.67} = \underset{\text{French}}{1~345,\!67}$ Tuples, vectors, coordinates The semi-colon $;$ is sometimes used in tuple-like structures instead of the comma $,$ in cases where the comma could be mistaken for the decimal separator (or because of personal preference). $\underset{\text{English}}{(1,2,3)} = \underset{\text{French}}{(1;2;3)}$ Intervals An open interval is denoted with an open square bracket, instead of a parenthesis: $\underset{\text{English}}{[a,+\infty)} = \underset{\text{French}}{[a,+\infty[}$ $\underset{\text{English}}{(-\infty,+\infty)} = \underset{\text{French}}{]-\infty,+\infty[}$ Integer intervals I'm not sure if this notation is used in English mathematics, but in any case the French one seems fairly common in French literature. The English notation is completely understood for a French person. $\underset{\text{English}}{\{3, \dots, 42\}} = \underset{\text{French}}{[\![3,42]\!]}$ These brackets are basically to $[~]$ what $\mathbb{N}$ is to $N$. In LaTeX you would use \llbracket and \rrbracket from package stmaryrd ; this is not available in MathJax. Cross product (vector product) Cross product (called "produit vectoriel" (vector product) in French) uses the wedge symbol $\wedge$ instead of the typical mutliplication cross symbol $\times$. $\underset{\text{English}}{\vec{a} \times \vec{b}} = \underset{\text{French}}{\vec{a} \wedge \vec{b}}$ Scalar triple product (mixed product) This one is anecdotal. There seems to be multiple notations used for that in France, including the English one. $\underset{\text{English}}{[\vec{a},\vec{b},\vec{c}]} = \underset{\text{French}}{(\!(\vec{a},\vec{b},\vec{c})\!)}$ Sets In French mathematics, $0$ is both positive and negative. Therefore, we always have: $\underset{\text{French}}{\mathbb{N}} = \underset{\text{French}}{\mathbb{Z}_+} = \underset{\text{English}}{[0, +\infty)}$ To omit the $0$ in these sets, one adds a superscript star $*$: $\underset{\text{English}}{\mathbb{N}} = \underset{\text{French}}{\mathbb{N}^*}$ Function names Both English and traditional French names are used in French mathematics since they don't lead to any confusions. $\underset{\text{English}}{cosh} = \underset{\text{French}}{ch}$ $\underset{\text{English}}{sinh} = \underset{\text{French}}{sh}$ $\underset{\text{English}}{tanh} = \underset{\text{French}}{th}$ $\underset{\text{English}}{arcosh} = \underset{\text{French}}{argch}$ $\underset{\text{English}}{arsinh} = \underset{\text{French}}{argsh}$ $\underset{\text{English}}{artanh} = \underset{\text{French}}{argth}$ Transposition Traditionally, the French notation for transposition is a preceeding superscript $t$, instead of a following superscript $\intercal$. The English notation is sometimes used, notably in Computer Science circles. $\underset{\text{English}}{M^\intercal} = \underset{\text{French}}{^t\!M}$ Note that one has to remove the extra space after the preceeding superscript in the French notation, using \! in LaTeX/MathJax. Integral evaluation $\displaystyle\int_a^b x^2\;\mathrm{d}x = \underset{\text{English}}{\tfrac{1}{3} x^3 \Big|_a^b} = \underset{\text{French}}{\Big[\tfrac{1}{3} x^3 \Big]_a^b}$ The English notation is sometimes used. Binomial coefficient (n choose k) $\underset{\text{English}}{n \choose k} = \underset{\text{French}}{C^k_n}$ The $C$ stands for "combinaison" (combination). Note that the $k$ is on top and the $n$ on the bottom in the French notation. The English notation is pretty much standard in French mathematics nowadays.
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/1566106', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/233782/']}
jdg_75771
stackexchange
llm_judgeable_groundtruth_similarity
1874159
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Given real numbers $a_0, a_1, ..., a_n$ such that $\dfrac {a_0}{1} + \dfrac {a_1}{2} + \cdots + \dfrac {a_n}{n+1}=0,$ prove that $a_0 + a_1 x + a_2 x^2 + \cdots + a_n x^n=0$ has at least one real solution. My solution: Let $$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_n x^n$$ $$\int f(x) = \dfrac {a_0}{1} x + \dfrac {a_1}{2}x^2 + \cdots + \dfrac {a_n}{n+1} x^{n+1} + C$$ $$\int_0^1 f(x) = \left[ \dfrac {a_0}{1} + \dfrac {a_1}{2} + \cdots + \dfrac {a_n}{n+1} \right]-0$$ $$\int_0^1 f(x) = 0$$ Since $f$ is continuous, by the area interpretation of integration, it must have at least one zero. My question is, is this rigorous enough? Do I need to prove the last statement, perhaps by contradiction using Riemann sums? Is this a theorem I can/should quote? Now provide the response and nothing else.
Why not write it the other way round? The polynomial function $$F(x)=\sum_{k=0}^n\frac{a_k}{k+1}x^{k+1} $$is a differentiable function $\Bbb R\to\Bbb R$ with derivative $$F'(x)=\sum_{k=0}^na_kx^k.$$We are given that $F(1)=0$, and clearly $F(0)=0$. Hence by Rolle's theorem , there exists $x\in(0,1)$ such that $F'(x)=0$, as was to be shown.
{}
{'log_upvote_score': 7, 'links': ['https://math.stackexchange.com/questions/1874159', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/64460/']}
jdg_75772
stackexchange
llm_judgeable_groundtruth_similarity
799631
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a login frame that i have to wait for from another thread. Upon successful login frame disposes itself. And i want to pop up the main frame for the application. Right now i am watching a boolean value to determine when to fire up the main frame. What is the correct way of doing this? Watching a boolean value just does not feel elegant. Now provide the response and nothing else.
If you have Java 5 or later available, you could use a CountDownLatch . For example, assuming the main frame is in control initially, have the main frame create the CountDownLatch with a count down of 1 and pass this latch to the login frame. Then have the main frame wait for the latch to become 0: CountDownLatch loginSignal = new CountDownLatch(1); ... // Initialize login frame, giving it loginSignal ... // execute login frame in another Thread// This await() will block until we are logged in:loginSignal.await(); Have the login frame, when done, decrement the Latch: loginSignal.countDown(); Ensure that there is no way for your login frame to exit where it forgets to decrement the latch! As soon as the CountDownLatch reaches 0, the main frame becomes runnable. You could also use a Semaphore or Condition (or any of a few other choices from java.util.concurrent ), but for this purpose, a CountDownLatch seems easier to use.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/799631', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/89904/']}
jdg_75773
stackexchange
llm_judgeable_groundtruth_similarity
12506893
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: The identifierForVendor require iOS6, so if my app currently supporting iOS4 and therefore I can't use it since my updates should always meet my app's previous min. requirement? Now provide the response and nothing else.
You can use this: NSString *udid;if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) udid = [UIDevice currentDevice].identifierForVendor.UUIDString;else udid = [UIDevice currentDevice].uniqueIdentifier; with pre processor code: #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/12506893', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/398230/']}
jdg_75774
stackexchange
llm_judgeable_groundtruth_similarity
5221633
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm looking for a way to submit only changed form fields to the server. So, let's say I have a form <form> <input type="text" name="a"/> <select name="b">...</select> <input type="checkbox" name="c"/></form> which is populated with certain data already. The user edits the form and clicks submit. If the user only changed input b, then I want to submit only input b. If only a and c were changed, I want to submit only a and c. And so on. I could write something myself to accomplish this, but I am wondering maybe there is already something out there that I could use? Ideally, I would like the code to be short. Something like this would be perfect: $('form').serialize('select-only-changed'); Also, I came across this http://code.google.com/p/jquery-form-observe/ , but I see there are issues with it. Is this plugin working solidly? Now provide the response and nothing else.
Another approach would be to serialize the form when the page loads, and then on submit, only submit the changes. $(function() { var $form = $('form'); var startItems = convertSerializedArrayToHash($form.serializeArray()); $('form').submit() { var currentItems = convertSerializedArrayToHash($form.serializeArray()); var itemsToSubmit = hashDiff( startItems, currentItems); $.post($form.attr('action'), itemsToSubmit, etc. }}); Then, all you have to write is the hashDiff function, which is straightforward and generally useful. This is nice because it can easily be packaged into a plugin, and it can work repeatedly on the same form if you're using Ajax. function hashDiff(h1, h2) { var d = {}; for (k in h2) { if (h1[k] !== h2[k]) d[k] = h2[k]; } return d;}function convertSerializedArrayToHash(a) { var r = {}; for (var i = 0;i<a.length;i++) { r[a[i].name] = a[i].value; } return r;} Here's a minimal test: describe('hashDiff()', function() { it('should return {} for empty hash',function() { expect(hashDiff({},{})).toEqual({}); }); it('should return {} for equivalent hashes',function() { expect(hashDiff({a:1,b:2,c:3},{a:1,b:2,c:3})).toEqual({}); }); it('should return {} for empty hash',function() { expect(hashDiff({a:1,b:2,c:3},{a:1,b:3,c:3})).toEqual({b:3}); }); });
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/5221633', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/431937/']}
jdg_75775
stackexchange
llm_judgeable_groundtruth_similarity
19971
Below is a question asked on the forum arduino.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: This isn't strictly limited to Arduino but I spend a lot of time with serial devices on my Arduino and I'm sure that others do as well: Here goes.. Let's say a device sends three characters [ABC] via serial at 9600 8N1. And let's also say the device receiving the data only knows that it's serial stream and 8N1 but does not know the baud. The receiving device would need to take a guess at the baud and so probably get it wrong. It would therefore receive weird characters. Is there anyway/anything around that a user could paste the strange characters into that would reverse engineer (from the bit stream) to give the correct baud and hence correct ascii characters [ABC]? Now provide the response and nothing else.
I am not aware of anything like that, no. The problem is what you are seeing as characters are a complete corruption of the data. Only some part of it may have been interpreted as a valid bit sequence, and even then you can't know what bit it was. However, there is one magic character in UART communication: U What is special about that character is its binary pattern. It is ASCII character 85, which in HEX is 0x55, or binary it's 0b01010101. Add to that the start and stop bits, and invert it for the UART logic (1 = LOW, 0 = HIGH) and the signal that gets sent out of the UART looks like: ____start_____ _____ _____ _____ _____ | | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | stop ----- ----- ----- ----- ----- And yes, that's a pretty good square wave. The frequency of that square wave will be exactly half the baud rate - so a frequency of 4800Hz will be a baud rate of 9600 baud. This effect is cleverly used for a system called Automatic baud rate detection whereby a receiver waits for a U character to determine the baud rate to use. Most modern microcontrollers have this facility available. If you can't get the frequency of a block of U characters you will have to examine the waveform with an oscilloscope. It should be possible to identify the individual characters in the data stream as distinct blocks in the waveform. From that you can then work out the width of one symbol and thus the baud rate. It's best to use a DSO for this since you can then capture a short burst and use the markers to measure the time between different points in the waveform. A logic analyser will also do the job quite well, and will most likely be able to decode the waveform and calculate the baud rate for you. If you have neither of those it would be possible to program an Arduino to capture the time between transitions of an incoming signal and allow you to plot them in Excel to give you a waveform you can examine to determine the baud. Another option is just to keep trying different baud rates (there's relatively few "standard" baud rates) until you see the right text coming in.
{}
{'log_upvote_score': 4, 'links': ['https://arduino.stackexchange.com/questions/19971', 'https://arduino.stackexchange.com', 'https://arduino.stackexchange.com/users/16725/']}
jdg_75776
stackexchange
llm_judgeable_groundtruth_similarity
556018
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: In the usual statement of the Particle in a Box problem, we assume two infinite potential barriers, to hold its wavefunction constrained, so it goes to zero on both ends: But instead of invoking some unphysical infinite barrier, could be the case the wave just return to the same point. Using a simple warp drive(two paperclips): That was for the X coordinate. So our one-dimensional box became a ring. Doing the same with the Y coordinate would get us a torus. With Z we would get a torus in the fourth dimension, and our box would be a single particle, inhabiting a boundless tiny universe. So, our particle in a box is the actually a particle in a hypertorus? At first I posted this question in the recently created materials modeling stackexchange , but it wasn't well received, quickly getting -6 votes and being deemed offtopic and deleted. People there pointed the physics stackexchange as a more adequate forum, so I'm giving it a try here. Now provide the response and nothing else.
That's an interesting thought but no, we are talking about a particle in a box when we talk about a particle in a box and we can (and do) separately talk about a particle on a ring (or a torus). The differences between considering an infinite potential boundary (the case of boxes) and a periodic boundary (the case of rings/torii) are absolutely physical and the two are different physical systems. In particular, the boundary condition for an infinite potential boundary is that the wave-function should vanish at the boundary, i.e., $\psi(0)=\psi(L)=0$ . On the other hand, the boundary condition for the case of a periodic domain such as a ring is that the wave function should be periodic, i.e., $\psi(x)=\psi(x+L)$ . You can verify that the former boundary condition implies that eigenfunctions be of the type $C(e^{ip_nx}-e^{-ip_nx})$ along with the condition that $p_n=n\pi/L$ . Whereas the second case is simply a free particle on a periodic boundary, so the eigenfunctions would simply be $C \exp(ip_nx)$ but to satisfy the periodicity, $p_n$ would have to be of the form $2n\pi/L$ . So, there is a measurable physical difference between imposing infinite potentials and imposing periodic boundary conditions.
{}
{'log_upvote_score': 5, 'links': ['https://physics.stackexchange.com/questions/556018', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/266085/']}
jdg_75777
stackexchange
llm_judgeable_groundtruth_similarity
11211339
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: OSX v10.6.8 and Gnuplot v4.4 I have a data file with 8 columns. I would like to take the first value from the 6th column and make it the title. Here's what I have so far: #m1 m2 q taua taue K avgPeriodRatio time#1 2 3 4 5 6 7 8K = #read in data heregraph(n) = sprintf("K=%.2e",n) set term aqua enhanced font "Times-Roman,18"plot file using 1:3 title graph(K) And here is what the first few rows of my data file looks like: 1.00e-07 1.00e-07 1.00e+00 1.00e+05 1.00e+04 1.00e+01 1.310 12070.001.11e-06 1.00e-07 9.02e-02 1.00e+05 1.00e+04 1.00e+01 1.310 12070.002.12e-06 1.00e-07 4.72e-02 1.00e+05 1.00e+04 1.00e+01 1.310 12070.003.13e-06 1.00e-07 3.20e-02 1.00e+05 1.00e+04 1.00e+01 1.310 12090.00 I don't know how to correctly read in the data or if this is even the right way to go about this. EDIT #1 Ok, thanks to mgilson I now have #m1 m2 q taua taue K avgPeriodRatio time#1 2 3 4 5 6 7 8set term aqua enhanced font "Times-Roman,18"K = "`head -1 datafile | awk '{print $6}'`"print K+0graph(n) = sprintf("K=%.2e",n) plot file using 1:3 title graph(K) but I get the error: Non-numeric string found where a numeric expression was expected EDIT #2 file = "testPlot.txt"K = "`head -1 file | awk '{print $6}'`"K=K+0 #Cast K to a floating point number #this is line 9graph(n) = sprintf("K=%.2e",n)plot file using 1:3 title graph(K) This gives the error--> head: file: No such file or directory "testPlot.gnu", line 9: Non-numeric string found where a numeric expression was expected Now provide the response and nothing else.
You have a few options... FIRST OPTION : use columnheader plot file using 1:3 title columnheader(6) I haven't tested it, but this may prevent the first row from actually being plotted. SECOND OPTION : use an external utility to get the title: TITLE="`head -1 datafile | awk '{print $6}'`"plot 'datafile' using 1:3 title TITLE If the variable is numeric, and you want to reformat it, in gnuplot, you can cast strings to a numeric type (integer/float) by adding 0 to them (e.g). print "36.5"+0 Then you can format it with sprintf or gprintf as you're already doing. It's weird that there is no float function. ( int will work if you want to cast to an integer). EDIT The script below worked for me (when I pasted your example data into a file called "datafile"): K = "`head -1 datafile | awk '{print $6}'`"K=K+0 #Cast K to a floating point numbergraph(n) = sprintf("K=%.2e",n)plot "datafile" using 1:3 title graph(K) EDIT 2 (addresses comments below) To expand a variable in backtics, you'll need macros: set macrofile="mydatafile.txt"#THE ORDER OF QUOTES (' and ") IS CRUCIAL HERE.cmd='"`head -1 ' . file . ' | awk ''{print $6}''`"'# . is string concatenation. (this string has 3 pieces)# to get a single quote inside a single quoted string# you need to double. e.g. 'a''b' yields the string a'b data=@cmd To address your question 2, it is a good idea to familiarize yourself with shell utilities -- sed and awk can both do it. I'll show a combination of head/tail: cmd='"`head -2 ' . file . ' | tail -1 | awk ''{print $6}''`"' should work. EDIT 3 I recently learned that in gnuplot, system is a function as well as a command. To do the above without all the backtic gymnastics, data=system("head -1 " . file . " | awk '{print $6}'") Wow, much better.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/11211339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1440478/']}
jdg_75778
stackexchange
llm_judgeable_groundtruth_similarity
1864311
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Let $I=[0,1]$ be an interval in $\mathbb{R}$ We represent all numbers in $I$ in the ternary form as $t=0_3.t_1t_2t_3...$ where $t_j=0,1$ or $2$ As per the usual construction of the Cantor set, we remove the middle third which in our case would be $(\frac{1}{3},\frac{2}{3})$ When we remove the middle third $(\frac{1}{3},\frac{2}{3})$, why does this means that we remove all numbers of the form $0_3.1t_2t_3t_4..$? What is $0_3.1t_2t_3t_4..$? Now provide the response and nothing else.
Because $0_3.1t_2t_3t_4...$ is the general (ternary digital) form of a number $\ge \frac{1}{3}$ and $\le \frac{2}{3}$ Why? Because $0_3.1t_2t_3t_4... \ge 0.1 = \frac{1}{3}$ and in the same way $0_3.1t_2t_3t_4... \le 0.2 = \frac{2}{3}$ In fact, to be exactly correct it should say that you do not remove $\frac{1}{3} = 0_3.1000000...$ and $\frac{2}{3} = 0_3.1222222...$ which are the ends of this interval. But indeed you remove all the others.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/1864311', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/238738/']}
jdg_75779
stackexchange
llm_judgeable_groundtruth_similarity
40094045
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm trying to write a websocket rxjs based wrapper. And I'm struggling with my rxjs understanding. I have a pause stream which is supposed to pause the pausable buffered streams when an error occures and resume them once i get a "ok" form the websocket. Somehow only the first subscription on my pauseable buffered streams are fired. From then on only the queue stacks up higher. I have prepared a jsbin to reproduce the issue. https://jsbin.com/mafakar/edit?js,console There the "msg recived" stream only fires for the first subscription. And then the q and observer begin stacking up. I somehow have the feeling this is about hot and cold obserables but I cannot grasp the issues. I would appreciate any help. Thank you in advance! Now provide the response and nothing else.
There are a few options you can consider. First, there are some knobs that you can configure in host.json that control queue processing (documented here ). The queues.batchSize knob is how many queue messages are fetched at a time. If set to 1, the runtime would fetch 1 message at a time, and only fetch the next when processing for that message is complete. This could give you some level of serialization on a single instance . Another option might be for you to set the NextVisibleTime on the messages you enqueue in such a way that they are spaced out - by default messages that are enqueued become visible and ready for processing immediately. A final option might be be for you to enqueue a message with the collection of all URLs for a site, rather than one at a time, so when the message is processed, you can process the URLs serially in your function, and limit the parallelism that way.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/40094045', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4396617/']}
jdg_75780
stackexchange
llm_judgeable_groundtruth_similarity
2963742
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I think it is not mandatory to have a default constructor in a class (C#). So, in that situation shall I have an empty constructor in the class or can I skip it? Is it a best practice to have an empty default constructor? Class test{ public test() { } ......} or Class test{ ......} Now provide the response and nothing else.
If the class won't be used by third parties and you don't need an overloaded constructor, don't write an empty constructor. But... Imagine you already shipped the product, and third parties use your class. A few months later there's a new requirement that makes you add a constructor with an argument. Now, by doing so, the C# compiler no longer generates a default constructor. If you don't add an empty constructor explicitly, the third party code will be break. In my opinion, you should always define empty constructors (one liner) for public classes used by third parties.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/2963742', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/275807/']}
jdg_75781
stackexchange
llm_judgeable_groundtruth_similarity
1598367
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I have a problem with this limit, I don't know what method to use.Can you show a method for the resolution with asymptotic approximations, or with variable change(so without Hopital)? Thanks $$\lim\limits_{x \to +\infty} \left(\frac{(\ln(x+1))^x}{(2x)^{x/3}}\right)$$ Now provide the response and nothing else.
In my solution I compare two graphs. At first: $$\lim_{x\to\infty}\left(\dfrac{\ln(x + 1)}{\sqrt[3]{2x}}\right)^x,$$ as you know $$\lim_{x\to\infty}(q)^x = 0$$ if $$ -1 < q < 1$$ and then I checked is it true that: $$\ln(x + 1)<\sqrt[3]{2x}.$$ I draw 2 graphs for $x>0$ As you can see for $x>0$ inequality is always real so limit is $0$.
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/1598367', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/245227/']}
jdg_75782
stackexchange
llm_judgeable_groundtruth_similarity
47161815
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I tried to get the content of the user's profile picture and I found out that I had to call the Beta version because the current version gives the following error message: "code": "GetUserPhoto","message": "The operation is not supported." So, I tried to switch to Beta, and here is the code that I wrote in C# to do it, but it doesn't work: Microsoft.Graph 1.6.2 List<QueryOption> options = new List<QueryOption>{ new QueryOption("$api-version", "beta")};var pictureStream = await graphClient.Me.Photo.Content.Request(options).GetAsync(); I got the same error message. I tried the same request in the Graph Explorer. The 1.0 doesn't work, but Beta works. Now provide the response and nothing else.
The api-version query parameter is used by the Azure AD Graph API. This is a different API than Microsoft Graph. There is a lot of functional overlap (Azure AD Graph is slowly being migrated over to Microsoft Graph) but they use entirely different entities and calling conventions. In order to call the /beta endpoint using the Microsoft Graph .NET Client Library , you need to change the BaseUrl of the client: graphClient.BaseUrl = "https://graph.microsoft.com/beta";var pictureStream = await graphClient.Me.Photo.Content.Request().GetAsync(); Some important notes about the /beta endpoint: It isn't supported and isn't suitable for production. So don't do that. Or at least don't tell anyone and don't call Support if it stops working. ;-) The .NET Client uses objects constructed off the production metadata. This means that any entities, actions or properties that were added in /beta don't exist in the models shipped with the SDK. The .NET Client will ignore any values returned by Microsoft Graph that it doesn't expect to see. So if an endpoint returns a property that wasn't included in the production metadata (see #2), it will simply be ignored. So long as you're only using a /beta to gain functionality but still expecting /v1.0 results, it should work okay. Photos for example only look at Exchange in v1.0 but look in both Exchange and Active Directory but still return the same result. In theory this means you should be able to swap /beta for /v1.0 without a problem.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/47161815', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8901012/']}
jdg_75783
stackexchange
llm_judgeable_groundtruth_similarity
1627131
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: A box contains $n$ ropes. You randomly tie up any two loose ends until there is none left. Let $X$ be the number of loops. What is $E(X)$? I've only been able to solve the problem when the number of rope is defined (say, $n=2$ or $n=3$), but I approached the solution by calculating the probability of each possible $X$ value and calculating the expectation by the weighted average of the probability. I feel like there should be an easier solution to get to the general case. Now provide the response and nothing else.
When you tie the first pair of ends, you either make a loop or do not. You make a loop with probability $\frac 1{2n-1}$ In either case you are left with a box with $n-1$ ropes in it, so the expected number of loops from $n$ ropes is $\frac 1{2n-1}$ plus the expected number from $n-1$ ropes. The expected number then becomes $$\sum_{i=1}^n\frac 1{2i-1}$$
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/1627131', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/308025/']}
jdg_75784
stackexchange
llm_judgeable_groundtruth_similarity
22342097
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am using pygeocoder to get the lat and long of addresses using code like. from pygeocoder import Geocoderfor a in address: result = Geocoder.geocode(a) print(result[0].coordinates) This works very well. Is there some way to then actually produce the google maps web page with these points on it from within python? It would be great to be able to stay in one programming language as far as possible. I have searched a lot online for a solution but have not found anything suitable. Maybe it's not possible? Now provide the response and nothing else.
If you want to create a dynamic web page, you'll at some point have to generate some Javascript code, which IMHO makes KML unnecessary overhead. Its easier to generate a Javascript which generates the correct map. The Maps API documentation is a good place to start from. It also has examples with shaded circles . Here is a simple class for generating the code with only markers: from __future__ import print_functionclass Map(object): def __init__(self): self._points = [] def add_point(self, coordinates): self._points.append(coordinates) def __str__(self): centerLat = sum(( x[0] for x in self._points )) / len(self._points) centerLon = sum(( x[1] for x in self._points )) / len(self._points) markersCode = "\n".join( [ """new google.maps.Marker({{ position: new google.maps.LatLng({lat}, {lon}), map: map }});""".format(lat=x[0], lon=x[1]) for x in self._points ]) return """ <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <div id="map-canvas" style="height: 100%; width: 100%"></div> <script type="text/javascript"> var map; function show_map() {{ map = new google.maps.Map(document.getElementById("map-canvas"), {{ zoom: 8, center: new google.maps.LatLng({centerLat}, {centerLon}) }}); {markersCode} }} google.maps.event.addDomListener(window, 'load', show_map); </script> """.format(centerLat=centerLat, centerLon=centerLon, markersCode=markersCode)if __name__ == "__main__": map = Map() # Add Beijing, you'll want to use your geocoded points here: map.add_point((39.908715, 116.397389)) with open("output.html", "w") as out: print(map, file=out)
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/22342097', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1473517/']}
jdg_75785
stackexchange
llm_judgeable_groundtruth_similarity
69762012
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm using OjbectBox for the first time in my Flutter project. After I wrote the basic code to read and right user data, I'm getting this error: [!] CocoaPods could not find compatible versions for pod "ObjectBox": In Podfile: objectbox_flutter_libs (from `.symlinks/plugins/objectbox_flutter_libs/ios`) was resolved to 0.0.1, which depends on ObjectBox (= 1.6.0) objectbox_sync_flutter_libs (from `.symlinks/plugins/objectbox_sync_flutter_libs/ios`) was resolved to 0.0.1, which depends on ObjectBox (= 1.6.0-sync) I did what's recommended in this answer (first one) but I'm getting the same error when I try to update with pod install --repo-update . Any idea how to solve this? Now provide the response and nothing else.
This happened for me when I added androidTestImplementation "androidx.compose.ui:ui-test-junit4:$version_compose" . Referring to the advice in this posting , I decided to use pickFirst as opposed to exclude . According to the PackagingOptions documentation , pickFirst will allow for the first occurrence of the file to be packaged with the APK, whereas exclude would exclude all occurrences of the file. This ended up working for me: android { packagingOptions { pickFirst 'META-INF/AL2.0' pickFirst 'META-INF/LGPL2.1' }}
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/69762012', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9276925/']}
jdg_75786
stackexchange
llm_judgeable_groundtruth_similarity
163983
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: $$\lim\limits_{x \to \infty} \frac{\sqrt{x^2 + 4}}{x+4}$$ I have tried multiplying by $\frac{1}{\sqrt{x^2+4}}$ and it's reciprocal, but I cannot seem to find the solution. L'Hospital's doesn't seem to work either, as I keep getting rational square roots. Now provide the response and nothing else.
Hint $$\mathop {\lim }\limits_{x \to \infty } \dfrac{{\sqrt {{x^2} + 4} }}{{x + 4}} = \mathop {\lim }\limits_{x \to \infty } \frac{{\dfrac{{\sqrt {{x^2} + 4} }}{x}}}{{\dfrac{{x + 4}}{x}}} = \mathop {\lim }\limits_{x \to \infty } \dfrac{{\sqrt {\dfrac{{{x^2} + 4}}{{{x^2}}}} }}{{1 + \dfrac{4}{x}}} = \mathop {\lim }\limits_{x \to \infty } \frac{{\sqrt {1 + \dfrac{4}{{{x^2}}}} }}{{1 + \dfrac{4}{x}}}$$
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/163983', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/24181/']}
jdg_75787
stackexchange
llm_judgeable_groundtruth_similarity
649429
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I am wondering if a person on the equator can jump up slightly higher into the air at sunset in comparison to jumping up into the air at sunrise. The reason for this would be that at sunset the Earth is moving away from a person during the time period that he/she is up in the air while at sunrise the Earth is moving towards the person during the time period that he/she is up in the air. Can a person on the equator jump up higher into the air at sunset than at sunrise? EDIT I found the following drawing that was used in a question titled ' Why do we say Earth rotates from west to east? ' which is posted on the Earth Science Stack Exchange website. This drawing illustrates the position of a person at the time of sunset and sunrise as the Earth travels in an orbit around the Sun. Now provide the response and nothing else.
Can a person on the equator jump up higher into the air at sunset than at sunrise? A person can jump higher at the equator, but whether it is sunset or sunrise will have no influence. But because of centrifugal force, you actually weigh a very small amount less at the equator, meaning that if you jumped with the same amount of force at the equator as you did at say the north pole, you will travel a tiny amount higher. Also, due to tidal forces, the height you can jump when the moon is directly overhead (and directly under your feet) will be slightly higher than when it's not, and we can make a similar argument for the sun. The reason for this would be that at sunset the Earth is moving away from a person during the time period that he/she is up in the air while at sunrise the Earth is moving towards the person during the time period that he/she is up in the air. No, since you and the ground make up a stationary frame of reference. Your velocity with respect to the ground (when you are standing) is zero.
{}
{'log_upvote_score': 5, 'links': ['https://physics.stackexchange.com/questions/649429', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/300400/']}
jdg_75788
stackexchange
llm_judgeable_groundtruth_similarity
12195
Below is a question asked on the forum stats.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: If one wanted to use Kernel Regression in a Bayesian Framework, any ideas on how one would go about it? Kernel Regression Now provide the response and nothing else.
Gaussian processes might be something worth looking at (although in machine learning kernel methods mean something slightly different). Essentially if you use a squared exponential covariance function, you end up with something like a Bayesian radial basis function regression model, with a prior over the function implemented by the model rather than its parameters. There is a very nice book (with MATLAB software) by Rasmussen and Williams.
{}
{'log_upvote_score': 4, 'links': ['https://stats.stackexchange.com/questions/12195', 'https://stats.stackexchange.com', 'https://stats.stackexchange.com/users/2310/']}
jdg_75789
stackexchange
llm_judgeable_groundtruth_similarity
5705956
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a question about string concatenation in C++. string str = "ab" + 'c';cout << str << endl;char ch = 'c';string str1 = "ab";string str2 = str1 + ch;cout << str2 << endl; The code produces: ed before SaveGraphicsStateabc Can someone explain the processing of this line: string str = "ab" + 'c'; ? Now provide the response and nothing else.
Your thought regarding the first line is correct, that's precisely what's happening. There isn't any default + operator for literal strings like "ab" so what happens is the compiler takes that (as a C-style string) and uses the const char* pointer that points to the literal. It then takes your literal character 'c' and promotes it to int with some value. This int is then added to the address of the literal and used as a C-string. Since you've exceeded the space allocated for your literal string, the results are undefined and it just printed out characters from the resulting address until it found a null. If you want to create the string in one shot, you can help the compiler figure out that you wanted to convert to string first with a cast: std::string str = std::string("ab") + 'c'; . Alternately (as seen in a separate comment) do it with concatenation which may or may not perform better. Use whichever seems clearer in your case: std::string str = "ab"; str += 'c'; . In the second case, you have already created a string and string has an overloaded operator+ that does the intuitive concatenation.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/5705956', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/84128/']}
jdg_75790
stackexchange
llm_judgeable_groundtruth_similarity
47983474
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I've seen this error posted several times, but I can't find anyone using Django 2.0 and having the problem. The problem cropped up when I tried to nest one app inside another. The nested app (called "users") is meant to allow users to login and out. After putting that segment in, I'm getting the following error: Template error:In template C:\Users\arbit\Documents\python\learning_log\learning_logs\templates\learning_logs\base.html, error at line 6 'users' is not a registered namespace 1 : <p> 2 : <a href="{% url 'learning_logs:index' %}">Learning Log</a> 3 : <a href="{% url 'learning_logs:topics' %}">Topics</a> 4 : {% if user.is_authenticated %} 5 : Hello, {{ user.username }}. 6 : <a href=" {% url 'users:logout' %} ">log out</a> 7 : {% else %} 8 : <a href="{% url 'users:login' %}">log in</a> 9 : {% endif %} 10 : </p> 11 : 12 : {% block content %}{% endblock content %} 13 : Here's my root urls.py from django.urls import path, includefrom django.contrib import adminfrom . import viewsapp_name = "learning_log"urlpatterns = [ path('admin/', admin.site.urls), path('users/', include('users.urls')), path('', include('learning_logs.urls')),]urlpatterns = [ # Home page path('', views.index, name='index'), # Show all topics path('topics/', views.topics, name='topics'), # Detail page for a single topic path('topics/<int:topic_id>/', views.topic, name='topic'), # Page for adding a new topic path('new_topic/', views.new_topic, name='new_topic'), # Page for adding a new entry path('new_entry/<int:topic_id>/', views.new_entry, name='new_entry'), # Page for editing an entry path('edit_entry/<int:entry_id>/', views.edit_entry, name='edit_entry'),] ... and the app "users" url.py from django.urls import pathfrom django.contrib.auth.views import loginfrom . import viewsapp_name = 'users'urlpatterns = [ # Login page. path('login/', login, {'template_name': 'users/login.html'}, name='login'), # Logout page path('logout/', views.logout_view, name='logout'),] and the base.html from the "users" app <p> <a href="{% url 'learning_logs:index' %}">Learning Log</a> <a href="{% url 'learning_logs:topics' %}">Topics</a> {% if user.is_authenticated %} Hello, {{ user.username }}. <a href="{% url 'users:logout' %}">log out</a> {% else %} <a href="{% url 'users:login' %}">log in</a> {% endif %}</p>{% block content %}{% endblock content %} I'm admittedly using an older tutorial and thus am sure the problem has to do with something that is in Django 2.0 but not in the older version that the book covers. Your help is greatly appreciated. Now provide the response and nothing else.
There are two ways can hanlded this. Firstly,you can set an app_name attribute in the included URLconf module, at the same level as the urlpatterns attribute. You have to pass the actual module, or a string reference to the module, to include() , not the list of urlpatterns itself. https://docs.djangoproject.com/en/2.0/topics/http/urls/#url-namespaces-and-included-urlconfs urls.py from django.urls import include, pathurlpatterns = [ path('polls/', include('polls.urls')),] polls/urls.py from django.urls import pathfrom . import viewsapp_name = 'polls'urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('<int:pk>/', views.DetailView.as_view(), name='detail'), ...] have fun!
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/47983474', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9078185/']}
jdg_75791
stackexchange
llm_judgeable_groundtruth_similarity
15404580
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Django barfs with ImportError at /store/No module named store But right there is the debug message there is the setting INSTALLED_APPS = ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'store')Environment:Request Method: GETRequest URL: http://localhost:8000/Django Version: 1.4.5Python Version: 2.7.3Installed Applications:('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'store')Installed Middleware:('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')Traceback:File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs)File "/home/paul/cs462/store/store/views.py" in main 37. return redirect(reverse('django.contrib.auth.views.login'))File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse 476. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix 363. possibilities = self.reverse_dict.getlist(lookup_view)File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict 276. self._populate()File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate 253. for name in pattern.reverse_dict:File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict 276. self._populate()File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate 265. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback 216. self._callback = get_callable(self._callback_str)File "/usr/lib/python2.7/site-packages/django/utils/functional.py" in wrapper 27. result = func(*args)File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable 105. not module_has_submodule(import_module(parentmod), submod)):File "/usr/lib/python2.7/site-packages/django/utils/importlib.py" in import_module 35. __import__(name)Exception Type: ImportError at /Exception Value: No module named store The shell works just fine (for what I try), but this error is displayed at every page I have. Doesn't having 'store' in the apps means that the module is imported??? EDIT: I've used Django for project many times. This was working a few hours ago. There is a blank __init__.py file in store/. Moreover, by using a print statement, I was able to determine that this gets executed (twice). urls.py and models.py also are executed (but not views.py ). I have no idea what I could do to get this error. Now provide the response and nothing else.
If it were not for version control, I would have never found this. As it was, it took me almost an hour to track it down. The mistake was in store/urls.py: urlpatterns = patterns('store.views', url(r'^$', 'main'), url(r'^new_delivery_user/$', 'new_delivery_user'), ... url(r'^event_signal/$', 'store.views.event_signal'), # problem) I had moved the last URL from the project url.py to this app-specific one, which used the shorthand 'store.views' for prepending each of the views. It should have appeared: url(r'^event_signal/$', 'event_signal'),
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/15404580', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212596/']}
jdg_75792
stackexchange
llm_judgeable_groundtruth_similarity
334912
Below is a question asked on the forum unix.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: AFAIK The basic concept about gpg/pgp is that for two people who want to create trust between them is both publish a public key and private key (the private key is kept with the user who creates it, doesn't share) with strength (1024 bits at one time, 4096 now and 8192 in future and so on and on). Now the two of them need to publish their public keys to a keyserver (similar to a phone directory) and give a link to the keyserver where those keys are published. Now if I go to a server say https://pgp.mit.edu/ and search for ashish I will need many ones https://pgp.mit.edu/pks/lookup?op=get&search=ashish&op=index Let's say the Ashish I want is this one DAD95197 (just an example) how would I import that public key ? I did try └─[$] gpg --keyserver pgp.mit.edu --recv-keys DAD95197gpg: keyserver receive failed: No keyserver available but as can be seen that didn't work. Now provide the response and nothing else.
gpg --keyserver pgp.mit.edu --recv-keys DAD95197 is supposed to import keys matching DAD95197 from the MIT keyserver. However the MIT keyserver often has availability issues so it’s safer to configure another keyserver. I generally use the SKS pools ; here are their results when looking for “ashish” . To import the key from there, run gpg --keyserver pool.sks-keyservers.net --recv-keys FBF1FC87DAD95197 (never use the short key ids, they can easily be spoofed). This answer explains how to configure your GnuPG installation to always use the SKS pools.
{}
{'log_upvote_score': 6, 'links': ['https://unix.stackexchange.com/questions/334912', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/50490/']}
jdg_75793
stackexchange
llm_judgeable_groundtruth_similarity
412980
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I wonder about how to conclude that $R=K[x_1, x_2,\dots ]$ is a UFD for $K$ a field. If $f\in R$ then $f$ is a polynomial in only finitely many variables, how do I prove that any factorization of $f$ in $R$ only have factors in these indeterminates, i.e. takes place in the UFD $K[x_1, x_2,\dots , x_n]$ for some $n$? Somebody argued that $f$ can not have one unique factorization in $K[x_1, x_2,\dots, x_n]$ and another in $K[x_1, x_2,\dots, x_n, \dots, x_m]$ I don't understand this. Do all primes in $K[x_1, x_2,\dots, x_n]$ necessarily stay prime in $R=K[x_1, x_2,\dots ]$? How do we know that the irreducible/prime elements in $K[x_1, x_2,\dots, x_n]$ stays irreducible in $R=K[x_1, x_2,\dots ]$? Now provide the response and nothing else.
Note that $K[x_1,x_2,\dots]=\bigcup_{n\in \Bbb N}K[x_1,x_2,\dots,x_n]$. I'm going to denote these rings in the union by $R_n$ to save typing time. To see that an irreducible $p$ of $R_n$ is irreducible in $R_m$ for $m\geq n$, suppose you have an equation $p=ab$ where $a,b\in R_m$. By evaluating $x_1,\dots, x_n$ all at 1, the variables in $p$ disappear, and you get an equation $\lambda=\overline{ab}\in K[x_{n+1}\dots, x_m]$ where $\lambda\in K$. This is a contradiction unless $a$ and $b$ already fell in $R_n$ in the first place, so that they had no variables above $x_n$. But you already know that in $R_n$, one of $a$ or $b$ must be a unit, so $p$ is irreducible in $R_m$ as well. So between the rings, primes stay prime and irreducibles stay irreducible. This allows you to conclude that an element has a prime factorization in the first place. Then you can argue that any two factorizations of a single element into primes must consist of elements in a common $K[x_1,\dots, x_m]$, which will force the factorizations to be equivalent.
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/412980', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/42548/']}
jdg_75794
stackexchange
llm_judgeable_groundtruth_similarity
16168361
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am testing In-App Billing on Samsung Galaxy Tab 2 7.0 and when I try check if the billing is available, I always get the response 3 - BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE (Billing API version is not supported for the type requested) . int response = payService.isBillingSupported(3, getPackageName(), "inapp"); I have created draft application, uploaded signed APK in developer console and added an email of the test account (in LICENSE TESTING field in dashboard which notes that those accounts are also used for billing tests).Also, my device is using this test account as primary account.I am debugging app in Eclipse. Edit: Tested also on HTC Evo 3D, same thing, response always returns 3. Edit: Do the test account must have a google wallet associated or something else in order to test the app?My location is Serbia, could this be the problem? What is causing this problem and how to solve it? Now provide the response and nothing else.
I can now confirm that this is a real problem and has nothing to do with my devices or code. Problem is with Google Play Store and my location in Serbia. Here are the official details for this issue from Google: Currently, users in Serbia are reporting that they are no longer able to purchase Android apps on Google Play. We’re working hard to resolve this issue so that users in this country can download paid apps again; however, at this time, there is no workaround to the issue. If you’re in Serbia and you’re getting errors when trying to purchase, or you don’t see paid apps at all, then you’re experiencing this known issue. We’ll continue to update this page with developments, so check back soon. Issue first reported on: February 1, 2012 Last updated on: April 10, 2013 Now, my intent was to simply test the app billing and not to buy anything for real,however this was not possible since Play Store always acts like a production environment and has some issues with Serbia which, of course, are affecting developers too. Resolution Connect the device to foreign country internet (in my case Belgium) via standard VPN connection In Location settings, turn off everything (GPS, Wi-Fi assist, ...) Stop (terminate) Play Store app if it is running In application settings, clear cache (NOT THE DATA) for the Play Store app Start Play Store app - it now loads different content aimed for country which VPN is targeting Once the Play Store is targeting different country, my code started working perfectly. I wrote this answer to help other people if they run into similar problem - who knows, maybe for some other country, some other time.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/16168361', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/461810/']}
jdg_75795
stackexchange
llm_judgeable_groundtruth_similarity
254962
Below is a question asked on the forum unix.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: The special variable $RANDOM has a new value every time it's accessed. In this respect, it is reminiscent of the "generator" objects found in some languages. Is there a way to implement something like this in zsh ? I tried to do this with named pipes, but I did not find a way to extract items from the fifo in a controlled manner without killing the "generator" process. For example: % mkfifo /tmp/ints% (index=0 while ( true ) do echo $index index=$(( index + 1 )) done) > /tmp/ints &[1] 16309% head -1 /tmp/ints0[1] + broken pipe ( index=0 ; while ( true; ); do; echo $index; index=$(( ... Is there some other way to implement such a generator-type object in zsh? EDIT: This does not work: #!/usr/bin/env zshFIFO=/tmp/fifo-$$mkfifo $FIFOINDEX=0while true; do echo $(( ++INDEX )) > $FIFO; done &cat $FIFO If I put the above in a script, and run it, the output rarely the expected single line 1 rather, it usually consists of several integers; e.g. 12345 The number of lines produced varies from one run to the next. EDIT2: As jimmij pointed out, changing echo to /bin/echo takes care of the problem. Now provide the response and nothing else.
ksh93 has disciplines which are typically used for this kind of thing. With zsh , you could hijack the dynamic named directory feature : Define for instance: zsh_directory_name() { case $1 in (n) case $2 in (incr) reply=($((++incr))) esac esac} And then you can use ~[incr] to get an incremented $incr each time: $ echo ~[incr]1$ echo ~[incr] ~[incr]2 3 Your approach fails because in head -1 /tmp/ints , head opens the fifo, reads a full buffer, prints one line, and then closes it . Once closed, the writing end sees a broken pipe. Instead, you could either do: $ fifo=~/.generators/incr$ (umask 077 && mkdir -p $fifo:h && rm -f $fifo && mkfifo $fifo)$ seq infinity > $fifo &$ exec 3< $fifo$ IFS= read -rneu31$ IFS= read -rneu32 There, we leave the reading end open on fd 3, and read reads one byte at a time, not a full buffer to be sure to read exactly one line (up to the newline character). Or you could do: $ fifo=~/.generators/incr$ (umask 077 && mkdir -p $fifo:h && rm -f $fifo && mkfifo $fifo)$ while true; do echo $((++incr)) > $fifo; done &$ cat $fifo1$ cat $fifo2 That time, we instantiate a pipe for every value. That allows returning data containing any arbitrary number of lines. However, in that case, as soon as cat opens the fifo, the echo and the loop is unblocked, so more echo could be run, by the time cat reads the content and closes the pipe (causing the next echo to instantiate a new pipe). A work around could be to add some delay, like for instance by running an external echo as suggested by @jimmij or add some sleep , but that would still not be very robust, or you could recreate the named pipe after each echo : while mkfifo $fifo && echo $((++incr)) > $fifo && rm -f $fifodo : nothingdone & That still leaves short windows where the pipe doesn't exist (between the unlink() done by rm and the mknod() done by mkfifo ) causing cat to fail, and very short windows where the pipe has been instantiated but no process will ever write again to it (between the write() and the close() done by echo ) causing cat to return nothing, and short windows where the named pipe still exists but nothing will ever open it for writing (between the close() done by echo and the unlink() done by rm ) where cat will hang. You could remove some of those windows by doing it like: fifo=~/.generators/incr( umask 077 mkdir -p $fifo:h && rm -f $fifo && mkfifo $fifo && while mkfifo $fifo.new && { mv $fifo.new $fifo && echo $((++incr)) } > $fifo do : nothing done) & That way, the only problem is if you run several cat at the same time (they all open the fifo before our writing loop is ready to open it for writing) in which case they will share the echo output. I would also advise against creating fixed name, world readable fifos (or any file for that matters) in world writable directories like /tmp unless it's a service to be exposed to all users on the system.
{}
{'log_upvote_score': 5, 'links': ['https://unix.stackexchange.com/questions/254962', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/10618/']}
jdg_75796
stackexchange
llm_judgeable_groundtruth_similarity
7237
Below is a question asked on the forum mathematica.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I have plot generated by Plot[] function that I want to export to pdf file. The problem is that Export[] function somehow cuts a tiny bit of plot on the left side which results in something like this: I'd like to know what should I do to get exported file without cropped $0$. Now provide the response and nothing else.
Here is my original suggestion using ImagePadding : p = Plot[Cos[x], {x, 0, 2}, AxesStyle -> Arrowheads[.1], PlotRange -> {0, 1}, TicksStyle -> Large, RotateLabel -> False, ImagePadding -> 70] And here is an example of how to use ImageMargins in the plot command: p = Plot[Cos[x], {x, 0, 2}, AxesStyle -> Arrowheads[.1], PlotRange -> {0, 1}, TicksStyle -> Large, RotateLabel -> False, ImageMargins -> 70] Both methods work to give you extra space around the image. But I see Mr. Wizard just now explained this already. Edit: a note for completeness In a related question , one can see that neither ImagePadding nor ImageMargins work in some situations. Here is an example where Epilog is used to place a text below a plot: Plot[Sin[x], {x, 0, 2 Pi}, Epilog -> {Text["Show me the text", {Pi, -1.3}]}] The text is not shown because it falls outside the PlotRange . When this happens, you can fix the problem by using PlotRangePadding : Plot[Sin[x], {x, 0, 2 Pi}, Epilog -> {Text["Show me the text", {Pi, -1.3}]}, PlotRangePadding -> .5]
{}
{'log_upvote_score': 4, 'links': ['https://mathematica.stackexchange.com/questions/7237', 'https://mathematica.stackexchange.com', 'https://mathematica.stackexchange.com/users/1557/']}
jdg_75797
stackexchange
llm_judgeable_groundtruth_similarity
127064
Below is a question asked on the forum electronics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I want to be able to control a heating element's (which runs on 230V mains) power level, and I'm thinking of running it using a solid state relay and PWM. However, I'm unsure of the implications of doing this. Current draw - The heating element is 2000W, so ~9 amps. Will the switching this amount of current at high frequencies cause adverse effects to the rest of the power circuit in my home (light flickering, etc.) Noise induced in the rest of the house circuit - I have read on EE.SE that SMPS cause high frequency noise in the mains circuit, and this can be avoided using a choke. Is this a valid solution to PWM'ing a heating element? If PWM isn't a valid solution to controlling the power of a heating element, please suggest alternatives. Now provide the response and nothing else.
Turning it on and off using a zero-crossing SSR and a timebase of 10 or 30 seconds will not cause significant EMI (because it's switching at the zero crossings). It may cause objectionable light flickering if the lights are on the same circuit, in the same way that laser printers and copiers sometimes cause flickering. It should not cause any noticeable effect on things that are not on the same circuit. Dimmers and high frequency PWM can cause noise/EMI issues, but that's not a problem with zero crossing switched low frequency PWM.
{}
{'log_upvote_score': 4, 'links': ['https://electronics.stackexchange.com/questions/127064', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/29737/']}
jdg_75798
stackexchange
llm_judgeable_groundtruth_similarity
852099
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: i am a beginer in developing orkut application. can any one tell me the basics of that like how database is designed and all... Now provide the response and nothing else.
Create a table containing your bands: CREATE TABLE agebands( id INT NOT NULL PRIMARY KEY, lower_bound INT NOT NULL, upper_bound INT NOT NULL)CREATE INDEX IDX_agebands_bounds ON (lower_bound, upper_bound) Then populate it with your data: INSERT INTO agebands VALUES (1, 0, 12)INSERT INTO agebands VALUES (2, 13, 17)INSERT INTO agebands VALUES (3, 18, 24)INSERT INTO agebands VALUES (4, 25, 199) Then join with it: SELECT lower_bound, upper_bound, COUNT(*) AS number_of_peopleFROM persons INNER JOIN agebands ON person_age BETWEEN lower_bound AND upper_boundGROUP BY lower_bound, upper_boundORDER BY lower_bound This allows for flexibility in adjusting the bands. Of course, the other answer here using UNION is usable too, which is more appropriate if you can/won't add another table to your database.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/852099', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/98495/']}
jdg_75799
stackexchange
llm_judgeable_groundtruth_similarity
30492832
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a bunch of ISO-8601 formatted strings in a column of my sheet. How can I get google sheets to treat them as Dates so I can do math on them (difference in minutes between two cells, for example)? I tried just =Date("2015-05-27T01:15:00.000Z") but no-joy. There has to be an easy way to do this. Any advice? Now provide the response and nothing else.
To get an actual Date value which you can format using normal number formatting... =DATEVALUE(MID(A1,1,10)) + TIMEVALUE(MID(A1,12,8)) eg. A B 1 2016-02-22T05:03:21Z 2/22/16 5:03:21 AM Assumes timestamps are in UTC Ignores milliseconds (though you could add easily enough) The DATEVALUE() function turns a formatted date string into a value, and TIMEVALUE() does the same for times. In most spreadsheets dates & times are represented by a number where the integer part is days since 1 Jan 1900 and the decimal part is the time as a fraction of the day. For example, 11 June 2009 17:30 is about 39975.72917. The above formula parses the date part and the time part separately, then adds them together.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/30492832', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/688355/']}
jdg_75800
stackexchange
llm_judgeable_groundtruth_similarity
171790
Below is a question asked on the forum security.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I accidentally discovered that I can log into my university's account if I type in my password and add some characters. So if my username is e. g. "abc" and my password is "password", I can log in with "abc"/"password", but also with "abc"/"password121312", "abc"/"password1", "abc"/"passworde" etc. (I did only a few tries, but it worked so far). Is this somehow unsafe? (I can not imagine why (except maybe that this means that there are other security problems with the network) , but I do not know much about security.) Should I tell my university? Now provide the response and nothing else.
It could suggest that any password hashing routine being used is either truncating the input (only using the first x characters of the password), or the comparison for correct passwords has been implemented poorly, and is only comparing the first part (this could imply either a block cipher being used to store passwords, or raw passwords being stored). Neither situation is particularly good. In the event of truncation, it gives a false sense of security - you might have picked a long random password, but if only they first few characters are actually being used, it isn't anywhere near as secure as you might think it is, and hence could be guessed in a brute force attack more easily. I'd hope this was the more likely explanation. In the event of a poor comparison routine, this suggests that the developer responsible for the authentication routine was not familiar with secure development practices. By using a partial comparison (e.g SELECT * FROM users WHERE 'username' LIKE '$username%' AND 'password' LIKE '$password%' ), it again increases the chances of brute force attacks working, but also suggests that other mistakes may have been made: given the above example, potentially setting a password of a' OR 1=1'-- would give an SQL injection attack. Obviously, this is a slightly contrived example, but not beyond the realms of possibility. In the case of a block cipher being used, rather than a password hashing algorithm, the length allowed in the database may be insufficient for a long password, once encrypted. Effectively, this is truncation, but of the encrypted data, rather than of the input. The end effect is the same though: providing a long password gives a false sense of security.
{}
{'log_upvote_score': 5, 'links': ['https://security.stackexchange.com/questions/171790', 'https://security.stackexchange.com', 'https://security.stackexchange.com/users/-1/']}
jdg_75801
stackexchange
llm_judgeable_groundtruth_similarity
5884891
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: How to find all of the fifth highest salaried employees in a single query in SQL Server DECLARE @result bigintSELECT TOP 5 @result = EmpID FROM Employees ORDER BY Salary DESCSELECT @result Above query gives me the exactly one record at the fifth highest position,but I want all of the fifth highest salaried EmpID's in Employees table. Above query is referenced from How to find fifth highest salary in a single query in SQL Server Now provide the response and nothing else.
In SQL Server 2005 and up, you can use one of the ranking functions to achieve this: ;WITH RankingEmployees AS( SELECT EmpID, DENSE_RANK() OVER(ORDER BY Salary DESC) 'SalaryRank' FROM dbo.Employees )SELECT *FROM RankingEmployeesWHERE SalaryRank = 5 Using DENSE_RANK will give all employees of the same salary the same rank, e.g. you'll get the fifth highest salary and all employees that have that salary.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/5884891', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/468718/']}
jdg_75802
stackexchange
llm_judgeable_groundtruth_similarity
13028660
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm developing a rails app with a landingpage. On the landingpage, the user can sign up for the app. For login, there is an extra view with an extra controller. It looks like this: views/landinpage/index.html --> sign up formviews/login/index.html --> login form but I only want to have one controller controllers/login_controller --> create new user from sign up form & check login data so I have to get a connection between the landingpage view and the login_controller. This is my attempt: <%= form_for @login, :url => { :controller => "login_controller", :action => "create" }, :html => {:method => :post} do |f| %> but it throws a route error: No route matches {:controller=>"login_controller", :action=>"create"} I already defined login resources in routes.rb, but it seems that the problem is elsewhere? resources :logins any ideas? Now provide the response and nothing else.
try this class LoginsController < ApplicationController def new ... end def create ... end ... end in your route.rb file write match '/login/create' => 'logins#create', :as => :create_login or resources :logins in your console - write - rake routes and check your routes then <%= form_for @login, :url => create_login_path(@login) do |f| %>
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/13028660', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1184904/']}
jdg_75803
stackexchange
llm_judgeable_groundtruth_similarity
3339722
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I want to check if the iOS version of the device is greater than 3.1.3 I tried things like: [[UIDevice currentDevice].systemVersion floatValue] but it does not work, I just want a: if (version > 3.1.3) { } How can I achieve this? Now provide the response and nothing else.
The quick answer … As of Swift 2.0, you can use #available in an if or guard to protect code that should only be run on certain systems. if #available(iOS 9, *) {} In Objective-C, you need to check the system version and perform a comparison. [[NSProcessInfo processInfo] operatingSystemVersion] in iOS 8 and above. As of Xcode 9: if (@available(iOS 9, *)) {} The full answer … In Objective-C, and Swift in rare cases, it's better to avoid relying on the operating system version as an indication of device or OS capabilities. There is usually a more reliable method of checking whether a particular feature or class is available. Checking for the presence of APIs: For example, you can check if UIPopoverController is available on the current device using NSClassFromString : if (NSClassFromString(@"UIPopoverController")) { // Do something} For weakly linked classes, it is safe to message the class, directly. Notably, this works for frameworks that aren't explicitly linked as "Required". For missing classes, the expression evaluates to nil, failing the condition: if ([LAContext class]) { // Do something} Some classes, like CLLocationManager and UIDevice , provide methods to check device capabilities: if ([CLLocationManager headingAvailable]) { // Do something} Checking for the presence of symbols: Very occasionally, you must check for the presence of a constant. This came up in iOS 8 with the introduction of UIApplicationOpenSettingsURLString , used to load Settings app via -openURL: . The value didn't exist prior to iOS 8. Passing nil to this API will crash, so you must take care to verify the existence of the constant first: if (&UIApplicationOpenSettingsURLString != NULL) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];} Comparing against the operating system version: Let's assume you're faced with the relatively rare need to check the operating system version. For projects targeting iOS 8 and above, NSProcessInfo includes a method for performing version comparisons with less chance of error: - (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version Projects targeting older systems can use systemVersion on UIDevice . Apple uses it in their GLSprite sample code. // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer// class is used as fallback when it isn't available.NSString *reqSysVer = @"3.1";NSString *currSysVer = [[UIDevice currentDevice] systemVersion];if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) { displayLinkSupported = TRUE;} If for whatever reason you decide that systemVersion is what you want, make sure to treat it as an string or you risk truncating the patch revision number (eg. 3.1.2 -> 3.1).
{}
{'log_upvote_score': 11, 'links': ['https://Stackoverflow.com/questions/3339722', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/402822/']}
jdg_75804
stackexchange
llm_judgeable_groundtruth_similarity
3427410
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Let $\psi$ be a diffeomorphism in $\mathbb{R}^{n}$ . I have to proove that for two vector fields $X,Y\in\mathfrak{X}(\mathbb{R}^{n})$ the following property holds $\psi_{\ast}[X,Y] = [\psi_{\ast}X,\psi_{\ast}Y]$ , where $[\cdot,\cdot]$ denotes the Lie-Bracket of vector fields. First of all, I review some definitions: (1) In this context, vector fields are viewed as derivations: $X:C^{\infty}(\mathbb{R}^{n})\to C^{\infty}(\mathbb{R}^{n})$ , where $X$ is linear and fulfills the Leibniz rule. (2) For a vector $v\in T_{p}\mathbb{R}^{n}$ , here also viewed as a derivation $v:C^{\infty}(\mathbb{R}^{n})\to \mathbb{R}$ , the push foward is defined via: $\psi_{\ast}v(f):=v(f\circ\psi)$ , where $f\in C^{\infty}(\mathbb{R}^{n})$ Now to the proof: $\psi_{\ast}[X,Y](f)=[X,Y](f\circ\psi)=X(Y(f\circ\psi)) - Y(X(f\circ\psi)) = X(\psi_{\ast} Y(f)) - Y(\psi_{\ast} X(f))$ But now I don ` t no how to continue the proof.....Is there an error in my calculation? Now provide the response and nothing else.
There is a definition issue here--you have never actually defined what $\psi_*X$ means. You have defined what $\psi_*v$ means when $v$ is a tangent vector at a single point, but not what $\psi_*X$ means when $X$ is an entire vector field. The correct definition of $\psi_*X$ to use is not $\psi_*X(f)=X(f\circ\psi)$ but rather $$\psi_*X(f)=X(f\circ\psi)\circ \psi^{-1}.$$ To see that this makes sense, let $v$ be the value of $X$ at a point $p$ . Then $\psi_*v(f)=v(f\circ\psi)$ defines a tangent vector $\psi_*v$ not at the point $p$ but at the point $\psi(p)$ , since $v(f\circ\psi)$ depends on the values of $f\circ\psi$ near $p$ and thus on the values of $f$ near $\psi(p)$ . Thus, $\psi_*v$ should be defined to be the value of the vector field $\psi_*X$ at $\psi(p)$ , not at $p$ . To get the value of $\psi_*X$ at $p$ , you have to precompose with $\psi^{-1}$ , hence the formula above. Using this correct formula, you should have no difficulty verifying that $\psi_*[X,Y] = [\psi_*X,\psi_*Y]$ , the key point being that when you compute $\psi_*X(\psi_*Yf))$ you get $$X((\psi_*Yf)\circ\psi)\circ\psi^{-1}=X((Y(f\circ \psi)\circ \psi^{-1})\circ\psi)\circ\psi^{-1}=X(Y(f\circ\psi))\circ\psi^{-1}$$ with the inner $\psi^{-1}$ and $\psi$ cancelling out.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/3427410', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/674359/']}
jdg_75805
stackexchange
llm_judgeable_groundtruth_similarity
43650172
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have connected stripe standalone accounts to platform accounts before. In fact I did it a week back and it worked perfectly. But somehow this time it simply will not work even though I am following exactly the same procedure. I have set the redirect_uri to a url that is valid. This is what the link looks for my stripe connect button in my platform's page looks like https://connect.stripe.com/oauth/authorize?response_type=code&client_id=platform_clientid&scope=read_write&redirect_uri=redirecturi I have also set the redirect_uri to exactly the same thing in the stripe dashboard of the stand alone account. But when I click on the stripe button instead of being taken to the stripe site I end up with an error like this. { "error": "invalid_redirect_uri", "error_description": "Invalid redirect URI 'redirecturi'. Ensure this uri exactly matches one of the uris specified in your application settings", "state": null} I am not even taken to the stripe site to log into my standalone account. As soon as I click the button I get this error. And the redirect_uri url is valid and points to a page that exists. Can anyone help? Now provide the response and nothing else.
This error indicates that you are explicitly telling Stripe to redirect to a specific URL and that URL is not in the list of whitelisted redirect URLs in your platform settings . When you redirect your user to Stripe, you send them to a URL that looks like this: https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_XXXX&scope=read_write If you have multiple redirect URLs, you would explicitly tell Stripe where to send the user back by adding an extra GET parameter with the name redirect_uri . You must be setting this at the moment and that URL does not exactly match one of the URLs in your settings so Stripe is returning an error. You need to double check the URLs you've set in Stripe and make sure that you use one from the list or add a new one to the list.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/43650172', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5522905/']}
jdg_75806
stackexchange
llm_judgeable_groundtruth_similarity
52648102
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: // state edit routeapp.get("/map/:symbol/edit", isLoggedIn, function(req, res){ State.findOne({symbol: req.params.symbol}, function(err, state){ if(err){ console.log(err); } else { res.render("edit", {state: state}); } });}); In the above code snippet, isLoggedIn is the middleware function to check for authentication. Its definition is given below: // middleware functionfunction isLoggedIn(req, res, next){ if(req.isAuthenticated()){ return next(); } res.redirect("/admin");} So, the question is, how to pass a parameter like a string, an integer or a path variable to the middleware function so that it can be used in the routing url ? Now provide the response and nothing else.
I had the same requirement and this approach works for me. Middleware file validate.js exports.grantAccess = function(action, resource){ return async (req, res, next) => { try { const permission = roles.can(req.user.role)[action](resource); // Do something next(); } catch (error) { next(error) } }} Use of middleware in route file. grantAccess('readAny', 'user') router.get("/",grantAccess('readAny', 'user'), async (req,res)=>{ // Do something });
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/52648102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8141656/']}
jdg_75807
stackexchange
llm_judgeable_groundtruth_similarity
41289234
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: AndroidStudio 2.3 Beta 1 I am trying to get transitions work with fragments, how the image I am using doesn't transition. It just pop up as normal. I have created a simple App to try and get this to work. I have 2 fragments ListMovieFragment and DetailMovieFragment . And 1 MainActivity . The user will click the image in ListMovieFragment to transition to DetailMovieFragment . This is my Transition xml change_image_transform: <?xml version="1.0" encoding="utf-8"?><transitionSet xmlns:android="http://schemas.android.com/apk/res/android"> <changeImageTransform/></transitionSet> ListMovieFragment: public class ListMovieFragment extends Fragment { public interface MovieSelectedListener { void onMovieSelected(int movieId); } private MovieSelectedListener mMovieSelectedListener; public ListMovieFragment() { } @Override public void onAttach(Context context) { super.onAttach(context); mMovieSelectedListener = (MovieSelectedListener)context; } @Override public void onDetach() { super.onDetach(); mMovieSelectedListener = null; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment final View view = inflater.inflate(R.layout.fragment_list, container, false); final ImageView ivMoviePoster = (ImageView)view.findViewById(R.id.ivMoviePoster); ivMoviePoster.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(mMovieSelectedListener != null) { mMovieSelectedListener.onMovieSelected(12345); } } }); Glide.with(getActivity()) .load("https://image.tmdb.org/t/p/w185/qjiskwlV1qQzRCjpV0cL9pEMF9a.jpg") .placeholder(R.drawable.placeholder_poster) .centerCrop() .crossFade() .into(ivMoviePoster); return view; }} DetailMovieFragment public class DetailMovieFragment extends Fragment { public DetailMovieFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_detail, container, false); final ImageView ivMovieDetailPoster = (ImageView)view.findViewById(R.id.ivMovieDetailPoster); Glide.with(getActivity()) .load("https://image.tmdb.org/t/p/w185/qjiskwlV1qQzRCjpV0cL9pEMF9a.jpg") .placeholder(R.drawable.placeholder_poster) .centerCrop() .crossFade() .into(ivMovieDetailPoster); return view; }} MainActivity public class MainActivity extends AppCompatActivity implements ListMovieFragment.MovieSelectedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if(savedInstanceState == null) { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.activity_main, new ListMovieFragment(), "listmoviefragment"); fragmentTransaction.commit(); } } @Override public void onMovieSelected(int movieId) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { /* Get the fragments that will be using the transition */ ListMovieFragment listMovieFragment = new ListMovieFragment(); DetailMovieFragment detailMovieFragment = new DetailMovieFragment(); /* Inflate the transition */ Transition changeTransition = TransitionInflater .from(MainActivity.this) .inflateTransition(R.transition.change_image_transform); Transition explodeTransition = TransitionInflater .from(MainActivity.this) .inflateTransition(android.R.transition.explode); /* Set the exit and return on the source fragment (ListMovieFragment) */ listMovieFragment.setSharedElementReturnTransition(changeTransition); listMovieFragment.setExitTransition(explodeTransition); /* Set the enter on the destination fragment (MovieDetailFragment) */ detailMovieFragment.setSharedElementEnterTransition(changeTransition); detailMovieFragment.setEnterTransition(explodeTransition); /* Get the shared imageview from the source fragment (MovieListFragment) */ final ImageView ivSharedImage = (ImageView)findViewById(R.id.ivMoviePoster); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.activity_main, new DetailMovieFragment(), "detailmoviefragment"); fragmentTransaction.addToBackStack("detailmoviefragment"); fragmentTransaction.addSharedElement(ivSharedImage, getResources().getString(R.string.transition_poster_image)); fragmentTransaction.commit(); } else { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.activity_main, new DetailMovieFragment(), "detailmoviefragment"); fragmentTransaction.addToBackStack("detailmoviefragment"); fragmentTransaction.commit(); } } @Override public void onBackPressed() { if(getSupportFragmentManager().getBackStackEntryCount() > 0) { getSupportFragmentManager().popBackStackImmediate(); } else { super.onBackPressed(); } }} The layout for ListMovieFragment <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="6dp"> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ivMoviePoster" android:layout_width="match_parent" android:layout_height="300dp" android:src="@drawable/placeholder_poster" android:scaleType="fitXY" android:adjustViewBounds="true" android:transitionName="@string/transition_poster_image"> </ImageView></LinearLayout> Layout for DetailMovieFragment: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="me.androidbox.fragmenttransitions.detail.DetailMovieFragment"> <ImageView android:id="@+id/ivMovieDetailPoster" android:layout_width="140dp" android:layout_height="160dp" android:layout_marginEnd="16dp" android:layout_marginTop="112dp" android:adjustViewBounds="true" android:scaleType="fitXY" android:layout_gravity="end" android:transitionName="@string/transition_poster_image"/></FrameLayout> The string name for the transition name: <string name="transition_poster_image">imagePoster</string> The implementation seems simple so I think my mistake is something i'm overlooking. Many thanks for any suggestions, Now provide the response and nothing else.
You have two problems in your code, inside your onMovieSelected method: You're creating a new instance of ListMovieFragment and then apply transition logic to it. But you forgot that you already have the instance of this fragment (you were created it in onCreate method). So you need to retrieve the existing ListMovieFragment object from FragmentManager , and apply your transitions to it. You're applying transition logic to one instance of DetailMovieFragment , but then suddenly replacing the ListMoveFragment with the new one. So your fixed onMovieSelected method will be: @Overridepublic void onMovieSelected(int movieId) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { /* Get the fragments that will be using the transition */ ListMovieFragment listMovieFragment = (ListMovieFragment) getSupportFragmentManager().findFragmentByTag("listmoviefragment"); DetailMovieFragment detailMovieFragment = new DetailMovieFragment(); /* Inflate the transition */ Transition changeTransition = TransitionInflater .from(MainActivity.this) .inflateTransition(R.transition.change_image_transform); Transition explodeTransition = TransitionInflater .from(MainActivity.this) .inflateTransition(android.R.transition.explode); /* Set the exit and return on the source fragment (ListMovieFragment) */ listMovieFragment.setSharedElementReturnTransition(changeTransition); listMovieFragment.setExitTransition(explodeTransition); /* Set the enter on the destination fragment (MovieDetailFragment) */ detailMovieFragment.setSharedElementEnterTransition(changeTransition); detailMovieFragment.setEnterTransition(explodeTransition); /* Get the shared imageview from the source fragment (MovieListFragment) */ final ImageView ivSharedImage = (ImageView)findViewById(R.id.ivMoviePoster); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.activity_main, detailMovieFragment, "detailmoviefragment"); fragmentTransaction.addToBackStack("detailmoviefragment"); fragmentTransaction.addSharedElement(ivSharedImage, getResources().getString(R.string.transition_poster_image)); fragmentTransaction.commit(); } else { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.activity_main, new DetailMovieFragment(), "detailmoviefragment"); fragmentTransaction.addToBackStack("detailmoviefragment"); fragmentTransaction.commit(); }} Now this should work. P.S. I've used your code and run it, and noticed you have some strange transitions, so if you will have some issues, check this great article , how to make smooth and user-friendly transitions with fragments:)
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/41289234', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/70942/']}
jdg_75808
stackexchange
llm_judgeable_groundtruth_similarity
34647303
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Our REST APIs are returning results in Pages. Here is an example of one Controller @RequestMapping(value = "/search", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8")@ResponseStatus(HttpStatus.OK)public Page<MyObject> findAll(Pageable pageable) { ...} Is there an easy way to consume that API with RestTemplate? if we do ParameterizedTypeReference<Page<MyObject>> responseType = new ParameterizedTypeReference<Page<MyObject>>() { };ResponseEntity<Page<MyObject>> result = restTemplate.exchange(url, HttpMethod.GET, null/*httpEntity*/, responseType);List<MyObject> searchResult = result.getBody().getContent(); it throws an exception org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not construct instance of org.springframework.data.domain.Page, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information at [Source: java.io.PushbackInputStream@3be1e1f2; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.data.domain.Page, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information Thank you in advance Now provide the response and nothing else.
Changed the code reading the Rest API response as; ParameterizedTypeReference<RestResponsePage<MyObject>> responseType = new ParameterizedTypeReference<RestResponsePage<MyObject>>() { };ResponseEntity<RestResponsePage<MyObject>> result = restTemplate.exchange(url, HttpMethod.GET, null/*httpEntity*/, responseType);List<MyObject> searchResult = result.getBody().getContent(); And here is the class I created for RestResponsePage package com.basf.gb.cube.seq.vaadinui.util;import java.util.ArrayList;import java.util.List;import org.springframework.data.domain.PageImpl;import org.springframework.data.domain.Pageable;public class RestResponsePage<T> extends PageImpl<T>{ private static final long serialVersionUID = 3248189030448292002L; public RestResponsePage(List<T> content, Pageable pageable, long total) { super(content, pageable, total); // TODO Auto-generated constructor stub } public RestResponsePage(List<T> content) { super(content); // TODO Auto-generated constructor stub } /* PageImpl does not have an empty constructor and this was causing an issue for RestTemplate to cast the Rest API response * back to Page. */ public RestResponsePage() { super(new ArrayList<T>()); }}
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/34647303', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3795595/']}
jdg_75809
stackexchange
llm_judgeable_groundtruth_similarity
20688034
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Facing an HTTPSHandler error while installing python packages using pip, following is the stack trace, --------desktop:~$ pip install Django==1.3Traceback (most recent call last): File "/home/env/.genv/bin/pip", line 9, in <module> load_entry_point('pip==1.4.1', 'console_scripts', 'pip')() File "/home/env/.genv/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/home/env/.genv/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point return ep.load() File "/home/env/.genv/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/home/env/.genv/lib/python2.7/site-packages/pip/__init__.py", line 10, in <module> from pip.util import get_installed_distributions, get_prog File "/home/env/.genv/lib/python2.7/site-packages/pip/util.py", line 17, in <module> from pip.vendor.distlib import version File "/home/env/.genv/lib/python2.7/site-packages/pip/vendor/distlib/version.py", line 13, in <module> from .compat import string_types File "/home/env/.genv/lib/python2.7/site-packages/pip/vendor/distlib/compat.py", line 31, in <module> from urllib2 import (Request, urlopen, URLError, HTTPError,ImportError: cannot import name HTTPSHandler I used to edit Modules/setup.dist file and uncomment SSL code lines and rebuilt it, with reference to following thread : http://forums.opensuse.org/english/get-technical-help-here/applications/488962-opensuse-python-openssl-2.html Now provide the response and nothing else.
OSX + homebrew users: You can get the latest updates to the recipe: brew reinstall python But if you still get the issue, e.g. maybe you have upgraded your OS, then you may need to get the latest openssl first. You can check which version and where it is used from: openssl version -awhich openssl To get the latest openssl: brew updatebrew install opensslbrew link --overwrite --dry-run openssl # safety first.brew link openssl --overwrite This may issue a warning: bash-4.3$ brew link --overwrite --dry-run opensslWarning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib Side note: this warning means that for other apps, you may want to use export LDFLAGS=-L/usr/local/opt/openssl/libexport CPPFLAGS=-I/usr/local/opt/openssl/include Then recompile python: brew uninstall pythonbrew install python --with-brewed-openssl or for python 3 brew uninstall python3brew install python3 --with-brewed-openssl
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/20688034', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3016020/']}
jdg_75810
stackexchange
llm_judgeable_groundtruth_similarity
54616643
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a string below that is a price in £, I want to remove the currency symbol and then convert this into a number/price I can use to compare against another value (eg. X >= Y ...) £14.50 I have previously converted strings to numbers used for currency with var priceNum = parseFloat(price); IDEAL OUTCOME 14.50 as a number value. Can this be done in a single line? Now provide the response and nothing else.
If the currency symbol will always be there, just use substring : var priceNum = parseFloat(price.substring(1)); If it may or may not be there, you could use replace to remove it: var priceNum = parseFloat(price.replace(/£/g, "")); Beware that parseFloat("") is 0 . If you don't want 0 for an empty input string, you'll need to handle that. This answer has a rundown of the various way to convert strings to numbers in JavaScript and what they do in various situations. Side note: Using JavaScript's standard numbers for currency information is generally not best practice, because if things like the classic 0.1 + 0.2 issue (the result is 0.30000000000000004 , not 0.3 ). There are various libraries to help, and BigInt is coming to JavaScript as well (it's a Stage 3 proposal at the moment, currently shipping in Chrome). BigInt is useful because you can use multiples of your basic currency (for instance, * 100 for pounds and pence).
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/54616643', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9289798/']}
jdg_75811
stackexchange
llm_judgeable_groundtruth_similarity
49296318
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I want to set different font sizes for iPhone 5, iPhone 6 Plus, iPhone 7 Plus and iPhone X using Xcode Storyboard. Can anyone offer any advice? Now provide the response and nothing else.
Use Size-Class and add size variation for fonts from Attribute Inspector of Label property. Here are different possible variations, you can set with Size class: Try this: Here is (result) preview of font-size variation, in iPhone and iPad Update The result you are expecting, may not be possible using IB (Storyboard) but you can try it with following programmatic solution: extension UIDevice { enum DeviceType: String { case iPhone4_4S = "iPhone 4 or iPhone 4S" case iPhones_5_5s_5c_SE = "iPhone 5, iPhone 5s, iPhone 5c or iPhone SE" case iPhones_6_6s_7_8 = "iPhone 6, iPhone 6S, iPhone 7 or iPhone 8" case iPhones_6Plus_6sPlus_7Plus_8Plus = "iPhone 6 Plus, iPhone 6S Plus, iPhone 7 Plus or iPhone 8 Plus" case iPhoneX = "iPhone X" case unknown = "iPadOrUnknown" } var deviceType: DeviceType { switch UIScreen.main.nativeBounds.height { case 960: return .iPhone4_4S case 1136: return .iPhones_5_5s_5c_SE case 1334: return .iPhones_6_6s_7_8 case 1920, 2208: return .iPhones_6Plus_6sPlus_7Plus_8Plus case 2436: return .iPhoneX default: return .unknown } }}// Get device type (with help of above extension) and assign font size accordingly.let label = UILabel()let deviceType = UIDevice.current.deviceTypeswitch deviceType { case .iPhone4_4S: label.font = UIFont.systemFont(ofSize: 10) case .iPhones_5_5s_5c_SE: label.font = UIFont.systemFont(ofSize: 12) case .iPhones_6_6s_7_8: label.font = UIFont.systemFont(ofSize: 14) case .iPhones_6Plus_6sPlus_7Plus_8Plus: label.font = UIFont.systemFont(ofSize: 16) case .iPhoneX: label.font = UIFont.systemFont(ofSize: 18) default: print("iPad or Unkown device") label.font = UIFont.systemFont(ofSize: 20)}
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/49296318', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7241050/']}
jdg_75812
stackexchange
llm_judgeable_groundtruth_similarity
12526194
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a users table and a payments table, for each user, those of which have payments, may have multiple associated payments in the payments table. I would like to select all users who have payments, but only select their latest payment. I'm trying this SQL but i've never tried nested SQL statements before so I want to know what i'm doing wrong. Appreciate the help SELECT u.* FROM users AS u INNER JOIN ( SELECT p.* FROM payments AS p ORDER BY date DESC LIMIT 1 ) ON p.user_id = u.idWHERE u.package = 1 Now provide the response and nothing else.
You need to have a subquery to get their latest date per user ID . SELECT a.*, c.*FROM users a INNER JOIN payments c ON a.id = c.user_ID INNER JOIN ( SELECT user_ID, MAX(date) maxDate FROM payments GROUP BY user_ID ) b ON c.user_ID = b.user_ID AND c.date = b.maxDateWHERE a.package = 1
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/12526194', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/695408/']}
jdg_75813
stackexchange
llm_judgeable_groundtruth_similarity
11352249
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm new to threading in C++, and I'm trying to get a clear picture about how memory is shared/not shared between threads. I'm using std::thread with C++11.From what I've read on other SO questions, stack memory is owned by only one thread and heap memory is shared between threads. So from what I think I understand about the stack vs. the heap, the following should be true: #include <thread>using namespace std;class Obj {public: int x; Obj(){x = 0;}};int main() { Obj stackObj; Obj *heapObj = new Obj(); thread t([&]{ stackObj.x++; heapObj->x++; }); t.join(); assert(heapObj->x == 1); assert(stackObj.x == 0);} forgive me if I screwed up a bunch of stuff, lambda syntax is very new to me. But hopefully what I'm trying to do is coherent.Would this perform as I expect? And if not, what am I misunderstanding? Now provide the response and nothing else.
Memory is memory. An object in C++ occupies some location in memory; that location may be on a stack or on the heap, or it may have been statically allocated. It doesn't matter where the object is located: any thread that has a reference or pointer to the object may access the object. If two threads have a reference or a pointer to the object, then both threads may access it. In your program, you create a worker thread (by constructing a std::thread ) that executes the lambda expression you provide it. Because you capture both stackObj and heapObj by reference (using the [&] capture default), that lambda has references to both of those objects. Those objects are both located on the main thread's stack (note that heapObj is a pointer-type object that is located on the main thread's stack and points to a dynamically allocated object that is located on the heap). No copies of these objects are made; rather, your lambda expression has references to the objects. It modifies the stackObj directly and modifies the object pointed to by heapObj indirectly. After the main thread joins with the worker thread, both heapObj->x and stackObj.x have a value of 1 . If you had used the value capture default ( [=] ), your lambda expression would have copied both stackObj and heapObj . The expression stackObj.x++ in the lambda expression would increment the copy , and the stackObj that you declare in main() would be left unchanged. If you capture the heapObj by value, only the pointer itself is copied, so while a copy of the pointer is used, it still points to the same dynamically allocated object. The expression heapObj->x++ would dereference that pointer, yielding the Obj you created via new Obj() , and increment its value. You would then observe at the end of main() that heapObj->x has been incremented. (Note that in order to modify an object captured by value, the lambda expression must be declared mutable .)
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/11352249', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1291990/']}
jdg_75814
stackexchange
llm_judgeable_groundtruth_similarity
308397
Below is a question asked on the forum stats.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: In RCTs, randomisation balances unmeasured confounders and, I'm told, ATE and ATT would be the same. In observational studies, this is not possible and Propensity Scores are used in various ways to estimate ATT and/or ATE. The analyses that I've performed and examples that I've seen (eg this helpful text ) shows different ATT and ATE (albeit slightly). Please can anyone help me understand why they are different and, more importantly, what the differences mean (eg. if ATE>ATT or ATT>ATE), if anything? Now provide the response and nothing else.
The Average Treatment Effect ( ATE ) and the Average Treatment Effect on Treated ( ATT ) are commonly defined across the different groups of individuals. In addition, ATE and ATT are often different because they might measure outcomes ($Y$) that are not affected from the treatment $D$ in the same manner. First, some additional notation: $Y^0$: population-level random variable for outcome $Y$ in control state. $Y^1$: population-level random variable for outcome $Y$ in treatment state. $\delta$: individual-level causal effect of the treatment. $\pi$: proportion of population that takes treatment. Given the above, the ATT is defined as: $\mathrm{E}[\delta|D=1]$ ie. what is the expected causal effect of the treatment for individuals in the treatment group. This can be decomposed more meaningfully as:\begin{align}\mathrm{E}[\delta|D=1] = & \mathrm{E}[Y^1 - Y^0|D=1] \\ & \mathrm{E}[Y^1|D=1] - \mathrm{E}[Y^0|D=1]\end{align} (Notice that $\mathrm{E}[Y^0|D=1]$ is unobserved so it refers to a counterfactual variable which is not realised in our observed sample.)Similarly the ATE is defined as: $\mathrm{E}[\delta]$, ie. what is the expected causal effect of the treatment across all individuals in the population. Again we can decompose this more meaningfully as: \begin{align}\mathrm{E}[\delta] =& \{ \pi \mathrm{E}[Y^1|D=1] + (1-\pi) \mathrm{E}[Y^1|D=0] \} \\ -& \{ \pi \mathrm{E}[Y^0|D=1] + (1-\pi) \mathrm{E}[Y^0|D=0] \}\end{align} As you see the ATT and the more general ATE are referring by definition to different portions of the population of interest. More importantly, in the ideal scenario of a randomised control trial ( RCT ) ATE equals ATT because we assume that: $\mathrm{E}[Y^0|D=1] = \mathrm{E}[Y^0|D=0]$ and $\mathrm{E}[Y^1|D=1] = \mathrm{E}[Y^1|D=0]$, ie. we have believe respectively that: the baseline of the treatment group equals the baseline of the control group (layman terms: people in the treatment group would do as bad as the control group if they were not treated) and the treatment effect on the treated group equals the treatment effect on the control group (layman terms: people in the control group would do as good as the treatment group if they were treated). These are very strong assumptions which are commonly violated in observational studies and therefore the ATT and the ATE are not expected to be equal. (Notice that if only the baselines are equal, you can still get an ATT through simple differences: $\mathrm{E}[Y^1|D=1] - \mathrm{E}[Y^0|D=0]$.) Especially in the cases where the individuals self-select to enter the treatment group or not (eg. an e-shop providing cash bonus where a customer can redeem a bonus coupon for $X$ amount given she shops items worth at least $Y$ amount) the baselines as well as the treatment effects can be different (eg. repeat buyers are more likely to redeem such a bonus, low-value customers might find the threshold $Y$ unrealistically high or high-value customers might be indifferent to the bonus amount $X$ - this also relates to SUTVA ). In scenarios like this even talking about ATE is probably ill-defined (eg. it is unrealistic to expect that all the customers of an e-shop will ever shop items worth $Y$). ATT being unequal to ATE is not unexpected. If ATT is smaller or greater than ATE is application specific. The inequality of the two suggests that the treatment assignment mechanism was potentially not random. In general, in an observational study because the above-mentioned assumptions do not generally hold, we either partition our sample accordingly or we control for difference through "regression-like" techniques. For a more detailed but easy to follow exposition of the matter I recommend looking into Morgan & Winship's Counterfactuals and Causal Inference .
{}
{'log_upvote_score': 7, 'links': ['https://stats.stackexchange.com/questions/308397', 'https://stats.stackexchange.com', 'https://stats.stackexchange.com/users/112640/']}
jdg_75815
stackexchange
llm_judgeable_groundtruth_similarity
59070
Below is a question asked on the forum mathematica.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I have data in the form points = {{1, 1, 1}, {1, 1, 2}, ...}vectors = {{2, 2, 5}, {2, 1, 7}, ...} Can somebody help to edit this data so I can ListVectorPlot a vector point[[i]] + vector[[i]] from a point point[[i]] ? Nothing seems to work! :( The data I have to work with is: points = {{-100, -100, 0}, {-100, -80, 0}, {-100, -60, 0}, {-100, -40, 0}, {-100, -20, 0}, {-100, 0, 0}, {-100, 20, 0}, {-100, 40, 0}, {-100, 60, 0}, {-100, 80, 0}, {-100, 100, 0}, {-80, -100, 0}, {-80, -80, 0}, {-80, -60, 0}, {-80, -40, 0}, {-80, -20, 0}, {-80, 0, 0}, {-80, 20, 0}, {-80, 40, 0}, {-80, 60, 0}, {-80, 80, 0}, {-80, 100, 0}, {-60, -100, 0}, {-60, -80, 0}, {-60, -60, 0}, {-60, -40, 0}, {-60, -20, 0}, {-60, 0, 0}, {-60, 20, 0}, {-60, 40, 0}, {-60, 60, 0}, {-60, 80, 0}, {-60, 100, 0}, {-40, -100, 0}, {-40, -80, 0}, {-40, -60, 0}, {-40, -40, 0}, {-40, -20, 0}, {-40, 0, 0}, {-40, 20, 0}, {-40, 40, 0}, {-40, 60, 0}, {-40, 80, 0}, {-40, 100, 0}, {-20, -100, 0}, {-20, -80, 0}, {-20, -60, 0}, {-20, -40, 0}, {-20, -20, 0}, {-20, 0, 0}, {-20, 20, 0}, {-20, 40, 0}, {-20, 60, 0}, {-20, 80, 0}, {-20, 100, 0}, {0, -100, 0}, {0, -80, 0}, {0, -60, 0}, {0, -40, 0}, {0, -20, 0}, {0, 0, 0}, {0, 20, 0}, {0, 40, 0}, {0, 60, 0}, {0, 80, 0}, {0, 100, 0}, {20, -100, 0}, {20, -80, 0}, {20, -60, 0}, {20, -40, 0}, {20, -20, 0}, {20, 0, 0}, {20, 20, 0}, {20, 40, 0}, {20, 60, 0}, {20, 80, 0}, {20, 100, 0}, {40, -100, 0}, {40, -80, 0}, {40, -60, 0}, {40, -40, 0}, {40, -20, 0}, {40, 0, 0}, {40, 20, 0}, {40, 40, 0}, {40, 60, 0}, {40, 80, 0}, {40, 100, 0}, {60, -100, 0}, {60, -80, 0}, {60, -60, 0}, {60, -40, 0}, {60, -20, 0}, {60, 0, 0}, {60, 20, 0}, {60, 40, 0}, {60, 60, 0}, {60, 80, 0}, {60, 100, 0}, {80, -100, 0}, {80, -80, 0}, {80, -60, 0}, {80, -40, 0}, {80, -20, 0}, {80, 0, 0}, {80, 20, 0}, {80, 40, 0}, {80, 60, 0}, {80, 80, 0}, {80, 100, 0}, {100, -100, 0}, {100, -80, 0}, {100, -60, 0}, {100, -40, 0}, {100, -20, 0}, {100, 0, 0}, {100, 20, 0}, {100, 40, 0}, {100, 60, 0}, {100, 80, 0}, {100, 100, 0}} and vectors = {{0., 0., -2.94877*10^-11}, {0., 0., -3.17712*10^-11}, {0., 0., -3.15544*10^-11}, {0., 0., -2.67049*10^-11}, {0., 0., -1.57288*10^-11}, {0., 0., 0.}, {0., 0., 1.57288*10^-11}, {0., 0., 2.67049*10^-11}, {0., 0., 3.15544*10^-11}, {0., 0., 3.17712*10^-11}, {0., 0., 2.94877*10^-11}, {0., 0., -3.97097*10^-11}, {0., 0., -4.60745*10^-11}, {0., 0., -5.00432*10^-11}, {0., 0., -4.66251*10^-11}, {0., 0., -2.97483*10^-11}, {0., 0., 0.}, {0., 0., 2.97483*10^-11}, {0., 0., 4.66251*10^-11}, {0., 0., 5.00432*10^-11}, {0., 0., 4.60745*10^-11}, {0., 0., 3.97097*10^-11}, {0., 0., -5.2583*10^-11}, {0., 0., -6.67217*10^-11}, {0., 0., -8.19101*10^-11}, {0., 0., -8.89697*10^-11}, {0., 0., -6.59367*10^-11}, {0., 0., 0.}, {0., 0., 6.59367*10^-11}, {0., 0., 8.89697*10^-11}, {0., 0., 8.19101*10^-11}, {0., 0., 6.67217*10^-11}, {0., 0., 5.2583*10^-11}, {0., 0., -6.67523*10^-11}, {0., 0., -9.3246*10^-11}, {0., 0., -1.33453*10^-10}, {0., 0., -1.84298*10^-10}, {0., 0., -1.86496*10^-10}, {0., 0., 0.}, {0., 0., 1.86496*10^-10}, {0., 0., 1.84298*10^-10}, {0., 0., 1.33453*10^-10}, {0., 0., 9.3246*10^-11}, {0., 0., 6.67523*10^-11}, {0., 0., -7.86329*10^-11}, {0., 0., -1.18988*10^-10}, {0., 0., -1.97808*10^-10}, {0., 0., -3.72992*10^-10}, {0., 0., -7.37191*10^-10}, {0., 0., 0.}, {0., 0., 7.37191*10^-10}, {0., 0., 3.72992*10^-10}, {0., 0., 1.97808*10^-10}, {0., 0., 1.18988*10^-10}, {0., 0., 7.86329*10^-11}, {0., 0., -3.13741*10^-11}, {0., 0., -4.65701*10^-11}, {0., 0., -7.45312*10^-11}, {0., 0., -1.2865*10^-10}, {0., 0., -2.005*10^-10}, {0., 0., 0.}, {0., 0., 2.005*10^-10}, {0., 0., 1.2865*10^-10}, {0., 0., 7.45312*10^-11}, {0., 0., 4.65701*10^-11}, {0., 0., 3.13741*10^-11}, {0., 0., -7.86329*10^-11}, {0., 0., -1.18988*10^-10}, {0., 0., -1.97808*10^-10}, {0., 0., -3.72992*10^-10}, {0., 0., -7.37191*10^-10}, {0., 0., 0.}, {0., 0., 7.37191*10^-10}, {0., 0., 3.72992*10^-10}, {0., 0., 1.97808*10^-10}, {0., 0., 1.18988*10^-10}, {0., 0., 7.86329*10^-11}, {0., 0., -6.67523*10^-11}, {0., 0., -9.3246*10^-11}, {0., 0., -1.33453*10^-10}, {0., 0., -1.84298*10^-10}, {0., 0., -1.86496*10^-10}, {0., 0., 0.}, {0., 0., 1.86496*10^-10}, {0., 0., 1.84298*10^-10}, {0., 0., 1.33453*10^-10}, {0., 0., 9.3246*10^-11}, {0., 0., 6.67523*10^-11}, {0., 0., -5.2583*10^-11}, {0., 0., -6.67217*10^-11}, {0., 0., -8.19101*10^-11}, {0., 0., -8.89697*10^-11}, {0., 0., -6.59367*10^-11}, {0., 0., 0.}, {0., 0., 6.59367*10^-11}, {0., 0., 8.89697*10^-11}, {0., 0., 8.19101*10^-11}, {0., 0., 6.67217*10^-11}, {0., 0., 5.2583*10^-11}, {0., 0., -3.97097*10^-11}, {0., 0., -4.60745*10^-11}, {0., 0., -5.00432*10^-11}, {0., 0., -4.66251*10^-11}, {0., 0., -2.97483*10^-11}, {0., 0., 0.}, {0., 0., 2.97483*10^-11}, {0., 0., 4.66251*10^-11}, {0., 0., 5.00432*10^-11}, {0., 0., 4.60745*10^-11}, {0., 0., 3.97097*10^-11}, {0., 0., -2.94877*10^-11}, {0., 0., -3.17712*10^-11}, {0., 0., -3.15544*10^-11}, {0., 0., -2.67049*10^-11}, {0., 0., -1.57288*10^-11}, {0., 0., 0.}, {0., 0., 1.57288*10^-11}, {0., 0., 2.67049*10^-11}, {0., 0., 3.15544*10^-11}, {0., 0., 3.17712*10^-11}, {0., 0., 2.94877*10^-11}} This code works Graphics3D[ Table[{Arrowheads[Small], Arrow[{tocke[[i]], polje[[i]] + tocke[[i]]}]}, {i, 1, 121}], Axes -> True, AxesLabel -> {x, y}] but I don't like the ouput and hopefully ListVectorPlot does it better. @m_goldberg Here is the data and it does not work: poljez0 = {{0., 0., -2.94877*10^-11}, {0., 0., -3.08265*10^-11}, {0., 0., -3.17712*10^-11}, {0., 0., -3.21021*10^-11}, {0., 0., -3.15544*10^-11}, {0., 0., -2.98416*10^-11}, {0., 0., -2.67049*10^-11}, {0., 0., -2.19887*10^-11}, {0., 0., -1.57288*10^-11}, {0., 0., -8.21739*10^-12}, {0., 0., 0.}, {0., 0., 8.21739*10^-12}, {0., 0., 1.57288*10^-11}, {0., 0., 2.19887*10^-11}, {0., 0., 2.67049*10^-11}, {0., 0., 2.98416*10^-11}, {0., 0., 3.15544*10^-11}, {0., 0., 3.21021*10^-11}, {0., 0., 3.17712*10^-11}, {0., 0., 3.08265*10^-11}, {0., 0., 2.94877*10^-11}, {0., 0., -3.42494*10^-11}, {0., 0., -3.64045*10^-11}, {0., 0., -3.82149*10^-11}, {0., 0., -3.93897*10^-11}, {0., 0., -3.95435*10^-11}, {0., 0., -3.82133*10^-11}, {0., 0., -3.49226*10^-11}, {0., 0., -2.93063*10^-11}, {0., 0., -2.12865*10^-11}, {0., 0., -1.12326*10^-11}, {0., 0., 0.}, {0., 0., 1.12326*10^-11}, {0., 0., 2.12865*10^-11}, {0., 0., 2.93063*10^-11}, {0., 0., 3.49226*10^-11}, {0., 0., 3.82133*10^-11}, {0., 0., 3.95435*10^-11}, {0., 0., 3.93897*10^-11}, {0., 0., 3.82149*10^-11}, {0., 0., 3.64045*10^-11}, {0., 0., 3.42494*10^-11}, {0., 0., -3.97097*10^-11}, {0., 0., -4.29899*10^-11}, {0., 0., -4.60745*10^-11}, {0., 0., -4.86039*10^-11}, {0., 0., -5.00432*10^-11}, {0., 0., -4.96684*10^-11}, {0., 0., -4.66251*10^-11}, {0., 0., -4.01173*10^-11}, {0., 0., -2.97483*10^-11}, {0., 0., -1.59157*10^-11}, {0., 0., 0.}, {0., 0., 1.59157*10^-11}, {0., 0., 2.97483*10^-11}, {0., 0., 4.01173*10^-11}, {0., 0., 4.66251*10^-11}, {0., 0., 4.96684*10^-11}, {0., 0., 5.00432*10^-11}, {0., 0., 4.86039*10^-11}, {0., 0., 4.60745*10^-11}, {0., 0., 4.29899*10^-11}, {0., 0., 3.97097*10^-11}, {0., 0., -4.5854*10^-11}, {0., 0., -5.06406*10^-11}, {0., 0., -5.55459*10^-11}, {0., 0., -6.01789*10^-11}, {0., 0., -6.38574*10^-11}, {0., 0., -6.55107*10^-11}, {0., 0., -6.3662*10^-11}, {0., 0., -5.6646*10^-11}, {0., 0., -4.32321*10^-11}, {0., 0., -2.35904*10^-11}, {0., 0., 0.}, {0., 0., 2.35904*10^-11}, {0., 0., 4.32321*10^-11}, {0., 0., 5.6646*10^-11}, {0., 0., 6.3662*10^-11}, {0., 0., 6.55107*10^-11}, {0., 0., 6.38574*10^-11}, {0., 0., 6.01789*10^-11}, {0., 0., 5.55459*10^-11}, {0., 0., 5.06406*10^-11}, {0., 0., 4.5854*10^-11}, {0., 0., -5.2583*10^-11}, {0., 0., -5.93105*10^-11}, {0., 0., -6.67217*10^-11}, {0., 0., -7.44992*10^-11}, {0., 0., -8.19101*10^-11}, {0., 0., -8.7531*10^-11}, {0., 0., -8.89697*10^-11}, {0., 0., -8.28876*10^-11}, {0., 0., -6.59367*10^-11}, {0., 0., -3.70582*10^-11}, {0., 0., 0.}, {0., 0., 3.70582*10^-11}, {0., 0., 6.59367*10^-11}, {0., 0., 8.28876*10^-11}, {0., 0., 8.89697*10^-11}, {0., 0., 8.7531*10^-11}, {0., 0., 8.19101*10^-11}, {0., 0., 7.44992*10^-11}, {0., 0., 6.67217*10^-11}, {0., 0., 5.93105*10^-11}, {0., 0., 5.2583*10^-11}, {0., 0., -5.96744*10^-11}, {0., 0., -6.87782*10^-11}, {0., 0., -7.94658*10^-11}, {0., 0., -9.17131*10^-11}, {0., 0., -1.05036*10^-10}, {0., 0., -1.17951*10^-10}, {0., 0., -1.27078*10^-10}, {0., 0., -1.26209*10^-10}, {0., 0., -1.06812*10^-10}, {0., 0., -6.29109*10^-11}, {0., 0., 0.}, {0., 0., 6.29109*10^-11}, {0., 0., 1.06812*10^-10}, {0., 0., 1.26209*10^-10}, {0., 0., 1.27078*10^-10}, {0., 0., 1.17951*10^-10}, {0., 0., 1.05036*10^-10}, {0., 0., 9.17131*10^-11}, {0., 0., 7.94658*10^-11}, {0., 0., 6.87782*10^-11}, {0., 0., 5.96744*10^-11}, {0., 0., -6.67523*10^-11}, {0., 0., -7.85691*10^-11}, {0., 0., -9.3246*10^-11}, {0., 0., -1.11406*10^-10}, {0., 0., -1.33453*10^-10}, {0., 0., -1.58847*10^-10}, {0., 0., -1.84298*10^-10}, {0., 0., -2.00169*10^-10}, {0., 0., -1.86496*10^-10}, {0., 0., -1.1899*10^-10}, {0., 0., 0.}, {0., 0., 1.1899*10^-10}, {0., 0., 1.86496*10^-10}, {0., 0., 2.00169*10^-10}, {0., 0., 1.84298*10^-10}, {0., 0., 1.58847*10^-10}, {0., 0., 1.33453*10^-10}, {0., 0., 1.11406*10^-10}, {0., 0., 9.3246*10^-11}, {0., 0., 7.85691*10^-11}, {0., 0., 6.67523*10^-11}, {0., 0., -7.32848*10^-11}, {0., 0., -8.79115*10^-11}, {0., 0., -1.06975*10^-10}, {0., 0., -1.32171*10^-10}, {0., 0., -1.65774*10^-10}, {0., 0., -2.10347*10^-10}, {0., 0., -2.66891*10^-10}, {0., 0., -3.2764*10^-10}, {0., 0., -3.55877*10^-10}, {0., 0., -2.63745*10^-10}, {0., 0., 0.}, {0., 0., 2.63745*10^-10}, {0., 0., 3.55877*10^-10}, {0., 0., 3.2764*10^-10}, {0., 0., 2.66891*10^-10}, {0., 0., 2.10347*10^-10}, {0., 0., 1.65774*10^-10}, {0., 0., 1.32171*10^-10}, {0., 0., 1.06975*10^-10}, {0., 0., 8.79115*10^-11}, {0., 0., 7.32848*10^-11}, {0., 0., -7.86329*10^-11}, {0., 0., -9.57814*10^-11}, {0., 0., -1.18988*10^-10}, {0., 0., -1.51309*10^-10}, {0., 0., -1.97808*10^-10}, {0., 0., -2.67028*10^-10}, {0., 0., -3.72992*10^-10}, {0., 0., -5.33815*10^-10}, {0., 0., -7.37191*10^-10}, {0., 0., -7.45985*10^-10}, {0., 0., 0.}, {0., 0., 7.45985*10^-10}, {0., 0., 7.37191*10^-10}, {0., 0., 5.33815*10^-10}, {0., 0., 3.72992*10^-10}, {0., 0., 2.67028*10^-10}, {0., 0., 1.97808*10^-10}, {0., 0., 1.51309*10^-10}, {0., 0., 1.18988*10^-10}, {0., 0., 9.57814*10^-11}, {0., 0., 7.86329*10^-11}, {0., 0., -8.21623*10^-11}, {0., 0., -1.01086*10^-10}, {0., 0., -1.2732*10^-10}, {0., 0., -1.65129*10^-10}, {0., 0., -2.22347*10^-10}, {0., 0., -3.14553*10^-10}, {0., 0., -4.75961*10^-10}, {0., 0., -7.91236*10^-10}, {0., 0., -1.49197*10^-9}, {0., 0., -2.94876*10^-9}, {0., 0., 0.}, {0., 0., 2.94876*10^-9}, {0., 0., 1.49197*10^-9}, {0., 0., 7.91236*10^-10}, {0., 0., 4.75961*10^-10}, {0., 0., 3.14553*10^-10}, {0., 0., 2.22347*10^-10}, {0., 0., 1.65129*10^-10}, {0., 0., 1.2732*10^-10}, {0., 0., 1.01086*10^-10}, {0., 0., 8.21623*10^-11}, {0., 0., -3.13741*10^-11}, {0., 0., -3.79051*10^-11}, {0., 0., -4.65701*10^-11}, {0., 0., -5.83094*10^-11}, {0., 0., -7.45312*10^-11}, {0., 0., -9.72345*10^-11}, {0., 0., -1.2865*10^-10}, {0., 0., -1.68328*10^-10}, {0., 0., -2.005*10^-10}, {0., 0., -1.65281*10^-10}, {0., 0., 0.}, {0., 0., 1.65281*10^-10}, {0., 0., 2.005*10^-10}, {0., 0., 1.68328*10^-10}, {0., 0., 1.2865*10^-10}, {0., 0., 9.72345*10^-11}, {0., 0., 7.45312*10^-11}, {0., 0., 5.83094*10^-11}, {0., 0., 4.65701*10^-11}, {0., 0., 3.79051*10^-11}, {0., 0., 3.13741*10^-11}, {0., 0., -8.21623*10^-11}, {0., 0., -1.01086*10^-10}, {0., 0., -1.2732*10^-10}, {0., 0., -1.65129*10^-10}, {0., 0., -2.22347*10^-10}, {0., 0., -3.14553*10^-10}, {0., 0., -4.75961*10^-10}, {0., 0., -7.91236*10^-10}, {0., 0., -1.49197*10^-9}, {0., 0., -2.94876*10^-9}, {0., 0., 0.}, {0., 0., 2.94876*10^-9}, {0., 0., 1.49197*10^-9}, {0., 0., 7.91236*10^-10}, {0., 0., 4.75961*10^-10}, {0., 0., 3.14553*10^-10}, {0., 0., 2.22347*10^-10}, {0., 0., 1.65129*10^-10}, {0., 0., 1.2732*10^-10}, {0., 0., 1.01086*10^-10}, {0., 0., 8.21623*10^-11}, {0., 0., -7.86329*10^-11}, {0., 0., -9.57814*10^-11}, {0., 0., -1.18988*10^-10}, {0., 0., -1.51309*10^-10}, {0., 0., -1.97808*10^-10}, {0., 0., -2.67028*10^-10}, {0., 0., -3.72992*10^-10}, {0., 0., -5.33815*10^-10}, {0., 0., -7.37191*10^-10}, {0., 0., -7.45985*10^-10}, {0., 0., 0.}, {0., 0., 7.45985*10^-10}, {0., 0., 7.37191*10^-10}, {0., 0., 5.33815*10^-10}, {0., 0., 3.72992*10^-10}, {0., 0., 2.67028*10^-10}, {0., 0., 1.97808*10^-10}, {0., 0., 1.51309*10^-10}, {0., 0., 1.18988*10^-10}, {0., 0., 9.57814*10^-11}, {0., 0., 7.86329*10^-11}, {0., 0., -7.32848*10^-11}, {0., 0., -8.79115*10^-11}, {0., 0., -1.06975*10^-10}, {0., 0., -1.32171*10^-10}, {0., 0., -1.65774*10^-10}, {0., 0., -2.10347*10^-10}, {0., 0., -2.66891*10^-10}, {0., 0., -3.2764*10^-10}, {0., 0., -3.55877*10^-10}, {0., 0., -2.63745*10^-10}, {0., 0., 0.}, {0., 0., 2.63745*10^-10}, {0., 0., 3.55877*10^-10}, {0., 0., 3.2764*10^-10}, {0., 0., 2.66891*10^-10}, {0., 0., 2.10347*10^-10}, {0., 0., 1.65774*10^-10}, {0., 0., 1.32171*10^-10}, {0., 0., 1.06975*10^-10}, {0., 0., 8.79115*10^-11}, {0., 0., 7.32848*10^-11}, {0., 0., -6.67523*10^-11}, {0., 0., -7.85691*10^-11}, {0., 0., -9.3246*10^-11}, {0., 0., -1.11406*10^-10}, {0., 0., -1.33453*10^-10}, {0., 0., -1.58847*10^-10}, {0., 0., -1.84298*10^-10}, {0., 0., -2.00169*10^-10}, {0., 0., -1.86496*10^-10}, {0., 0., -1.1899*10^-10}, {0., 0., 0.}, {0., 0., 1.1899*10^-10}, {0., 0., 1.86496*10^-10}, {0., 0., 2.00169*10^-10}, {0., 0., 1.84298*10^-10}, {0., 0., 1.58847*10^-10}, {0., 0., 1.33453*10^-10}, {0., 0., 1.11406*10^-10}, {0., 0., 9.3246*10^-11}, {0., 0., 7.85691*10^-11}, {0., 0., 6.67523*10^-11}, {0., 0., -5.96744*10^-11}, {0., 0., -6.87782*10^-11}, {0., 0., -7.94658*10^-11}, {0., 0., -9.17131*10^-11}, {0., 0., -1.05036*10^-10}, {0., 0., -1.17951*10^-10}, {0., 0., -1.27078*10^-10}, {0., 0., -1.26209*10^-10}, {0., 0., -1.06812*10^-10}, {0., 0., -6.29109*10^-11}, {0., 0., 0.}, {0., 0., 6.29109*10^-11}, {0., 0., 1.06812*10^-10}, {0., 0., 1.26209*10^-10}, {0., 0., 1.27078*10^-10}, {0., 0., 1.17951*10^-10}, {0., 0., 1.05036*10^-10}, {0., 0., 9.17131*10^-11}, {0., 0., 7.94658*10^-11}, {0., 0., 6.87782*10^-11}, {0., 0., 5.96744*10^-11}, {0., 0., -5.2583*10^-11}, {0., 0., -5.93105*10^-11}, {0., 0., -6.67217*10^-11}, {0., 0., -7.44992*10^-11}, {0., 0., -8.19101*10^-11}, {0., 0., -8.7531*10^-11}, {0., 0., -8.89697*10^-11}, {0., 0., -8.28876*10^-11}, {0., 0., -6.59367*10^-11}, {0., 0., -3.70582*10^-11}, {0., 0., 0.}, {0., 0., 3.70582*10^-11}, {0., 0., 6.59367*10^-11}, {0., 0., 8.28876*10^-11}, {0., 0., 8.89697*10^-11}, {0., 0., 8.7531*10^-11}, {0., 0., 8.19101*10^-11}, {0., 0., 7.44992*10^-11}, {0., 0., 6.67217*10^-11}, {0., 0., 5.93105*10^-11}, {0., 0., 5.2583*10^-11}, {0., 0., -4.5854*10^-11}, {0., 0., -5.06406*10^-11}, {0., 0., -5.55459*10^-11}, {0., 0., -6.01789*10^-11}, {0., 0., -6.38574*10^-11}, {0., 0., -6.55107*10^-11}, {0., 0., -6.3662*10^-11}, {0., 0., -5.6646*10^-11}, {0., 0., -4.32321*10^-11}, {0., 0., -2.35904*10^-11}, {0., 0., 0.}, {0., 0., 2.35904*10^-11}, {0., 0., 4.32321*10^-11}, {0., 0., 5.6646*10^-11}, {0., 0., 6.3662*10^-11}, {0., 0., 6.55107*10^-11}, {0., 0., 6.38574*10^-11}, {0., 0., 6.01789*10^-11}, {0., 0., 5.55459*10^-11}, {0., 0., 5.06406*10^-11}, {0., 0., 4.5854*10^-11}, {0., 0., -3.97097*10^-11}, {0., 0., -4.29899*10^-11}, {0., 0., -4.60745*10^-11}, {0., 0., -4.86039*10^-11}, {0., 0., -5.00432*10^-11}, {0., 0., -4.96684*10^-11}, {0., 0., -4.66251*10^-11}, {0., 0., -4.01173*10^-11}, {0., 0., -2.97483*10^-11}, {0., 0., -1.59157*10^-11}, {0., 0., 0.}, {0., 0., 1.59157*10^-11}, {0., 0., 2.97483*10^-11}, {0., 0., 4.01173*10^-11}, {0., 0., 4.66251*10^-11}, {0., 0., 4.96684*10^-11}, {0., 0., 5.00432*10^-11}, {0., 0., 4.86039*10^-11}, {0., 0., 4.60745*10^-11}, {0., 0., 4.29899*10^-11}, {0., 0., 3.97097*10^-11}, {0., 0., -3.42494*10^-11}, {0., 0., -3.64045*10^-11}, {0., 0., -3.82149*10^-11}, {0., 0., -3.93897*10^-11}, {0., 0., -3.95435*10^-11}, {0., 0., -3.82133*10^-11}, {0., 0., -3.49226*10^-11}, {0., 0., -2.93063*10^-11}, {0., 0., -2.12865*10^-11}, {0., 0., -1.12326*10^-11}, {0., 0., 0.}, {0., 0., 1.12326*10^-11}, {0., 0., 2.12865*10^-11}, {0., 0., 2.93063*10^-11}, {0., 0., 3.49226*10^-11}, {0., 0., 3.82133*10^-11}, {0., 0., 3.95435*10^-11}, {0., 0., 3.93897*10^-11}, {0., 0., 3.82149*10^-11}, {0., 0., 3.64045*10^-11}, {0., 0., 3.42494*10^-11}, {0., 0., -2.94877*10^-11}, {0., 0., -3.08265*10^-11}, {0., 0., -3.17712*10^-11}, {0., 0., -3.21021*10^-11}, {0., 0., -3.15544*10^-11}, {0., 0., -2.98416*10^-11}, {0., 0., -2.67049*10^-11}, {0., 0., -2.19887*10^-11}, {0., 0., -1.57288*10^-11}, {0., 0., -8.21739*10^-12}, {0., 0., 0.}, {0., 0., 8.21739*10^-12}, {0., 0., 1.57288*10^-11}, {0., 0., 2.19887*10^-11}, {0., 0., 2.67049*10^-11}, {0., 0., 2.98416*10^-11}, {0., 0., 3.15544*10^-11}, {0., 0., 3.21021*10^-11}, {0., 0., 3.17712*10^-11}, {0., 0., 3.08265*10^-11}, {0., 0., 2.94877*10^-11}} and tockez0 = {{-100, -100, 10}, {-90, -100, 10}, {-80, -100, 10}, {-70, -100, 10}, {-60, -100, 10}, {-50, -100, 10}, {-40, -100, 10}, {-30, -100, 10}, {-20, -100, 10}, {-10, -100, 10}, {0, -100, 10}, {10, -100, 10}, {20, -100, 10}, {30, -100, 10}, {40, -100, 10}, {50, -100, 10}, {60, -100, 10}, {70, -100, 10}, {80, -100, 10}, {90, -100, 10}, {100, -100, 10}, {-100, -90, 10}, {-90, -90, 10}, {-80, -90, 10}, {-70, -90, 10}, {-60, -90, 10}, {-50, -90, 10}, {-40, -90, 10}, {-30, -90, 10}, {-20, -90, 10}, {-10, -90, 10}, {0, -90, 10}, {10, -90, 10}, {20, -90, 10}, {30, -90, 10}, {40, -90, 10}, {50, -90, 10}, {60, -90, 10}, {70, -90, 10}, {80, -90, 10}, {90, -90, 10}, {100, -90, 10}, {-100, -80, 10}, {-90, -80, 10}, {-80, -80, 10}, {-70, -80, 10}, {-60, -80, 10}, {-50, -80, 10}, {-40, -80, 10}, {-30, -80, 10}, {-20, -80, 10}, {-10, -80, 10}, {0, -80, 10}, {10, -80, 10}, {20, -80, 10}, {30, -80, 10}, {40, -80, 10}, {50, -80, 10}, {60, -80, 10}, {70, -80, 10}, {80, -80, 10}, {90, -80, 10}, {100, -80, 10}, {-100, -70, 10}, {-90, -70, 10}, {-80, -70, 10}, {-70, -70, 10}, {-60, -70, 10}, {-50, -70, 10}, {-40, -70, 10}, {-30, -70, 10}, {-20, -70, 10}, {-10, -70, 10}, {0, -70, 10}, {10, -70, 10}, {20, -70, 10}, {30, -70, 10}, {40, -70, 10}, {50, -70, 10}, {60, -70, 10}, {70, -70, 10}, {80, -70, 10}, {90, -70, 10}, {100, -70, 10}, {-100, -60, 10}, {-90, -60, 10}, {-80, -60, 10}, {-70, -60, 10}, {-60, -60, 10}, {-50, -60, 10}, {-40, -60, 10}, {-30, -60, 10}, {-20, -60, 10}, {-10, -60, 10}, {0, -60, 10}, {10, -60, 10}, {20, -60, 10}, {30, -60, 10}, {40, -60, 10}, {50, -60, 10}, {60, -60, 10}, {70, -60, 10}, {80, -60, 10}, {90, -60, 10}, {100, -60, 10}, {-100, -50, 10}, {-90, -50, 10}, {-80, -50, 10}, {-70, -50, 10}, {-60, -50, 10}, {-50, -50, 10}, {-40, -50, 10}, {-30, -50, 10}, {-20, -50, 10}, {-10, -50, 10}, {0, -50, 10}, {10, -50, 10}, {20, -50, 10}, {30, -50, 10}, {40, -50, 10}, {50, -50, 10}, {60, -50, 10}, {70, -50, 10}, {80, -50, 10}, {90, -50, 10}, {100, -50, 10}, {-100, -40, 10}, {-90, -40, 10}, {-80, -40, 10}, {-70, -40, 10}, {-60, -40, 10}, {-50, -40, 10}, {-40, -40, 10}, {-30, -40, 10}, {-20, -40, 10}, {-10, -40, 10}, {0, -40, 10}, {10, -40, 10}, {20, -40, 10}, {30, -40, 10}, {40, -40, 10}, {50, -40, 10}, {60, -40, 10}, {70, -40, 10}, {80, -40, 10}, {90, -40, 10}, {100, -40, 10}, {-100, -30, 10}, {-90, -30, 10}, {-80, -30, 10}, {-70, -30, 10}, {-60, -30, 10}, {-50, -30, 10}, {-40, -30, 10}, {-30, -30, 10}, {-20, -30, 10}, {-10, -30, 10}, {0, -30, 10}, {10, -30, 10}, {20, -30, 10}, {30, -30, 10}, {40, -30, 10}, {50, -30, 10}, {60, -30, 10}, {70, -30, 10}, {80, -30, 10}, {90, -30, 10}, {100, -30, 10}, {-100, -20, 10}, {-90, -20, 10}, {-80, -20, 10}, {-70, -20, 10}, {-60, -20, 10}, {-50, -20, 10}, {-40, -20, 10}, {-30, -20, 10}, {-20, -20, 10}, {-10, -20, 10}, {0, -20, 10}, {10, -20, 10}, {20, -20, 10}, {30, -20, 10}, {40, -20, 10}, {50, -20, 10}, {60, -20, 10}, {70, -20, 10}, {80, -20, 10}, {90, -20, 10}, {100, -20, 10}, {-100, -10, 10}, {-90, -10, 10}, {-80, -10, 10}, {-70, -10, 10}, {-60, -10, 10}, {-50, -10, 10}, {-40, -10, 10}, {-30, -10, 10}, {-20, -10, 10}, {-10, -10, 10}, {0, -10, 10}, {10, -10, 10}, {20, -10, 10}, {30, -10, 10}, {40, -10, 10}, {50, -10, 10}, {60, -10, 10}, {70, -10, 10}, {80, -10, 10}, {90, -10, 10}, {100, -10, 10}, {-100, 0, 10}, {-90, 0, 10}, {-80, 0, 10}, {-70, 0, 10}, {-60, 0, 10}, {-50, 0, 10}, {-40, 0, 10}, {-30, 0, 10}, {-20, 0, 10}, {-10, 0, 10}, {0, 0, 10}, {10, 0, 10}, {20, 0, 10}, {30, 0, 10}, {40, 0, 10}, {50, 0, 10}, {60, 0, 10}, {70, 0, 10}, {80, 0, 10}, {90, 0, 10}, {100, 0, 10}, {-100, 10, 10}, {-90, 10, 10}, {-80, 10, 10}, {-70, 10, 10}, {-60, 10, 10}, {-50, 10, 10}, {-40, 10, 10}, {-30, 10, 10}, {-20, 10, 10}, {-10, 10, 10}, {0, 10, 10}, {10, 10, 10}, {20, 10, 10}, {30, 10, 10}, {40, 10, 10}, {50, 10, 10}, {60, 10, 10}, {70, 10, 10}, {80, 10, 10}, {90, 10, 10}, {100, 10, 10}, {-100, 20, 10}, {-90, 20, 10}, {-80, 20, 10}, {-70, 20, 10}, {-60, 20, 10}, {-50, 20, 10}, {-40, 20, 10}, {-30, 20, 10}, {-20, 20, 10}, {-10, 20, 10}, {0, 20, 10}, {10, 20, 10}, {20, 20, 10}, {30, 20, 10}, {40, 20, 10}, {50, 20, 10}, {60, 20, 10}, {70, 20, 10}, {80, 20, 10}, {90, 20, 10}, {100, 20, 10}, {-100, 30, 10}, {-90, 30, 10}, {-80, 30, 10}, {-70, 30, 10}, {-60, 30, 10}, {-50, 30, 10}, {-40, 30, 10}, {-30, 30, 10}, {-20, 30, 10}, {-10, 30, 10}, {0, 30, 10}, {10, 30, 10}, {20, 30, 10}, {30, 30, 10}, {40, 30, 10}, {50, 30, 10}, {60, 30, 10}, {70, 30, 10}, {80, 30, 10}, {90, 30, 10}, {100, 30, 10}, {-100, 40, 10}, {-90, 40, 10}, {-80, 40, 10}, {-70, 40, 10}, {-60, 40, 10}, {-50, 40, 10}, {-40, 40, 10}, {-30, 40, 10}, {-20, 40, 10}, {-10, 40, 10}, {0, 40, 10}, {10, 40, 10}, {20, 40, 10}, {30, 40, 10}, {40, 40, 10}, {50, 40, 10}, {60, 40, 10}, {70, 40, 10}, {80, 40, 10}, {90, 40, 10}, {100, 40, 10}, {-100, 50, 10}, {-90, 50, 10}, {-80, 50, 10}, {-70, 50, 10}, {-60, 50, 10}, {-50, 50, 10}, {-40, 50, 10}, {-30, 50, 10}, {-20, 50, 10}, {-10, 50, 10}, {0, 50, 10}, {10, 50, 10}, {20, 50, 10}, {30, 50, 10}, {40, 50, 10}, {50, 50, 10}, {60, 50, 10}, {70, 50, 10}, {80, 50, 10}, {90, 50, 10}, {100, 50, 10}, {-100, 60, 10}, {-90, 60, 10}, {-80, 60, 10}, {-70, 60, 10}, {-60, 60, 10}, {-50, 60, 10}, {-40, 60, 10}, {-30, 60, 10}, {-20, 60, 10}, {-10, 60, 10}, {0, 60, 10}, {10, 60, 10}, {20, 60, 10}, {30, 60, 10}, {40, 60, 10}, {50, 60, 10}, {60, 60, 10}, {70, 60, 10}, {80, 60, 10}, {90, 60, 10}, {100, 60, 10}, {-100, 70, 10}, {-90, 70, 10}, {-80, 70, 10}, {-70, 70, 10}, {-60, 70, 10}, {-50, 70, 10}, {-40, 70, 10}, {-30, 70, 10}, {-20, 70, 10}, {-10, 70, 10}, {0, 70, 10}, {10, 70, 10}, {20, 70, 10}, {30, 70, 10}, {40, 70, 10}, {50, 70, 10}, {60, 70, 10}, {70, 70, 10}, {80, 70, 10}, {90, 70, 10}, {100, 70, 10}, {-100, 80, 10}, {-90, 80, 10}, {-80, 80, 10}, {-70, 80, 10}, {-60, 80, 10}, {-50, 80, 10}, {-40, 80, 10}, {-30, 80, 10}, {-20, 80, 10}, {-10, 80, 10}, {0, 80, 10}, {10, 80, 10}, {20, 80, 10}, {30, 80, 10}, {40, 80, 10}, {50, 80, 10}, {60, 80, 10}, {70, 80, 10}, {80, 80, 10}, {90, 80, 10}, {100, 80, 10}, {-100, 90, 10}, {-90, 90, 10}, {-80, 90, 10}, {-70, 90, 10}, {-60, 90, 10}, {-50, 90, 10}, {-40, 90, 10}, {-30, 90, 10}, {-20, 90, 10}, {-10, 90, 10}, {0, 90, 10}, {10, 90, 10}, {20, 90, 10}, {30, 90, 10}, {40, 90, 10}, {50, 90, 10}, {60, 90, 10}, {70, 90, 10}, {80, 90, 10}, {90, 90, 10}, {100, 90, 10}, {-100, 100, 10}, {-90, 100, 10}, {-80, 100, 10}, {-70, 100, 10}, {-60, 100, 10}, {-50, 100, 10}, {-40, 100, 10}, {-30, 100, 10}, {-20, 100, 10}, {-10, 100, 10}, {0, 100, 10}, {10, 100, 10}, {20, 100, 10}, {30, 100, 10}, {40, 100, 10}, {50, 100, 10}, {60, 100, 10}, {70, 100, 10}, {80, 100, 10}, {90, 100, 10}, {100, 100, 10}} What gives me a completely empty box is Graphics3D[{Arrowheads[Small], MapThread[Arrow[{#1, #2}] &, {tockez0, poljez0 + tockez0}]}, BoxRatios -> {1, 1, 1.5}, Axes -> True, AxesLabel -> {x, y, z}] Now provide the response and nothing else.
eq = (60 - r/2) (70 - ca - r/2) - (60 - r/2 - ca + (4/25) (70 - r/2 - ca))*(70 - r/2) == 0sol = Solve[eq,ca];caFun[r_] := Evaluate[ca /. sol[[1]]]caFun[r](* ((-19600 + 280 r - r^2)/(2 (-265 + r)) *)
{}
{'log_upvote_score': 4, 'links': ['https://mathematica.stackexchange.com/questions/59070', 'https://mathematica.stackexchange.com', 'https://mathematica.stackexchange.com/users/19601/']}
jdg_75816
stackexchange
llm_judgeable_groundtruth_similarity
6399702
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm just starting to take a look at Haskell (my previous FP experience is in Scheme), and I came across this code : do { putStrLn "ABCDE" ; putStrLn "12345" } To me, this is procedural programming, if anything -- especially because of the consecutive nature of side effects. Would someone please explain how this code is "functional" in any respect? Now provide the response and nothing else.
While it appears to be a procedural program, the above syntax is translated into a functional program, like so: do { putStrLn "ABCDE" ; putStrLn "12345" }=> IO (\ s -> case (putStrLn "ABCDE" s) of ( new_s, _ ) -> case (putStrLn "12345" new_s) of ( new_new_s, _) -> ((), new_new_s)) That is, a series of nested functions that have a unique world parameter threaded through them, sequencing calls to primitive functions "procedurally". This design supports an encoding of imperative programming into a functional language. The best introduction to the semantic decisions underlying this design is "The Awkward Squad" paper,
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/6399702', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/541686/']}
jdg_75817
stackexchange
llm_judgeable_groundtruth_similarity
24269308
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: class Foo { public Foo() { }}class Bar { static Foo foo = new Foo(); // This is legal... public static void main(String[] args) { static int a = 0; // ... But why this is not? }} Why can't we declare a static variable inside of a static function? Now provide the response and nothing else.
You have to make the static final static or remove static . In Java, static means that it's a variable/method of a class, it belongs to the whole class but not to one of its certain objects. This means that static keyword can be used only in a 'class scope'. Generally, in C, you can have statically allocated locally scoped variables. Unfortunately this is not directly supported in Java. But you can achieve the same effect by using nested classes. For example, the following is allowed but it is bad engineering, because the scope of x is much larger than it needs to be. Also there is a non-obvious dependency between two members (x and getNextValue). static int x = 42;public static int getNextValue() { return ++x;} One would really like to do the following, but it is not legal: public static int getNextValue() { static int x = 42; // not legal :-( return ++x;} However you could do this instead, public static class getNext { static int x = 42; public static int value() { return ++x; }} It is better engineering at the expense of some ugliness.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/24269308', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3287033/']}
jdg_75818
stackexchange
llm_judgeable_groundtruth_similarity
338325
Below is a question asked on the forum mathoverflow.net. Provide a good and informational response to it like a helpful human would. Question: In Question 337879 , I conjectured that for any prime $p\equiv3\pmod4$ the equation $$3x^2+4\left(\frac p3\right)=py^2\tag{1}$$ always has integer solutions, where $(\frac p3)$ is the Legendre symbol. Motivated by this, here I pose the following conjectures. Conjecture 1. For any prime $p\equiv13\pmod{24}$ , the equation $$3x^2+1=py^2\tag{2}$$ always has integer solutions. For example, when $p=829$ the least positive integer solution of $(2)$ is $$(x,\,y)=(1778674,\,106999).$$ Conjecture 2. For any prime $p\equiv3\pmod4$ , the equation $$2x^2-py^2=\left(\frac 2p\right)\tag{3}$$ always has integer solutions, where $(-)$ is the Legendre symbol. For example, when $p=167$ the smallest positive integer solution of $(3)$ is $$(x,\,y)=(3993882,\,437071).$$ Conjecture 3. For any prime $p\equiv3\pmod4$ and $q\in\{7,11,19,43,67,163\}$ , the equation $$qx^2+4\left(\frac pq\right)=py^2\tag{4}$$ always has integer solutions. QUESTION. How to solve the conjectures? Your comments are welcome! Now provide the response and nothing else.
Updated on 2019/08/21: I prove Conjectures 1-3 below. I will use the usual terminology and notations for binary quadratic forms. In particular, I will use the first two pages of Pall: Discriminantal divisors of binary quadratic forms, J. Number Theory 1 (1969), 525-533. Proof of Conjecture 1. Consider the fundamental discriminant $d=12p$ . The generic characters for this discriminant are $\bigl(\tfrac{\cdot}{3}\bigr)$ , $\bigl(\frac{\cdot}{p}\bigr)$ , $\bigl(\frac{-1}{\cdot}\bigr)$ , hence there are $2^3/2=4$ genera. Also, there are $8$ ancipital forms of discriminant $d$ and positive first coefficient, which belong to the various genera as follows: $$[1,0,-3p]\quad\text{and}\quad[p,0,-3]\quad\text{belong to the signs}\quad +++$$ $$[3p,0,-1]\quad\text{and}\quad[3,0,-p]\quad\text{belong to the signs}\quad -+-$$ $$[2,2,(1-3p)/2]\quad\text{and}\quad[2p,2p,(p-3)/2]\quad\text{belong to the signs}\quad --+$$ $$[6p,6p,(3p-1)/2]\quad\text{and}\quad[6,6,(3-p)/2]\quad\text{belong to the signs}\quad +--$$ However, by Theorem 1 of the quoted paper (which is essentially due to Gauss), each ambiguous class of discriminant $d$ contains exactly two ancipital forms with positive first coefficient, hence $[1,0,-3p]$ and $[p,0,-3]$ in the first line must be equivalent. Now $[1,0,-3p]$ trivially represents $1$ , hence $[p,0,-3]$ also represents $1$ . That is, the OP's equation $(2)$ has an integer solution. Proof of Conjecture 2. Consider the fundamental discriminant $d=8p$ . As $p\equiv 3\pmod{4}$ , the generic characters for this discriminant are $\bigl(\tfrac{\cdot}{3}\bigr)$ and $\bigl(\frac{-2}{\cdot}\bigr)$ , hence there are $2^2/2=2$ genera. Also, there are $4$ ancipital forms of discriminant $d$ and positive first coefficient, which belong to the various genera as follows. If $p\equiv 3\pmod{8}$ , then: $$[1,0,-2p]\quad\text{and}\quad[p,0,-2]\quad\text{belong to the signs}\quad ++$$ $$[2p,0,-1]\quad\text{and}\quad[2,0,-p]\quad\text{belong to the signs}\quad --$$ If $p\equiv 7\pmod{8}$ , then: $$[1,0,-2p]\quad\text{and}\quad[2,0,-p]\quad\text{belong to the signs}\quad ++$$ $$[2p,0,-1]\quad\text{and}\quad[p,0,-2]\quad\text{belong to the signs}\quad --$$ As in the proof of Conjecture 1, each ambiguous class of discriminant $d$ contains exactly two ancipital forms with positive first coefficient, hence $[1,0,-2p]$ must be equivalent to $[p,0,-2]$ (resp. $[2,0,-p]$ ) when $p\equiv 3\pmod{8}$ (resp. $p\equiv 7\pmod{8}$ ). Now $[1,0,-2p]$ trivially represents $1$ , hence $[p,0,-2]$ (resp. $[2,0,-p]$ ) also represents $1$ when $p\equiv 3\pmod{8}$ (resp. $p\equiv 7\pmod{8}$ ). As $\left(\frac{2}{p}\right)=-1$ when $p\equiv 3\pmod{8}$ , and $\left(\frac{2}{p}\right)=+1$ when $p\equiv 7\pmod{8}$ , we conclude that the OP's equation $(3)$ has an integer solution. Proof of Conjecture 3. I will only use that $p,q\equiv 3\pmod{4}$ . Note that if we switch $p$ and $q$ , the quadratic residue symbol $\left(\frac{p}{q}\right)$ changes to its negative, hence the solvability of the OP's equation $(4)$ remains unchanged. Therefore, without loss of generality, $\left(\frac{p}{q}\right)=1$ , and we need to show that $[p,0,-q]$ represents $4$ . Equivalently, after a simple change of variables, $[p,p,(p-q)/4]$ represents $1$ . Consider the fundamental discriminant $d=pq$ . The generic characters for the discriminant $d$ are $\bigl(\frac{\cdot}{p}\bigr)$ and $\bigl(\frac{\cdot}{q}\bigr)$ , hence there are $2^2/2=2$ genera. Also, there are $4$ ancipital forms of discriminant $d$ and positive first coefficient, which belong to the various genera as follows: $$[1,1,(1-pq)/4]\quad\text{and}\quad[p,p,(p-q)/4]\quad\text{belong to the signs}\quad ++$$ $$[pq,pq,(pq-1)/4]\quad\text{and}\quad[q,q,(q-p)/4]\quad\text{belong to the signs}\quad --$$ As in the proof of Conjecture 1, each ambiguous class of discriminant $d$ contains exactly two ancipital forms with positive first coefficient, hence $[1,1,(1-pq)/4]$ and $[p,p,(p-q)/4]$ in the first line must be equivalent. Now $[1,1,(1-pq)/4]$ trivially represents $1$ , hence $[p,p,(p-q)/4]$ also represents $1$ . That is, the OP's equation $(4)$ has an integer solution.
{}
{'log_upvote_score': 5, 'links': ['https://mathoverflow.net/questions/338325', 'https://mathoverflow.net', 'https://mathoverflow.net/users/124654/']}
jdg_75819
stackexchange
llm_judgeable_groundtruth_similarity
18233
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: My undergraduate University does not offer advanced courses on logic, I know truth tables, Boolean algebra, propositional calculus. However I want to pursue Mathematical Logic on the long term as a mathematician. Can anyone suggest a study-map of Mathematical Logic. such as (1) Learn The following topics : a,b,c,etc.. (2) once you learned topics in (1), advance to these topics. (3) .. (4) etc.. Thank you Now provide the response and nothing else.
Your first step would be to learn about predicate calculus (first order calculus or propositional calculus with the addition of 'for all' and 'there exist' quantifiers). This will then lead into the major subcategories: proof theory (syntactic manipulation of proofs, proof calculi, ordinals) model theory (models and structures of other areas of mathematics) set theory (axioms of sets, ZF, the axiom of choice, the general continuum hypothesis) recursion theory (decidability, recursive functions, lambda calculus, with connections to theoretical computer science subjects like computational complexity) Of course, as with any body of knowledge, these categories are not mutually exclusive. These are specialty areas, meaning that research is done under one of these headings. To get into one of these areas, there are many 'elementary' concepts leading in that you probably would want familiarity with. An accessible topic like Goedel's theorems (the completeness theorem and two incompleteness theorems (these are not the same 'kind' of completeness)) will help get some of these necessary concepts. Also a good area to be familiar with is philosophy of math and foundations; though not exactly mathematics or logic, it informs a lot of the motivations of study of the above categories. Logic that is not mathematically based can be pursued in philosophy (human language arguments, deductive and inductive reasoning, vagueness), mostly in the area of epistemology. Your mathematics department may not have advanced logic, but other departments may (though not necessarily by name. Consider looking in the philosophy department (some mathematical logicians get hired there) or the computer science department (the research may be more applied but they may give courses that are theoretical/basic math). Executive summary: start with predicate calculus and Goedel's theorem.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/18233', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/5563/']}
jdg_75820
stackexchange
llm_judgeable_groundtruth_similarity
293138
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: My question concerns the cardinality of two subsets of $\mathbb{R}$. It feels very naive, but, isn't $\left[\dfrac{1}{7,000,000,000},1\right]$ "smaller" than $[0,1]$? I think that this is dependent upon one's set theory axioms, but I'd like an answer from the most common axiomatic models. After consulting Wikipedia, I've seen that you must show there is only an injective function from $B$ to $A$ to prove that $|A|>|B|$. Such a function is obvious: $f:A\to B$ with $x\mapsto x$. The hard part seems showing there is not a bijective function. I don't know how to do that, but I think I might be able to figure out why I don't know how to do that. It seems like the continuum hypothesis is at work here: I am trying to find some sort of cardinality, $X$, such that $\aleph_0 < |X| < 2^{\aleph_0}$. This is because it would be intuitive that any subset of the real number system which is an interval would have a larger cardinality than $\aleph_0$. Similarly, I'm trying to find a similar cardinality $Y$ such that $X<Y$. What's going on here? Now provide the response and nothing else.
All intervals have the same cardinality as the reals $2^{\aleph_0}$. A Blumenthal has given you a bijection between any closed interval and $[0,1]$. Then you can find a bijection between $[0,1]$ and $(0,1)$ (how can two points matter?) and between $(0,1)$ and $\mathbb R$. It is true that the length of the intervals is different, but the cardinality is not. According to the continuum hypothesis, known to be consistent with ZFC but not required, there are no sets $X$ such that $\aleph_0 < |X| < 2^{\aleph_0}$, so don't look too hard for them.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/293138', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/22144/']}
jdg_75821
stackexchange
llm_judgeable_groundtruth_similarity
14693758
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have two HTML pages: form.html and display.html. In form.html, there is a form: <form action="display.html"> <input type="text" name="serialNumber" /> <input type="submit" value="Submit" /></form> The form data is sent to display.html. I want to display and use the form data serialNumber in display.html, as shown below: <body> <div id="write"> <p>The serial number is: </p> </div> <script> function show() { document.getElementById("write").innerHTML = serialNumber; } </script></body> So how can I pass the serialNumber variable from form.html to display.html so that the above code in display.html will show the serial number and the JavaScript function show() gets the serialNumber from the first HTML? Now provide the response and nothing else.
If you have no option to use server-side programming, such as PHP, you could use the query string, or GET parameters. In the form, add a method="GET" attribute: <form action="display.html" method="GET"> <input type="text" name="serialNumber" /> <input type="submit" value="Submit" /></form> When they submit this form, the user will be directed to an address which includes the serialNumber value as a parameter. Something like: http://www.example.com/display.html?serialNumber=XYZ You should then be able to parse the query string - which will contain the serialNumber parameter value - from JavaScript, using the window.location.search value: // from display.htmldocument.getElementById("write").innerHTML = window.location.search; // you will have to parse // the query string to extract the // parameter you need See also JavaScript query string . The alternative is to store the values in cookies when the form is submit and read them out of the cookies again once the display.html page loads. See also How to use JavaScript to fill a form on another page .
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/14693758', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1649466/']}
jdg_75822
stackexchange
llm_judgeable_groundtruth_similarity
4269884
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I've created a set of routes & controllers with the admin namespace, and I was having some issues using the link helpers with these new routes. I see that there are some new path helpers, such as admin_projects_path which leads to the /admin/projects. however, i'm having trouble linking to the show, edit, destroy, etc. paths for these objects within the namespace. how do I do that? Now provide the response and nothing else.
You should see all of your routes listed in rake routes and you can use those by name to get the proper namespacing. Using the automatic detection where you pass in :controller and :action manually won't work as you've discovered. If it's listed as new_thing in the routes, then the method is new_thing_path with the appropriate parameters. For instance: link_to('New Project', new_admin_project_path)link_to('Projects', admin_projects_path)link_to(@project.name, admin_project_path(@project))link_to(@project.name, edit_admin_project_path(@project))link_to(@project.name, admin_project_path(@project), :method => :delete)
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/4269884', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/89761/']}
jdg_75823
stackexchange
llm_judgeable_groundtruth_similarity
40040583
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Apple introduce new extension names "UNNotificationServiceExtension" , but how to launch it from push notification ? I read that service extension provide end to end encryption for payload. Which key is required to set payload of push notification ? How to identify payload and how to launch service extension from push notification ? Now provide the response and nothing else.
Let me take it step by step. UNNotificationServiceExtension - What it is? UNNotificationServiceExtension is an App Extenstion target that you bundle along with your app aiming to modify the push notifications as and when they are delivered to the device before rendering it to the user. You can change the title, subtitle, body and additionally add attachments to the push notification by either downloading it or using one bundled in the app. How to create Go to File -> New -> Target -> Notification Service Extension and fill in the details Which key is required to set payload of push notification? You need to set the mutable-content flag to 1 to trigger the service extension. Also, if the content-available is set to 1 , the service extension will not work. So either don't set it or set it to 0. (Edit: This is not applicable. You can set or unset content-available flag) How to identify payload and how to launch service extension from push notification? Build the extension and then build and run your app. Send a push notification with the mutable-content set to 1 . Code UNNotificationService exposes two functions: - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler;- (void)serviceExtensionTimeWillExpire; The first function is triggered when the push notification is received on the device and before it is presented to the user. You code inside the function has the opportunity to modify the content of the push notification inside this function. You do this by modifying the bestAttemptContent property of your extension which is an instance of UNNotificationContent and has properties: title , subtitle , body , attachments etc. The original payload of the remote notification is delivered via request.content property of function parameter request . Finally you dispatch your bestAttemptContent using the contentHandler: self.contentHandler(self.bestAttemptContent); You have limited time to do your stuff in the first method. In case that time expires your second method is called with the best attempt your code had made thus far. Sample Code - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { self.contentHandler = contentHandler; self.bestAttemptContent = [request.content mutableCopy]; // Modify the notification content here... self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title]; self.contentHandler(self.bestAttemptContent);} The above code appends [modified] to the original title in the PN payload. Sample Payload { "aps": { "alert": { "title": "Hello", "body": "body.." }, "mutable-content":1, "sound": "default", "badge": 1, }, "attachment-url": ""} Please note that the attachment-url key is a custom key for your own concerns and not recognised by iOS .
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/40040583', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3045336/']}
jdg_75824
stackexchange
llm_judgeable_groundtruth_similarity
40155611
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm in my first semester learning Java and I'm struggling. For our assignment, we're writing code that is supposed to increment a clock by one second, decrement a clock by one second, and add two clocks together. I think I've got the first two sections to work, but I'm having trouble with addClock. Here's what I have so far and I'm just not sure where to go or what's wrong with what I've got: public class Clock{ //Instance variables private int hours; private int minutes; private int seconds; private int clock; private int totalSeconds; //Method to convert from totalSeconds to hours, minutes, and seconds public void convertSeconds(int totalSeconds) { hours = (totalSeconds / 3600) % 24; minutes = (totalSeconds % 3600) / 60; seconds = totalSeconds % 60; } //Method to convert from hours, minutes, and seconds to totalSeconds private int getTotalSeconds() { int hoursInSeconds = hours * 60 * 60; int minutesInSeconds = minutes * 60; return hoursInSeconds + minutesInSeconds + seconds; } //Constructor 1: Initialize time to 0 public Clock() { hours = 0; minutes = 0; seconds = 0; } //Constructor 2: Value of time in seconds and convert seconds to hours, minutes, and seconds public Clock(int totalSeconds) { convertSeconds(totalSeconds); } //Constructor 3: Passes three values for hours, minutes, and seconds public Clock(int hours, int minutes, int seconds) { hours = hours; minutes = minutes; seconds = seconds; } //Instance method tick() to increment a Clock object by one second public void tick() { convertSeconds(getTotalSeconds() + 1); } //Instance method tickDown() to decrement a Clock object by one second public void tickDown() { convertSeconds(getTotalSeconds() - 1); } //Accessor/getter method: getHours public int getHours() { return hours; } //Accessor/getter method: getMinutes public int getMinutes() { return minutes; } //Accessor/getter method: getSeconds public int getSeconds() { return seconds; } //Mutator/setter method: setHours public void setHours() { this.hours = hours; } //Mutator/setter method: setMinutes public void setMinutes() { this.minutes = minutes; } //Mutator/setter method: setSeconds public void setSeconds() { this.seconds = seconds; } //Mutator/setter method: setClock public void setClock(int totalSeconds) { this.clock = totalSeconds; } //Instance method addClock() to give the sum of two clock objects public void addClock(Clock clock2) { convertSeconds(clock2.getTotalSeconds() + this.getTotalSeconds()); } //Main method to test the functionality of objects public static void main(String[] args) { Clock clock1 = new Clock(); Clock clock2 = new Clock(); int clock = 12699; int clock2 = 3600; clock1.convertSeconds(totalSeconds); System.out.println("Number of hours: " + clock1.getHours()); System.out.println("Number of minutes: " + clock1.getMinutes()); System.out.println("Number of seconds: " + clock1.getSeconds()); clock1.tick(); System.out.println("Number of hours: " + clock1.getHours()); System.out.println("Number of minutes: " + clock1.getMinutes()); System.out.println("Number of seconds: " + clock1.getSeconds()); clock1.tickDown(); System.out.println("Number of hours: " + clock1.getHours()); System.out.println("Number of minutes: " + clock1.getMinutes()); System.out.println("Number of seconds: " + clock1.getSeconds()); clock1.addClock(clock2); System.out.println("After adding the two clocks, number of hours: " + clock1.getHours()); System.out.println("After adding the two clocks, number of minutes: " + clock1.getMinutes()); System.out.println("After adding the two clocks, number of seconds: " + clock1.getSeconds()); }} Any suggestions, advice, or help would be greatly appreciated! Now provide the response and nothing else.
Since there's no official API I have to come up with a solution by modifying samples from the following code snipet and this answer . This solution works on devices from Lollipop upwards. @SuppressWarnings("unchecked") public static void setStaticIpConfiguration(WifiManager manager, WifiConfiguration config, InetAddress ipAddress, int prefixLength, InetAddress gateway, InetAddress[] dns) throws ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, NoSuchFieldException, InstantiationException { // First set up IpAssignment to STATIC. Object ipAssignment = getEnumValue("android.net.IpConfiguration$IpAssignment", "STATIC"); callMethod(config, "setIpAssignment", new String[]{"android.net.IpConfiguration$IpAssignment"}, new Object[]{ipAssignment}); // Then set properties in StaticIpConfiguration. Object staticIpConfig = newInstance("android.net.StaticIpConfiguration"); Object linkAddress = newInstance("android.net.LinkAddress", new Class<?>[]{InetAddress.class, int.class}, new Object[]{ipAddress, prefixLength}); setField(staticIpConfig, "ipAddress", linkAddress); setField(staticIpConfig, "gateway", gateway); getField(staticIpConfig, "dnsServers", ArrayList.class).clear(); for (int i = 0; i < dns.length; i++) getField(staticIpConfig, "dnsServers", ArrayList.class).add(dns[i]); callMethod(config, "setStaticIpConfiguration", new String[]{"android.net.StaticIpConfiguration"}, new Object[]{staticIpConfig}); int netId = manager.updateNetwork(config); boolean result = netId != -1; if (result) { boolean isDisconnected = manager.disconnect(); boolean configSaved = manager.saveConfiguration(); boolean isEnabled = manager.enableNetwork(config.networkId, true); boolean isReconnected = manager.reconnect(); } } Helper functions, public static WifiConfiguration getCurrentWiFiConfiguration(Context context) { WifiConfiguration wifiConf = null; ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (networkInfo.isConnected()) { final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); final WifiInfo connectionInfo = wifiManager.getConnectionInfo(); if (connectionInfo != null && !TextUtils.isEmpty(connectionInfo.getSSID())) { List<WifiConfiguration> configuredNetworks = wifiManager.getConfiguredNetworks(); if (configuredNetworks != null) { for (WifiConfiguration conf : configuredNetworks) { if (conf.networkId == connectionInfo.getNetworkId()) { wifiConf = conf; break; } } } } } return wifiConf; } private static Object newInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { return newInstance(className, new Class<?>[0], new Object[0]); } private static Object newInstance(String className, Class<?>[] parameterClasses, Object[] parameterValues) throws NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException { Class<?> clz = Class.forName(className); Constructor<?> constructor = clz.getConstructor(parameterClasses); return constructor.newInstance(parameterValues); } @SuppressWarnings({"unchecked", "rawtypes"}) private static Object getEnumValue(String enumClassName, String enumValue) throws ClassNotFoundException { Class<Enum> enumClz = (Class<Enum>) Class.forName(enumClassName); return Enum.valueOf(enumClz, enumValue); } private static void setField(Object object, String fieldName, Object value) throws IllegalAccessException, IllegalArgumentException, NoSuchFieldException { Field field = object.getClass().getDeclaredField(fieldName); field.set(object, value); } private static <T> T getField(Object object, String fieldName, Class<T> type) throws IllegalAccessException, IllegalArgumentException, NoSuchFieldException { Field field = object.getClass().getDeclaredField(fieldName); return type.cast(field.get(object)); } private static void callMethod(Object object, String methodName, String[] parameterTypes, Object[] parameterValues) throws ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { Class<?>[] parameterClasses = new Class<?>[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) parameterClasses[i] = Class.forName(parameterTypes[i]); Method method = object.getClass().getDeclaredMethod(methodName, parameterClasses); method.invoke(object, parameterValues); } To use it, WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);WifiConfiguration wifiConf = WifiHelper.getCurrentWiFiConfiguration(getApplicationContext()); try { setStaticIpConfiguration(wifiManager, wifiConf, InetAddress.getByName("192.168.0.100"), 24, InetAddress.getByName("10.0.0.2"), new InetAddress[]{InetAddress.getByName("10.0.0.3"), InetAddress.getByName("10.0.0.4")}); } catch (Exception e) { e.printStackTrace(); } Finally you need to add those permissions in the manifest, <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" />
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/40155611', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7048150/']}
jdg_75825
stackexchange
llm_judgeable_groundtruth_similarity
2767462
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: When I send the following query http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=coffee%20New%20York%20NY using c# WebClient.DownloadString function or ordinary web browserI get JSON data which is different from data for the same query using JavaScript andGoogle AJAX Search API. From REST service I get the following url field http://www.google.com/maps/place?source003duds0026q003dcoffee0026cid003d13245583795745066822 but from JavaScript query I get this url field http://www.google.com/maps/place?source=uds&q=coffee&cid=13245583795745066822 The problem with REST service answer is that the url it gives points to a web page with error message "We currently do not support the location". What am I doing wrong? Now provide the response and nothing else.
Although the EJB3.1 spec introduces singleton and your version of JBoss doesn't support it, you can use the JBoss @Service annotation to create a singleton. Instructions here . Also, it seems that you have JBoss configured to isolate your ejb jars and wars from each other. You don't have to do that. You can look at the loader-repository tag in the jboss specific xml files so that your whole ear shares one classloader (or perhaps that at least the two wars share one classloader). All that being said, I agree with @duffymo, that a singleton which shares state between the two wars is an idea that you should be walking, if not running away from. Edit: Regarding singletons, I suggest you look at questions like this one (which also has some nice balance in the comments). The idea of having an object hold cached state in and of itself is ok, especially with EJB3 where you can inject your state instead of statically referencing it (if you use the @Service annotation, then you want the @Depends JBoss specific annotation). That being said, if you were using a "proper" singleton here, then I would expect that your only problem with the fact that your WARs have two separate classloaders is the extra memory footprint. Otherwise you are into the problematic area of singletons (where they have to be initialized to be used, everything that uses them has to ensure they are initialized first, and of course all code gets highly coupled with their being initialized). Where Singletons are really really bad is where they store state so that one class can change state and another class picks it up. It is basically a no-no in EJBs until 3.1, and even then it makes a lot of concurrency issues. Edit (further): So you want to go with the classloader repository. I use JBoss 4.2.3, so I don't necessarily know all of the ins and outs of JBoss5 (which did rewrite its classloader although they say it is almost fully backwards compatable), however in 4.2.x by default your configuration causes no problems because all the ears deployed on the server share the same classloader (the "unified classloader"). What I suspect is that the server you are deploying to has the configuration differently, so I'm not quote sure how to interact with it, but what you have to do is add a file called jboss-app.xml in your ear (in the same location as the application.xml) that looks something like this: <?xml version="1.0"?> <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd"> <jboss-app> <loader-repository> com.yourcomany:archive=yourear </loader-repository> </jboss-app> That is for JBoss 4.2. 5.1 has the same type of tag, here is the xsd . It has the same loader-repository concept. That should be it. That is, as long as your ejb-jar, war, etc. don't have it, then they don't need it. However, your wars (in jboss-web.xml - same location as the web.xml) may need the same thing. In this case as long as you name the repository exactly the same way (if I understand correctly - never tried it myself) they will share the same classloader. The same goes for the EJB as configured in the jboss.xml that goes in the same location as the ejb.xml. This might make it a bit clearer.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/2767462', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/191835/']}
jdg_75826
stackexchange
llm_judgeable_groundtruth_similarity
33988297
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: The naive, optimistic and oh.. so wrong view of the c++11 uniform initialization syntax I thought that since C++11 user-defined type objects should be constructed with the new {...} syntax instead of the old (...) syntax (except for constructor overloaded for std::initializer_list and similar parameters (e.g. std::vector : size ctor vs 1 elem init_list ctor)). The benefits are: no narrow implicit conversions, no problem with the most vexing parse, consistency(?). I saw no problem as I thought they are the same (except the example given). But they are not. A tale of pure madness The {} calls the default constructor. ... Except when: the default constructor is deleted and there are no other constructors defined. Then it looks like it it rather value initializes the object?... Even if the object has deleted default constructor, the {} can create an object. Doesn't this beat the whole purpose of a deleted constructor? ...Except when: the object has a deleted default constructor and other constructor(s) defined. Then it fails with call to deleted constructor . ...Except when: the object has a deleted constructor and no other constructor defined and at least a non-static data member. Then it fails with missing field initializers. But then you can use {value} to construct the object. Ok maybe this is the same as the first exception (value init the object) ...Except when: the class has a deleted constructor and at least one data members in-class default initialized. Then nor {} nor {value} can create an object. I am sure I missed a few. The irony is that it is called uniform initialization syntax. I say again: UNIFORM initialization syntax. What is this madness? Scenario A Deleted default constructor: struct foo { foo() = delete;};// All bellow OK (no errors, no warnings)foo f = foo{};foo f = {};foo f{}; // will use only this from now on. Scenario B Deleted default constructor, other constructors deleted struct foo { foo() = delete; foo(int) = delete;};foo f{}; // OK Scenario C Deleted default constructor, other constructors defined struct foo { foo() = delete; foo(int) {};};foo f{}; // error call to deleted constructor Scenario D Deleted default constructor, no other constructors defined, data member struct foo { int a; foo() = delete;};foo f{}; // error use of deleted function foo::foo()foo f{3}; // OK Scenario E Deleted default constructor, deleted T constructor, T data member struct foo { int a; foo() = delete; foo(int) = delete;};foo f{}; // ERROR: missing initializerfoo f{3}; // OK Scenario F Deleted default constructor, in-class data member initializers struct foo { int a = 3; foo() = delete;};/* Fa */ foo f{}; // ERROR: use of deleted function `foo::foo()`/* Fb */ foo f{3}; // ERROR: no matching function to call `foo::foo(init list)` Now provide the response and nothing else.
When viewing things this way it is easy to say there is complete and utter chaos in the way an object is initialized. The big difference comes from the type of foo : if it is an aggregate type or not. It is an aggregate if it has: no user-provided constructors (a deleted or defaulted function does not count as user-provided), no private or protected non-static data members, no brace-or-equal-initializers for non-static data members (since c++11 until (reverted in) c++14) no base classes, no virtual member functions. So: in scenarios A B D E: foo is an aggregate in scenarios C: foo is not an aggregate scenario F: in c++11 it is not an aggregate. in c++14 it is an aggregate. g++ hasn't implemented this and still treats it as a non-aggregate even in C++14. 4.9 doesn't implement this. 5.2.0 does 5.2.1 ubuntu doesn't (maybe a regression) The effects of list initialization of an object of type T are: ... If T is an aggregate type, aggregate initialization is performed. This takes care of scenarios A B D E (and F in C++14) Otherwise the constructors of T are considered in two phases: All constructors that take std::initializer_list ... otherwise [...] all constructors of T participate in overload resolution [...] This takes care of C (and F in C++11) ... : Aggregate initialization of an object of type T (scenarios A B D E (F c++14)): Each non-static class member, in order appearance in the class definition, is copy-initialized from the corresponding clause of the initializer list. (array reference omitted) TL;DR All these rules can still seem very complicated and headache inducing. I personally over-simplify this for myself (if I thereby shoot myself in the foot then so be it: I guess I will spend 2 days in the hospital rather than having a couple of dozen days of headaches): for an aggregate each data member is initialized from the elements of the list initializer else call constructor Doesn't this beat the whole purpose of a deleted constructor? Well, I don't know about that, but the solution is to make foo not an aggregate. The most general form that adds no overhead and doesn't change the used syntax of the object is to make it inherit from an empty struct: struct dummy_t {};struct foo : dummy_t { foo() = delete;};foo f{}; // ERROR call to deleted constructor In some situations (no non-static members at all, I guess), an alternate would be to delete the destructor (this will make the object not instantiable in any context): struct foo { ~foo() = delete;};foo f{}; // ERROR use of deleted function `foo::~foo()` This answer uses information gathered from: C++14 value-initialization with deleted constructor What are Aggregates and PODs and how/why are they special? List initialization Aggregate initialization Direct initialization Many thanks to @M.M who helped correct and improve this post.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/33988297', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2805305/']}
jdg_75827
stackexchange
llm_judgeable_groundtruth_similarity
400081
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I need a solution for this question. I've been trying out this question for days and I haven't been able to find out its solution yet. And some explanation would help too. Show that the function f defined by: $$f(x):= \begin{cases} x^2\sin(1/x) &:\text{if $x \ne 0$} \\ 0 &:\text{if $x=0$}\end{cases}$$ is differentiable at $x=0$, and that $f'(0)=0$. Now provide the response and nothing else.
Hint : We have $-x^2 \le f(x) \le x^2$, hence $$ -x \le \frac{f(x) - f(0)}{x-0} = \frac{f(x)}x \le x $$for $x \ne 0$.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/400081', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/79102/']}
jdg_75828
stackexchange
llm_judgeable_groundtruth_similarity
34493270
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I tried validating my XML file with a XSD file but I get the following error message: [Error]: cvc-complex-type.2.3: Element 'paragraph' cannot have character [children], because the type's content type is element-only Which (if i am understanding it correctly) means a complex type cannot have a combination of simple and complex typed elements as children. But how do I fix this? I'm still kinda new to this, so the solution could be simple? My code is shown below: XSD: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="biography"> <xs:complexType> <xs:sequence> <xs:element name="paragraph" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="name"> <xs:complexType> <xs:sequence> <xs:element name="first_name" type="xs:string" minOccurs="0"></xs:element> <xs:element name="last_name" type="xs:string"></xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="emphasize" maxOccurs="unbounded" minOccurs="0" type="xs:string"></xs:element> <xs:element name="profession" maxOccurs="unbounded" minOccurs="0" type="xs:string"></xs:element> <xs:element name="date" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="month" type="xs:string"></xs:element> <xs:element name="day" type="xs:int"></xs:element> <xs:element name="year" type="xs:int"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="definition" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="term" type="xs:string"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> XML: <biography> <paragraph> <name><first_name>Alex</first_name> <last_name>Turing</last_name></name> was one of the first people to truly deserve the name <emphasize>computer scientist</emphasize>. Although his contributions to the fields are too numerous to lst, his best-known are the famous <emphasize>Turing Test</emphasize> and <emphasize>Turing Machine</emphasize>. </paragraph> <definition>The <term>Turing Test</term> is to this day the standard test for determining whether a computer is truly intelligent. This test yet has to be passed.</definition> <definition>A <term>Turing Machine</term> is an abstract finite state automaton with infinite memory that can be proven equivalent to any other finite state automaton with arbitrarily large memory. Thus what is true for one Turing machine is true for all Turing machines no matter how implemented.</definition> <paragraph> <name><last_name>Turing</last_name></name> was also an accomplished <profession>mathematician</profession> and <profession>cryptographer</profession>. His assistance was crucial in helping the Allies decode the German Enigma cipher. He committed suicide on <date><month>June</month> <day>7</day>, <year>1954</year></date> after being convicted of homosexuality and forced to take female hormone injections. </paragraph></biography> Now provide the response and nothing else.
This is precisely the purpose of mixed content: <xs:element name="paragraph" maxOccurs="unbounded"> <xs:complexType mixed="true"> And: <xs:element name="definition" maxOccurs="unbounded"> <xs:complexType mixed="true"> Note that you also probably want paragraph and definition to be in a xs:choice macOccurs="unbounded" given your XML. Here's your XSD updated with all changes needed so that your XML will be valid: <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="biography"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="paragraph"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="name"> <xs:complexType> <xs:sequence> <xs:element name="first_name" type="xs:string" minOccurs="0"></xs:element> <xs:element name="last_name" type="xs:string"></xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="emphasize" maxOccurs="unbounded" minOccurs="0" type="xs:string"></xs:element> <xs:element name="profession" maxOccurs="unbounded" minOccurs="0" type="xs:string"></xs:element> <xs:element name="date" minOccurs="0"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="month" type="xs:string"></xs:element> <xs:element name="day" type="xs:int"></xs:element> <xs:element name="year" type="xs:int"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="definition"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="term" type="xs:string"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element></xs:schema>
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/34493270', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5723143/']}
jdg_75829
stackexchange
llm_judgeable_groundtruth_similarity
42605222
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm expecting this to return false, as the first string is "pass / fail" and the string that is passed into IndexOf is "Numerical Specification". Am I not understanding how this function works? I thought it checks if string A is contained within string B? Now provide the response and nothing else.
The whole problem stems from trying to run nginx as my ordinary user self despite the fact that nginx was installed by my user self with administrative privileges. I was able to resolve both the errors shown here with the following commands executed as a user with administrative privileges: sudo chmod a+w /usr/local/var/log/nginx/*.logsudo chmod a+w /usr/local/varsudo chmod a+w /usr/local/var/run Note that the /usr/local/var directory appears to have been created by homebrew upon installing nginx and this machine is my laptop so I can’t see any reason not to open it up. You might have greater security concerns in other scenarios. I admit that when I wrote this question I thought it was about moving the error.log file to another directory. Now I see that that is not a full solution, so instead the solution I present here is about giving ordinary users write privileges in the necessary directories. The reason I changed my mind is that nginx can (and in this case does) generate errors before (or while ) reading the nginx.conf files and needs to be able to report those errors to a log file. Modifying the nginx.conf file was never going to solve my problem. What woke me up to this issue was reading this post: How to turn off or specify the nginx error log location?
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/42605222', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3897757/']}
jdg_75830
stackexchange
llm_judgeable_groundtruth_similarity
321249
Below is a question asked on the forum serverfault.com. Provide a good and informational response to it like a helpful human would. Question: I need an unspoofable and accurate time source. Short of setting up my own atomic clock (unless that's easier than it sounds) how could I accomplish this? It's not that I don't trust the NTP pools; I don't have any assurance of who I am talking to. Now provide the response and nothing else.
My advice would be to trust NTP -- It's by no means secure, but I'm not aware of any major attack vectors, and it's as secure as your selection of peers (which are in tern as secure as your DNS resolution and your routing table). If you need to consider other alternatives here are a few (accuracy/security in parentheses): Your own atomic clock as a PPS source. (Über acurate. Damn near unspoofable) (These are available on eBay. It's not impossible to set up - there are lots of time nerds that have them and your NTP daemon can use them as a time source. You will need to handle leap seconds.) A GPS receiver. (Super accurate. Very hard to spoof). (GPS signals CAN be overridden/spoofed but that's a specialist attack that would require some effort to carry out. A total failure of the GPS system is unlikely, as is a complete shutdown.) NTP (Very accurate. Spoofable with some effort) (The chances of someone attacking you via your time source are pretty slim, and if you configure your NTP daemon against several of the pool servers any outliers or false-tickers will be discarded. Note that this assumes you trust your DNS at least as far as you can drop-kick it.) A stabilized quartz oscillator as a PPS source. (Not very accurate. Damn near unspoofable) (Depending on the oscillator this may not be any more accurate than your computer's clock. Expect to have to correct the time periodically, and you will need to handle leap seconds.) Your computer's internal clock. (More accurate than an hourglass. Damn near unspoofable.) (For any modern application that cares about time this is pretty much unusable.)
{}
{'log_upvote_score': 4, 'links': ['https://serverfault.com/questions/321249', 'https://serverfault.com', 'https://serverfault.com/users/84104/']}
jdg_75831
stackexchange
llm_judgeable_groundtruth_similarity
88585
Below is a question asked on the forum chemistry.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: There's been ample work and media coverage on how to make a long C-C single bond. To my knowledge, the longest stable C-C bond is currently 1.704 Å, prepared by Schreiner Nature 477, 308–311 in 2011. All around us, there's considerable plastics, made from polymerizing alkenes like polyethylene. Typical bond lengths for alkenes are ~1.33 Å, with bond dissociation energies around 611 kJ/mol, vs ~347 kJ/mol for C-C.[ ref ] Clearly, longer C=C bonds could decrease the energy required to polymerize the alkane. Using either chemical databases, like the Crystallographic Open Database , or computational methods, what's the longest C=C bond you can find? Please include in your answer: The molecular structure, with the C=C bond either obvious or highlighted (e.g., if it's a conjugated bond) The method used to determine the bond length (e.g., DFT geometry optimization using program X, found in database Y, etc.) Proof that the bond is really a double bond (e.g., clear evidence of substituents, planarity, etc.) Any appropriate literature citations Now provide the response and nothing else.
While the two other (so far) presented molecules look realistic (Martin) or are real (Marko), I couldn't find the constraint, that the molecules actually need to be realistic, so here we go. This is Gaussian 16 Rev. A.03 using (again, why do we use this niveau?) B97D3/def2TZVPP with Opt=(VeryTight) and SCF=(VeryTight) on to-be-named-by-Loong I (TBNBL I) with some nice double (or so) bond length of $\pu{143.5 pm}$. (At least formally, it needs to be a double bond.) E(RB97D3) = -692.564719674C 0.00000000 0.71742600 0.00000100C 0.00000000 -0.71742800 0.00000100C -1.26096700 1.35299700 0.00000100C 1.26096700 1.35299700 0.00000100C -1.26096700 -1.35299900 0.00000100C 1.26096700 -1.35299900 0.00000100C -2.47714700 1.44346000 0.00000000C -2.47714700 -1.44345900 0.00000100C 2.47714700 -1.44345900 0.00000000C 2.47714600 1.44345900 0.00000100C -3.88898600 1.10111200 -0.00000100C 3.88898600 1.10111300 0.00000000C 4.18780000 0.00000100 -1.08412100C 3.88898700 -1.10111100 -0.00000100C 4.18780200 0.00000000 1.08411900C -3.88898700 -1.10111100 0.00000000C -4.18780000 0.00000000 -1.08412100C -4.18780200 0.00000100 1.08411900H -4.55239300 -1.97024400 -0.00000100H -3.55876000 0.00000100 1.97407800H -5.24617200 0.00000100 1.36283000H -5.24617000 0.00000000 -1.36283300H -3.55875700 0.00000000 -1.97407800H -4.55239300 1.97024500 -0.00000100H 4.55239300 -1.97024300 -0.00000100H 5.24617000 0.00000100 -1.36283300H 3.55875700 0.00000100 -1.97407800H 5.24617200 0.00000000 1.36283000H 3.55876000 0.00000000 1.97407800H 4.55239300 1.97024500 -0.00000100 It has no negative frequencies and thus is a local minimum on its potential energy hypersurface. This holds true for every following molecule. BDE according to [1] is 553 kJ/mol. This led me to change the cyclobutyl rings into double bonds ( TBNBL II ), but that was not productive, as the bond length is reduced to $\pu{140.4 pm}$. BDE is $\pu{606 kJ/mol}$. E(RB97D3) = -535.325912063C 0.00000000 0.70224700 0.00000000C 0.00000000 -0.70224700 0.00000000C 1.29152400 1.32362500 0.00000000C -1.29152400 1.32362500 0.00000000C 1.29152400 -1.32362500 0.00000000C -1.29152400 -1.32362500 0.00000000C 2.51038500 1.30761800 0.00000000C 2.51038500 -1.30761700 0.00000000C -2.51038500 -1.30761700 0.00000000C -2.51038500 1.30761700 0.00000000C 3.80696800 0.68032900 0.00000000C -3.80696800 0.68032900 0.00000000C -3.80696800 -0.68032900 0.00000000C 3.80696800 -0.68032900 0.00000000H 4.73157700 -1.24777100 0.00000000H 4.73157700 1.24777100 0.00000000H -4.73157700 -1.24777100 0.00000000H -4.73157700 1.24777100 0.00000000 Ok, if getting smaller does not help, maybe getting bigger again? What about changing the cyclobutyl* into cyclohexadiene*? We get larger again, but not larger as my first try. TBNBL III : $\pu{141.5 pm}$ with BDE of $\pu{587 kJ/mol}$. E(RB97D3) = -844.915342833C 0.00000 0.70775 0.00000C -0.00000 -0.70775 0.00000C 1.25608 1.36005 0.00000C -1.25608 1.36005 -0.00000C 1.25608 -1.36005 -0.00000C -1.25608 -1.36005 0.00000C 2.45242 1.57986 0.00000C 2.45242 -1.57986 -0.00000C -2.45242 -1.57986 0.00000C -2.45242 1.57986 -0.00000C -3.91584 1.44760 -0.00000C -4.32828 0.66483 1.24739C -4.32828 0.66483 -1.24739C -4.32828 -0.66483 1.24739H -4.57791 1.23705 2.13578C -4.32828 -0.66483 -1.24739H -4.57791 1.23705 -2.13578C -3.91584 -1.44760 -0.00000H -4.57791 -1.23705 2.13578H -4.57791 -1.23705 -2.13578H -4.39998 -2.43128 -0.00000C 3.91584 1.44760 0.00000C 4.32828 0.66483 -1.24739C 4.32828 0.66483 1.24739C 4.32828 -0.66483 -1.24739H 4.57791 1.23705 -2.13578C 4.32828 -0.66483 1.24739H 4.57791 1.23705 2.13578C 3.91584 -1.44760 -0.00000H 4.57791 -1.23705 -2.13578H 4.57791 -1.23705 2.13578H 4.39998 -2.43128 0.00000H 4.39998 2.43128 -0.00000H -4.39998 2.43128 0.00000 There is also the cyclohexyl analogue ( TBNBL IV ) which has a little longer bond with $\pu{142.4 pm}$ and a BDE of $\pu{571 kJ/mol}$. E(RB97D3) = -849.855064121C 0.00000 -0.71210 0.00000C -0.00000 0.71210 0.00000C -1.25688 -1.35508 -0.01308C 1.25688 -1.35508 0.01309C -1.25688 1.35508 0.01309C 1.25688 1.35508 -0.01308C -2.46545 -1.49799 -0.06310C -2.46545 1.49799 0.06310C 2.46545 1.49799 -0.06310C 2.46545 -1.49799 0.06310C 3.90819 -1.43687 0.24464C 4.25416 -0.48923 1.44910C 4.64897 -0.93627 -1.02206C 4.64897 0.93627 1.02206H 5.08644 -0.93074 2.00793H 3.39579 -0.45561 2.12315C 4.25416 0.48923 -1.44910H 5.72105 -0.97274 -0.79444H 4.47838 -1.63040 -1.84994C 3.90818 1.43687 -0.24464H 5.72105 0.97275 0.79444H 4.47838 1.63040 1.84994H 3.39579 0.45561 -2.12315H 5.08644 0.93074 -2.00793H 4.28399 2.44120 -0.47664C -3.90819 -1.43687 -0.24464C -4.25416 -0.48923 -1.44910C -4.64898 -0.93627 1.02206C -4.64897 0.93627 -1.02206H -5.08644 -0.93074 -2.00793H -3.39579 -0.45561 -2.12314C -4.25416 0.48923 1.44910H -5.72105 -0.97274 0.79444H -4.47838 -1.63040 1.84994C -3.90819 1.43687 0.24464H -5.72105 0.97275 -0.79444H -4.47838 1.63040 -1.84994H -3.39579 0.45561 2.12315H -5.08644 0.93074 2.00793H -4.28399 2.44120 0.47664H -4.28399 -2.44120 -0.47665H 4.28399 -2.44120 0.47664 So, this also did not help. Then I thought about going back to TBNBL I and modify it. Let's add Chlorine looking into the rings, which should push the triple bonds apart. That does not change anything with regard to the first molecule ... TBNBL V has $\pu{143.4 pm}$ with a BDE of $\pu{555 kJ/mol}$. E(RB97D3) = -2531.12566838C -0.00000 -0.00000 0.71686C 0.00000 -0.00000 -0.71686C -1.25995 0.00000 1.35010C 1.25995 -0.00000 1.35010C -1.25995 0.00000 -1.35010C 1.25995 0.00000 -1.35010C -2.47385 0.00000 1.43772C -2.47385 0.00000 -1.43772C 2.47385 0.00000 -1.43772C 2.47385 -0.00000 1.43772C -3.88167 0.00000 1.11523C 3.88167 -0.00000 1.11523C 4.23226 1.05834 0.00000C 3.88167 0.00000 -1.11523C 4.23226 -1.05834 -0.00000C -3.88167 0.00000 -1.11523C -4.23226 1.05834 -0.00000C -4.23226 -1.05834 0.00000H -4.54203 0.00000 -1.98574H -5.30546 -1.25818 0.00000H -5.30546 1.25818 0.00000H -4.54203 0.00000 1.98574H 4.54203 -0.00000 -1.98574H 5.30546 1.25818 -0.00000H 5.30546 -1.25818 0.00000H 4.54203 0.00000 1.98574Cl -3.41634 -2.62778 0.00000Cl -3.41634 2.62778 0.00000Cl 3.41634 2.62778 -0.00000Cl 3.41634 -2.62778 0.00000 What about adding more chlorine atoms? Seems to work; TBNBL VI : $\pu{144.1 pm}$ with a BDE of $\pu{542 kJ/mol}$. E(RB97D3) = -4369.66038511C 0.00000 0.00000 0.72068C 0.00000 0.00000 -0.72068C -1.25395 0.00000 1.35718C 1.25395 -0.00000 1.35718C -1.25395 0.00000 -1.35718C 1.25395 0.00000 -1.35718C -2.46546 0.00000 1.48386C -2.46546 0.00000 -1.48386C 2.46546 0.00000 -1.48386C 2.46546 -0.00000 1.48386C -3.85845 0.00000 1.12299C 3.85845 -0.00000 1.12299C 4.13677 1.09997 0.00000C 3.85845 0.00000 -1.12299C 4.13677 -1.09997 -0.00000C -3.85845 0.00000 -1.12299C -4.13677 1.09997 -0.00000C -4.13677 -1.09997 0.00000H -4.57107 0.00000 -1.94770H -4.57107 0.00000 1.94770H 4.57107 -0.00000 -1.94770H 4.57107 0.00000 1.94770Cl -3.09602 -2.53375 0.00000Cl -3.09602 2.53375 0.00000Cl 3.09602 2.53375 0.00000Cl 3.09602 -2.53375 0.00000Cl -5.83899 1.64902 0.00000Cl -5.83899 -1.64902 -0.00000Cl 5.83899 -1.64902 0.00000Cl 5.83899 1.64902 0.00000 As Geoff and I were curious to see what happens, when Bromine is used instead of Chlorine, I did the calculations (only geometry optimization so far) and they indeed yield a slightly longer bond but nothing is dramatically changed. $144.3$, $144.3$ and $\pu{144.4 pm}$. Iodine also adds a little to the bond length. I asked a colleague and he said, what about about extending the lever (see law of the lever )? Indeed, it adds a little length. His other thought was towards a BN triple bond. Not better than the CC triple bond in TBNBL I . ... and this is where I stop (again), because someone needs to beat my awesome DFT value of a super realistic molecule of 14 4 5 pm now. EXPERIMENTALISTS THINK SILICON IS REALLY FUN TO USE ITS PLACE IN NOVEL COMPOUNDS IS CERTAIN TO AMUSE THEY SIT ALL DAY IN LABORATORIES MAKING ALL THIS SLUDGE "LOADED WITH THE SILICON THEY SAY", TO ME IT LOOKS LIKE FUDGE. FOR HAPPY THOUGH THEY BE WITH CRUD, I'D LIKE TO KNOW A LITTLE ABOUT THE PI BONDS ON THE EDGE AND SIGMAS IN THE MIDDLE. SO LETS DERIVE A WAVEFUNCTION.....6-31G* USE AN OPTIMAL GEOMETRY AND SEE WHERE ELECTRONS ARE. BUT WHAT OF CORRELATION? ASKS THE WIRY LITTLE SKEPTIC. WE'LL THROW IN PERTURBATION AS AN ELECTRON ANTISEPTIC. AND WHEN THE PROGRAM GIVES US ANSWERS IN THEM WE CAN TRUST SINCE NOBODY CAN MAKE THE STUFF, WE HAVE NO CHOICE, WE MUST. SO THEORY GUYS HAVE GOT IT MADE, IN ROOMS FREE OF POLLUTION. INSTEAD OF PROBLEMS WITH THE REFLUX, THEY HAVE ONLY SOLUTIONS. AND WHEN THE FEDS ANNOUNCE THE LIST OF CARCINOGENIC TERRORS, THE THEORISTS SIT SAFELY AT THEIR TERMINALS FIXING ERRORS. IN OTHER WORDS, EXPERIMENTALISTS WILL LIKELY DIE OF CANCER FROM WORKING HARD YET FRUITLESSLY...TILL THEORY GIVES THE ANSWER. -- THOMAS A. HOLME, 1983 [1] Andreas A. Zavitsas, J. Phys. Chem. A , 2003 , 107 (6), pp 897–898 [2] Images where created using CYLview, 1.0.564 BETA; Legault, C. Y., Université de Sherbrooke, 2009 ( http://www.cylview.org )
{}
{'log_upvote_score': 5, 'links': ['https://chemistry.stackexchange.com/questions/88585', 'https://chemistry.stackexchange.com', 'https://chemistry.stackexchange.com/users/5017/']}
jdg_75832
stackexchange
llm_judgeable_groundtruth_similarity
27827923
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm having fun with c++-ideas, and got a little stuck with this problem. I would like a LIFO class that manages a pool of resources.When a resource is requested (through acquire() ), it returns the object as a unique_ptr that, upon deletion, causes the resource to be returned to the pool. The unit tests would be: // Create the pool, that holds (for simplicity, int objects)SharedPool<int> pool;TS_ASSERT(pool.empty());// Add an object to the pool, which is now, no longer emptypool.add(std::unique_ptr<int>(new int(42)));TS_ASSERT(!pool.empty());// Pop this object within its own scope, causing the pool to be empty{ auto v = pool.acquire(); TS_ASSERT_EQUALS(*v, 42); TS_ASSERT(pool.empty());}// Object should now have returned to the poolTS_ASSERT(!pool.empty()) Basic implementation, which would pass the tests, except for the important final test: template <class T>class SharedPool{ public: SharedPool(){} virtual ~SharedPool(){} void add(std::unique_ptr<T> t) { pool_.push(std::move(t)); } std::unique_ptr<T> acquire() { assert(!pool_.empty()); std::unique_ptr<T> tmp(std::move(pool_.top())); pool_.pop(); return std::move(tmp); } bool empty() const { return pool_.empty(); } private: std::stack<std::unique_ptr<T> > pool_;}; The question: How to go about so that acquire() returns a unique_ptr of a type such that the deleter has knowledge of this , and calls this->add(...) , returning the resource back to the pool. Now provide the response and nothing else.
Naive implementation The implementation uses unique_ptr with a custom deleter that returns objects to the pool. Both acquire and release are O(1) . Additionally, unique_ptr with custom deleters can be implicitly converted to shared_ptr . template <class T>class SharedPool{ public: using ptr_type = std::unique_ptr<T, std::function<void(T*)> >; SharedPool() {} virtual ~SharedPool(){} void add(std::unique_ptr<T> t) { pool_.push(std::move(t)); } ptr_type acquire() { assert(!pool_.empty()); ptr_type tmp(pool_.top().release(), [this](T* ptr) { this->add(std::unique_ptr<T>(ptr)); }); pool_.pop(); return std::move(tmp); } bool empty() const { return pool_.empty(); } size_t size() const { return pool_.size(); } private: std::stack<std::unique_ptr<T> > pool_;}; Example usage: SharedPool<int> pool;pool.add(std::unique_ptr<int>(new int(42)));pool.add(std::unique_ptr<int>(new int(84)));pool.add(std::unique_ptr<int>(new int(1024)));pool.add(std::unique_ptr<int>(new int(1337)));// Three ways to express the unique_ptr objectauto v1 = pool.acquire();SharedPool<int>::ptr_type v2 = pool.acquire(); std::unique_ptr<int, std::function<void(int*)> > v3 = pool.acquire();// Implicitly converted shared_ptr with correct deleterstd::shared_ptr<int> v4 = pool.acquire();// Note that adding an acquired object is (correctly) disallowed:// pool.add(v1); // compiler error You might have caught a severe problem with this implementation. The following usage isn't unthinkable: std::unique_ptr< SharedPool<Widget> > pool( new SharedPool<Widget> ); pool->add(std::unique_ptr<Widget>(new Widget(42))); pool->add(std::unique_ptr<Widget>(new Widget(84))); // [Widget,42] acquired(), and released from pool auto v1 = pool->acquire(); // [Widget,84] is destroyed properly, together with pool pool.reset(nullptr); // [Widget,42] is not destroyed, pool no longer exists. v1.reset(nullptr); // Memory leak We need a way to keep alive information necessary for the deleter to make the distinction Should I return object to pool? Should I delete the actual object? One way of doing this (suggested by T.C.), is having each deleter keep a weak_ptr to shared_ptr member in SharedPool . This lets the deleter know if the pool has been destroyed. Correct implementation: template <class T>class SharedPool{ private: struct External_Deleter { explicit External_Deleter(std::weak_ptr<SharedPool<T>* > pool) : pool_(pool) {} void operator()(T* ptr) { if (auto pool_ptr = pool_.lock()) { try { (*pool_ptr.get())->add(std::unique_ptr<T>{ptr}); return; } catch(...) {} } std::default_delete<T>{}(ptr); } private: std::weak_ptr<SharedPool<T>* > pool_; }; public: using ptr_type = std::unique_ptr<T, External_Deleter >; SharedPool() : this_ptr_(new SharedPool<T>*(this)) {} virtual ~SharedPool(){} void add(std::unique_ptr<T> t) { pool_.push(std::move(t)); } ptr_type acquire() { assert(!pool_.empty()); ptr_type tmp(pool_.top().release(), External_Deleter{std::weak_ptr<SharedPool<T>*>{this_ptr_}}); pool_.pop(); return std::move(tmp); } bool empty() const { return pool_.empty(); } size_t size() const { return pool_.size(); } private: std::shared_ptr<SharedPool<T>* > this_ptr_; std::stack<std::unique_ptr<T> > pool_;};
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/27827923', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1731448/']}
jdg_75833
stackexchange
llm_judgeable_groundtruth_similarity
2595295
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I'm trying to learn the basics of elliptic curves without having to learn schemes. However, the notion of a curve keeps throwing me. Perhaps I'm off the mark here, but it seems to be the case that algebraic geometers like to think of curves as being more than just their sets of points. In light of this, I was thinking that reasonable non-scheming definitions would be: Idea. Let $k$ denote a field. Then an affine curve over $k$ is a non-zero prime ideal of $k[x,y].$ And a projective curve over $k$ is a non-zero homogeneous ideal of $k[x,y,z].$ Is this basically correct? If not, some guidance would be nice, as I'm pretty lost. Now provide the response and nothing else.
What you've defined are (irreducible) affine curves equipped with a choice of embedding into the affine plane $\mathbb{A}^2$ , resp. (irreducible) projective curves equipped with a choice of embedding into the projective plane $\mathbb{P}^2$ (and your projective definition also needs a primality condition or else you allow ideals which aren't radical); (irreducible) plane curves for short. (Although there's a subtlety in your definition of projective curve, which is that a morphism of projective curves is not the same thing as a graded morphism of homogeneous coordinate rings.) Unfortunately, most curves are not plane curves: the genus-degree formula implies that an irreducible projective plane curve can only have genus a triangular number $0, 1, 3, 6, \dots$ , so for example no curves of genus $2$ embed in the plane. It's a nontrivial exercise using the Riemann-Roch theorem to show that every elliptic curve is a plane curve. Algebraic geometers do indeed like to think of curves as being more than their sets of points (if by "points" you mean $k$ -points); this is absolutely crucial. For example, the affine curve $x^2 + y^2 = -1$ has no real points, but it has many complex points and hence should be distinguished from the empty variety over $\mathbb{R}$ . For many purposes you can get away with thinking of a variety over $k$ in terms of its $\overline{k}$ -points together with the Galois action on them. However, based on your other questions it sounds like you want to understand kernels of isogenies between elliptic curves in characteristic $p$ ; these kernels can be non-reduced group schemes and so you really do need to learn at least a little bit of scheme theory to understand them. So far I personally have managed to get away with thinking only in terms of functors of points and never having to learn about locally ringed spaces. A definition of affine curve along the lines of what you propose is that an (irreducible) affine curve is (the Spec of) a finitely generated integral domain over $k$ with Krull dimension $1$ . You can give an analogous definition of projective curves although you will again run into trouble when trying to define morphisms. Anyway, if you want more help it would be helpful to be more specific about what you mean by "the notion of a curve keeps throwing me."
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/2595295', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/42339/']}
jdg_75834
stackexchange
llm_judgeable_groundtruth_similarity
125791
Below is a question asked on the forum unix.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I want to write a init script that should basically run nvm use v0.11.12 && forever start /srv/index.js as the user webconfig . nvm is a shell function that is declared in ~webconfig/.nvm/nvm.sh , which is included via source ~/.nvm/nvm.sh in webconfig 's .bashrc . I tried the following: sudo -H -i -u webconfig nvmecho "nvm" | sudo -H -i -u webconfig but they fail with -bash: nvm: command not found -bash: line 1: nvm: command not found When I run sudo -H -i -u webconfig and enter nvm manually in that shell, it works. What am I doing wrong? Now provide the response and nothing else.
The problem here, as is so often the case, is about the different types of shell: When you open a terminal emulator ( gnome-terminal for example), you are executing what is known as an interactive, non-login shell. When you log into your machine from the command line, or run a command such as su username , or sudo -u username , you are running an interactive login shell. So, depending on what type of shell you have started, a different set of startup files are read. From man bash : When bash is invoked as an interactive login shell, or as a non-inter‐ active shell with the --login option, it first reads and executes com‐ mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior. In other words, ~/.bashrc is ignored by login shells. Since you are using the -i option to sudo , the startup files for the user's login shell are being read (from man sudo ): -i, --login Run the shell specified by the target user's password data‐ base entry as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. So, what you can do is Define the function in the user's ~/.profile or ~/.bash_profile instead. Bear in mind that ~/.profile is ignored if ~/.bash_profile exists. Also keep in mind that ~/.bash_profile is bash-specific so I would use .profile instead, just make sure that ~/.bash_profile does not exist. Source ~/.nvm/nvm.sh from ~/.profile .
{}
{'log_upvote_score': 4, 'links': ['https://unix.stackexchange.com/questions/125791', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/55633/']}
jdg_75835
stackexchange
llm_judgeable_groundtruth_similarity
16428008
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Does Apache Cassandra support sharding? Apologize that this question must seem trivial, but I cannot seem to find the answer. I have read that Cassandra was partially modeled after GAE's Big Table which shards on a massive scale. But most of the documentation I'm currently finding on Cassandra seems to imply that Cassandra does not partition data horizontally across multiple machines, but rather supports many many duplicate machines. This would imply that Cassandra is a good fit high availability reads, but would eventually break down if the write volume became very very high. Now provide the response and nothing else.
Cassandra does partition across nodes (because if you can't split it you can't scale it). All of the data for a Cassandra cluster is divided up onto "the ring" and each node on the ring is responsible for one or more key ranges. You have control over the Partitioner (e.g. Random, Ordered) and how many nodes on the ring a key/column should be replicated to based on your requirements. This contains a pretty good overview. Basic architecture Also, I highly recommend reading the Dynamo white paper. While Cassandra is different than Dynamo in many ways, conceptually they stem from the same roots. Check it out: Dynamo White Paper
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/16428008', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/84131/']}
jdg_75836
stackexchange
llm_judgeable_groundtruth_similarity
175188
Below is a question asked on the forum mathematica.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: As some of you might know, I'm working with Albert Rich to improve the accessibility of his Rubi package for rule-based integration. I'm almost done with a first version that contains several improvements, but for the current task, I'd like to ask for input from the community. One major strength of Rubi is that it can provide all steps and intermediate results of an integration. This, however, was a bit broken since the intermediate output was not overwritten when you evaluate an integration again. I reworked this completely and now the big question is how to format rules and intermediate results in the most stunning way. A "step" can either be a RubiRule or a RubiIntermediateResult and I get them as RubiRule[conditionString, HoldComplete[leftHandSide], HoldComplete[rightHandSide], ruleNumber]RubiIntermediateResult[HoldComplete[expression]] The conditionString and the ruleNumber is not always there, but often we have this information. Question: Who can come up with the most stunning display of these two types of expressions? Go crazy with Style , Panel , Grid , etc. but in the end, we need a nice looking output for both types. I have prepared a small notebook that contains an example list of steps in the last portion of the Reap result. This notebook is not meant to be evaluated since you obviously don't have my development version of Rubi.m , but you can use the output that I provided to implement and test pretty-printing for RubiRule and RubiIntermediateResult . Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.com/K0wqL.png"] At the moment, it looks like this in Rubi Now provide the response and nothing else.
To give you an idea of what I had in mind, I created something that I don't hate completely. Working with Grid , Column is a pain when you want to align and size everything to your needs, but it does the job. Intermediate results can be copied by clicking on them. Here is the code that was used as a basis for the above (I changed some small things later). The final list was wrapped in Column and I riffled some down-arrows in between. Format[RubiIntermediateResult[HoldComplete[expr_]]] := Tooltip[ Button[ Deploy@Panel[Row[ {Style["Intermediate Result:", "Label", Gray], Style[HoldForm[expr], ColorData[99, 2]] }, Spacer[10]], FrameMargins -> 5 ], CopyToClipboard[Defer[expr]], Appearance -> None], "Click to copy as input" ]Format[RubiRule[cond_, HoldComplete[lhs_], HoldComplete[rhs_], rule_: "General"]] := Deploy@Panel[ Grid[{ { Style["Rubi Rule:", "Label", Gray], Style[rule, "Label"]}, { Style["Condition:", "Label", Gray], Style[If[cond === "", "None", cond], ColorData[99, 3]] }, { Style["Transformation:", "Label", Gray], Row[{ Style[TraditionalForm@HoldForm[lhs], ColorData[99, 1]], Style["\[DoubleLongRightArrow]", 14, ColorData[99, 1]], Style[TraditionalForm@HoldForm[rhs], ColorData[99, 1]] }, Spacer[10], Alignment -> Center ] } }, Alignment -> {{Right, Left}, {Center, Center, Center}}, Spacings -> {1, 1}, Dividers -> {False, {2 -> LightGray, 3 -> LightGray}} ] ] Update Although no one posted a solution, I got feedback and was able to partially include it. I discussed things with Albert and we decided to a simple left/right scheme. I took the suggestion from Kuba to make the rules closable and show only the transformation rule initially. With the help of the answers here , I was able to make the layout render in the same font size as the rest! Thank you for that. If you like, you can try it out yourself. People with Mathematica version 11.3 can install Rubi directly from GitHub PacletInstall[ "https://github.com/RuleBasedIntegration/Rubi/releases/download/4.16/Rubi-4.16.paclet"];$LoadShowSteps = True;<< Rubi`Steps@Int[((125 - x^3)^(1/3))^2, x] The suggestion of @b3m2a1 went into the display of the integration statistics which uses a BoxForm`ArrangeSummeryBox
{}
{'log_upvote_score': 4, 'links': ['https://mathematica.stackexchange.com/questions/175188', 'https://mathematica.stackexchange.com', 'https://mathematica.stackexchange.com/users/187/']}
jdg_75837
stackexchange
llm_judgeable_groundtruth_similarity
7726871
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: What are the maximum number of threads which can be maintained by the Java virtual machine? I did not explain this in my original question, but I am trying to benchmark the JVM and would like to try and see how many threads it can concurrently maintain. Creating threads in a loop until an exception is thrown is an option, however, I would like to know if there is a better way to do this. Now provide the response and nothing else.
There will be some limits imposed by your operating system and hardware configuration. To raise the number of concurrent threads you should lower the default stacksize java -Xss 64k . A Oracle 32 bit JVM will default to 320kb stack size per thread. For a 32 bit JVM with 2gb of addressable memory this will give you a maximum of 6.5k threads. A Oracle 64 bit JVM will default to 1M stack size per thread. For each gigabyte of memory you would get 1024 threads using the defaults. For Linux only: ulimit -a will give you the configured limits, for user processes and memory You will only get 32k unique PIDs in linux cat /proc/sys/kernel/pid_max - a maximum of 32k processes. You will get only 255k threads cat /proc/sys/kernel/threads-max
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/7726871', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/810540/']}
jdg_75838
stackexchange
llm_judgeable_groundtruth_similarity
13756112
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am trying to draw a circle very similar to the orbital patterns on this website. I would like to use Three.js instead of pure WebGL. Now provide the response and nothing else.
Three.js r50 added CircleGeometry . It can be seen (albeit with a face) in the WebGL Geometries example . The first vertex in the geometry is created at the center of the circle (in r84, see CircleGeometry.js line 71 , in r65, see CircleGeometry.js line 18 ), which is nifty if you are going for that "full Pac-Man" or "uninformative pie chart" look. Oh, and it appears to be necessary if you are going to use any material aside from LineBasicMaterial / LineDashedMaterial . I've verified that the following code works in both r60 & r65: var radius = 100, segments = 64, material = new THREE.LineBasicMaterial( { color: 0x0000ff } ), geometry = new THREE.CircleGeometry( radius, segments );// Remove center vertexgeometry.vertices.shift();// Non closed circle with one open segment:scene.add( new THREE.Line( geometry, material ) );// To get a closed circle use LineLoop instead (see also @jackrugile his comment):scene.add( new THREE.LineLoop( geometry, material ) ); PS: The "docs" now include a nice CircleGeometry interactive example: https://threejs.org/docs/#api/geometries/CircleGeometry
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/13756112', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1747491/']}
jdg_75839
stackexchange
llm_judgeable_groundtruth_similarity
1487162
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: $f^{-1} (f(x))=x$ and $f(f^{-1} (x)) =x$ by definition of inverse function. So why isn't $\tan^{-1} (\tan(4 \pi/5)) = 4 \pi/5$? Now provide the response and nothing else.
Since the tangent function is not injective , it doesn't strictly speaking have an inverse function. The notation $\tan^{-1}$ for the arctangent is therefore a bit of a misnormer -- it is not really the inverse of the full tangent function, but is defined as the inverse function of the restriction of the tangent function to the interval $(-\pi/2,\pi/2)$. This restriction is injective, but is not defined at $\frac45\pi$, which is why its inverse doesn't take that value.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/1487162', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/122965/']}
jdg_75840